Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-metadata-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-metadata-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-metadata-create.sql 14 Mar 2001 14:07:31 -0000 1.2 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-metadata-create.sql 20 Mar 2001 06:02:57 -0000 1.3 @@ -606,7 +606,8 @@ begin v_idx := position(''.'' in create_type__name_method); if v_idx <> 0 then - v_name_method := substr(create_type__name_method,1,v_idx - 1) || ''__'' || substr(create_type__name_method, v_idx + 1); + v_name_method := substr(create_type__name_method,1,v_idx - 1) || + ''__'' || substr(create_type__name_method, v_idx + 1); else v_name_method := create_type__name_method; end if; @@ -646,7 +647,8 @@ from acs_attributes where object_type = drop_type__object_type loop - PERFORM acs_attribute__drop_attribute (drop_type__object_type, row.attribute_name); + PERFORM acs_attribute__drop_attribute (drop_type__object_type, + row.attribute_name); end loop; delete from acs_attributes @@ -681,21 +683,23 @@ declare is_subtype_p__object_type_1 alias for $1; is_subtype_p__object_type_2 alias for $2; - v_result integer; + v_result integer; begin -- select count(*) into v_result -- where exists (select 1 -- from acs_object_types t -- where t.object_type = is_subtype_p__object_type_2 -- connect by prior t.object_type = t.supertype -- start with t.supertype = is_subtype_p__object_type_1); - select count(*) + + select count(*) into v_result where exists (select 1 from acs_object_types t where t.object_type = is_subtype_p__object_type_2 - and tree_sortkey like (select tree_sortkey || ''%'' - from acs_object_types - where object_type = is_subtype_p__object_type_1 )); + and tree_sortkey like + (select tree_sortkey || ''%'' + from acs_object_types + where object_type = is_subtype_p__object_type_1 )); if v_result > 0 then return ''t''; 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.10 -r1.11 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql 20 Mar 2001 04:20:44 -0000 1.10 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql 20 Mar 2001 06:02:57 -0000 1.11 @@ -587,7 +587,7 @@ returns integer as ' declare initialize_attributes__object_id alias for $1; - v_object_type acs_objects.object_type%TYPE; + v_object_type acs_objects.object_type%TYPE; begin -- XXX This should be fixed to initialize supertypes properly. @@ -1021,7 +1021,7 @@ v_table_name := acs_object__get_attr_storage_table(v_storage); v_key_sql := acs_object__get_attr_storage_sql(v_storage); - execute ''update '' || quote_identifier(v_table_name) || '' set '' || quote_identifier(v_column) || '' = '' || quote_literal(value_in) || '' where '' || quote_literal(v_key_sql); + execute ''update '' || quote_ident(v_table_name) || '' set '' || quote_ident(v_column) || '' = '' || quote_literal(value_in) || '' where '' || quote_literal(v_key_sql); return 0; end;' language 'plpgsql'; @@ -1082,8 +1082,8 @@ check_object_ancestors__object_id alias for $1; check_object_ancestors__ancestor_id alias for $2; check_object_ancestors__n_generations alias for $3; - context_id acs_objects.context_id%TYPE; - security_inherit_p acs_objects.security_inherit_p%TYPE; + check_object_ancestors__context_id acs_objects.context_id%TYPE; + check_object_ancestors__security_inherit_p acs_objects.security_inherit_p%TYPE; n_rows integer; n_gens integer; result boolean; @@ -1102,12 +1102,14 @@ -- Grab the context and security_inherit_p flag of the current -- ancestor''''s parent. - select context_id, security_inherit_p into context_id, security_inherit_p + select context_id, security_inherit_p + into check_object_ancestors__context_id, + check_object_ancestors__security_inherit_p from acs_objects where object_id = check_object_ancestors__ancestor_id; if check_object_ancestors__ancestor_id = 0 then - if context_id is null then + if check_object_ancestors__context_id is null then result := ''t''; else -- This can be a constraint, can''''t it? @@ -1116,15 +1118,20 @@ result := ''f''; end if; else - if context_id is null or security_inherit_p = ''f'' then - context_id := 0; + if check_object_ancestors__context_id is null or + check_object_ancestors__security_inherit_p = ''f'' + THEN + check_object_ancestors__context_id := 0; end if; - if acs_object__check_context_index(check_object_ancestors__object_id, check_object_ancestors__ancestor_id, check_object_ancestors__n_generations) = ''f'' then + if acs_object__check_context_index(check_object_ancestors__object_id, + check_object_ancestors__ancestor_id, + check_object_ancestors__n_generations) = ''f'' then result := ''f''; end if; - if acs_object__check_object_ancestors(check_object_ancestors__object_id, context_id, + if acs_object__check_object_ancestors(check_object_ancestors__object_id, + check_object_ancestors__context_id, check_object_ancestors__n_generations + 1) = ''f'' then result := ''f''; end if; @@ -1207,7 +1214,8 @@ check_path__context_id := 0; end if; - return acs_object__check_path(check_path__context_id, check_path__ancestor_id); + return acs_object__check_path(check_path__context_id, + check_path__ancestor_id); end;' language 'plpgsql'; @@ -1225,8 +1233,8 @@ begin result := ''t''; PERFORM acs_log__notice(''acs_object.check_representation'', - ''Running acs_object.check_representation on object_id = '' || - check_representation__object_id || ''.''); + ''Running acs_object.check_representation on object_id = '' + || check_representation__object_id || ''.''); select object_type into check_representation__object_type from acs_objects @@ -1267,11 +1275,13 @@ PERFORM acs_log__notice(''acs_object.check_representation'', ''OBJECT CONTEXT INTEGRITY TEST''); - if acs_object__check_object_ancestors(check_representation__object_id, check_representation__object_id, 0) = ''f'' then + if acs_object__check_object_ancestors(check_representation__object_id, + check_representation__object_id, 0) = ''f'' then result := ''f''; end if; - if acs_object__check_object_descendants(check_representation__object_id, check_representation__object_id, 0) = ''f'' then + if acs_object__check_object_descendants(check_representation__object_id, + check_representation__object_id, 0) = ''f'' then result := ''f''; end if; for row in select object_id, ancestor_id, n_generations Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql 18 Mar 2001 05:22:27 -0000 1.3 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql 20 Mar 2001 06:02:57 -0000 1.4 @@ -321,7 +321,8 @@ delete from acs_rel_types where rel_type = drop_type__rel_type; - PERFORM acs_object_type__drop_type(drop_type__rel_type, drop_type__cascade_p); + PERFORM acs_object_type__drop_type(drop_type__rel_type, + drop_type__cascade_p); return 0; end;' language 'plpgsql'; @@ -410,9 +411,6 @@ actual_object_type_one acs_object_types.object_type%TYPE; actual_object_type_two acs_object_types.object_type%TYPE; begin - -/* - select 1 into dummy from acs_rel_types rt, acs_objects o1, @@ -434,6 +432,7 @@ and rt.rel_type = new.rel_type and o1.object_id = new.object_id_one and o2.object_id = new.object_id_two; + if NOT FOUND then -- At least one of the object types must have been wrong. @@ -447,15 +446,16 @@ and o1.object_id = new.object_id_one and o2.object_id = new.object_id_two; - raise EXCEPTION ''-20001: %'', new.rel_type || '' violation: Invalid object types. '' || - ''Object '' || new.object_id_one || - '' ('' || actual_object_type_one || '') '' || - ''must be of type '' || target_object_type_one || ''. '' || - ''Object '' || new.object_id_two || - '' ('' || actual_object_type_two || '') '' || - ''must be of type '' || target_object_type_two || ''.''; + raise EXCEPTION ''-20001: % violation: Invalid object types. Object % (%) must be of type % Object % (%) must be of type %'', new.rel_type, + new.object_id_one, + actual_object_type_one, + target_object_type_one, + new.object_id_two, + actual_object_type_two, + target_object_type_two; + end if; -*/ + return new; end;' language 'plpgsql'; 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.5 -r1.6 --- openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql 20 Mar 2001 04:12:10 -0000 1.5 +++ openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql 20 Mar 2001 06:02:57 -0000 1.6 @@ -815,14 +815,14 @@ returns varchar as ' declare name__group_id alias for $1; - group_name varchar(200); + name__group_name varchar(200); begin select group_name - into group_name + into name__group_name from groups where group_id = name__group_id; - return group_name; + return name__group_name; end;' language 'plpgsql'; Index: openacs-4/packages/acs-kernel/sql/postgresql/rel-segments-body-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/rel-segments-body-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-kernel/sql/postgresql/rel-segments-body-create.sql 17 Mar 2001 21:46:06 -0000 1.2 +++ openacs-4/packages/acs-kernel/sql/postgresql/rel-segments-body-create.sql 20 Mar 2001 06:02:57 -0000 1.3 @@ -142,14 +142,14 @@ returns varchar as ' declare name__segment_id alias for $1; - segment_name varchar(200); + name__segment_name varchar(200); begin select segment_name - into segment_name + into name__segment_name from rel_segments where segment_id = name__segment_id; - return segment_name; + return name__segment_name; end;' language 'plpgsql'; 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.3 -r1.4 --- openacs-4/packages/acs-kernel/sql/postgresql/site-nodes-create.sql 18 Mar 2001 05:22:27 -0000 1.3 +++ openacs-4/packages/acs-kernel/sql/postgresql/site-nodes-create.sql 20 Mar 2001 06:02:57 -0000 1.4 @@ -194,8 +194,8 @@ new__pattern_p alias for $6; new__creation_user alias for $7; new__creation_ip alias for $8; - v_node_id site_nodes.node_id%TYPE; - v_directory_p site_nodes.directory_p%TYPE; + v_node_id site_nodes.node_id%TYPE; + v_directory_p site_nodes.directory_p%TYPE; begin if new__parent_id is not null then select directory_p into v_directory_p Index: openacs-4/packages/acs-kernel/sql/postgresql/utilities-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/utilities-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-kernel/sql/postgresql/utilities-create.sql 14 Mar 2001 04:39:10 -0000 1.1 +++ openacs-4/packages/acs-kernel/sql/postgresql/utilities-create.sql 20 Mar 2001 06:02:57 -0000 1.2 @@ -41,7 +41,7 @@ v_rec record; begin for counter in 1..v_count loop - for v_rec in EXECUTE ''select '' || quote_identifier(v_sequence_name) ''.nextval as a_seq_val'' + for v_rec in EXECUTE ''select '' || quote_ident(v_sequence_name) ''.nextval as a_seq_val'' LOOP a_sequence_values := a_sequence_values || '''','''' || v_rec.a_seq_val; exit;