Index: openacs-4/packages/acs-events/sql/postgresql/test/timespan-test.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-events/sql/postgresql/test/timespan-test.sql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-events/sql/postgresql/test/timespan-test.sql	17 May 2003 09:47:26 -0000	1.2
+++ openacs-4/packages/acs-events/sql/postgresql/test/timespan-test.sql	30 Mar 2013 13:00:30 -0000	1.3
@@ -12,20 +12,19 @@
 \i utest-create.sql
 
 -- Set-up the regression test
-create function ut__setup()
-returns integer as '
-begin
+CREATE OR REPLACE FUNCTION ut__setup() RETURNS integer AS $$
+BEGIN
 
-	raise notice ''Setting up timespans test...'';
+	raise notice 'Setting up timespans test...';
 
 	-- create copies of the tables (shadow tables) to verify API operations
 	-- No need for execute here?
 	create table ut_timespans as select * from timespans;
 
 	-- For testing purposes, both tables should still be empty
-	PERFORM ut_assert__eqtable (''Comparing copied data for time interval'',
-				    ''timespans'',
-				    ''ut_timespans''
+	PERFORM ut_assert__eqtable ('Comparing copied data for time interval',
+				    'timespans',
+				    'ut_timespans'
 				    );
 
 	-- Store keys that are in the table prior to the regresion test
@@ -34,15 +33,15 @@
 
 	return 0;
 
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 
 -- Clean up the mess that regression testing did
-create function ut__teardown()
-returns integer as '
-begin
+CREATE OR REPLACE FUNCTION ut__teardown() RETURNS integer AS $$
+BEGIN
 
-	raise notice ''Tearing down timespans test...'';
+	raise notice 'Tearing down timespans test...';
 
 	-- Delete intervals added by tests
 	-- cascade delete in timespans should delete corresponding entries in that table
@@ -66,23 +65,30 @@
 
 	return 0;
 
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 
 -- Postgres has this weird behavior that you cannot change a row twice
 -- within a transaction.  
 
 
 -- We test the creation of a time interval entry
-create function ut__new(
-       integer	-- time_intervals.interval_id%TYPE;
-)
-returns integer as '
-declare
-	new__interval_id    alias for $1;
+
+
+-- added
+select define_function_args('ut__new','interval_id');
+
+--
+-- procedure ut__new/1
+--
+CREATE OR REPLACE FUNCTION ut__new(
+   new__interval_id integer
+) RETURNS integer AS $$
+DECLARE
 	v_interval_id	    time_intervals.interval_id%TYPE;
 	v_timespan_id	    timespans.timespan_id%TYPE;
-begin
+BEGIN
 
 	-- The new function will create a copy on the time_intervals table
 	v_timespan_id := timespan__new(new__interval_id);
@@ -99,33 +105,36 @@
 
 	-- The new function will create a copy on the time_intervals table
 	-- We do two test.  First, we check whether the copying mechanism is ok
-	PERFORM ut_assert__eq (''Test of timespan__new copying mechanism: '',
+	PERFORM ut_assert__eq ('Test of timespan__new copying mechanism: ',
 			       time_interval__eq(v_interval_id, new__interval_id),
 			       true
 			       );
 
 	-- Second, we check whether the timespans table is properly populated
-	PERFORM ut_assert__eqtable (''Test of timespan__new entry in timespans table: '',
-				    ''ut_timespans'',
-				    ''timespans''
+	PERFORM ut_assert__eqtable ('Test of timespan__new entry in timespans table: ',
+				    'ut_timespans',
+				    'timespans'
 				    );
 
 	-- If successful, interval id is correct
 	return v_timespan_id;
 
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 -- We test the creation of a time interval entry
-create function ut__new(
-       timestamptz,
-       timestamptz
-)
-returns integer as '
-declare
-	new__date1	    alias for $1;
-	new__date2	    alias for $2;
+
+
+--
+-- procedure ut__new/2
+--
+CREATE OR REPLACE FUNCTION ut__new(
+   new__date1 timestamptz,
+   new__date2 timestamptz
+) RETURNS integer AS $$
+DECLARE
 	v_interval_id	    time_intervals.interval_id%TYPE;
-begin
+BEGIN
 
 	-- We first want to create an entry in the time interval table
 	-- because the timespan_new function copies this interval
@@ -134,24 +143,31 @@
 	-- Create a new timespan using the function above
 	return ut__new(v_interval_id);
 
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 
 -- Check the deletion of a time interval
-create function ut__delete(
-       integer	-- timespans.timespan_id%TYPE
-)
-returns integer as '
-declare
-	delete__timespan_id  alias for $1;
-begin
 
+
+-- added
+select define_function_args('ut__delete','timespan_id');
+
+--
+-- procedure ut__delete/1
+--
+CREATE OR REPLACE FUNCTION ut__delete(
+   delete__timespan_id integer
+) RETURNS integer AS $$
+DECLARE
+BEGIN
+
 	-- Delete the row from actual table
 	PERFORM timespan__delete(delete__timespan_id);
 
-	PERFORM ut_assert__eqtable (''Testing timespan__delete: '',
-				    ''ut_timespans'',
-				    ''timespans''
+	PERFORM ut_assert__eqtable ('Testing timespan__delete: ',
+				    'ut_timespans',
+				    'timespans'
 				    );
 
 	-- Delete entry from shadow table
@@ -171,23 +187,28 @@
 	-- If successful, interval id is correct
 	return 0;
 
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 
-create function ut__join_interval (
-       integer,	     -- timespans.timespan_id%TYPE;
-       integer,	     -- time_intervals.interval_id%TYPE;
-       boolean	     -- copy_p (if false, create new)
-)
-returns integer as '
-declare
-	join_interval__timespan_id	alias for $1;
-	join_interval__interval_id	alias for $2;
-	join_interval__copy_p		alias for $3;
+
+
+-- added
+select define_function_args('ut__join_interval','timespan_id,interval_id,copy_p');
+
+--
+-- procedure ut__join_interval/3
+--
+CREATE OR REPLACE FUNCTION ut__join_interval(
+   join_interval__timespan_id integer,
+   join_interval__interval_id integer,
+   join_interval__copy_p boolean
+) RETURNS integer AS $$
+DECLARE
 	v_interval_id			 time_intervals.interval_id%TYPE;
 	v_interval_id_ck		 time_intervals.interval_id%TYPE;
 	v_interval_id_cp		 time_intervals.interval_id%TYPE;
-begin
+BEGIN
 
 	-- Get interval id of orginal interval (before join)
 	select interval_id into v_interval_id
@@ -205,17 +226,17 @@
 	values (join_interval__timespan_id,v_interval_id_cp);
 
 	-- Check if there are now two intervals with the same timespan_id in timespans table
-	PERFORM ut_assert__eqquery (''Testing timespan__join with two intervals (2 entries): '',
-				    ''select count(*) 
+	PERFORM ut_assert__eqquery ('Testing timespan__join with two intervals (2 entries): ',
+				    'select count(*) 
 				      from timespans
-				      where timespan_id = '' || join_interval__timespan_id,
-				    ''select 2 from dual''
+				      where timespan_id = ' || join_interval__timespan_id,
+				    'select 2 from dual'
 				    );
 
 	-- This is probably a more robust check, since we want to compare the resulting timespan table
-	PERFORM ut_assert__eqtable (''Testing timespan__join: table comparison test: '',
-				    ''ut_timespans'',
-				    ''timespans''
+	PERFORM ut_assert__eqtable ('Testing timespan__join: table comparison test: ',
+				    'ut_timespans',
+				    'timespans'
 				    );
 
 				   
@@ -224,18 +245,23 @@
 	-- AND checking that only two intervals are in the time span should be enough!
 	return 0;
 
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
-create function ut__join(
-       integer,   -- timespans.timespan_id%TYPE;
-       integer	  -- timespans.timespan_id%TYPE;
-)
-returns integer as '
-declare
-	join__timespan_id_1 alias for $1;
-	join__timespan_id_2 alias for $2;
+
+
+-- added
+
+--
+-- procedure ut__join/2
+--
+CREATE OR REPLACE FUNCTION ut__join(
+   join__timespan_id_1 integer,
+   join__timespan_id_2 integer
+) RETURNS integer AS $$
+DECLARE
 	rec_timespan	    record;
-begin
+BEGIN
 
 	PERFORM timespan__join(join__timespan_id_1,join__timespan_id_2);
 
@@ -252,25 +278,30 @@
 
 
 	-- Check equality of tables
-	PERFORM	 ut_assert__eqtable (''Testing timespan__join by specifying timespan_id: '',
-				     ''ut_timespans'',
-				     ''timespans''
+	PERFORM	 ut_assert__eqtable ('Testing timespan__join by specifying timespan_id: ',
+				     'ut_timespans',
+				     'timespans'
 				     );
 	return 0;
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
-create function ut__join(
-       integer,    -- timespans.timespan_id%TYPE;
-       timestamptz,  -- time_intervals.start_date%TYPE;
-       timestamptz  -- time_intervals.end_date%TYPE;
-)
-returns integer as '
-declare
-	join__timespan_id alias for $1;
-	join__start_date  alias for $2;
-	join__end_date	  alias for $3;
+
+
+-- added
+select define_function_args('ut__join','timespan_id,start_date,end_date');
+
+--
+-- procedure ut__join/3
+--
+CREATE OR REPLACE FUNCTION ut__join(
+   join__timespan_id integer,
+   join__start_date timestamptz,
+   join__end_date timestamptz
+) RETURNS integer AS $$
+DECLARE
 	v_interval_id	  time_intervals.interval_id%TYPE;
-begin
+BEGIN
 
 
 
@@ -282,26 +313,32 @@
 	values (join__timespan_id,v_interval_id);
 
 	-- Check equality of tables
-	PERFORM	 ut_assert__eqtable (''Testing timespan__join by specifying start and end dates: '',
-				     ''ut_timespans'',
-				     ''timespans''
+	PERFORM	 ut_assert__eqtable ('Testing timespan__join by specifying start and end dates: ',
+				     'ut_timespans',
+				     'timespans'
 				     );
 	return 0;
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
-create function ut__copy(
-       integer,	-- timespans.timespan_id%TYPE
-       interval	-- offset
-)
-returns integer as '
-declare
-	copy__timespan_id	alias for $1;
-	copy__offset		alias for $2;
+
+
+-- added
+select define_function_args('ut__copy','timespan_id,offset');
+
+--
+-- procedure ut__copy/2
+--
+CREATE OR REPLACE FUNCTION ut__copy(
+   copy__timespan_id integer,
+   copy__offset interval
+) RETURNS integer AS $$
+DECLARE
 	v_timespan_id		timespans.timespan_id%TYPE;
 	v_interval_id		time_intervals.interval_id%TYPE;
 	v_interval_id_ck	time_intervals.interval_id%TYPE;
 	rec_timespan		record;
-begin
+BEGIN
 
 	v_timespan_id := timespan__copy(copy__timespan_id,copy__offset);
 
@@ -318,122 +355,153 @@
 	end loop;
 
 	-- Check proper population of shadow table
-	PERFORM ut_assert__eqtable (''Testing timespan__copy: '',
-				    ''ut_timespans'',
-				    ''timespans''
+	PERFORM ut_assert__eqtable ('Testing timespan__copy: ',
+				    'ut_timespans',
+				    'timespans'
 				    );
 
 	return v_timespan_id;
 
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 
-create function ut__exists_p (
-       integer,	-- timespans.timespan_id%TYPE;
-       boolean
-)
-returns integer as '
-declare
-	exists_p__timespan_id	alias for $1;
-	exists_p__result	alias for $2;
-begin
 
-	PERFORM ut_assert__eq (''Testing timespan__exists_p: '',
+
+-- added
+select define_function_args('ut__exists_p','timespan_id,result');
+
+--
+-- procedure ut__exists_p/2
+--
+CREATE OR REPLACE FUNCTION ut__exists_p(
+   exists_p__timespan_id integer,
+   exists_p__result boolean
+) RETURNS integer AS $$
+DECLARE
+BEGIN
+
+	PERFORM ut_assert__eq ('Testing timespan__exists_p: ',
 			       timespan__exists_p(exists_p__timespan_id),
 			       exists_p__result
 			       );
 			       
 	return 0;
 
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
-create function ut__multi_interval_p (
-       integer,  -- timespans.timespan_id%TYPE
-       boolean   -- result
-)
-returns integer as '
-declare
-	multi_interval_p__timespan_id   alias for $1;
-	multi_interval_p__result   alias for $2;
-begin
 
-      return ut_assert__eq (''Testing timespan__multi_interval_p: '',
+
+-- added
+select define_function_args('ut__multi_interval_p','timespan_id,result');
+
+--
+-- procedure ut__multi_interval_p/2
+--
+CREATE OR REPLACE FUNCTION ut__multi_interval_p(
+   multi_interval_p__timespan_id integer,
+   multi_interval_p__result boolean
+) RETURNS integer AS $$
+DECLARE
+BEGIN
+
+      return ut_assert__eq ('Testing timespan__multi_interval_p: ',
 			    timespan__multi_interval_p(multi_interval_p__timespan_id),
 			    multi_interval_p__result
 			    );
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 
-create function ut__overlaps_interval_p(
-       integer,		-- timespans.timespan_id%TYPE;
-       integer,		-- time_intervals.interval_id%TYPE;
-       boolean
-)
-returns integer as '
-declare
-	overlaps_interval_p__timespan_id alias for $1;
-	overlaps_interval_p__interval_id alias for $2;
-	overlaps_interval_p__result	 alias for $3;
-begin
 
-      return ut_assert__eq (''Testing timespan__overlaps_interval_p: '',
+
+-- added
+select define_function_args('ut__overlaps_interval_p','timespan_id,interval_id,result');
+
+--
+-- procedure ut__overlaps_interval_p/3
+--
+CREATE OR REPLACE FUNCTION ut__overlaps_interval_p(
+   overlaps_interval_p__timespan_id integer,
+   overlaps_interval_p__interval_id integer,
+   overlaps_interval_p__result boolean
+) RETURNS integer AS $$
+DECLARE
+BEGIN
+
+      return ut_assert__eq ('Testing timespan__overlaps_interval_p: ',
 			    timespan__overlaps_interval_p(overlaps_interval_p__timespan_id,
 							  overlaps_interval_p__interval_id),
 			    overlaps_interval_p__result
 			    );
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
-create function ut__overlaps_p(
-       integer,		-- timespans.timespan_id%TYPE;
-       integer,		-- timespans.timespan_id%TYPE;
-       boolean
-)
-returns integer as '
-declare
-	overlaps_p__timespan_1_id alias for $1;
-	overlaps_p__timespan_2_id alias for $2;
-	overlaps_p__result	  alias for $3;
-begin
 
-      return ut_assert__eq (''Testing timespan__overlaps_p, timespan vs. timespan: '',
+
+-- added
+
+--
+-- procedure ut__overlaps_p/3
+--
+CREATE OR REPLACE FUNCTION ut__overlaps_p(
+   overlaps_p__timespan_1_id integer,
+   overlaps_p__timespan_2_id integer,
+   overlaps_p__result boolean
+) RETURNS integer AS $$
+DECLARE
+BEGIN
+
+      return ut_assert__eq ('Testing timespan__overlaps_p, timespan vs. timespan: ',
 			    timespan__overlaps_p(overlaps_p__timespan_1_id,
 						 overlaps_p__timespan_2_id),
 			    overlaps_p__result
 			    );
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
-create function ut__overlaps_p(
-       integer,		-- timespans.timespan_id%TYPE;
-       timestamptz,	-- time_intervals.start_date%TYPE;
-       timestamptz,	-- time_intervals.end_date%TYPE;
-       boolean
-)
-returns integer as '
-declare
-	overlaps_p__timespan_id alias for $1;
-	overlaps_p__start_date alias for $2;
-	overlaps_p__end_date   alias for $3;
-	overlaps_p__result     alias for $4;
-begin
 
-      return ut_assert__eq (''Test of timespan__overlaps_p, timespan vs. start and end dates: '',
+
+-- added
+select define_function_args('ut__overlaps_p','timespan_id,start_date,end_date,result');
+
+--
+-- procedure ut__overlaps_p/4
+--
+CREATE OR REPLACE FUNCTION ut__overlaps_p(
+   overlaps_p__timespan_id integer,
+   overlaps_p__start_date timestamptz,
+   overlaps_p__end_date timestamptz,
+   overlaps_p__result boolean
+) RETURNS integer AS $$
+DECLARE
+BEGIN
+
+      return ut_assert__eq ('Test of timespan__overlaps_p, timespan vs. start and end dates: ',
 			    timespan__overlaps_p(overlaps_p__timespan_id,
 						 overlaps_p__start_date,
 						 overlaps_p__end_date),
 			    overlaps_p__result
 			    );
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
-create function ut__interval_delete (
-       integer,	  -- timespans.timespan_id%TYPE;
-       integer    -- time_intervals.interval_id%TYPE;
-)
-returns integer as '
-declare
-	  interval_delete__timespan_id	alias for $1;
-	  interval_delete__interval_id  alias for $2;
-begin
 
+
+-- added
+select define_function_args('ut__interval_delete','timespan_id,interval_id');
+
+--
+-- procedure ut__interval_delete/2
+--
+CREATE OR REPLACE FUNCTION ut__interval_delete(
+   interval_delete__timespan_id integer,
+   interval_delete__interval_id integer
+) RETURNS integer AS $$
+DECLARE
+BEGIN
+
 	PERFORM timespan__interval_delete(interval_delete__timespan_id,interval_delete__interval_id);
 				
 	-- Remove from shadow table
@@ -442,34 +510,41 @@
 	      and
 	      interval_id = interval_delete__interval_id;
 
-	return ut_assert__eqtable(''Testing timespan__interval_delete: '',
-				  ''ut_timespans'',
-				  ''timespans''
+	return ut_assert__eqtable('Testing timespan__interval_delete: ',
+				  'ut_timespans',
+				  'timespans'
 				  );
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 
-create function ut__regression1()
-returns integer as '
-declare
+
+
+--
+-- procedure ut__regression1/0
+--
+CREATE OR REPLACE FUNCTION ut__regression1(
+
+) RETURNS integer AS $$
+DECLARE
 	v_result	 integer := 0;
 	v_interval_id	 time_intervals.interval_id%TYPE;
 	v_interval_id_ck time_intervals.interval_id%TYPE;
 	v_timespan_id	 timespans.timespan_id%TYPE;
 	v_timespan_id_ck	 timespans.timespan_id%TYPE;
-begin
+BEGIN
 
-	raise notice ''Regression test, part 1 (creates and edits).'';
+	raise notice 'Regression test, part 1 (creates and edits).';
 
 	-- First create an interval
-	v_interval_id := time_interval__new(timestamptz ''2001-01-01'',timestamptz ''2001-01-20'');
+	v_interval_id := time_interval__new(timestamptz '2001-01-01',timestamptz '2001-01-20');
 
 	--Check if creation of timespans work by supplying an interval id to be copied
 	PERFORM ut__new(v_interval_id);
 
 	-- We first check if the creation of timespans work
 	-- This should be equivalent to what we have above
-	v_timespan_id := ut__new(timestamptz ''2001-01-25'',timestamptz ''2001-02-02'');
+	v_timespan_id := ut__new(timestamptz '2001-01-25',timestamptz '2001-02-02');
 
 	-- Test if timespan exists
 	PERFORM ut__exists_p(v_timespan_id,true);
@@ -494,20 +569,20 @@
 	PERFORM ut__overlaps_interval_p(v_timespan_id,v_interval_id,true);
 
 	-- A new timespans
-	v_timespan_id := ut__new(timestamptz ''2001-03-05'',timestamptz ''2001-03-31'');
-	v_timespan_id_ck := ut__new(timestamptz ''2001-06-05'',timestamptz ''2001-06-30'');
+	v_timespan_id := ut__new(timestamptz '2001-03-05',timestamptz '2001-03-31');
+	v_timespan_id_ck := ut__new(timestamptz '2001-06-05',timestamptz '2001-06-30');
 
 	-- These timespans should not overlap
 	PERFORM ut__overlaps_p(v_timespan_id,v_timespan_id_ck,false);
 
 	-- Check overlaps against these known dates
-	PERFORM ut__overlaps_p(v_timespan_id,timestamptz ''2001-02-06'',timestamptz ''2001-03-25'',true);
-	PERFORM ut__overlaps_p(v_timespan_id,timestamptz ''2001-03-07'',timestamptz ''2001-04-01'',true);
-	PERFORM ut__overlaps_p(v_timespan_id,timestamptz ''2001-01-01'',timestamptz ''2001-03-20'',true);
-	PERFORM ut__overlaps_p(v_timespan_id,timestamptz ''2001-01-01'',null,true);
-	PERFORM ut__overlaps_p(v_timespan_id,null,timestamptz ''2001-04-01'',true);
-	PERFORM ut__overlaps_p(v_timespan_id,timestamptz ''2001-04-01'',timestamptz ''2001-04-30'',false);
-	PERFORM ut__overlaps_p(v_timespan_id,timestamptz ''2001-02-01'',timestamptz ''2001-02-27'',false);
+	PERFORM ut__overlaps_p(v_timespan_id,timestamptz '2001-02-06',timestamptz '2001-03-25',true);
+	PERFORM ut__overlaps_p(v_timespan_id,timestamptz '2001-03-07',timestamptz '2001-04-01',true);
+	PERFORM ut__overlaps_p(v_timespan_id,timestamptz '2001-01-01',timestamptz '2001-03-20',true);
+	PERFORM ut__overlaps_p(v_timespan_id,timestamptz '2001-01-01',null,true);
+	PERFORM ut__overlaps_p(v_timespan_id,null,timestamptz '2001-04-01',true);
+	PERFORM ut__overlaps_p(v_timespan_id,timestamptz '2001-04-01',timestamptz '2001-04-30',false);
+	PERFORM ut__overlaps_p(v_timespan_id,timestamptz '2001-02-01',timestamptz '2001-02-27',false);
 
 
 	-- Join the first interval with the second, making a copy
@@ -520,10 +595,10 @@
 	PERFORM ut__overlaps_p(v_timespan_id,v_timespan_id_ck,true);
 
 	-- Join an interval instead
-	PERFORM ut__join(v_timespan_id_ck,timestamptz ''2001-12-01'',timestamptz ''2001-12-31'');
+	PERFORM ut__join(v_timespan_id_ck,timestamptz '2001-12-01',timestamptz '2001-12-31');
 
 	-- Copy a timespan (will only contain two)
-	PERFORM ut__copy(v_timespan_id,interval ''0 days'');
+	PERFORM ut__copy(v_timespan_id,interval '0 days');
 	
 	-- Now try to delete the interval just joined
 	PERFORM ut__interval_delete(v_timespan_id,v_interval_id);
@@ -534,16 +609,23 @@
 	-- enough to declare success.
        	return v_result;
 
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
-create function ut__regression2()
-returns integer as '
-declare
+
+
+--
+-- procedure ut__regression2/0
+--
+CREATE OR REPLACE FUNCTION ut__regression2(
+
+) RETURNS integer AS $$
+DECLARE
 	v_result	 integer := 0;
 	rec_timespan	 record;
-begin
+BEGIN
 
-	raise notice ''Regression test, part 2 (deletes).'';
+	raise notice 'Regression test, part 2 (deletes).';
 
 	-- Remove all entries made by regression test
 	-- This also tests the deletion mechanism
@@ -560,7 +642,8 @@
 	-- enough to declare success.
        	return v_result;
 
-end;' language 'plpgsql';
+END;
+$$ LANGUAGE plpgsql;
 
 --------------------------------------------------------------------------------
 -- Main regression test.  PostgreSQL does not allow multiple changes made to a 
