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.133 -r1.134 --- openacs-4/packages/acs-kernel/acs-kernel.info 15 May 2015 14:30:02 -0000 1.133 +++ openacs-4/packages/acs-kernel/acs-kernel.info 30 Jun 2015 21:08:32 -0000 1.134 @@ -9,15 +9,15 @@ f t - + OpenACS Core Team Routines and data models providing the foundation for OpenACS-based Web services. 2013-09-08 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/oracle/security-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/security-create.sql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-kernel/sql/oracle/security-create.sql 26 Sep 2006 14:48:02 -0000 1.4 +++ openacs-4/packages/acs-kernel/sql/oracle/security-create.sql 30 Jun 2015 21:08:32 -0000 1.5 @@ -52,3 +52,49 @@ -- the increment here without changing the procedure! create sequence sec_id_seq cache 100 increment by 100; + + +create or replace package sec_session_property +as + procedure upsert ( + p_session_id in sec_session_properties.session_id%TYPE, + p_module in sec_session_properties.module%TYPE, + p_name in sec_session_properties.property_name%TYPE, + p_value in sec_session_properties.property_value%TYPE, + p_secure_p in sec_session_properties.secure_p%TYPE, + p_last_hit in sec_session_properties.last_hit%TYPE + ); +end sec_session_property; +/ +show errors + +create or replace package body sec_session_property +as + procedure upsert( + p_session_id in sec_session_properties.session_id%TYPE, + p_module in sec_session_properties.module%TYPE, + p_name in sec_session_properties.property_name%TYPE, + p_value in sec_session_properties.property_value%TYPE, + p_secure_p in sec_session_properties.secure_p%TYPE, + p_last_hit in sec_session_properties.last_hit%TYPE + ) + is + BEGIN + insert into sec_session_properties + (session_id, module, property_name, secure_p, last_hit) + values (p_session_id, p_module, p_name, p_secure_p, p_last_hit); + exception + when dup_val_on_index then + update sec_session_properties + set property_value = p_value, + secure_p = p_secure_p, + last_hit = p_last_hit + where + session_id = p_session_id and + module = p_module and + property_name = p_name; + END upsert; + +end sec_session_property; +/ +show errors Index: openacs-4/packages/acs-kernel/sql/oracle/security-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/security-drop.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-kernel/sql/oracle/security-drop.sql 20 Mar 2001 22:51:56 -0000 1.1 +++ openacs-4/packages/acs-kernel/sql/oracle/security-drop.sql 30 Jun 2015 21:08:32 -0000 1.2 @@ -7,6 +7,7 @@ -- @creation-date 2000-07-27 -- @cvs-id $Id$ -- +drop package sec_session_property; drop sequence sec_id_seq; drop sequence sec_security_token_id_seq; Index: openacs-4/packages/acs-kernel/sql/oracle/upgrade/upgrade-5.9.0d3-5.9.0d4.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/upgrade/upgrade-5.9.0d3-5.9.0d4.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-kernel/sql/oracle/upgrade/upgrade-5.9.0d3-5.9.0d4.sql 30 Jun 2015 21:08:32 -0000 1.1 @@ -0,0 +1,45 @@ + +create or replace package sec_session_property +as + procedure upsert ( + p_session_id in sec_session_properties.session_id%TYPE, + p_module in sec_session_properties.module%TYPE, + p_name in sec_session_properties.property_name%TYPE, + p_value in sec_session_properties.property_value%TYPE, + p_secure_p in sec_session_properties.secure_p%TYPE, + p_last_hit in sec_session_properties.last_hit%TYPE + ); +end sec_session_property; +/ +show errors + +create or replace package body sec_session_property +as + procedure upsert( + p_session_id in sec_session_properties.session_id%TYPE, + p_module in sec_session_properties.module%TYPE, + p_name in sec_session_properties.property_name%TYPE, + p_value in sec_session_properties.property_value%TYPE, + p_secure_p in sec_session_properties.secure_p%TYPE, + p_last_hit in sec_session_properties.last_hit%TYPE + ) + is + BEGIN + insert into sec_session_properties + (session_id, module, property_name, secure_p, last_hit) + values (p_session_id, p_module, p_name, p_secure_p, p_last_hit); + exception + when dup_val_on_index then + update sec_session_properties + set property_value = p_value, + secure_p = p_secure_p, + last_hit = p_last_hit + where + session_id = p_session_id and + module = p_module and + property_name = p_name; + END upsert; + +end sec_session_property; +/ +show errors Index: openacs-4/packages/acs-kernel/sql/postgresql/security-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/security-create.sql,v diff -u -r1.8 -r1.9 --- openacs-4/packages/acs-kernel/sql/postgresql/security-create.sql 27 Oct 2014 16:39:36 -0000 1.8 +++ openacs-4/packages/acs-kernel/sql/postgresql/security-create.sql 30 Jun 2015 21:08:32 -0000 1.9 @@ -49,3 +49,46 @@ create sequence t_sec_id_seq cache 100 increment 100; create view sec_id_seq as select nextval('t_sec_id_seq') as nextval; + + +select define_function_args('sec_session_property__upsert','session_id,module,name,secure_p,last_hit'); + +CREATE OR REPLACE FUNCTION sec_session_property__upsert( + p_session_id bigint, + p_module varchar, + p_name varchar, + p_value varchar, + p_secure_p boolean, + p_last_hit integer +) RETURNS void as +$$ +BEGIN + LOOP + -- first try to update the key + update sec_session_properties + set property_value = p_value, secure_p = p_secure_p, last_hit = p_last_hit + where session_id = p_session_id and module = p_module and property_name = p_name; + IF found THEN + return; + END IF; + -- not there, so try to insert the key + -- if someone else inserts the same key concurrently, + -- we could get a unique-key failure + BEGIN + insert into sec_session_properties + (session_id, module, property_name, secure_p, last_hit) + values (p_session_id, p_module, p_name, p_secure_p, p_last_hit); + RETURN; + EXCEPTION WHEN unique_violation THEN + -- Do nothing, and loop to try the UPDATE again. + END; + END LOOP; +END; +$$ LANGUAGE plpgsql; + + + + + + + Index: openacs-4/packages/acs-kernel/sql/postgresql/security-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/security-drop.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-kernel/sql/postgresql/security-drop.sql 18 Jun 2004 18:21:57 -0000 1.2 +++ openacs-4/packages/acs-kernel/sql/postgresql/security-drop.sql 30 Jun 2015 21:08:32 -0000 1.3 @@ -15,3 +15,7 @@ drop table sec_session_properties; drop index sec_sessions_by_server; drop table secret_tokens; + +drop FUNCTION sec_session_property__upsert(bigint,varchar,varchar,varchar,boolean,integer); + + Index: openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.9.0d3-5.9.0d4.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.9.0d3-5.9.0d4.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.9.0d3-5.9.0d4.sql 30 Jun 2015 21:08:32 -0000 1.1 @@ -0,0 +1,40 @@ + + +select define_function_args('sec_session_property__upsert','session_id,module,name,secure_p,last_hit'); + +CREATE OR REPLACE FUNCTION sec_session_property__upsert( + p_session_id bigint, + p_module varchar, + p_name varchar, + p_value varchar, + p_secure_p boolean, + p_last_hit integer +) RETURNS void as +$$ +BEGIN + LOOP + -- first try to update the key + update sec_session_properties + set property_value = p_value, secure_p = p_secure_p, last_hit = p_last_hit + where session_id = p_session_id and module = p_module and property_name = p_name; + IF found THEN + return; + END IF; + -- not there, so try to insert the key + -- if someone else inserts the same key concurrently, + -- we could get a unique-key failure + BEGIN + insert into sec_session_properties + (session_id, module, property_name, secure_p, last_hit) + values (p_session_id, p_module, p_name, p_secure_p, p_last_hit); + RETURN; + EXCEPTION WHEN unique_violation THEN + -- Do nothing, and loop to try the UPDATE again. + END; + END LOOP; +END; +$$ LANGUAGE plpgsql; + + + +