Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql,v diff -u -r1.8 -r1.9 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql 17 Mar 2001 16:14:54 -0000 1.8 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql 24 Mar 2001 00:34:53 -0000 1.9 @@ -182,7 +182,7 @@ v_rec record; begin - -- now iterate over all of the children of the parent of the + -- now iterate over all of the children of the -- previous node. for v_rec in select privilege, child_privilege Index: openacs-4/packages/acs-kernel/sql/postgresql/rel-constraints-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/rel-constraints-create.sql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-kernel/sql/postgresql/rel-constraints-create.sql 18 Mar 2001 05:22:27 -0000 1.5 +++ openacs-4/packages/acs-kernel/sql/postgresql/rel-constraints-create.sql 24 Mar 2001 00:34:53 -0000 1.6 @@ -77,11 +77,13 @@ begin select max(tree_sortkey) into max_key from rel_constraints - where required_rel_segment = new.required_rel_segment; + where rel_segment = new.rel_segment + and rel_side = new.rel_side; select coalesce(max(tree_sortkey),'''') into v_parent_sk from rel_constraints - where rel_segment = new.required_rel_segment; + where required_rel_segment = new.rel_segment + and rel_side = new.rel_side; new.tree_sortkey := v_parent_sk || ''/'' || tree_next_key(max_key); @@ -101,38 +103,46 @@ clr_keys_p boolean default ''t''; begin if new.rel_segment = old.rel_segment and - new.required_rel_segment = old.required_rel_segment then + new.required_rel_segment = old.required_rel_segment and + new.rel_side = old.rel_side + THEN return new; end if; - for v_rec in select rel_segment + for v_rec in select required_rel_segment from rel_constraints - where tree_sortkey like new.tree_sortkey || ''%'' + where rel_side = new.rel_side + and tree_sortkey like new.tree_sortkey || ''%'' order by tree_sortkey LOOP if clr_keys_p then update rel_constraints set tree_sortkey = null - where tree_sortkey like new.tree_sortkey || ''%''; + where tree_sortkey like new.tree_sortkey || ''%'' + and rel_side = new.rel_side; clr_keys_p := ''f''; end if; select max(tree_sortkey) into max_key from rel_constraints - where required_rel_segment = (select required_rel_segment - from rel_constraints - where rel_segment = v_rec.rel_segment); + where rel_side = new.rel_side + and rel_segment = (select rel_segment + from rel_constraints + where rel_side = new.rel_side + and required_rel_segment = v_rec.required_rel_segment); select coalesce(max(tree_sortkey),'''') into v_parent_sk from rel_constraints - where rel_segment = (select required_rel_segment - from rel_constraints - where rel_segment = v_rec.rel_segment); + where required_rel_segment = (select rel_segment + from rel_constraints + where rel_side = new.rel_side + and required_rel_segment = v_rec.required_rel_segment); update rel_constraints set tree_sortkey = v_parent_sk || ''/'' || tree_next_key(max_key) - where rel_segment = v_rec.rel_segment; + where required_rel_segment = v_rec.required_rel_segment + and rel_side = new.rel_side; end LOOP; @@ -595,18 +605,15 @@ create view rc_segment_required_seg_map as select rc.rel_segment, rc.rel_side, rc_required.required_rel_segment from rel_constraints rc, rel_constraints rc_required -where rc.rel_segment in ( - select c.rel_segment - from rel_constraints c - where ('two' = (select rel_side - from rel_constraints - where rel_segment = c.required_rel_segment) - or c.rel_segment = rc_required.rel_segment) - and c.tree_sortkey - like - (select tree_sortkey || '%' - from rel_constraints - where rel_segment = rc_required.rel_segment)); +where rc.rel_segment in (select c2.rel_segment + from rel_constraints c1, rel_constraints c2 + where exists (select 1 + from rel_constraints + where rel_side = 'two' + and rel_segment = c2.required_rel_segment) + and c1.rel_segment = rc_required.rel_segment + and c2.tree_sortkey <= c1.tree_sortkey + and c1.tree_sortkey like (c2.tree_sortkey || '%')); -- View: rc_segment_dependency_levels -- Index: openacs-4/packages/acs-kernel/sql/postgresql/site-nodes-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/site-nodes-create.sql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-kernel/sql/postgresql/site-nodes-create.sql 21 Mar 2001 05:46:40 -0000 1.5 +++ openacs-4/packages/acs-kernel/sql/postgresql/site-nodes-create.sql 24 Mar 2001 00:34:53 -0000 1.6 @@ -66,14 +66,22 @@ v_parent_sk varchar; max_key varchar; begin - select max(tree_sortkey) into max_key - from site_nodes - where parent_id = new.parent_id; + if new.parent_id is null then + select max(tree_sortkey) into max_key + from site_nodes + where parent_id is null; - select coalesce(max(tree_sortkey),'''') into v_parent_sk - from site_nodes - where node_id = new.parent_id; + v_parent_sk := ''''; + else + select max(tree_sortkey) into max_key + from site_nodes + where parent_id = new.parent_id; + select coalesce(max(tree_sortkey),'''') into v_parent_sk + from site_nodes + where node_id = new.parent_id; + end if; + new.tree_sortkey := v_parent_sk || ''/'' || tree_next_key(max_key); return new; @@ -88,6 +96,7 @@ declare v_parent_sk varchar; max_key varchar; + p_id integer; v_rec record; clr_keys_p boolean default ''t''; begin @@ -109,18 +118,26 @@ clr_keys_p := ''f''; end if; - select max(tree_sortkey) into max_key + select parent_id into p_id from site_nodes - where parent_id = (select parent_id - from site_nodes - where node_id = v_rec.node_id); + where node_id = v_rec.node_id; - select coalesce(max(tree_sortkey),'''') into v_parent_sk - from site_nodes - where node_id = (select parent_id - from site_nodes - where node_id = v_rec.node_id); + if p_id is null then + select max(tree_sortkey) into max_key + from site_nodes + where parent_id is null; + v_parent_sk := ''''; + else + select max(tree_sortkey) into max_key + from site_nodes + where parent_id = p_id; + + select coalesce(max(tree_sortkey),'''') into v_parent_sk + from site_nodes + where node_id = p_id; + end if; + update site_nodes set tree_sortkey = v_parent_sk || ''/'' || tree_next_key(max_key) where node_id = v_rec.node_id; Index: openacs-4/packages/acs-kernel/sql/postgresql/test/rel-constraints-test.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/test/rel-constraints-test.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-kernel/sql/postgresql/test/rel-constraints-test.sql 23 Mar 2001 00:21:50 -0000 1.2 +++ openacs-4/packages/acs-kernel/sql/postgresql/test/rel-constraints-test.sql 24 Mar 2001 00:34:53 -0000 1.3 @@ -262,6 +262,42 @@ insert into groups_test_segs values (side_two_constraint,1,''side_two_constraint''); insert into groups_test_segs values (side_one_constraint,2,''side_one_constraint''); + side_two_constraint := rel_constraint__new( + null, + ''rel_constraint'', + ''A: side 2 must be a blah of C'', + rel_segment__get_or_new(A, + ''blah_member_rel'', + null), + ''two'', + rel_segment__get_or_new(C, + ''blah_member_rel'', + null), + null, + null, + null + + ); + + side_one_constraint := rel_constraint__new( + null, + ''rel_constraint'', + ''E: side 1 must be a component of B'', + rel_segment__get_or_new(E, + ''composition_rel'', + null), + ''one'', + rel_segment__get_or_new(B, + ''composition_rel'', + null), + null, + null, + null + ); + + insert into groups_test_segs values (side_two_constraint,3,''side_two_constraint 1''); + insert into groups_test_segs values (side_one_constraint,4,''side_one_constraint 1''); + delete from acs_logs; -- Make a couple of memberships. @@ -433,7 +469,16 @@ -- Remove the constraints PERFORM rel_constraint__delete(side_one_constraint); PERFORM rel_constraint__delete(side_two_constraint); + select seg_id into side_one_constraint + from groups_test_segs + where sname = ''side_one_constraint 1''; + select seg_id into side_two_constraint + from groups_test_segs + where sname = ''side_two_constraint 1''; + PERFORM rel_constraint__delete(side_one_constraint); + PERFORM rel_constraint__delete(side_two_constraint); + -- Remove the test memebership relations for r in select * from blah_member_rels LOOP PERFORM blah_member_rel__delete(r.rel_id); @@ -487,3 +532,4 @@ select log_level, log_key, message from acs_logs where log_key = 'error'; + Index: openacs-4/packages/acs-kernel/sql/postgresql/test/rel-segments-test.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/test/rel-segments-test.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-kernel/sql/postgresql/test/rel-segments-test.sql 23 Mar 2001 00:21:50 -0000 1.2 +++ openacs-4/packages/acs-kernel/sql/postgresql/test/rel-segments-test.sql 24 Mar 2001 00:34:53 -0000 1.3 @@ -388,3 +388,4 @@ select log_level, log_key, message from acs_logs where log_level = 'error'; +