Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql,v
diff -u -r1.19 -r1.20
--- openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql	8 Jun 2001 01:52:31 -0000	1.19
+++ openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql	9 Jun 2001 01:06:04 -0000	1.20
@@ -546,7 +546,7 @@
                    where
                      workflow_key = ''publishing_wf''
                    and
-                     object_id = is_publishable__item_id;
+                     object_id = is_publishable__item_id
 
   LOOP
     if v_pub_wf.state != ''finished'' then
@@ -1407,7 +1407,7 @@
 
 -- function get_revision_count
 create function content_item__get_revision_count (integer)
-returns number as '
+returns integer as '
 declare
   get_revision_count__item_id   alias for $1;  
   v_count                       integer;       
Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-revision.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-revision.sql,v
diff -u -r1.19 -r1.20
--- openacs-4/packages/acs-content-repository/sql/postgresql/content-revision.sql	17 May 2001 03:59:04 -0000	1.19
+++ openacs-4/packages/acs-content-repository/sql/postgresql/content-revision.sql	9 Jun 2001 01:06:04 -0000	1.20
@@ -386,12 +386,13 @@
 
 -- function get_number
 create function content_revision__get_number (integer)
-returns number as '
+returns integer as '
 declare
   get_number__revision_id            alias for $1;  
   v_number                           integer;       
   v_revision                         cr_revisions.revision_id%TYPE;
-  row_count                          integer default 0;
+  v_row_count                        integer default 0;
+  rev_cur                            record;
 begin
   for rev_cur in select
                    revision_id
@@ -405,9 +406,9 @@
                  order by
                    o.creation_date
   LOOP
-    row_count := row_count + 1;
+    v_row_count := v_row_count + 1;
     if v_revision = get_number__revision_id then 
-       v_number := row_count;
+       v_number := v_row_count;
        exit;
     end if;
   end LOOP;
@@ -570,15 +571,13 @@
 declare
   content_copy__revision_id            alias for $1;  
   content_copy__revision_id_dest       alias for $2;  -- default null  
-  lobs                                 blob;          
-  lobd                                 blob;          
   v_item_id                            cr_items.item_id%TYPE;
   v_content_length                     cr_revisions.content_length%TYPE;
   v_revision_id_dest                   cr_revisions.revision_id%TYPE;
   v_content                            cr_revisions.content%TYPE;
   v_lob                                cr_revisions.lob%TYPE;
   v_new_lob                            cr_revisions.lob%TYPE;
-  v_content_type                       cr_revisions.content_type%TYPE;
+  v_storage_type                       varchar;
 begin
 
   select
@@ -616,7 +615,7 @@
       into v_content, v_content_length, v_lob, v_storage_type
       from cr_revisions r, cr_items i 
      where r.item_id = i.item_id 
-       and r.revision_id = content_copy__revision_id
+       and r.revision_id = content_copy__revision_id;
 
     if v_storage_type = ''lob'' then
         v_new_lob := empty_lob();
Index: openacs-4/packages/cms/www/modules/items/attributes-edit.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/attributes-edit.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/cms/www/modules/items/attributes-edit.xql	25 May 2001 04:56:36 -0000	1.1
+++ openacs-4/packages/cms/www/modules/items/attributes-edit.xql	9 Jun 2001 01:06:04 -0000	1.2
@@ -5,7 +5,7 @@
       <querytext>
 
   select 
-    i.content_type, i.name, coalesce(r.title, i.name) title, i.latest_revision
+    i.content_type, i.name, coalesce(r.title, i.name) as title, i.latest_revision
   from
     cr_items i left outer join cr_revisions r on i.latest_revision = r.revision_id 
   where
Index: openacs-4/packages/cms/www/modules/items/publish-status-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/publish-status-postgresql.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/cms/www/modules/items/publish-status-postgresql.xql	25 May 2001 04:56:36 -0000	1.1
+++ openacs-4/packages/cms/www/modules/items/publish-status-postgresql.xql	9 Jun 2001 01:06:04 -0000	1.2
@@ -52,7 +52,7 @@
     child_type, relation_tag, min_n, 
     o.pretty_name as child_type_pretty, 
     o.pretty_plural as child_type_plural, 
-    case when max_n = null then '-' else max_n end as max_n,
+    case when max_n = null then '-'::text else max_n::text end as max_n,
     (
       select
         count(*)
@@ -64,7 +64,7 @@
         content_item__get_content_type( child_id ) = c.child_type
       and
         relation_tag = c.relation_tag
-    ) child_count
+    ) as child_count
   from
     cr_type_children c, cr_items i, acs_object_types o
   where
@@ -86,7 +86,7 @@
     target_type, relation_tag, min_n, 
     o.pretty_name as target_type_pretty,
     o.pretty_plural as target_type_plural,
-    case when max_n is null then '-' else max_n end as max_n,
+    case when max_n is null then '-'::text else max_n::text end as max_n,
     (
       select
         count(*)
@@ -98,7 +98,7 @@
         content_item__get_content_type( related_object_id ) = r.target_type
       and
         relation_tag = r.relation_tag
-    ) rel_count
+    ) as rel_count
   from
     cr_type_relations r, cr_items i, acs_object_types o
   where
Index: openacs-4/packages/cms/www/modules/items/revisions-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/revisions-oracle.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/cms/www/modules/items/revisions-oracle.xql	25 May 2001 04:56:36 -0000	1.1
+++ openacs-4/packages/cms/www/modules/items/revisions-oracle.xql	9 Jun 2001 01:06:04 -0000	1.2
@@ -40,7 +40,7 @@
   from 
     cr_revisions r
   where 
-    r.item_id = :item_id
+    r.item_id = $item_id
   order by
     revision_number desc" $page
       </querytext>
Index: openacs-4/packages/cms/www/modules/items/revisions-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/revisions-postgresql.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/cms/www/modules/items/revisions-postgresql.xql	25 May 2001 04:56:36 -0000	1.1
+++ openacs-4/packages/cms/www/modules/items/revisions-postgresql.xql	9 Jun 2001 01:06:04 -0000	1.2
@@ -40,7 +40,7 @@
   from 
     cr_revisions r
   where 
-    r.item_id = :item_id
+    r.item_id = $item_id
   order by
     revision_number desc
 
Index: openacs-4/packages/cms/www/modules/items/revisions.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/revisions.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/cms/www/modules/items/revisions.tcl	27 May 2001 04:39:19 -0000	1.3
+++ openacs-4/packages/cms/www/modules/items/revisions.tcl	9 Jun 2001 01:06:04 -0000	1.4
@@ -52,6 +52,9 @@
   order by
     revision_number desc" $page]
 
-set total_pages [pagination::get_total_pages]
 
+set sql [db_map get_revisions]
+
+set total_pages [pagination::get_total_pages $sql]
+
 set pagination_html [pagination::page_number_links $page $total_pages]
Index: openacs-4/packages/cms/www/modules/items/templates-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/cms/www/modules/items/templates-postgresql.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/cms/www/modules/items/templates-postgresql.xql	30 May 2001 22:56:27 -0000	1.2
+++ openacs-4/packages/cms/www/modules/items/templates-postgresql.xql	9 Jun 2001 01:06:04 -0000	1.3
@@ -37,7 +37,7 @@
       
   select 
     template_id, use_context, 
-    content_item__get_path( template_id ) as path,
+    content_item__get_path( template_id, null ) as path,
     cms_permission__permission_p( template_id, :user_id, 'cm_examine')
       as can_read_template
   from