Index: openacs-4/packages/file-storage/sql/postgresql/file-storage-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/postgresql/file-storage-create.sql,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/file-storage/sql/postgresql/file-storage-create.sql	25 Sep 2001 16:55:14 -0000	1.7
+++ openacs-4/packages/file-storage/sql/postgresql/file-storage-create.sql	8 Dec 2001 01:18:00 -0000	1.8
@@ -58,8 +58,6 @@
                 unique
 );
 
-
-
 create function file_storage__get_root_folder (
        --
        -- Returns the root folder corresponding to a particular
@@ -89,7 +87,7 @@
 
         return v_folder_id;
 
-end;' language 'plpgsql';
+end;' language 'plpgsql' with (iscachable);
 
 
 
@@ -687,13 +685,12 @@
 	
 		-- We want to delete all cr_items entries, starting from the leaves all
 		--  the way up the root folder (old.folder_id).
-		select item_id,content_type
-		from cr_items
-		where  tree_sortkey like (select tree_sortkey || ''%''
-						            from cr_items
-						            where item_id = old.folder_id)
-		and item_id != old.folder_id
-                order by tree_sortkey desc
+		select c1.item_id, c1.content_type
+		from cr_items c1, cr_items c2
+                where c2.item_id = old.folder_id
+		  and c1.tree_sortkey between c2.tree_sortkey and tree_right(c2.tree_sortkey)
+		  and item_id != old.folder_id
+                order by c1.tree_sortkey desc
 	loop
 
 
