We (in MicroOLAP Technologies) just finished client libraries update for 8.4.1 version.

Quick facts:

  • Two packages were updated:
    • Deployment libraries shipped with PostgreSQL installation
    • Deployment libraries built with MinGW environment
  • Both packages are built against 8.4.1 version of PostgreSQL
  • Comparing to 8.3.6 version libpq.dll library shipped with PostgreSQL installation depends on 12 libraries now (were 9 in 8.3.6)
  • Dump and restore libraries for 8.3.x and 8.2.x PostgreSQL branches are included into “Deployment libraries built with MinGW environment” package
  • Included dump libraries (pg_dump-8.2.14.dll, pg_dump-8.3.8.dll) may be used with PaGoDump utility either

Enjoy!


Visited 10 states (4.44%)
Create your own visited map of The World

PS Any invitation appreciated :)

David Fetter wrote a post about GCD calculations using SQL.

Reading this post I remembered my university years and course of number theory in particular. It’s still impossible to forget Mrs. Alexeeva’s lectures. Who knows her will understand what I mean. :)

Anyway. In my previous post I proposed function for GCD calculation. Thus we can calculate LCM either. The only thing we should recall that

LCM(a,b) · GCD(a,b) = |a · b|
=>
LCM(a,b) = |a · b| ÷ GCD(a,b)

However, I suggest you to change formula a bit to

LCM(a,b) = |a| ÷ GCD(a,b) · |b|

This is the correct change because GCD is the divisor for both numbers. This will reduce the required storage needed for intermediate result.

CREATE OR REPLACE FUNCTION lcm(bigint, bigint)
  RETURNS bigint AS
$BODY$
  SELECT $1 / gcd($1, $2) * $2;
$BODY$
IMMUTABLE
STRICT
LANGUAGE SQL;

PS. gcd(bigint, bigint) function declaration was in my previous post.

Continuing the idea outlined earlier I would like to offer my version of the GCD function.

CREATE OR REPLACE FUNCTION gcd(bigint, bigint) RETURNS bigint AS
$BODY$
 WITH RECURSIVE t(a, b) AS (
	VALUES (abs($1) :: bigint, abs($2) :: bigint)
UNION ALL
	SELECT b, mod(a,b) FROM t
	WHERE b > 0
)
SELECT a AS gcd FROM t WHERE b = 0;
$BODY$
IMMUTABLE
STRICT
LANGUAGE SQL;

BTW, I believe this version should be available in the PostgreSQL Wiki instead of David Fetter’s one (David, with all respect! It was inspired by yours.). ;)

“Why?” — you may ask.

  • It is much, much faster;
  • It handles negative numbers properly;
  • Because I wish to make this world better! :)

Cheers! Don’t do drugs!

David Fetter wrote a post about how to find GCD of two numbers. In his post David call it “a quick way”. :) But let me disagree. This is more efficient way:

WITH RECURSIVE t(a, b) AS (
	VALUES (38, 12)
UNION ALL
	SELECT b, mod(a,b) FROM t
	WHERE b > 0
)
SELECT a AS gcd FROM t WHERE b = 0;

Cheers!

Next Page »