Index: openacs-4/packages/acs-kernel/sql/postgresql/postgresql.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/postgresql.sql,v diff -u -r1.30 -r1.31 --- openacs-4/packages/acs-kernel/sql/postgresql/postgresql.sql 9 Jul 2002 22:34:52 -0000 1.30 +++ openacs-4/packages/acs-kernel/sql/postgresql/postgresql.sql 21 Dec 2002 22:31:16 -0000 1.31 @@ -272,6 +272,82 @@ ---------------------------------------------------------------------------- +create function inline_0 () returns integer as ' +-- Create a bitfromint4(integer) function if it doesn''t exists. +-- Due to a bug in PG 7.3 this function is absent in PG 7.3. +declare + v_bitfromint4_count integer; +begin + select into v_bitfromint4_count count(*) from pg_proc where proname = ''bitfromint4''; + if v_bitfromint4_count = 0 then + create or replace function bitfromint4 (integer) returns bit varying as '' + begin + return "bit"($1); + end;'' language ''plpgsql''; + end if; + return 1; +end;' language 'plpgsql'; + +select inline_0(); +drop function inline_0(); + +create function inline_1 () returns integer as ' +-- Create a bitfromint4(integer) function if it doesn''t exists. +-- Due to a bug in PG 7.3 this function is absent in PG 7.3. +declare + v_bittoint4_count integer; +begin + select into v_bittoint4_count count(*) from pg_proc where proname = ''bittoint4''; + if v_bittoint4_count = 0 then + create or replace function bittoint4 (bit varying) returns integer as '' + begin + return "int4"($1); + end;'' language ''plpgsql''; + end if; + return 1; +end;' language 'plpgsql'; + +select inline_1(); +drop function inline_1(); + +create function inline_0 () returns integer as ' +-- Create a bitfromint4(integer) function if it doesn''t exists. +-- Due to a bug in PG 7.3 this function is absent in PG 7.3. +declare + v_bitfromint4_count integer; +begin + select into v_bitfromint4_count count(*) from pg_proc where proname = ''bitfromint4''; + if v_bitfromint4_count = 0 then + create or replace function bitfromint4 (integer) returns bit varying as '' + begin + return "bit"($1); + end;'' language ''plpgsql''; + end if; + return 1; +end;' language 'plpgsql'; + +select inline_0(); +drop function inline_0(); + +create function inline_1 () returns integer as ' +-- Create a bitfromint4(integer) function if it doesn''t exists. +-- Due to a bug in PG 7.3 this function is absent in PG 7.3. +declare + v_bittoint4_count integer; +begin + select into v_bittoint4_count count(*) from pg_proc where proname = ''bittoint4''; + if v_bittoint4_count = 0 then + create or replace function bittoint4 (bit varying) returns integer as '' + begin + return "int4"($1); + end;'' language ''plpgsql''; + end if; + return 1; +end;' language 'plpgsql'; + +select inline_1(); +drop function inline_1(); + -- tree query support, m-vgID method. -- DRB: I've replaced the old, text-based tree sort keys with a @@ -326,7 +402,7 @@ if p_intkey < 128 then return substring(bitfromint4(p_intkey), 25, 8); else - return substring(bitfromint4(-2^31 + p_intkey), 1, 32); + return substring(bitfromint4(cast (-2^31 + p_intkey as int4)), 1, 32); end if; end;' language 'plpgsql' with (isstrict, iscachable);