Index: openacs-4/packages/forums/sql/postgresql/upgrade/upgrade-0.2d-0.3d.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/postgresql/upgrade/upgrade-0.2d-0.3d.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/forums/sql/postgresql/upgrade/upgrade-0.2d-0.3d.sql	3 Oct 2003 19:38:15 -0000	1.1
+++ openacs-4/packages/forums/sql/postgresql/upgrade/upgrade-0.2d-0.3d.sql	12 Aug 2013 09:34:30 -0000	1.2
@@ -4,14 +4,22 @@
 
 create unique index forums_mess_forum_sk_un on forums_messages(forum_id, tree_sortkey);
 
-create or replace function forums_message__root_message_id (integer)
-returns integer as '
-declare
-    p_message_id                    alias for $1;
+
+
+-- added
+select define_function_args('forums_message__root_message_id','message_id');
+
+--
+-- procedure forums_message__root_message_id/1
+--
+CREATE OR REPLACE FUNCTION forums_message__root_message_id(
+   p_message_id integer
+) RETURNS integer AS $$
+DECLARE
     v_message_id                    forums_messages.message_id%TYPE;
     v_forum_id                      forums_messages.forum_id%TYPE;
     v_sortkey                       forums_messages.tree_sortkey%TYPE;
-begin
+BEGIN
     select forum_id, tree_sortkey
     into v_forum_id, v_sortkey
     from forums_messages
@@ -24,5 +32,6 @@
     and tree_sortkey = tree_ancestor_key(v_sortkey, 1);
 
     return v_message_id;
-end;
-' language 'plpgsql' with(isstrict,iscachable);
+END;
+
+$$ LANGUAGE plpgsql with(isstrict,iscachable);
