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 -r1.142 -r1.143 --- openacs-4/packages/acs-kernel/acs-kernel.info 23 Mar 2018 22:56:42 -0000 1.142 +++ openacs-4/packages/acs-kernel/acs-kernel.info 30 Apr 2018 14:02:27 -0000 1.143 @@ -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 -r1.49 -r1.50 --- openacs-4/packages/acs-kernel/sql/postgresql/postgresql.sql 7 Aug 2017 23:47:56 -0000 1.49 +++ openacs-4/packages/acs-kernel/sql/postgresql/postgresql.sql 30 Apr 2018 14:02:27 -0000 1.50 @@ -465,9 +465,9 @@ end if; if substring(p_tree_key, v_parent_pos, 1) = '1' then - return bittoint4(substring(p_tree_key, v_parent_pos + 1, 31)); + return substring(p_tree_key, v_parent_pos + 1, 31)::bit(31)::integer; else - return bittoint4(substring(p_tree_key, v_parent_pos, 8)); + return substring(p_tree_key, v_parent_pos, 8)::bit(8)::integer; end if; END; @@ -555,9 +555,9 @@ end loop; if substring(p_tree_key, v_leaf_pos, 1) = '1' then - return bittoint4(substring(p_tree_key, v_leaf_pos + 1, 31)); + return substring(p_tree_key, v_leaf_pos + 1, 31)::bit(31)::integer; else - return bittoint4(substring(p_tree_key, v_leaf_pos, 8)); + return substring(p_tree_key, v_leaf_pos, 8)::bit(8)::integer; end if; END; Index: openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.10.0d4-5.10.0d5.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.10.0d4-5.10.0d5.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.10.0d4-5.10.0d5.sql 30 Apr 2018 14:02:27 -0000 1.1 @@ -0,0 +1,78 @@ +-- +-- Replace obsolete funktion bittoint4() by cast +--- +-- ... but keep emulation function still around in case somebodes uses +-- this still.... +-- + + +-- +-- procedure tree_key_to_int/2 +-- +CREATE OR REPLACE FUNCTION tree_key_to_int( + p_tree_key varbit, + p_level integer +) RETURNS integer AS $$ +-- Convert the compressed key for the node at the given level to an +-- integer. +DECLARE + v_level integer default 0; + v_parent_pos integer default 1; + v_pos integer default 1; +BEGIN + + -- Find the right key first + while v_pos < length(p_tree_key) and v_level < p_level loop + v_parent_pos := v_pos; + v_level := v_level + 1; + if substring(p_tree_key, v_pos, 1) = '1' then + v_pos := v_pos + 32; + else + v_pos := v_pos + 8; + end if; + end loop; + + if v_level < p_level then + raise exception 'tree_key_to_int: key is at a level less than %', p_level; + end if; + + if substring(p_tree_key, v_parent_pos, 1) = '1' then + return substring(p_tree_key, v_parent_pos + 1, 31)::bit(31)::integer; + else + return substring(p_tree_key, v_parent_pos, 8)::bit(8)::integer; + end if; + +END; +$$ LANGUAGE plpgsql immutable strict; + +-- +-- procedure tree_leaf_key_to_int/1 +-- +CREATE OR REPLACE FUNCTION tree_leaf_key_to_int( + p_tree_key varbit +) RETURNS integer AS $$ +-- Convert the bitstring for the last, or leaf, node represented by this key +-- to an integer. +DECLARE + v_leaf_pos integer default 1; + v_pos integer default 1; +BEGIN + + -- Find the leaf key first + while v_pos < length(p_tree_key) loop + v_leaf_pos := v_pos; + if substring(p_tree_key, v_pos, 1) = '1' then + v_pos := v_pos + 32; + else + v_pos := v_pos + 8; + end if; + end loop; + + if substring(p_tree_key, v_leaf_pos, 1) = '1' then + return substring(p_tree_key, v_leaf_pos + 1, 31)::bit(31)::integer; + else + return substring(p_tree_key, v_leaf_pos, 8)::bit(8)::integer; + end if; + +END; +$$ LANGUAGE plpgsql immutable strict;