Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql,v diff -u -r1.19 -r1.20 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql 22 Aug 2001 00:33:35 -0000 1.19 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql 29 Aug 2001 05:12:50 -0000 1.20 @@ -668,8 +668,12 @@ create table cr_folders ( folder_id integer - constraint cr_folder_id_fk references - cr_items on delete cascade + -- removed due to postgresql RI bug which causes deletion failures. + -- replace with user triggers + -- DanW (dcwickstrom@earthlink.net) + + -- constraint cr_folder_id_fk references + -- cr_items on delete cascade constraint cr_folders_pk primary key, label varchar(1000), @@ -684,6 +688,46 @@ '; +create function cr_folder_ins_up_ri_trg() returns opaque as ' +declare + dummy integer; + v_latest integer; + v_live integer; +begin + select 1 into dummy + from + cr_items + where + item_id = new.folder_id; + + if NOT FOUND then + raise EXCEPTION ''Referential Integrity: folder_id does not exist in cr_items: %'', new.folder_id; + end if; + + return new; +end;' language 'plpgsql'; + +create function cr_folder_del_ri_trg() returns opaque as ' +declare + dummy integer; +begin + delete from cr_folders where folder_id = old.item_id; + return old; +end;' language 'plpgsql'; + +-- reimplementation of RI triggers. (DanW dcwickstrom@earthlink.net) + +create trigger cr_folder_ins_up_ri_trg +before insert or update on cr_folders +for each row execute procedure cr_folder_ins_up_ri_trg(); + +create trigger cr_folder_del_ri_trg +before delete on cr_items +for each row execute procedure cr_folder_del_ri_trg(); + + + + create table cr_folder_type_map ( folder_id integer constraint cr_folder_type_map_fldr_fk Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-test.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-test.sql,v diff -u -r1.8 -r1.9 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-test.sql 28 Aug 2001 23:31:30 -0000 1.8 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-test.sql 29 Aug 2001 05:12:50 -0000 1.9 @@ -1,4 +1,16 @@ -- set serveroutput on +drop function content_test__create(); +drop function content_test__check1(); +drop function content_test__check2(); +drop function content_test__check3(); +drop function content_test__check4(); +drop function content_test__check5(); +drop function content_test__put_line(text); +drop function cast_char(boolean); +drop function content_test__dump(); +drop function content_test__get_val(varchar); +drop function content_test__save_val(integer,varchar); +drop table tst_ids; create table tst_ids ( id integer, name varchar(400) @@ -663,16 +675,16 @@ -- symlinks/revisions should be deleted automatically - PERFORM content_item__delete(simple_item_id); PERFORM content_template__delete(item_template_id); - PERFORM content_item__delete(item_id); PERFORM content_template__delete(type_template_id); PERFORM content_template__delete(def_type_template_id); PERFORM content_template__delete(dum_template_id); + PERFORM content_item__delete(simple_item_id); + PERFORM content_item__delete(item_id); + PERFORM content_folder__delete(folder_b_id); PERFORM content_folder__delete(sub_sub_folder_id); PERFORM content_folder__delete(sub_folder_id); PERFORM content_folder__delete(folder_id); - PERFORM content_folder__delete(folder_b_id); return null; @@ -688,17 +700,4 @@ select content_test__check4(); select content_test__check5(); \t -drop function content_test__create(); -drop function content_test__check1(); -drop function content_test__check2(); -drop function content_test__check3(); -drop function content_test__check4(); -drop function content_test__check5(); -drop function content_test__put_line(text); -drop function cast_char(boolean); -drop function content_test__dump(); -drop function content_test__get_val(varchar); -drop function content_test__save_val(integer,varchar); -drop table tst_ids; -