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.6 -r1.7 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql 18 Mar 2001 05:22:27 -0000 1.6 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql 19 Mar 2001 05:07:08 -0000 1.7 @@ -761,7 +761,7 @@ where o.object_id = default_name__object_id and o.object_type = ot.object_type; - return object_type_pretty_name || '' '' || object_id; + return object_type_pretty_name || '' '' || default_name__object_id; end;' language 'plpgsql'; @@ -1050,20 +1050,25 @@ where object_id = check_context_index__object_id and ancestor_id = check_context_index__ancestor_id; - if n_gens != n_generations then - PERFORM acs_log__error(''acs_object.check_representation'', ''Ancestor '' || - ancestor_id || '' of object '' || object_id || + if n_gens != check_context_index__n_generations then + PERFORM acs_log__error(''acs_object.check_representation'', + ''Ancestor '' || + check_context_index__ancestor_id || '' of object '' || + check_context_index__object_id || '' reports being generation '' || n_gens || - '' when it is actually generation '' || n_generations || + '' when it is actually generation '' || + check_context_index__n_generations || ''.''); return ''f''; else return ''t''; end if; else - PERFORM acs_log__error(''acs_object.check_representation'', ''Ancestor '' || - ancestor_id || '' of object '' || object_id || - '' is missing an entry in acs_object_context_index.''); + PERFORM acs_log__error(''acs_object.check_representation'', + ''Ancestor '' || + check_context_index__ancestor_id || + '' of object '' || check_context_index__object_id + || '' is missing an entry in acs_object_context_index.''); return ''f''; end if; @@ -1209,27 +1214,22 @@ result boolean; check_representation__object_type acs_objects.object_type%TYPE; n_rows integer; - t record; + v_rec record; row record; begin result := ''t''; PERFORM acs_log__notice(''acs_object.check_representation'', ''Running acs_object.check_representation on object_id = '' || check_representation__object_id || ''.''); - -- If this fails then there isn''''t even an object associated with - -- this id. I''m going to let that error propogate as an exception. select object_type into check_representation__object_type from acs_objects where object_id = check_representation__object_id; PERFORM acs_log__notice(''acs_object.check_representation'', ''OBJECT STORAGE INTEGRITY TEST''); - -- Let''s look through every primary storage table associated with - -- this object type and all of its supertypes and make sure there - -- is a row with OBJECT_ID as theh primary key. - for t in select t.object_type, t.table_name, t.id_column + for v_rec in select t.object_type, t.table_name, t.id_column from acs_object_type_supertype_map m, acs_object_types t where m.ancestor_type = t.object_type and m.object_type = check_representation__object_type @@ -1238,7 +1238,8 @@ from acs_object_types where object_type = check_representation__object_type LOOP - for row in execute ''select case when count(*) = 0 then 0 else 1 end as n_rows from '' || quote_identifier(t.table_name) || '' where '' || quote_identifier(t.id_column) || '' = '' || check_representation__object_id + + for row in execute ''select case when count(*) = 0 then 0 else 1 end as n_rows from '' || quote_ident(v_rec.table_name) || '' where '' || quote_ident(v_rec.id_column) || '' = '' || check_representation__object_id LOOP n_rows := row.n_rows; exit; @@ -1247,33 +1248,28 @@ if n_rows = 0 then result := ''f''; PERFORM acs_log__error(''acs_object.check_representation'', - ''Table '' || t.table_name || '' (primary storage for '' || - t.object_type || '') doesn''''t have a row for object '' || - check_representation__object_id || '' of type '' || check_representation__object_type || ''.''); + ''Table '' || v_rec.table_name || + '' (primary storage for '' || + v_rec.object_type || + '') doesn''''t have a row for object '' || + check_representation__object_id || '' of type '' || + check_representation__object_type || ''.''); end if; + end loop; PERFORM acs_log__notice(''acs_object.check_representation'', ''OBJECT CONTEXT INTEGRITY TEST''); - -- Do a bunch of dirt simple sanity checks. - - -- First let''s check that all of our ancestors appear in - -- acs_object_context_index with the correct generation listed. if acs_object__check_object_ancestors(check_representation__object_id, check_representation__object_id, 0) = ''f'' then result := ''f''; end if; - -- Now let''s check that all of our descendants appear in - -- acs_object_context_index with the correct generation listed. if acs_object__check_object_descendants(check_representation__object_id, check_representation__object_id, 0) = ''f'' then result := ''f''; end if; - -- Ok, we know that the index contains every entry that it is - -- supposed to have. Now let''s make sure it doesn''t contain any - -- extraneous entries. - for row in select * + for row in select object_id, ancestor_id, n_generations from acs_object_context_index where object_id = check_representation__object_id or ancestor_id = check_representation__object_id loop Index: openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql 18 Mar 2001 05:22:27 -0000 1.3 +++ openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql 19 Mar 2001 05:07:08 -0000 1.4 @@ -667,6 +667,7 @@ result := ''t''; if acs_object__check_representation(check_representation__rel_id) = ''f'' then + raise notice ''acs_object rep failed''; result := ''f''; end if; @@ -677,6 +678,7 @@ and m.rel_id = check_representation__rel_id; if membership_rel__check_index(group_id, member_id, group_id) = ''f'' then + raise notice ''check index failed''; result := ''f''; end if; @@ -687,6 +689,7 @@ if composition_rel__check_path_exists_p(row.container_id, row.group_id) = ''f'' then result := ''f''; + raise notice ''path exists failed''; PERFORM acs_log__error(''membership_rel.check_representation'', ''Extra row in group_member_index: '' || ''group_id = '' || row.group_id || '', '' || @@ -843,39 +846,43 @@ declare group_id alias for $1; result boolean; - c record; - m record; + comp record; + memb record; begin result := ''t''; PERFORM acs_log__notice(''acs_group.check_representation'', ''Running check_representation on group '' || group_id); if acs_object__check_representation(group_id) = ''f'' then + raise notice ''failed 1''; result := ''f''; end if; - for c in select c.rel_id + for comp in select c.rel_id from acs_rels r, composition_rels c where r.rel_id = c.rel_id and r.object_id_one = group_id LOOP - if composition_rel__check_representation(c.rel_id) = ''f'' then + if composition_rel__check_representation(comp.rel_id) = ''f'' then + raise notice ''failed 2''; result := ''f''; end if; end loop; - for m in select m.rel_id + for memb in select m.rel_id from acs_rels r, membership_rels m where r.rel_id = m.rel_id and r.object_id_one = group_id LOOP - if membership_rel__check_representation(m.rel_id) = ''f'' then + if membership_rel__check_representation(memb.rel_id) = ''f'' then + raise notice ''failed 3''; result := ''f''; end if; end loop; PERFORM acs_log__notice(''acs_group.check_representation'', ''Done running check_representation on group '' || group_id); + return result; end;' language 'plpgsql'; 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.1 -r1.2 --- openacs-4/packages/acs-kernel/sql/postgresql/postgresql.sql 14 Mar 2001 04:39:10 -0000 1.1 +++ openacs-4/packages/acs-kernel/sql/postgresql/postgresql.sql 19 Mar 2001 05:07:08 -0000 1.2 @@ -1,3 +1,5 @@ + + create function instr(varchar,char,integer,integer) returns integer as ' declare str alias for $1;