Index: openacs-4/packages/acs-kernel/acs-kernel.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/acs-kernel.info,v diff -u -N -r1.143 -r1.144 --- openacs-4/packages/acs-kernel/acs-kernel.info 30 Apr 2018 14:02:27 -0000 1.143 +++ openacs-4/packages/acs-kernel/acs-kernel.info 1 May 2018 10:43:05 -0000 1.144 @@ -9,15 +9,15 @@ f t - + OpenACS Core Team Routines and data models providing the foundation for OpenACS-based Web services. 2017-08-06 OpenACS The OpenACS kernel contains the core datamodel create and drop scripts for such things as objects, groups, partiies and the supporting PL/SQL and PL/pgSQL procedures. 3 - + 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 -N -r1.50 -r1.51 --- openacs-4/packages/acs-kernel/sql/postgresql/postgresql.sql 30 Apr 2018 14:02:27 -0000 1.50 +++ openacs-4/packages/acs-kernel/sql/postgresql/postgresql.sql 1 May 2018 10:43:05 -0000 1.51 @@ -347,7 +347,7 @@ CREATE OR REPLACE FUNCTION inline_1( ) RETURNS integer AS $$ --- Create a bitfromint4(integer) function if it doesn't exists. +-- Create a bittoint4(integer) function if it doesn't exists. -- This function is no longer present in 7.3 and above DECLARE v_bittoint4_count integer; @@ -424,9 +424,9 @@ end if; if p_intkey < 128 then - return substring(bitfromint4(p_intkey), 25, 8); + return substring(p_intkey::bit(32), 25, 8); else - return substring(bitfromint4(cast (-2^31 + p_intkey as int4)), 1, 32); + return substring((cast (-2^31 + p_intkey as int4))::bit(32), 1, 32); end if; END; Index: openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.10.0d5-5.10.0d6.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.10.0d5-5.10.0d6.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.10.0d5-5.10.0d6.sql 1 May 2018 10:43:05 -0000 1.1 @@ -0,0 +1,38 @@ +-- +-- Replace obsolete funktion bitfromint4() by cast +--- +-- ... but keep emulation function still around in case somebodes uses +-- this still.... +-- + + +-- +-- procedure int_to_tree_key/1 +-- +CREATE OR REPLACE FUNCTION int_to_tree_key( + p_intkey integer +) RETURNS varbit AS $$ +-- Convert an integer into the bit string format used to store +-- tree sort keys. Using 4 bytes for the long keys requires +-- using -2^31 rather than 2^31 to avoid a twos-complement +-- "integer out of range" error in PG - if for some reason you +-- want to use a smaller value use positive powers of two! + +-- There was an "out of range" check in here when I was using 15 +-- bit long keys but the only check that does anything with the long +-- keys is to check for negative numbers. +DECLARE +BEGIN + if p_intkey < 0 then + raise exception 'int_to_tree_key: key must be a positive integer'; + end if; + + if p_intkey < 128 then + return substring(p_intkey::bit(32), 25, 8); + else + return substring((cast (-2^31 + p_intkey as int4))::bit(32), 1, 32); + end if; + +END; +$$ LANGUAGE plpgsql immutable strict; +