Index: openacs-4/packages/notifications/sql/postgresql/notifications-core-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/postgresql/notifications-core-drop.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/notifications/sql/postgresql/notifications-core-drop.sql 9 Aug 2002 20:51:50 -0000 1.3 +++ openacs-4/packages/notifications/sql/postgresql/notifications-core-drop.sql 30 Mar 2013 18:50:28 -0000 1.4 @@ -16,33 +16,33 @@ drop table notification_intervals; drop table notification_delivery_methods; -create function inline_0 () -returns integer as ' -begin +CREATE OR REPLACE FUNCTION inline_0 () RETURNS integer AS $$ +BEGIN perform acs_object_type__drop_type( - ''notification_interval'', ''f'' + 'notification_interval', 'f' ); perform acs_object_type__drop_type( - ''notification_delivery_method'', ''f'' + 'notification_delivery_method', 'f' ); perform acs_object_type__drop_type( - ''notification_type'', ''f'' + 'notification_type', 'f' ); perform acs_object_type__drop_type( - ''notification_request'', ''f'' + 'notification_request', 'f' ); perform acs_object_type__drop_type( - ''notification'', ''f'' + 'notification', 'f' ); return null; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; select inline_0(); drop function inline_0(); Index: openacs-4/packages/notifications/sql/postgresql/notifications-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/postgresql/notifications-package-create.sql,v diff -u -r1.14 -r1.15 --- openacs-4/packages/notifications/sql/postgresql/notifications-package-create.sql 27 Jun 2007 18:54:47 -0000 1.14 +++ openacs-4/packages/notifications/sql/postgresql/notifications-package-create.sql 30 Mar 2013 18:50:28 -0000 1.15 @@ -9,21 +9,26 @@ select define_function_args ('notification_interval__new','interval_id,name,n_seconds,creation_date,creation_user,creation_ip,context_id'); -create function notification_interval__new (integer, varchar, integer, timestamptz, integer, varchar, integer) -returns integer as ' -declare - p_interval_id alias for $1; - p_name alias for $2; - p_n_seconds alias for $3; - p_creation_date alias for $4; - p_creation_user alias for $5; - p_creation_ip alias for $6; - p_context_id alias for $7; + + +-- +-- procedure notification_interval__new/7 +-- +CREATE OR REPLACE FUNCTION notification_interval__new( + p_interval_id integer, + p_name varchar, + p_n_seconds integer, + p_creation_date timestamptz, + p_creation_user integer, + p_creation_ip varchar, + p_context_id integer +) RETURNS integer AS $$ +DECLARE v_interval_id integer; -begin +BEGIN v_interval_id := acs_object__new( p_interval_id, - ''notification_interval'', + 'notification_interval', p_creation_date, p_creation_user, p_creation_ip, @@ -37,39 +42,51 @@ (v_interval_id, p_name, p_n_seconds); return v_interval_id; -end; -' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; + select define_function_args ('notification_interval__delete','interval_id'); -create function notification_interval__delete(integer) -returns integer as ' -declare - p_interval_id alias for $1; -begin + + +-- +-- procedure notification_interval__delete/1 +-- +CREATE OR REPLACE FUNCTION notification_interval__delete( + p_interval_id integer +) RETURNS integer AS $$ +DECLARE +BEGIN perform acs_object__delete(p_interval_id); return 0; -end; -' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; + select define_function_args ('notification_delivery_method__new','delivery_method_id,sc_impl_id,short_name,pretty_name,creation_date,creation_user,creation_ip,context_id'); -create function notification_delivery_method__new (integer, integer, varchar, varchar, timestamptz, integer, varchar, integer) -returns integer as ' -declare - p_delivery_method_id alias for $1; - p_sc_impl_id alias for $2; - p_short_name alias for $3; - p_pretty_name alias for $4; - p_creation_date alias for $5; - p_creation_user alias for $6; - p_creation_ip alias for $7; - p_context_id alias for $8; + + +-- +-- procedure notification_delivery_method__new/8 +-- +CREATE OR REPLACE FUNCTION notification_delivery_method__new( + p_delivery_method_id integer, + p_sc_impl_id integer, + p_short_name varchar, + p_pretty_name varchar, + p_creation_date timestamptz, + p_creation_user integer, + p_creation_ip varchar, + p_context_id integer +) RETURNS integer AS $$ +DECLARE v_delivery_method_id integer; -begin +BEGIN v_delivery_method_id := acs_object__new( p_delivery_method_id, - ''notification_delivery_method'', + 'notification_delivery_method', p_creation_date, p_creation_user, p_creation_ip, @@ -83,10 +100,11 @@ (v_delivery_method_id, p_sc_impl_id, p_short_name, p_pretty_name); return v_delivery_method_id; -end; -' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; + create function notification_delivery_method__delete(integer) returns integer as ' DECLARE @@ -95,9 +113,10 @@ perform acs_object__delete(p_delivery_method_id); return 0; END; -' language 'plpgsql'; +$$ LANGUAGE plpgsql; + -- Notification Types Package select define_function_args ('notification_type__new','type_id,sc_impl_id,short_name,pretty_name,description,creation_date,creation_user,creation_ip,context_id'); @@ -119,7 +138,7 @@ BEGIN v_type_id:= acs_object__new ( p_type_id, - ''notification_type'', + 'notification_type', p_creation_date, p_creation_user, p_creation_ip, @@ -131,20 +150,27 @@ return v_type_id; END; -' language 'plpgsql'; +$$ LANGUAGE plpgsql; + select define_function_args ('notification_type__delete','type_id'); -create function notification_type__delete(integer) -returns integer as ' -declare - p_type_id alias for $1; -begin + + +-- +-- procedure notification_type__delete/1 +-- +CREATE OR REPLACE FUNCTION notification_type__delete( + p_type_id integer +) RETURNS integer AS $$ +DECLARE +BEGIN perform acs_object__delete(p_type_id); return 0; -end; -' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; + select define_function_args ('notification_request__new','request_id,object_type;notification_request,type_id,user_id,object_id,interval_id,delivery_method_id,format,dynamic_p;f,creation_date,creation_user,creation_ip,context_id'); create function notification_request__new ( @@ -194,16 +220,22 @@ return v_request_id; END; -' language 'plpgsql'; +$$ LANGUAGE plpgsql; + select define_function_args ('notification_request__delete','request_id'); -create or replace function notification_request__delete(integer) -returns integer as ' -declare - p_request_id alias for $1; + + +-- +-- procedure notification_request__delete/1 +-- +CREATE OR REPLACE FUNCTION notification_request__delete( + p_request_id integer +) RETURNS integer AS $$ +DECLARE v_notifications record; -begin +BEGIN for v_notifications in select notification_id from notifications n, notification_requests nr where n.response_id = nr.object_id @@ -214,17 +246,23 @@ perform acs_object__delete(p_request_id); return 0; -end; -' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; + select define_function_args ('notification_request__delete_all', 'object_id'); -create function notification_request__delete_all(integer) -returns integer as ' -declare - p_object_id alias for $1; + + +-- +-- procedure notification_request__delete_all/1 +-- +CREATE OR REPLACE FUNCTION notification_request__delete_all( + p_object_id integer +) RETURNS integer AS $$ +DECLARE v_request RECORD; -begin +BEGIN for v_request in select request_id from notification_requests where object_id= p_object_id @@ -233,17 +271,23 @@ end loop; return 0; -end; -' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; + select define_function_args ('notification_request__delete_all_for_user', 'user_id'); -create function notification_request__delete_all_for_user(integer) -returns integer as ' -declare - p_user_id alias for $1; + + +-- +-- procedure notification_request__delete_all_for_user/1 +-- +CREATE OR REPLACE FUNCTION notification_request__delete_all_for_user( + p_user_id integer +) RETURNS integer AS $$ +DECLARE v_request RECORD; -begin +BEGIN for v_request in select request_id from notification_requests where user_id= p_user_id @@ -252,35 +296,41 @@ end loop; return 0; -end; -' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; + select define_function_args ('notification__new','notification_id,type_id,object_id,notif_date,response_id,notif_user,notif_subject,notif_text,notif_html,file_ids,creation_date,creation_user,creation_ip,context_id'); -create or replace function notification__new(integer,integer,integer,timestamptz,integer,integer,varchar,text,text,text,timestamptz,integer,varchar,integer) -returns integer as ' -declare - p_notification_id alias for $1; - p_type_id alias for $2; - p_object_id alias for $3; - p_notif_date alias for $4; - p_response_id alias for $5; - p_notif_user alias for $6; - p_notif_subject alias for $7; - p_notif_text alias for $8; - p_notif_html alias for $9; - p_file_ids alias for $10; - p_creation_date alias for $11; - p_creation_user alias for $12; - p_creation_ip alias for $13; - p_context_id alias for $14; + + +-- +-- procedure notification__new/14 +-- +CREATE OR REPLACE FUNCTION notification__new( + p_notification_id integer, + p_type_id integer, + p_object_id integer, + p_notif_date timestamptz, + p_response_id integer, + p_notif_user integer, + p_notif_subject varchar, + p_notif_text text, + p_notif_html text, + p_file_ids text, + p_creation_date timestamptz, + p_creation_user integer, + p_creation_ip varchar, + p_context_id integer +) RETURNS integer AS $$ +DECLARE v_notification_id integer; v_notif_date notifications.notif_date%TYPE; -begin +BEGIN v_notification_id := acs_object__new( p_notification_id, - ''notification'', + 'notification', p_creation_date, p_creation_user, p_creation_ip, @@ -300,18 +350,25 @@ (v_notification_id, p_type_id, p_object_id, v_notif_date, p_response_id, p_notif_user, p_notif_subject, p_notif_text, p_notif_html, p_file_ids); return v_notification_id; -end; -' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; + select define_function_args ('notification__delete','notification_id'); -create function notification__delete(integer) -returns integer as ' -declare - p_notification_id alias for $1; -begin + + +-- +-- procedure notification__delete/1 +-- +CREATE OR REPLACE FUNCTION notification__delete( + p_notification_id integer +) RETURNS integer AS $$ +DECLARE +BEGIN delete from notifications where notification_id = p_notification_id; perform acs_object__delete(p_notification_id); return 0; -end; -' language 'plpgsql'; +END; + +$$ LANGUAGE plpgsql; Index: openacs-4/packages/notifications/sql/postgresql/notifications-replies-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/postgresql/notifications-replies-drop.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/notifications/sql/postgresql/notifications-replies-drop.sql 8 Mar 2004 12:34:12 -0000 1.1 +++ openacs-4/packages/notifications/sql/postgresql/notifications-replies-drop.sql 30 Mar 2013 18:50:28 -0000 1.2 @@ -1,16 +1,16 @@ drop table notification_replies; -create function inline_0 () -returns integer as ' -begin +CREATE OR REPLACE FUNCTION inline_0 () RETURNS integer AS $$ +BEGIN perform acs_object_type__drop_type( - ''notification_reply'', ''f'' + 'notification_reply', 'f' ); return null; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; select inline_0(); drop function inline_0(); Index: openacs-4/packages/notifications/sql/postgresql/notifications-replies-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/postgresql/notifications-replies-package-create.sql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/notifications/sql/postgresql/notifications-replies-package-create.sql 17 May 2003 10:53:27 -0000 1.5 +++ openacs-4/packages/notifications/sql/postgresql/notifications-replies-package-create.sql 30 Mar 2013 18:50:28 -0000 1.6 @@ -34,7 +34,7 @@ BEGIN v_reply_id:= acs_object__new ( p_reply_id, - ''notification_reply'', + 'notification_reply', p_creation_date, p_creation_user, p_creation_ip, @@ -49,9 +49,10 @@ return v_reply_id; END; -' language 'plpgsql'; +$$ LANGUAGE plpgsql; + create function notification_reply__delete(integer) returns integer as ' DECLARE @@ -60,4 +61,5 @@ perform acs_object__delete(p_reply_id); return (0); END; -' language 'plpgsql'; + +$$ LANGUAGE plpgsql; Index: openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-0.1d-0.2d.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-0.1d-0.2d.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-0.1d-0.2d.sql 19 Aug 2002 20:38:49 -0000 1.2 +++ openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-0.1d-0.2d.sql 30 Mar 2013 18:50:28 -0000 1.3 @@ -1,13 +1,22 @@ drop function notification__delete; -create function notification__delete(integer) -returns integer as ' -declare - p_notification_id alias for $1; -begin + + +-- added +select define_function_args('notification__delete','notification_id'); + +-- +-- procedure notification__delete/1 +-- +CREATE OR REPLACE FUNCTION notification__delete( + p_notification_id integer +) RETURNS integer AS $$ +DECLARE +BEGIN delete from notifications where notification_id = p_notification_id; perform acs_object__delete(p_notification_id); return 0; -end; -' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; + Index: openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-0.3d-0.4d.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-0.3d-0.4d.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-0.3d-0.4d.sql 25 Feb 2003 10:09:57 -0000 1.2 +++ openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-0.3d-0.4d.sql 30 Mar 2013 18:50:28 -0000 1.3 @@ -84,6 +84,7 @@ return v_request_id; END; -' language 'plpgsql'; +$$ LANGUAGE plpgsql; + Index: openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-0.4d-4.6.1.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-0.4d-4.6.1.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-0.4d-4.6.1.sql 17 May 2003 10:53:56 -0000 1.2 +++ openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-0.4d-4.6.1.sql 30 Mar 2013 18:50:28 -0000 1.3 @@ -1,11 +1,19 @@ -- DRB: deleting requests would fail if any notification were still pending -create or replace function notification_request__delete(integer) -returns integer as ' -declare - p_request_id alias for $1; + + +-- added +select define_function_args('notification_request__delete','request_id'); + +-- +-- procedure notification_request__delete/1 +-- +CREATE OR REPLACE FUNCTION notification_request__delete( + p_request_id integer +) RETURNS integer AS $$ +DECLARE v_notifications record; -begin +BEGIN for v_notifications in select notification_id from notifications n, notification_requests nr where n.response_id = nr.object_id @@ -16,6 +24,7 @@ perform acs_object__delete(p_request_id); return 0; -end; -' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; + Index: openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-4.6.1-4.6.2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-4.6.1-4.6.2.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-4.6.1-4.6.2.sql 17 May 2003 10:53:56 -0000 1.2 +++ openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-4.6.1-4.6.2.sql 30 Mar 2013 18:50:28 -0000 1.3 @@ -84,6 +84,7 @@ return v_request_id; END; -' language 'plpgsql'; +$$ LANGUAGE plpgsql; + Index: openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-4.6.2-4.6.4.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-4.6.2-4.6.4.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-4.6.2-4.6.4.sql 28 Aug 2003 09:41:58 -0000 1.2 +++ openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-4.6.2-4.6.4.sql 30 Mar 2013 18:50:28 -0000 1.3 @@ -24,28 +24,33 @@ -- The define the new one select define_function_args ('notification__new','notification_id,type_id,object_id,notif_date,response_id,notif_user,notif_subject,notif_text,notif_html,creation_date,creation_user,creation_ip,context_id'); -create or replace function notification__new(integer,integer,integer,timestamptz,integer,integer,varchar,text,text,timestamptz,integer,varchar,integer) -returns integer as ' -declare - p_notification_id alias for $1; - p_type_id alias for $2; - p_object_id alias for $3; - p_notif_date alias for $4; - p_response_id alias for $5; - p_notif_user alias for $6; - p_notif_subject alias for $7; - p_notif_text alias for $8; - p_notif_html alias for $9; - p_creation_date alias for $10; - p_creation_user alias for $11; - p_creation_ip alias for $12; - p_context_id alias for $13; + + +-- +-- procedure notification__new/13 +-- +CREATE OR REPLACE FUNCTION notification__new( + p_notification_id integer, + p_type_id integer, + p_object_id integer, + p_notif_date timestamptz, + p_response_id integer, + p_notif_user integer, + p_notif_subject varchar, + p_notif_text text, + p_notif_html text, + p_creation_date timestamptz, + p_creation_user integer, + p_creation_ip varchar, + p_context_id integer +) RETURNS integer AS $$ +DECLARE v_notification_id integer; v_notif_date notifications.notif_date%TYPE; -begin +BEGIN v_notification_id := acs_object__new( p_notification_id, - ''notification'', + 'notification', p_creation_date, p_creation_user, p_creation_ip, @@ -65,5 +70,6 @@ (v_notification_id, p_type_id, p_object_id, v_notif_date, p_response_id, p_notif_user, p_notif_subject, p_notif_text, p_notif_html); return v_notification_id; -end; -' language 'plpgsql'; +END; + +$$ LANGUAGE plpgsql; Index: openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.0.0a5-5.0.0a6.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.0.0a5-5.0.0a6.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.0.0a5-5.0.0a6.sql 26 Feb 2004 15:29:20 -0000 1.3 +++ openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.0.0a5-5.0.0a6.sql 30 Mar 2013 18:50:28 -0000 1.4 @@ -2,13 +2,21 @@ -- see Bug http://openacs.org/bugtracker/openacs/bug?filter%2estatus=resolved&filter%2eactionby=6815&bug%5fnumber=260 -- @author Peter Marklund -create or replace function safe_drop_cosntraint(name, name) -returns integer as ' -declare - p_table_name alias for $1; - p_constraint_name alias for $2; + + +-- added +select define_function_args('safe_drop_cosntraint','table_name,constraint_name'); + +-- +-- procedure safe_drop_cosntraint/2 +-- +CREATE OR REPLACE FUNCTION safe_drop_cosntraint( + p_table_name name, + p_constraint_name name +) RETURNS integer AS $$ +DECLARE v_constraint_p integer; -begin +BEGIN select count(*) into v_constraint_p from pg_constraint con, pg_class c @@ -17,11 +25,12 @@ and c.relname = p_table_name; if v_constraint_p > 0 then - execute ''alter table '' || p_table_name || '' drop constraint '' || p_constraint_name; + execute 'alter table ' || p_table_name || ' drop constraint ' || p_constraint_name; end if; return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; select safe_drop_cosntraint('notifications', 'notif_reponse_id_fk'); Index: openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.0.0b4-5.1.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.0.0b4-5.1.0d2.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.0.0b4-5.1.0d2.sql 24 Jul 2004 08:34:44 -0000 1.2 +++ openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.0.0b4-5.1.0d2.sql 30 Mar 2013 18:50:28 -0000 1.3 @@ -1,11 +1,16 @@ select define_function_args ('notification_request__delete_all_for_user', 'user_id'); -create function notification_request__delete_all_for_user(integer) -returns integer as ' -declare - p_user_id alias for $1; + + +-- +-- procedure notification_request__delete_all_for_user/1 +-- +CREATE OR REPLACE FUNCTION notification_request__delete_all_for_user( + p_user_id integer +) RETURNS integer AS $$ +DECLARE v_request RECORD; -begin +BEGIN for v_request in select request_id from notification_requests where user_id= p_user_id @@ -14,5 +19,6 @@ end loop; return 0; -end; -' language 'plpgsql'; +END; + +$$ LANGUAGE plpgsql; Index: openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.1.0d2-5.1.0d3.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.1.0d2-5.1.0d3.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.1.0d2-5.1.0d3.sql 24 Jul 2004 08:34:44 -0000 1.2 +++ openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.1.0d2-5.1.0d3.sql 30 Mar 2013 18:50:28 -0000 1.3 @@ -10,13 +10,21 @@ -- see Bug http://openacs.org/bugtracker/openacs/bug?filter%2estatus=resolved&filter%2eactionby=6815&bug%5fnumber=260 -- @author Peter Marklund -create or replace function safe_drop_cosntraint(name, name) -returns integer as ' -declare - p_table_name alias for $1; - p_constraint_name alias for $2; + + +-- added +select define_function_args('safe_drop_cosntraint','table_name,constraint_name'); + +-- +-- procedure safe_drop_cosntraint/2 +-- +CREATE OR REPLACE FUNCTION safe_drop_cosntraint( + p_table_name name, + p_constraint_name name +) RETURNS integer AS $$ +DECLARE v_constraint_p integer; -begin +BEGIN select count(*) into v_constraint_p from pg_constraint con, pg_class c @@ -25,11 +33,12 @@ and c.relname = p_table_name; if v_constraint_p > 0 then - execute ''alter table '' || p_table_name || '' drop constraint '' || p_constraint_name; + execute 'alter table ' || p_table_name || ' drop constraint ' || p_constraint_name; end if; return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; -- Add on delete cascade to notifications.notif_notif_id_fk foreign key constraint Index: openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.4.0d2-5.4.0d3.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.4.0d2-5.4.0d3.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.4.0d2-5.4.0d3.sql 27 Jun 2007 18:54:48 -0000 1.1 +++ openacs-4/packages/notifications/sql/postgresql/upgrade/upgrade-5.4.0d2-5.4.0d3.sql 30 Mar 2013 18:50:28 -0000 1.2 @@ -3,29 +3,34 @@ select define_function_args ('notification__new','notification_id,type_id,object_id,notif_date,response_id,notif_user,notif_subject,notif_text,notif_html,file_ids,creation_date,creation_user,creation_ip,context_id'); -create or replace function notification__new(integer,integer,integer,timestamptz,integer,integer,varchar,text,text,text,timestamptz,integer,varchar,integer) -returns integer as ' -declare - p_notification_id alias for $1; - p_type_id alias for $2; - p_object_id alias for $3; - p_notif_date alias for $4; - p_response_id alias for $5; - p_notif_user alias for $6; - p_notif_subject alias for $7; - p_notif_text alias for $8; - p_notif_html alias for $9; - p_file_ids alias for $10; - p_creation_date alias for $11; - p_creation_user alias for $12; - p_creation_ip alias for $13; - p_context_id alias for $14; + + +-- +-- procedure notification__new/14 +-- +CREATE OR REPLACE FUNCTION notification__new( + p_notification_id integer, + p_type_id integer, + p_object_id integer, + p_notif_date timestamptz, + p_response_id integer, + p_notif_user integer, + p_notif_subject varchar, + p_notif_text text, + p_notif_html text, + p_file_ids text, + p_creation_date timestamptz, + p_creation_user integer, + p_creation_ip varchar, + p_context_id integer +) RETURNS integer AS $$ +DECLARE v_notification_id integer; v_notif_date notifications.notif_date%TYPE; -begin +BEGIN v_notification_id := acs_object__new( p_notification_id, - ''notification'', + 'notification', p_creation_date, p_creation_user, p_creation_ip, @@ -45,5 +50,6 @@ (v_notification_id, p_type_id, p_object_id, v_notif_date, p_response_id, p_notif_user, p_notif_subject, p_notif_text, p_notif_html, p_file_ids); return v_notification_id; -end; -' language 'plpgsql'; +END; + +$$ LANGUAGE plpgsql; Index: openacs-4/packages/ref-timezones/sql/postgresql/ref-timezones-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ref-timezones/sql/postgresql/ref-timezones-create.sql,v diff -u -r1.11 -r1.12 --- openacs-4/packages/ref-timezones/sql/postgresql/ref-timezones-create.sql 4 Jun 2006 00:45:55 -0000 1.11 +++ openacs-4/packages/ref-timezones/sql/postgresql/ref-timezones-create.sql 30 Mar 2013 18:50:28 -0000 1.12 @@ -109,210 +109,330 @@ -- TimeZone package ------------------------------------------------------------------------------- -create or replace function rdbms_date(varchar) returns timestamptz as ' -declare - p_raw_date alias for $1; -begin - return "timestamptz" (p_raw_date || ''+00''); -end;' language 'plpgsql' stable strict; -create or replace function timezone__new (varchar, varchar) returns integer as ' -declare - p_tz alias for $1; - p_gmt_offset alias for $2; -begin + +-- added +select define_function_args('rdbms_date','raw_date'); + +-- +-- procedure rdbms_date/1 +-- +CREATE OR REPLACE FUNCTION rdbms_date( + p_raw_date varchar +) RETURNS timestamptz AS $$ +DECLARE +BEGIN + return "timestamptz" (p_raw_date || '+00'); +END; +$$ LANGUAGE plpgsql stable strict; + + + +-- added +select define_function_args('timezone__new','tz,gmt_offset'); + +-- +-- procedure timezone__new/2 +-- +CREATE OR REPLACE FUNCTION timezone__new( + p_tz varchar, + p_gmt_offset varchar +) RETURNS integer AS $$ +DECLARE +BEGIN insert into timezones (tz_id, tz, gmt_offset) values - (nextval(''timezone_seq''), p_tz, gmt_offset); + (nextval('timezone_seq'), p_tz, gmt_offset); return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; -create or replace function timezone__delete (integer) returns integer as ' -declare - p_tz_id alias for $1; -begin + + +-- added +select define_function_args('timezone__delete','tz_id'); + +-- +-- procedure timezone__delete/1 +-- +CREATE OR REPLACE FUNCTION timezone__delete( + p_tz_id integer +) RETURNS integer AS $$ +DECLARE +BEGIN delete from timezone_rules where tz_id = p_tz_id; delete from timezones where tz_id = p_tz_id; return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; -- private function for looking up timezone id's -create or replace function timezone__get_id (varchar) returns integer as ' -declare - p_tz alias for $1; + + +-- added +select define_function_args('timezone__get_id','tz'); + +-- +-- procedure timezone__get_id/1 +-- +CREATE OR REPLACE FUNCTION timezone__get_id( + p_tz varchar +) RETURNS integer AS $$ +DECLARE v_tz_id integer; -begin +BEGIN return tz_id from timezones where tz = p_tz; -end;' language 'plpgsql' stable strict; +END; +$$ LANGUAGE plpgsql stable strict; -create or replace function timezone__add_rule (varchar, varchar, integer, varchar, varchar, varchar, varchar, varchar) returns integer as ' -declare - p_tz alias for $1; - p_abbrev alias for $2; - p_isdst_p alias for $3; - p_gmt_offset alias for $4; - p_utc_start alias for $5; - p_utc_end alias for $6; - p_local_start alias for $7; - p_local_end alias for $8; -begin + + +-- added +select define_function_args('timezone__add_rule','tz,abbrev,isdst_p,gmt_offset,utc_start,utc_end,local_start,local_end'); + +-- +-- procedure timezone__add_rule/8 +-- +CREATE OR REPLACE FUNCTION timezone__add_rule( + p_tz varchar, + p_abbrev varchar, + p_isdst_p integer, + p_gmt_offset varchar, + p_utc_start varchar, + p_utc_end varchar, + p_local_start varchar, + p_local_end varchar +) RETURNS integer AS $$ +DECLARE +BEGIN insert into timezone_rules (tz_id, abbrev, utc_start, utc_end, local_start, local_end, gmt_offset, isdst_p) select timezone__get_id(p_tz), p_abbrev, rdbms_date(p_utc_start), rdbms_date(p_utc_end), rdbms_date(p_local_start), to_date(p_local_end), p_gmt_offset, - case p_isdst_p when 0 then ''f'' else ''t''end; -end;' language 'plpgsql'; + case p_isdst_p when 0 then 'f' else 't'end; +END; +$$ LANGUAGE plpgsql; -create or replace function timezone__convert_to_utc (integer, varchar) returns timestamptz as ' -declare - p_tz_id alias for $1; - p_local_varchar alias for $2; + + +-- added +select define_function_args('timezone__convert_to_utc','tz_id,local_varchar'); + +-- +-- procedure timezone__convert_to_utc/2 +-- +CREATE OR REPLACE FUNCTION timezone__convert_to_utc( + p_tz_id integer, + p_local_varchar varchar +) RETURNS timestamptz AS $$ +DECLARE v_base_time timestamptz; -begin +BEGIN select "timestamptz" (p_local_varchar || substr(gmt_offset,1,5)) into v_base_time from timezones where tz_id = p_tz_id; if not found then - return "timestamptz" (p_local_varchar || ''+00''); + return "timestamptz" (p_local_varchar || '+00'); end if; - return "timestamptz" (p_local_varchar) - "interval" (gmt_offset || ''seconds'') + return "timestamptz" (p_local_varchar) - "interval" (gmt_offset || 'seconds') from timezone_rules where tz_id = p_tz_id and v_base_time between utc_start and utc_end; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; -create or replace function timezone__convert_to_local (integer, varchar) returns timestamptz as ' -declare - p_tz_id alias for $1; - p_utc_varchar alias for $2; + + +-- added +select define_function_args('timezone__convert_to_local','tz_id,utc_varchar'); + +-- +-- procedure timezone__convert_to_local/2 +-- +CREATE OR REPLACE FUNCTION timezone__convert_to_local( + p_tz_id integer, + p_utc_varchar varchar +) RETURNS timestamptz AS $$ +DECLARE v_base_time timestamptz; -begin +BEGIN select "timestamptz" (p_utc_varchar || substr(gmt_offset,1,5)) into v_base_time from timezones where tz_id = p_tz_id; if not found then - return "timestamptz" (p_utc_varchar || ''+00''); + return "timestamptz" (p_utc_varchar || '+00'); end if; - return "timestamptz" (p_utc_varchar) + "interval" (gmt_offset || ''seconds'') + return "timestamptz" (p_utc_varchar) + "interval" (gmt_offset || 'seconds') from timezone_rules where tz_id = p_tz_id and v_base_time between utc_start and utc_end; -end;' language 'plpgsql' stable; +END; +$$ LANGUAGE plpgsql stable; -create or replace function timezone__get_offset (integer, timestamptz) returns interval as ' -declare - p_tz_id alias for $1; - p_time alias for $2; + + +-- added +select define_function_args('timezone__get_offset','tz_id,time'); + +-- +-- procedure timezone__get_offset/2 +-- +CREATE OR REPLACE FUNCTION timezone__get_offset( + p_tz_id integer, + p_time timestamptz +) RETURNS interval AS $$ +DECLARE v_offset integer; -begin - v_offset := ''0''; +BEGIN + v_offset := '0'; select gmt_offset into v_offset from timezone_rules where tz_id = p_tz_id and p_time between utc_start and utc_end; - return "interval" (v_offset || ''seconds''); -end;' language 'plpgsql' stable; + return "interval" (v_offset || 'seconds'); +END; +$$ LANGUAGE plpgsql stable; -create or replace function timezone__get_rawoffset (integer, timestamptz) returns interval as ' -declare - p_tz_id alias for $1; - p_time alias for $2; + + +-- added +select define_function_args('timezone__get_rawoffset','tz_id,time'); + +-- +-- procedure timezone__get_rawoffset/2 +-- +CREATE OR REPLACE FUNCTION timezone__get_rawoffset( + p_tz_id integer, + p_time timestamptz +) RETURNS interval AS $$ +DECLARE v_offset varchar; -begin - v_offset := ''0''; +BEGIN + v_offset := '0'; select case isdst_p - when ''t'' then "interval" (gmt_offset || ''seconds'') - ''3600 seconds'' - else "interval" (gmt_offset || ''seconds'') + when 't' then "interval" (gmt_offset || 'seconds') - '3600 seconds' + else "interval" (gmt_offset || 'seconds') end into v_offset from timezone_rules where tz_id = p_tz_id and p_time between utc_start and utc_end; return v_offset; -end;' language 'plpgsql' stable; +END; +$$ LANGUAGE plpgsql stable; -create or replace function timezone__get_abbrev (integer, timestamptz) returns varchar as ' -declare - p_tz_id alias for $1; - p_time alias for $2; + + +-- added +select define_function_args('timezone__get_abbrev','tz_id,time'); + +-- +-- procedure timezone__get_abbrev/2 +-- +CREATE OR REPLACE FUNCTION timezone__get_abbrev( + p_tz_id integer, + p_time timestamptz +) RETURNS varchar AS $$ +DECLARE v_abbrev timezone_rules.abbrev%TYPE; -begin - v_abbrev := ''GMT''; +BEGIN + v_abbrev := 'GMT'; select abbrev into v_abbrev from timezone_rules where tz_id = p_tz_id and p_time between local_start and local_end; return v_abbrev; -end;' language 'plpgsql' stable; +END; +$$ LANGUAGE plpgsql stable; -- Returns a formatted date with timezone info appended -create or replace function timezone__get_date (integer, timestamptz, varchar, boolean) returns varchar as ' -declare - p_tz_id alias for $1; - p_timestamp alias for $2; - p_format alias for $3; - p_append_timezone_p alias for $4; + + +-- added +select define_function_args('timezone__get_date','tz_id,timestamp,format,append_timezone_p'); + +-- +-- procedure timezone__get_date/4 +-- +CREATE OR REPLACE FUNCTION timezone__get_date( + p_tz_id integer, + p_timestamp timestamptz, + p_format varchar, + p_append_timezone_p boolean +) RETURNS varchar AS $$ +DECLARE v_timestamp timestamptz; v_abbrev text; v_date text; -begin +BEGIN - v_abbrev := ''''; + v_abbrev := ''; if p_append_timezone_p then select abbrev into v_abbrev from timezone_rules where tz_id = p_tz_id and p_timestamp between utc_start and utc_end; end if; select to_char(p_timestamp + "interval" ( - (extract(timezone_hour from p_timestamp) * 3600 + extract(timezone_minute from p_timestamp) * 60) || ''seconds'') + - "interval" (gmt_offset || ''seconds''), p_format) || '' '' || v_abbrev + (extract(timezone_hour from p_timestamp) * 3600 + extract(timezone_minute from p_timestamp) * 60) || 'seconds') + + "interval" (gmt_offset || 'seconds'), p_format) || ' ' || v_abbrev into v_date from timezone_rules where tz_id = p_tz_id and p_timestamp between utc_start and utc_end; if not found then - select to_char(p_timestamp + "interval" ((extract(timezone_hour from p_timestamp) * 3600 + extract(timezone_minute from p_timestamp) * 60) || ''seconds''), p_format) + select to_char(p_timestamp + "interval" ((extract(timezone_hour from p_timestamp) * 3600 + extract(timezone_minute from p_timestamp) * 60) || 'seconds'), p_format) into v_date; end if; return v_date; -end;' language 'plpgsql' stable; +END; +$$ LANGUAGE plpgsql stable; -- Returns 't' if timezone is currently using DST -create or replace function timezone__isdst_p (integer, timestamptz) returns boolean as ' -declare - p_tz_id alias for $1; - p_time alias for $2; + + +-- added +select define_function_args('timezone__isdst_p','tz_id,time'); + +-- +-- procedure timezone__isdst_p/2 +-- +CREATE OR REPLACE FUNCTION timezone__isdst_p( + p_tz_id integer, + p_time timestamptz +) RETURNS boolean AS $$ +DECLARE v_isdst_p boolean; -begin - v_isdst_p := ''f''; +BEGIN + v_isdst_p := 'f'; select isdst_p into v_isdst_p from timezone_rules where tz_id = p_tz_id and p_time between local_start and local_end; return v_isdst_p; -end;' language 'plpgsql' stable; +END; +$$ LANGUAGE plpgsql stable; Index: openacs-4/packages/ref-timezones/sql/postgresql/ref-timezones-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ref-timezones/sql/postgresql/ref-timezones-drop.sql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/ref-timezones/sql/postgresql/ref-timezones-drop.sql 17 May 2003 11:11:11 -0000 1.4 +++ openacs-4/packages/ref-timezones/sql/postgresql/ref-timezones-drop.sql 30 Mar 2013 18:50:28 -0000 1.5 @@ -6,16 +6,24 @@ -- @created 2000-12-04 -- @cvs-id $Id$ -create function inline_0() returns integer as ' -declare + + +-- +-- procedure inline_0/0 +-- +CREATE OR REPLACE FUNCTION inline_0( + +) RETURNS integer AS $$ +DECLARE rec acs_reference_repositories%ROWTYPE; -begin - for rec in select * from acs_reference_repositories where upper(table_name) = ''TIMEZONES'' loop - execute ''drop table '' || rec.table_name; +BEGIN + for rec in select * from acs_reference_repositories where upper(table_name) = 'TIMEZONES' loop + execute 'drop table ' || rec.table_name; perform acs_reference__delete(rec.repository_id); end loop; return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; select inline_0(); drop function inline_0(); Index: openacs-4/packages/ref-timezones/sql/postgresql/upgrade/upgrade-0.2d-0.3.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ref-timezones/sql/postgresql/upgrade/upgrade-0.2d-0.3.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/ref-timezones/sql/postgresql/upgrade/upgrade-0.2d-0.3.sql 18 Aug 2003 15:24:38 -0000 1.1 +++ openacs-4/packages/ref-timezones/sql/postgresql/upgrade/upgrade-0.2d-0.3.sql 30 Mar 2013 18:50:28 -0000 1.2 @@ -5,25 +5,35 @@ -- @creation-date 2003-08-06 -- -create or replace function timezone__convert_to_local (integer, varchar) returns timestamptz as ' -declare - p_tz_id alias for $1; - p_utc_varchar alias for $2; + + +-- added +select define_function_args('timezone__convert_to_local','tz_id,utc_varchar'); + +-- +-- procedure timezone__convert_to_local/2 +-- +CREATE OR REPLACE FUNCTION timezone__convert_to_local( + p_tz_id integer, + p_utc_varchar varchar +) RETURNS timestamptz AS $$ +DECLARE v_base_time timestamptz; -begin +BEGIN select "timestamptz" (p_utc_varchar || substr(gmt_offset,1,5)) into v_base_time from timezones where tz_id = p_tz_id; if not found then - return "timestamptz" (p_utc_varchar || ''+00''); + return "timestamptz" (p_utc_varchar || '+00'); end if; - return "timestamptz" (p_utc_varchar) + "interval" (gmt_offset || ''seconds'') + return "timestamptz" (p_utc_varchar) + "interval" (gmt_offset || 'seconds') from timezone_rules where tz_id = p_tz_id and v_base_time between utc_start and utc_end; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; Index: openacs-4/packages/ref-timezones/sql/postgresql/upgrade/upgrade-5.2.0d1-5.2.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ref-timezones/sql/postgresql/upgrade/upgrade-5.2.0d1-5.2.0d2.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/ref-timezones/sql/postgresql/upgrade/upgrade-5.2.0d1-5.2.0d2.sql 24 Jul 2004 15:10:16 -0000 1.1 +++ openacs-4/packages/ref-timezones/sql/postgresql/upgrade/upgrade-5.2.0d1-5.2.0d2.sql 30 Mar 2013 18:50:28 -0000 1.2 @@ -1,15 +1,25 @@ -- alias missing from p_time decl. -create or replace function timezone__get_abbrev (integer, timestamptz) returns varchar as ' -declare - p_tz_id alias for $1; - p_time alias for $2; + + +-- added +select define_function_args('timezone__get_abbrev','tz_id,time'); + +-- +-- procedure timezone__get_abbrev/2 +-- +CREATE OR REPLACE FUNCTION timezone__get_abbrev( + p_tz_id integer, + p_time timestamptz +) RETURNS varchar AS $$ +DECLARE v_abbrev timezone_rules.abbrev%TYPE; -begin - v_abbrev := ''GMT''; +BEGIN + v_abbrev := 'GMT'; select abbrev into v_abbrev from timezone_rules where tz_id = p_tz_id and p_time between local_start and local_end; return v_abbrev; -end;' language 'plpgsql' stable; +END; +$$ LANGUAGE plpgsql stable; Index: openacs-4/packages/search/sql/postgresql/search-packages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/postgresql/search-packages-create.sql,v diff -u -r1.6 -r1.7 --- openacs-4/packages/search/sql/postgresql/search-packages-create.sql 14 May 2004 10:17:35 -0000 1.6 +++ openacs-4/packages/search/sql/postgresql/search-packages-create.sql 30 Mar 2013 18:50:29 -0000 1.7 @@ -2,12 +2,17 @@ -- -- @cvs-id $Id$ -create or replace function search_observer__enqueue(integer,varchar) -returns integer as ' -declare - p_object_id alias for $1; - p_event alias for $2; -begin + + +-- +-- procedure search_observer__enqueue/2 +-- +CREATE OR REPLACE FUNCTION search_observer__enqueue( + p_object_id integer, + p_event varchar +) RETURNS integer AS $$ +DECLARE +BEGIN insert into search_observer_queue ( object_id, event @@ -18,26 +23,33 @@ return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; select define_function_args('search_observer__enqueue','object_id,event'); -create or replace function search_observer__dequeue(integer,timestamptz,varchar) -returns integer as ' -declare - p_object_id alias for $1; - p_event_date alias for $2; - p_event alias for $3; -begin + +-- +-- procedure search_observer__dequeue/3 +-- +CREATE OR REPLACE FUNCTION search_observer__dequeue( + p_object_id integer, + p_event_date timestamptz, + p_event varchar +) RETURNS integer AS $$ +DECLARE +BEGIN + delete from search_observer_queue where object_id = p_object_id and event = p_event - and to_char(event_date,''yyyy-mm-dd hh24:mi:ss.us-tz'') = to_char(p_event_date,''yyyy-mm-dd hh24:mi:ss.us-tz''); + and to_char(event_date,'yyyy-mm-dd hh24:mi:ss.us-tz') = to_char(p_event_date,'yyyy-mm-dd hh24:mi:ss.us-tz'); return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; select define_function_args('search_observer__dequeue','object_id,event_date,event'); Index: openacs-4/packages/search/sql/postgresql/upgrade/upgrade-4.5-4.5.1.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/postgresql/upgrade/upgrade-4.5-4.5.1.sql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/search/sql/postgresql/upgrade/upgrade-4.5-4.5.1.sql 12 Oct 2003 22:20:28 -0000 1.4 +++ openacs-4/packages/search/sql/postgresql/upgrade/upgrade-4.5-4.5.1.sql 30 Mar 2013 18:50:29 -0000 1.5 @@ -9,22 +9,31 @@ drop function search_observer__dequeue(integer,timestamp with time zone,varchar); -create function search_observer__dequeue(integer,timestamp with time zone,varchar) -returns integer as ' -declare - p_object_id alias for $1; - p_event_date alias for $2; - p_event alias for $3; -begin + +-- added +select define_function_args('search_observer__dequeue','object_id,event_date,event'); + +-- +-- procedure search_observer__dequeue/3 +-- +CREATE OR REPLACE FUNCTION search_observer__dequeue( + p_object_id integer, + p_event_date timestamp with time zone, + p_event varchar +) RETURNS integer AS $$ +DECLARE +BEGIN + delete from search_observer_queue where object_id = p_object_id and event = p_event and event_date = p_event_date; return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; -- Index: openacs-4/packages/tsearch2-driver/sql/postgresql/tsearch2-driver-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tsearch2-driver/sql/postgresql/tsearch2-driver-package-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/tsearch2-driver/sql/postgresql/tsearch2-driver-package-create.sql 6 Jun 2004 20:31:55 -0000 1.1 +++ openacs-4/packages/tsearch2-driver/sql/postgresql/tsearch2-driver-package-create.sql 30 Mar 2013 18:50:29 -0000 1.2 @@ -1,24 +1,33 @@ -create or replace function ts2_to_tsvector ( varchar, varchar ) returns varchar as ' -declare -ts2_cfg alias for $1; -ts2_txt alias for $2; +-- +-- procedure ts2_to_tsvector/2 +-- +CREATE OR REPLACE FUNCTION ts2_to_tsvector ( + ts2_cfg varchar, + ts2_txt varchar +) RETURNS varchar AS $$ +DECLARE ts2_result varchar; -begin +BEGIN + perform set_curcfg(ts2_cfg); + select to_tsvector(ts2_cfg,ts2_txt) into ts2_result; + return ts2_result; +END; +$$ language plpgsql; -perform set_curcfg(ts2_cfg); -select to_tsvector(ts2_cfg,ts2_txt) into ts2_result; -return ts2_result; -end;' language 'plpgsql'; - -create or replace function ts2_to_tsquery ( varchar, varchar ) returns tsquery as ' -declare -ts2_cfg alias for $1; -ts2_txt alias for $2; +-- +-- procedure ts2_to_tsquery/2 +-- +CREATE OR REPLACE FUNCTION ts2_to_tsquery ( + ts2_cfg varchar, + ts2_txt varchar +) RETURNS tsquery AS $$ +DECLARE ts2_result tsquery; -begin -perform set_curcfg(ts2_cfg); -select 1 into ts2_result; -select to_tsquery(ts2_cfg,ts2_txt) into ts2_result; -return ts2_result; -end;' language 'plpgsql'; +BEGIN + perform set_curcfg(ts2_cfg); + select 1 into ts2_result; + select to_tsquery(ts2_cfg,ts2_txt) into ts2_result; + return ts2_result; +END; +$$ LANGUAGE plpgsql;