Index: openacs-4/packages/cms/sql/postgresql/cms-update.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/cms/sql/postgresql/cms-update.sql,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/cms/sql/postgresql/cms-update.sql	19 May 2001 01:20:10 -0000	1.1
+++ openacs-4/packages/cms/sql/postgresql/cms-update.sql	21 May 2001 23:13:59 -0000	1.2
@@ -1,60 +1,85 @@
 
 -- Modify permissions to include the cm_relate permission
+create function inline_0 ()
+returns integer as '
 declare
   v_exists integer;
 begin
   select count(*) into v_exists from acs_privileges 
-    where privilege = 'cm_admin';
+    where privilege = ''cm_admin'';
 
   if v_exists > 0 then
     select count(*) into v_exists from acs_privileges 
-      where privilege = 'cm_relate';
+      where privilege = ''cm_relate'';
 
     if v_exists < 1 then
-      acs_privilege.create_privilege('cm_relate', 'Relate Items', 'Relate Items'); 
-      acs_privilege.add_child('cm_admin', 'cm_relate');
       update acs_privilege_hierarchy 
-	set privilege = 'cm_relate'
-      where privilege = 'cm_admin' 
-	and child_privilege = 'cm_write';
+	set privilege = ''cm_relate''
+      where privilege = ''cm_admin'' 
+	and child_privilege = ''cm_write'';
     end if;
   end if;
-end;
-/
-show errors
 
+  return 0;
+end;' language 'plpgsql';
+
+select inline_0 ();
+
+drop function inline_0 ();
+
+
+-- show errors
+
 -- This parent_id column was not included in the cr_keywords table
 -- for RC 0.  Ensure this column is there.
 
+create function inline_1 ()
+returns integer as '
 begin
 
-  if not column_exists('cr_keywords', 'parent_id') then
+  if not column_exists(''cr_keywords'', ''parent_id'') then
 
-    dbms_output.put_line('Adding PARENT_ID column to CR_KEYWORDS' || 
-      ' and updating the parent id from the context id');
+    raise notice ''Adding PARENT_ID column to CR_KEYWORDS and updating the parent id from the context id'';
 
-    execute immediate 'alter table cr_keywords add 
+    execute ''alter table cr_keywords add 
        parent_id      integer 
                       constraint cr_keywords_hier
-                      references cr_keywords';
+                      references cr_keywords'';
 
-    execute immediate 'update cr_keywords set parent_id = (
+    execute ''update cr_keywords set parent_id = (
                          select context_id from acs_objects 
-                         where object_id = keyword_id)';
+                         where object_id = keyword_id)'';
 
   end if;
 
-end;
-/
-show errors
+  return 0;
+end;' language 'plpgsql';
 
+select inline_1 ();
+
+drop function inline_1 ();
+
+
+-- show errors
+
 -- Drop the broken trigger, if any
+create function inline_2 ()
+returns integer as '
 begin
-  execute immediate 'drop trigger cr_item_permission_tr';
-exception when others then null;
-end;
-/
-show errors
+  -- FIXME: DCW - can't locate where this trigger is created.  Need a table
+  -- name in order to drop it in pg.
 
-exec content_type.register_mime_type ('content_template', 'text/html');
-exec content_type.register_mime_type ('content_template', 'text/plain');
+  -- execute ''drop trigger cr_item_permission_tr'';
+
+  return 0;
+end;' language 'plpgsql';
+
+select inline_2 ();
+
+drop function inline_2 ();
+
+
+-- show errors
+
+select content_type__register_mime_type ('content_template', 'text/html');
+select content_type__register_mime_type ('content_template', 'text/plain');
