Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql,v diff -u -r1.13 -r1.14 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql 21 Mar 2001 06:41:31 -0000 1.13 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql 23 Mar 2001 00:21:50 -0000 1.14 @@ -228,20 +228,28 @@ create trigger acs_objects_last_mod_update_tr before update on acs_objects for each row execute procedure acs_objects_last_mod_update_tr (); - create function acs_objects_insert_tr () returns opaque as ' declare v_parent_sk varchar; max_key varchar; begin - select max(tree_sortkey) into max_key - from acs_objects - where context_id = new.context_id; + if new.context_id is null then + select max(tree_sortkey) into max_key + from acs_objects + where context_id is null; - select coalesce(max(tree_sortkey),'''') into v_parent_sk - from acs_objects - where object_id = new.context_id; + v_parent_sk := ''''; + else + select max(tree_sortkey) into max_key + from acs_objects + where context_id = new.context_id; + select coalesce(max(tree_sortkey),'''') into v_parent_sk + from acs_objects + where object_id = new.context_id; + end if; + + new.tree_sortkey := v_parent_sk || ''/'' || tree_next_key(max_key); return new; @@ -256,6 +264,7 @@ declare v_parent_sk varchar; max_key varchar; + ctx_id integer; v_rec record; clr_keys_p boolean default ''t''; begin @@ -277,18 +286,26 @@ clr_keys_p := ''f''; end if; - select max(tree_sortkey) into max_key + select context_id into ctx_id from acs_objects - where context_id = (select context_id - from acs_objects - where object_id = v_rec.object_id); + where object_id = v_rec.object_id; - select coalesce(max(tree_sortkey),'''') into v_parent_sk - from acs_objects - where object_id = (select context_id - from acs_objects - where object_id = v_rec.object_id); + if ctx_id is null then + select max(tree_sortkey) into max_key + from acs_objects + where context_id is null; + v_parent_sk := ''''; + else + select max(tree_sortkey) into max_key + from acs_objects + where context_id = ctx_id; + + select coalesce(max(tree_sortkey),'''') into v_parent_sk + from acs_objects + where object_id = ctx_id; + end if; + update acs_objects set tree_sortkey = v_parent_sk || ''/'' || tree_next_key(max_key) where object_id = v_rec.object_id; @@ -708,7 +725,7 @@ returns varchar as ' declare name__object_id alias for $1; - object_name varchar(500); + object_name varchar; v_object_id integer; obj_type record; obj record; @@ -742,7 +759,8 @@ -- Native Dynamic SQL, to ascertain the name of this object. -- --execute ''select '' || object_type.name_method || ''(:1) from dual'' - for obj in execute ''select '' || obj_type.name_method || ''('' || name__object_id || '') as object_name'' loop + + for obj in execute ''select '' || obj_type.name_method || ''('' || name__object_id || '')::varchar as object_name'' loop object_name := obj.object_name; exit; end loop; Index: openacs-4/packages/acs-kernel/sql/postgresql/postgresql.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/postgresql.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-kernel/sql/postgresql/postgresql.sql 20 Mar 2001 22:51:56 -0000 1.3 +++ openacs-4/packages/acs-kernel/sql/postgresql/postgresql.sql 23 Mar 2001 00:21:50 -0000 1.4 @@ -321,12 +321,10 @@ pos := length(skey); LOOP ch := substr(skey,pos,1); - if carry = ''t'' then + if carry then select code::varchar || nkey, - case when code = ''0'' - then ''t'' - else ''f'' - end into nkey, carry + code = ''0'' + into nkey, carry from tree_encodings where deci = (select (deci + 1) % base from tree_encodings @@ -335,15 +333,12 @@ nkey := ch::varchar || nkey; end if; pos := pos - 1; - select case when substr(skey,pos - 1,1) = ''/'' - then ''t'' - else ''f'' - end into stop; + select substr(skey,pos - 1,1) = ''/'' into stop; - exit when stop = ''t''; + exit when stop; END LOOP; - if carry = ''t'' then + if carry then nkey := ''0'' || nkey; end if; end if; Index: openacs-4/packages/acs-kernel/sql/postgresql/rel-constraints-body-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/rel-constraints-body-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-kernel/sql/postgresql/rel-constraints-body-create.sql 22 Mar 2001 00:09:24 -0000 1.3 +++ openacs-4/packages/acs-kernel/sql/postgresql/rel-constraints-body-create.sql 23 Mar 2001 00:21:50 -0000 1.4 @@ -100,7 +100,8 @@ LIMIT 1 LOOP - v_error := v_error || ''Relational Constraint Violation: '' || + v_error := coalesce(v_error,'''') || + ''Relational Constraint Violation: '' || constraint_violated.constraint_name || '' (constraint_id='' || constraint_violated.constraint_id || ''). ''; @@ -115,10 +116,11 @@ LIMIT 1 LOOP - v_error := v_error || ''Relational Constraint Violation: '' || - constraint_violated.constraint_name || - '' (constraint_id='' || - constraint_violated.constraint_id || ''). ''; + v_error := coalesce(v_error,'''') || + ''Relational Constraint Violation: '' || + constraint_violated.constraint_name || + '' (constraint_id='' || + constraint_violated.constraint_id || ''). ''; return v_error; end loop; Index: openacs-4/packages/acs-kernel/sql/postgresql/test/acs-objects-test.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/test/acs-objects-test.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-kernel/sql/postgresql/test/acs-objects-test.sql 22 Mar 2001 00:21:19 -0000 1.1 +++ openacs-4/packages/acs-kernel/sql/postgresql/test/acs-objects-test.sql 23 Mar 2001 00:21:50 -0000 1.2 @@ -72,7 +72,6 @@ -- create or replace package body ut#acs_object -- as -drop function ut_acs_object__setup(); create function ut_acs_object__setup() returns integer as ' declare attr_id acs_attributes.attribute_id%TYPE; @@ -120,7 +119,6 @@ end;' language 'plpgsql'; -drop function ut_acs_object__teardown(); create function ut_acs_object__teardown() returns integer as ' begin raise NOTICE ''Tearing down...''; @@ -142,7 +140,6 @@ end;' language 'plpgsql'; -drop function ut_acs_object__new(); create function ut_acs_object__new() returns integer as ' declare result boolean; @@ -189,7 +186,6 @@ end;' language 'plpgsql'; -drop function ut_acs_object__delete(); create function ut_acs_object__delete() returns integer as ' declare v_rec record; @@ -212,7 +208,6 @@ end;' language 'plpgsql'; -drop function ut_acs_object__name(); create function ut_acs_object__name() returns integer as ' begin raise NOTICE ''Testing name...''; @@ -225,7 +220,6 @@ end;' language 'plpgsql'; -drop function ut_acs_object__default_name(); create function ut_acs_object__default_name() returns integer as ' begin raise NOTICE ''Testing default_name...''; @@ -238,7 +232,6 @@ end;' language 'plpgsql'; -drop function ut_acs_object__set_attribute(); create function ut_acs_object__set_attribute() returns integer as ' declare v_sql_result test_objects.data%TYPE; @@ -267,7 +260,6 @@ end;' language 'plpgsql'; -drop function ut_acs_object__get_attribute(); create function ut_acs_object__get_attribute() returns integer as ' declare v_attr_value varchar(4000); @@ -309,3 +301,12 @@ select ut_acs_object__get_attribute(); select ut_acs_object__teardown(); + +drop function ut_acs_object__setup(); +drop function ut_acs_object__teardown(); +drop function ut_acs_object__new(); +drop function ut_acs_object__delete(); +drop function ut_acs_object__name(); +drop function ut_acs_object__default_name(); +drop function ut_acs_object__set_attribute(); +drop function ut_acs_object__get_attribute(); 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.1 -r1.2 --- openacs-4/packages/acs-kernel/sql/postgresql/test/rel-constraints-test.sql 22 Mar 2001 00:21:19 -0000 1.1 +++ openacs-4/packages/acs-kernel/sql/postgresql/test/rel-constraints-test.sql 23 Mar 2001 00:21:50 -0000 1.2 @@ -19,30 +19,41 @@ uname varchar(100) ); +create table groups_test_segs ( + seg_id integer, + sorder integer, + sname varchar(100) +); + create function rel_constraint_dump_views() returns integer as ' +declare r record; str varchar; begin - raise NOTICE ''Contents of view ''rel_constraints_violated_one'':''; + raise NOTICE ''Contents of view rel_constraints_violated_one:''; + str := rpad(''constraint_id'', 20) || rpad(''rel_id'', 20) || + rpad(''name(container_id)'',20) || + rpad(''name(party_id)'',20); + raise NOTICE ''%'', str; for r in select * from rel_constraints_violated_one LOOP - str := rpad(r.constraint_id, 10) || - rpad(r.rel_id, 10) || + str := rpad(r.constraint_id, 20) || + rpad(r.rel_id, 20) || rpad(acs_object__name(r.container_id), 20) || rpad(acs_object__name(r.party_id), 20); raise NOTICE ''%'', str; end LOOP; - raise NOTICE ''Contents of view ''rel_constraints_violated_two'':''; + raise NOTICE ''Contents of view rel_constraints_violated_two:''; for r in select * from rel_constraints_violated_two LOOP - str := rpad(r.constraint_id, 10) || - rpad(r.rel_id, 10) || + str := rpad(r.constraint_id, 20) || + rpad(r.rel_id, 20) || rpad(acs_object__name(r.container_id), 20) || rpad(acs_object__name(r.party_id), 20); @@ -53,13 +64,13 @@ end;' language 'plpgsql'; -create function rel_constraint_test_check (integer, boolean) +create function rel_constraint_test_check (integer, char) returns integer as ' declare - rel_id alias for $1; + v_rel_id alias for $1; expect_violation_p alias for $2; v_violation_msg varchar(4000); - v_violation_p boolean; + v_violation_p char; v_object_id_one integer; v_object_id_two integer; v_rel_type acs_rels.rel_type%TYPE; @@ -68,22 +79,23 @@ v_violation_p := ''f''; - v_violation_msg := rel_constraint__violation(rel_id); + v_violation_msg := rel_constraint__violation(v_rel_id); if v_violation_msg is not null then v_violation_p := ''t''; end if; - if v_violation_p != expect_violation_p then + if v_violation_p::char != expect_violation_p::char then select object_id_one, object_id_two, rel_type into v_object_id_one, v_object_id_two, v_rel_type from acs_rels - where rel_id = rel_constraint_test_check.rel_id; + where rel_id = v_rel_id; - str := ''Relation '' || acs_object_name(rel_id) || - '' ('' || rel_id || '')'' || - '' failed (violation_p = '' || v_violation_p || ''). '' || + str := ''Relation '' || acs_object__name(v_rel_id) || + '' ('' || v_rel_id || '')'' || + '' failed (violation_p = '' || v_violation_p::varchar + || ''). '' || ''Rel info: type = '' || v_rel_type || '', object one = '' || acs_object__name(v_object_id_one) || @@ -99,13 +111,15 @@ raise NOTICE ''Violation Message:''; raise NOTICE ''%'', v_violation_msg; + else + raise NOTICE ''passed %'', v_rel_id; end if; return null; end;' language 'plpgsql'; --- creates blah_member_rel and yippe_member_rel relationships +-- creates blah_member_rel and yippie_member_rel relationships \i rel-segments-test-types-create.sql @@ -130,6 +144,14 @@ reg_users integer; + rel_a integer; + rel_b integer; + rel_c integer; + rel_d integer; + rel_e integer; + rel_f integer; + rel_g integer; + rel_id integer; side_one_constraint integer; @@ -175,6 +197,8 @@ stacy := acs_user__new(''stacy@asdf.com'',''Stacy'', ''Smith'',''assword'',''p''); + reg_users := acs__magic_object_id(''registered_users''); + insert into groups_test_users values (joe,1,''joe''); insert into groups_test_users values (jane,2,''jane''); insert into groups_test_users values (bob,3,''bob''); @@ -183,10 +207,10 @@ insert into groups_test_users values (jill,6,''jill''); insert into groups_test_users values (sven,7,''sven''); insert into groups_test_users values (stacy,8,''stacy''); + insert into groups_test_users values (reg_users,9,''reg_users''); -- Make a couple of compositions. - reg_users := acs__magic_object_id(''registered_users''); rel_id := composition_rel__new(A, B); rel_id := composition_rel__new(A, C); @@ -197,17 +221,17 @@ rel_id := composition_rel__new(reg_users, E); rel_id := composition_rel__new(reg_users, G); + -- define a few segments. -- define a few relational constraints. - side_two_constraint := rel_constraint__new( null, ''rel_constraint'', - ''Yippe: side 2 must be a blah of A'', + ''Yippie: side 2 must be a blah of A'', rel_segment__get_or_new(reg_users, - ''yippe_member_rel'', + ''yippie_member_rel'', null), ''two'', rel_segment__get_or_new(A, @@ -219,13 +243,12 @@ ); - side_one_constraint := rel_constraint__new( null, ''rel_constraint'', - ''Yippe: side 1 must be a component of E'', + ''Yippie: side 1 must be a component of E'', rel_segment__get_or_new(reg_users, - ''yippe_member_rel'', + ''yippie_member_rel'', null), ''one'', rel_segment__get_or_new(E, @@ -236,55 +259,156 @@ null ); + 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''); delete from acs_logs; - -- Make a couple of memberships. -- LEGAL MEMBERSHIPS: -- textbook case: -- joe is a blah of A, and F is component of E, so its legal to make joe - -- a yippe of F. + -- a yippie of F. - rel_id := blah_member_rel__new(null, ''blah_member_rel'', A, joe); + rel_a := blah_member_rel__new(null, ''blah_member_rel'', A, joe); - PERFORM rel_constraint_test_check(rel_id, ''f''); + rel_b := yippie_member_rel__new(null, ''yippie_member_rel'', F, joe); - rel_id := yippe_member_rel__new(null, ''yippie_member_rel'', F, joe); - - PERFORM rel_constraint_test_check(rel_id, ''f''); - -- do constraints respect group hierarchy? If so, this will be legal: - rel_id := blah_member_rel__new(null, ''blah_member_rel'', B, jane); + rel_c := blah_member_rel__new(null, ''blah_member_rel'', B, jane); - PERFORM rel_constraint_test_check(rel_id, ''f''); + rel_d := yippie_member_rel__new(null, ''yippie_member_rel'', F, jane); - rel_id := yippe_member_rel__new(null, ''yippie_member_rel'', F, jane); - - PERFORM rel_constraint_test_check(rel_id, ''f''); - -- ILLEGAL MEMBERSHIPS: - -- G is not a component of F, therefore no one can be a yippe of G + -- G is not a component of F, therefore no one can be a yippie of G -- This should violated 2 constraints (object one and object two are both -- invalid). - rel_id := yippe_member_rel__new(null, ''yippie_member_rel'', G, bob); + rel_e := yippie_member_rel__new(null, ''yippie_member_rel'', G, bob); - PERFORM rel_constraint_test_check(rel_id, ''t''); + -- betty is not a blah of A, therefore she cannot be a yippie of F. + rel_f := yippie_member_rel__new(null, ''yippie_member_rel'', F, betty); - -- betty is not a blah of A, therefore she cannot be a yippe of F. - rel_id := yippe_member_rel__new(null, ''yippie_member_rel'', F, betty); + -- make sven be a regular member of A. Sven cannot be a yippie of F. + rel_id := membership_rel__new(A, sven); + rel_g := yippie_member_rel__new(null, ''yippie_member_rel'', F, sven); - PERFORM rel_constraint_test_check(rel_id, ''t''); + insert into groups_test_segs values (rel_a,3,''a''); + insert into groups_test_segs values (rel_b,4,''b''); + insert into groups_test_segs values (rel_c,5,''c''); + insert into groups_test_segs values (rel_d,6,''d''); + insert into groups_test_segs values (rel_e,7,''e''); + insert into groups_test_segs values (rel_f,8,''f''); + insert into groups_test_segs values (rel_g,9,''g''); - -- make sven be a regular member of A. Sven cannot be a yippe of F. - rel_id := membership_rel__new(A, sven); - rel_id := yippe_member_rel__new(null, ''yippie_member_rel'', F, sven); + return null; - PERFORM rel_constraint_test_check(rel_id, ''t''); +end;' language 'plpgsql'; +create function check_rel_constraints() returns integer as ' +declare + A integer; + B integer; + C integer; + D integer; + E integer; + F integer; + G integer; + + joe integer; + jane integer; + bob integer; + betty integer; + jack integer; + jill integer; + sven integer; + stacy integer; + + reg_users integer; + + rel_a integer; + rel_b integer; + rel_c integer; + rel_d integer; + rel_e integer; + rel_f integer; + rel_g integer; + + rel_id integer; + + side_one_constraint integer; + side_two_constraint integer; + + v_count integer; + + r record; +begin + select group_id into A from groups_test_groups where gname = ''A''; + select group_id into B from groups_test_groups where gname = ''B''; + select group_id into C from groups_test_groups where gname = ''C''; + select group_id into D from groups_test_groups where gname = ''D''; + select group_id into E from groups_test_groups where gname = ''E''; + select group_id into F from groups_test_groups where gname = ''F''; + select group_id into G from groups_test_groups where gname = ''G''; + + select user_id into joe from groups_test_users where uname = ''joe''; + select user_id into jane from groups_test_users where uname = ''jane''; + select user_id into bob from groups_test_users where uname = ''bob''; + select user_id into betty from groups_test_users where uname = ''betty''; + select user_id into jack from groups_test_users where uname = ''jack''; + select user_id into jill from groups_test_users where uname = ''jill''; + select user_id into sven from groups_test_users where uname = ''sven''; + select user_id into stacy from groups_test_users where uname = ''stacy''; + select user_id into reg_users from groups_test_users where uname = ''reg_users''; + + select seg_id into side_one_constraint + from groups_test_segs + where sname = ''side_one_constraint''; + + select seg_id into side_two_constraint + from groups_test_segs + where sname = ''side_two_constraint''; + + select seg_id into rel_a from groups_test_segs where sname = ''a''; + select seg_id into rel_b from groups_test_segs where sname = ''b''; + select seg_id into rel_c from groups_test_segs where sname = ''c''; + select seg_id into rel_d from groups_test_segs where sname = ''d''; + select seg_id into rel_e from groups_test_segs where sname = ''e''; + select seg_id into rel_f from groups_test_segs where sname = ''f''; + select seg_id into rel_g from groups_test_segs where sname = ''g''; + + -- Make a couple of memberships. + + -- LEGAL MEMBERSHIPS: + + -- textbook case: + -- joe is a blah of A, and F is component of E, so its legal to make joe + -- a yippie of F. + + PERFORM rel_constraint_test_check(rel_a, ''f''); + + PERFORM rel_constraint_test_check(rel_b, ''f''); + + -- do constraints respect group hierarchy? If so, this will be legal: + PERFORM rel_constraint_test_check(rel_c, ''f''); + + PERFORM rel_constraint_test_check(rel_d, ''f''); + + -- ILLEGAL MEMBERSHIPS: + + -- G is not a component of F, therefore no one can be a yippie of G + -- This should violated 2 constraints (object one and object two are both + -- invalid). + PERFORM rel_constraint_test_check(rel_e, ''t''); + + -- betty is not a blah of A, therefore she cannot be a yippie of F. + PERFORM rel_constraint_test_check(rel_f, ''t''); + + -- make sven be a regular member of A. Sven cannot be a yippie of F. + PERFORM rel_constraint_test_check(rel_g, ''t''); + -- TEST THE VIEWS (there should be 4 violated constraints, -- 1 side one violation and 3 side two violations. @@ -306,7 +430,6 @@ PERFORM rel_constraint_dump_views(); end if; - -- Remove the constraints PERFORM rel_constraint__delete(side_one_constraint); PERFORM rel_constraint__delete(side_two_constraint); @@ -316,14 +439,14 @@ PERFORM blah_member_rel__delete(r.rel_id); end loop; - for r in select * from yippe_member_rels LOOP - PERFORM yippe_member_rel__delete(r.rel_id); + for r in select * from yippie_member_rels LOOP + PERFORM yippie_member_rel__delete(r.rel_id); end loop; -- Remove the test segments. PERFORM rel_segment__delete(rel_segment__get(A,''blah_member_rel'')); PERFORM rel_segment__delete(rel_segment__get(E,''composition_rel'')); - PERFORM rel_segment__delete(rel_segment__get(reg_users,''yippe_member_rel'')); + PERFORM rel_segment__delete(rel_segment__get(reg_users,''yippie_member_rel'')); -- Remove the test groups. PERFORM acs_group__delete(G); @@ -348,13 +471,16 @@ end;' language 'plpgsql'; - select test_rel_constraints(); +select check_rel_constraints(); + drop function rel_constraint_dump_views(); -drop function rel_constraint_test_check (integer, boolean); +drop function rel_constraint_test_check (integer, char); drop function test_rel_constraints(); +drop function check_rel_constraints(); drop table groups_test_groups; drop table groups_test_users; +drop table groups_test_segs; \i rel-segments-test-types-drop.sql Index: openacs-4/packages/acs-kernel/sql/postgresql/test/rel-segments-test-types-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/test/rel-segments-test-types-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-kernel/sql/postgresql/test/rel-segments-test-types-create.sql 22 Mar 2001 00:21:19 -0000 1.1 +++ openacs-4/packages/acs-kernel/sql/postgresql/test/rel-segments-test-types-create.sql 23 Mar 2001 00:21:50 -0000 1.2 @@ -22,13 +22,13 @@ PERFORM acs_rel_type__create_type ( - ''yippe_member_rel'', - ''Yippe Membership Relationship'', - ''Yippe Membership Relationships'', + ''yippie_member_rel'', + ''Yippie Membership Relationship'', + ''Yippie Membership Relationships'', ''membership_rel'', - ''yippe_member_rels'', + ''yippie_member_rels'', ''rel_id'', - ''yippe_member_rel'', + ''yippie_member_rel'', ''group'', null, 0, @@ -57,10 +57,10 @@ primary key ); -create table yippe_member_rels ( - rel_id integer constraint yippe_member_rel_id_fk +create table yippie_member_rels ( + rel_id integer constraint yippie_member_rel_id_fk references membership_rels (rel_id) - constraint yippe_member_rel_pk + constraint yippie_member_rel_pk primary key ); @@ -135,34 +135,34 @@ --- create or replace package yippe_member_rel +-- create or replace package yippie_member_rel -- is -- function new ( --- rel_id in yippe_member_rels.rel_id%TYPE +-- rel_id in yippie_member_rels.rel_id%TYPE -- default null, -- rel_type in acs_rels.rel_type%TYPE --- default 'yippe_member_rel', +-- default 'yippie_member_rel', -- object_id_one in groups.group_id%TYPE, -- object_id_two in parties.party_id%TYPE --- ) return yippe_member_rels.rel_id%TYPE; +-- ) return yippie_member_rels.rel_id%TYPE; -- -- procedure delete ( --- rel_id in yippe_member_rels.rel_id%TYPE +-- rel_id in yippie_member_rels.rel_id%TYPE -- ); --- end yippe_member_rel; +-- end yippie_member_rel; -- show errors --- create or replace package body yippe_member_rel +-- create or replace package body yippie_member_rel -- function new -create function yippe_member_rel__new (integer,varchar,integer,integer) +create function yippie_member_rel__new (integer,varchar,integer,integer) returns integer as ' declare new__rel_id alias for $1; new__rel_type alias for $2; new__object_id_one alias for $3; new__object_id_two alias for $4; - v_rel_id yippe_member_rels.rel_id%TYPE; + v_rel_id yippie_member_rels.rel_id%TYPE; begin v_rel_id := membership_rel__new( @@ -175,8 +175,7 @@ null ); - - insert into yippe_member_rels + insert into yippie_member_rels (rel_id) values (v_rel_id); @@ -187,13 +186,13 @@ -- procedure delete -create function yippe_member_rel__delete (yippe_member_rels) +create function yippie_member_rel__delete (integer) returns integer as ' declare delete__rel_id alias for $1; begin - delete from yippe_member_rels where rel_id = delete__rel_id; + delete from yippie_member_rels where rel_id = delete__rel_id; PERFORM membership_rel__delete(delete__rel_id); Index: openacs-4/packages/acs-kernel/sql/postgresql/test/rel-segments-test-types-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/test/rel-segments-test-types-drop.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-kernel/sql/postgresql/test/rel-segments-test-types-drop.sql 22 Mar 2001 00:21:19 -0000 1.1 +++ openacs-4/packages/acs-kernel/sql/postgresql/test/rel-segments-test-types-drop.sql 23 Mar 2001 00:21:50 -0000 1.2 @@ -1,14 +1,14 @@ select drop_package('blah_member_rel'); -select drop_package('yippe_member_rel'); +select drop_package('yippie_member_rel'); drop table blah_member_rels; -drop table yippe_member_rels; +drop table yippie_member_rels; begin; select acs_rel_type__drop_type('blah_member_rel','f'); - select acs_rel_type__drop_type('yippe_member_rel','f'); + select acs_rel_type__drop_type('yippie_member_rel','f'); end; 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.1 -r1.2 --- openacs-4/packages/acs-kernel/sql/postgresql/test/rel-segments-test.sql 22 Mar 2001 00:21:19 -0000 1.1 +++ openacs-4/packages/acs-kernel/sql/postgresql/test/rel-segments-test.sql 23 Mar 2001 00:21:50 -0000 1.2 @@ -26,7 +26,7 @@ sname varchar(100) ); --- creates blah_member_rel and yippe_member_rel relationships +-- creates blah_member_rel and yippie_member_rel relationships \i rel-segments-test-types-create.sql @@ -50,16 +50,19 @@ if NOT v_pass_p then str := ''Row missing from rel_segment_party_map for'' || - '' segment '''''' || acs_object.name(segment_id) || - '''''' ('' || segment_id || '')'' || - '', party '''''' || acs_object.name(party_id) || - '''''' ('' || party_id || '')'' || - '', container '''''' || acs_object.name(container_id) || - '''''' ('' ||container_id || '')''; + '' segment '' || + acs_object__name(test_check__segment_id) || + '' ('' || test_check__segment_id || '')'' || + '', party '' || + acs_object__name(test_check__party_id) || + '' ('' || test_check__party_id || '')'' || + '', container '' || + acs_object__name(test_check__container_id) || + '' ('' || test_check__container_id || '')''; raise NOTICE ''%'', str; - acs_log.error(''rel_segment_test_check'', str); + PERFORM acs_log__error(''rel_segment_test_check'', str); end if; @@ -87,8 +90,9 @@ sven integer; stacy integer; - seg_G_blahs integer; - seg_E_yippes integer; + seg_G_blahs integer; + seg_E_yippies integer; + seg_F integer; rel_id integer; begin @@ -150,11 +154,11 @@ -- Make a couple of memberships. rel_id := blah_member_rel__new(null, ''blah_member_rel'', B, joe); - rel_id := yippe_member_rel__new(null, ''yippie_member_rel'', B, jane); + rel_id := yippie_member_rel__new(null, ''yippie_member_rel'', B, jane); rel_id := blah_member_rel__new(null, ''blah_member_rel'', B, betty); - rel_id := yippe_member_rel__new(null, ''yippie_member_rel'', A, bob); + rel_id := yippie_member_rel__new(null, ''yippie_member_rel'', A, bob); rel_id := blah_member_rel__new(null, ''blah_member_rel'', A, betty); - rel_id := yippe_member_rel__new(null, ''yippie_member_rel'', E, betty); + rel_id := yippie_member_rel__new(null, ''yippie_member_rel'', E, betty); -- define a few segments. @@ -172,22 +176,25 @@ null ); - -- the segment of all parties that are yippe members of E - seg_E_yippes := rel_segment__new(null, + -- the segment of all parties that are yippie members of E + seg_E_yippies := rel_segment__new(null, ''rel_segment'', now(), null, null, null, null, - ''Yippes of Group E'', + ''Yippies of Group E'', E, - ''yippe_member_rel'', + ''yippie_member_rel'', null ); + seg_F := rel_segment__get_or_new(F,''membership_rel'',null); + insert into groups_test_segs values (seg_G_blahs,1,''seg_G_blahs''); - insert into groups_test_segs values (seg_E_yippes,2,''seg_E_yippes''); + insert into groups_test_segs values (seg_E_yippies,2,''seg_E_yippies''); + insert into groups_test_segs values (seg_F,3,''seg_F''); delete from acs_logs; @@ -214,8 +221,9 @@ sven integer; stacy integer; - seg_G_blahs integer; - seg_E_yippes integer; + seg_G_blahs integer; + seg_E_yippies integer; + seg_F integer; rel_id integer; r record; @@ -230,30 +238,34 @@ select group_id into F from groups_test_groups where gname = ''F''; select group_id into G from groups_test_groups where gname = ''G''; - select user_id into joe from groups_test_users where gname = ''joe''; - select user_id into jane from groups_test_users where gname = ''jane''; - select user_id into bob from groups_test_users where gname = ''bob''; - select user_id into betty from groups_test_users where gname = ''betty''; - select user_id into jack from groups_test_users where gname = ''jack''; - select user_id into jill from groups_test_users where gname = ''jill''; - select user_id into sven from groups_test_users where gname = ''sven''; - select user_id into stacy from groups_test_users where gname = ''stacy''; + select user_id into joe from groups_test_users where uname = ''joe''; + select user_id into jane from groups_test_users where uname = ''jane''; + select user_id into bob from groups_test_users where uname = ''bob''; + select user_id into betty from groups_test_users where uname = ''betty''; + select user_id into jack from groups_test_users where uname = ''jack''; + select user_id into jill from groups_test_users where uname = ''jill''; + select user_id into sven from groups_test_users where uname = ''sven''; + select user_id into stacy from groups_test_users where uname = ''stacy''; select seg_id into seg_G_blahs from groups_test_segs where sname = ''seg_G_blahs''; - select seg_id into seg_E_yippes + select seg_id into seg_E_yippies from groups_test_segs - where sname = ''seg_G_blahs''; + where sname = ''seg_E_yippies''; + select seg_id into seg_F + from groups_test_segs + where sname = ''seg_F''; + -- group_element_index_dump; -- rel_segment_party_map_dump; -- Expectations: -- 1. seg_G_blahs should include joe and betty - -- 2. seg_E_yippes should include bob, and jane, betty + -- 2. seg_E_yippies should include bob, and jane, betty -- check: seg_G_blahs contains joe with container B if rel_segment_test_check(seg_G_blahs, joe, B) = ''f'' then @@ -279,26 +291,26 @@ raise NOTICE ''%'', str; end if; - -- check: seg_E_yippes contains jane with container B - if rel_segment_test_check(seg_E_yippes, jane, B) = ''f'' then - str := ''Segment '' || acs_object__name(seg_E_yippes) || - ''('' || seg_E_yippes || '') failed. Group_id = '' + -- check: seg_E_yippies contains jane with container B + if rel_segment_test_check(seg_E_yippies, jane, B) = ''f'' then + str := ''Segment '' || acs_object__name(seg_E_yippies) || + ''('' || seg_E_yippies || '') failed. Group_id = '' || E; raise NOTICE ''%'', str; end if; - -- check: seg_E_yippes contains bob with container A - if rel_segment_test_check(seg_E_yippes, bob, A) = ''f'' then - str := ''Segment '' || acs_object__name(seg_E_yippes) || - ''('' || seg_E_yippes || '') failed. Group_id = '' + -- check: seg_E_yippies contains bob with container A + if rel_segment_test_check(seg_E_yippies, bob, A) = ''f'' then + str := ''Segment '' || acs_object__name(seg_E_yippies) || + ''('' || seg_E_yippies || '') failed. Group_id = '' || E; raise NOTICE ''%'', str; end if; - -- check: seg_E_yippes contains betty with container E - if rel_segment_test_check(seg_E_yippes, betty, E) = ''f'' then - str := ''Segment '' || acs_object__name(seg_E_yippes) || - ''('' || seg_E_yippes || '') failed. Group_id = '' + -- check: seg_E_yippies contains betty with container E + if rel_segment_test_check(seg_E_yippies, betty, E) = ''f'' then + str := ''Segment '' || acs_object__name(seg_E_yippies) || + ''('' || seg_E_yippies || '') failed. Group_id = '' || E; raise NOTICE ''%'', str; end if; @@ -307,8 +319,7 @@ -- function: -- The segment of all memers of F should contain jane through group B - if rel_segment_test_check( - rel_segment__get_or_new(F,''membership_rel''), jane, B) = ''f'' then + if rel_segment_test_check(seg_F, jane, B) = ''f'' then str := ''Segment '' || acs_object__name(rel_segment__get(F,''membership_rel'')) || ''('' || rel_segment__get(F,''membership_rel'') @@ -317,8 +328,7 @@ end if; -- The segment of all memers of F should contain betty through group A - if rel_segment_test_check( - rel_segment__get_or_new(F,''membership_rel''), betty, A) = ''f'' then + if rel_segment_test_check(seg_F, betty, A) = ''f'' then str := ''Segment '' || acs_object__name(rel_segment__get(F,''membership_rel'')) || ''('' || rel_segment__get(F,''membership_rel'') @@ -328,16 +338,16 @@ -- Remove the test segments. PERFORM rel_segment__delete(seg_G_blahs); - PERFORM rel_segment__delete(seg_E_yippes); + PERFORM rel_segment__delete(seg_E_yippies); PERFORM rel_segment__delete(rel_segment__get(F,''membership_rel'')); -- Remove the test memebership relations for r in select * from blah_member_rels LOOP PERFORM blah_member_rel__delete(r.rel_id); end loop; - for r in select * from yippe_member_rels LOOP - PERFORM yippe_member_rel__delete(r.rel_id); + for r in select * from yippie_member_rels LOOP + PERFORM yippie_member_rel__delete(r.rel_id); end loop; -- Remove the test groups. @@ -350,14 +360,14 @@ PERFORM acs_group__delete(A); -- Remove the test members. - PERFROM acs_user__delete(joe); - PERFROM acs_user__delete(jane); - PERFROM acs_user__delete(bob); - PERFROM acs_user__delete(betty); - PERFROM acs_user__delete(jack); - PERFROM acs_user__delete(jill); - PERFROM acs_user__delete(sven); - PERFROM acs_user__delete(stacy); + PERFORM acs_user__delete(joe); + PERFORM acs_user__delete(jane); + PERFORM acs_user__delete(bob); + PERFORM acs_user__delete(betty); + PERFORM acs_user__delete(jack); + PERFORM acs_user__delete(jill); + PERFORM acs_user__delete(sven); + PERFORM acs_user__delete(stacy); return null; @@ -369,6 +379,9 @@ drop function rel_segment_test_check(integer, integer, integer); drop function test_segs(); drop function check_segs(); +drop table groups_test_groups; +drop table groups_test_users; +drop table groups_test_segs; \i rel-segments-test-types-drop.sql Index: openacs-4/packages/acs-kernel/sql/postgresql/test-harness/acs-core.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/test-harness/acs-core.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-kernel/sql/postgresql/test-harness/acs-core.sql 22 Mar 2001 00:21:19 -0000 1.1 +++ openacs-4/packages/acs-kernel/sql/postgresql/test-harness/acs-core.sql 23 Mar 2001 00:21:50 -0000 1.2 @@ -58,22 +58,11 @@ end;' language 'plpgsql'; -begin; + select test_acs_core (); select test_del_user (); -end; + drop function test_acs_core (); drop function test_del_user (); --- select acs_user__delete(1); - -/* -delete from user_preferences -where user_id = 1; - -delete from users -where user_id = 1; - -select person__delete(1); -*/