Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
acs-kernel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
acs-kernel
Commits
2cb60180
Commit
2cb60180
authored
Dec 03, 2015
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- OpenACS 5.9
parent
7a72953b
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1237 additions
and
0 deletions
+1237
-0
upgrade-5.7.0d1-5.7.0d2.sql
sql/postgresql/upgrade/upgrade-5.7.0d1-5.7.0d2.sql
+103
-0
upgrade-5.7.0d10-5.7.0d11.sql
sql/postgresql/upgrade/upgrade-5.7.0d10-5.7.0d11.sql
+297
-0
upgrade-5.7.0d2-5.7.0d3.sql
sql/postgresql/upgrade/upgrade-5.7.0d2-5.7.0d3.sql
+81
-0
upgrade-5.7.0d3-5.7.0d4.sql
sql/postgresql/upgrade/upgrade-5.7.0d3-5.7.0d4.sql
+637
-0
upgrade-5.7.0d4-5.6.0d5.sql
sql/postgresql/upgrade/upgrade-5.7.0d4-5.6.0d5.sql
+119
-0
No files found.
sql/postgresql/upgrade/upgrade-5.7.0d1-5.7.0d2.sql
0 → 100644
View file @
2cb60180
-- Support for postgresql 9.x
-- @author Victor Guerra (vguerra@gmail.com)
create
or
replace
function
acs_objects_context_id_up_tr
()
returns
trigger
as
'
declare
pair record;
outer_record record;
inner_record record;
security_context_root integer;
begin
if new.object_id = old.object_id
and ((new.context_id = old.context_id)
or (new.context_id is null and old.context_id is null))
and new.security_inherit_p = old.security_inherit_p then
return new;
end if;
-- Remove my old ancestors from my descendants.
for outer_record in select object_id from acs_object_context_index where
ancestor_id = old.object_id and object_id <> old.object_id loop
for inner_record in select ancestor_id from acs_object_context_index where
object_id = old.object_id and ancestor_id <> old.object_id loop
delete from acs_object_context_index
where object_id = outer_record.object_id
and ancestor_id = inner_record.ancestor_id;
end loop;
end loop;
-- Kill all my old ancestors.
delete from acs_object_context_index
where object_id = old.object_id;
insert into acs_object_context_index
(object_id, ancestor_id, n_generations)
values
(new.object_id, new.object_id, 0);
if new.context_id is not null and new.security_inherit_p =
''
t
''
then
-- Now insert my new ancestors for my descendants.
for pair in select *
from acs_object_context_index
where ancestor_id = new.object_id
LOOP
insert into acs_object_context_index
(object_id, ancestor_id, n_generations)
select
pair.object_id, ancestor_id,
n_generations + pair.n_generations + 1 as n_generations
from acs_object_context_index
where object_id = new.context_id;
end loop;
else
security_context_root = acs__magic_object_id(
''
security_context_root
''
);
if new.object_id != security_context_root then
-- We need to make sure that new.OBJECT_ID and all of its
-- children have security_context_root as an ancestor.
for pair in select *
from acs_object_context_index
where ancestor_id = new.object_id
LOOP
insert into acs_object_context_index
(object_id, ancestor_id, n_generations)
values
(pair.object_id, security_context_root, pair.n_generations + 1);
end loop;
end if;
end if;
return new;
end;'
language
'plpgsql'
;
create
or
replace
function
acs_object__get_attribute
(
integer
,
varchar
)
returns
text
as
'
declare
object_id_in alias for $1;
attribute_name_in alias for $2;
v_table_name varchar(200);
v_column varchar(200);
v_key_sql text;
v_return text;
v_storage text;
v_rec record;
begin
v_storage := acs_object__get_attribute_storage(object_id_in, attribute_name_in);
v_column := acs_object__get_attr_storage_column(v_storage);
v_table_name := acs_object__get_attr_storage_table(v_storage);
v_key_sql := acs_object__get_attr_storage_sql(v_storage);
for v_rec in execute
''
select
''
|| quote_ident(v_column) ||
''
::text as column_return from
''
|| quote_ident(v_table_name) ||
''
where
''
|| v_key_sql
LOOP
v_return := v_rec.column_return;
exit;
end loop;
if not FOUND then
return null;
end if;
return v_return;
end;'
language
'plpgsql'
stable
;
sql/postgresql/upgrade/upgrade-5.7.0d10-5.7.0d11.sql
0 → 100644
View file @
2cb60180
This diff is collapsed.
Click to expand it.
sql/postgresql/upgrade/upgrade-5.7.0d2-5.7.0d3.sql
0 → 100644
View file @
2cb60180
--
--
--
-- @author Victor Guerra (vguerra@gmail.com)
-- @creation-date 2010-11-15
-- @cvs-id $Id$
--
-- Avoiding the usage of the coalesce function
-- on the site_nodes columns in the where clause
-- because this leads to usage of a sequencial scan,
-- instead we enforce the usage of an index scan
-- by issolating the case on which we need to compare null values
-- and using the equal operator.
-- function node_id
create
or
replace
function
site_node__node_id
(
varchar
,
integer
)
returns
integer
as
'
declare
node_id__url alias for $1;
node_id__parent_id alias for $2; -- default null
v_pos integer;
v_first site_nodes.name%TYPE;
v_rest text;
v_node_id integer;
v_pattern_p site_nodes.pattern_p%TYPE;
v_url text;
v_directory_p site_nodes.directory_p%TYPE;
v_trailing_slash_p boolean;
begin
v_url := node_id__url;
if substr(v_url, length(v_url), 1) =
''
/
''
then
-- It ends with a / so it must be a directory.
v_trailing_slash_p :=
''
t
''
;
v_url := substr(v_url, 1, length(v_url) - 1);
end if;
v_pos := 1;
while v_pos <= length(v_url) and substr(v_url, v_pos, 1) <>
''
/
''
loop
v_pos := v_pos + 1;
end loop;
if v_pos = length(v_url) then
v_first := v_url;
v_rest := null;
else
v_first := substr(v_url, 1, v_pos - 1);
v_rest := substr(v_url, v_pos + 1);
end if;
if node_id__parent_id is not null then
select node_id, directory_p into v_node_id, v_directory_p
from site_nodes
where parent_id = node_id__parent_id
and name = v_first;
else
select node_id, directory_p into v_node_id, v_directory_p
from site_nodes
where parent_id is null
and name = v_first;
end if;
if NOT FOUND then
return site_node__find_pattern(node_id__parent_id);
end if;
if v_rest is null then
if v_trailing_slash_p =
''
t
''
and v_directory_p =
''
f
''
then
return site_node__find_pattern(node_id__parent_id);
else
return v_node_id;
end if;
else
return site_node__node_id(v_rest, v_node_id);
end if;
end;'
language
'plpgsql'
;
sql/postgresql/upgrade/upgrade-5.7.0d3-5.7.0d4.sql
0 → 100644
View file @
2cb60180
This diff is collapsed.
Click to expand it.
sql/postgresql/upgrade/upgrade-5.7.0d4-5.6.0d5.sql
0 → 100644
View file @
2cb60180
select
define_function_args
(
'acs_object_type__create_type'
,
'object_type,pretty_name,pretty_plural,supertype,table_name,id_column,package_name,abstract_p;f,type_extension_table,name_method,create_table_p;f,dynamic_p;f'
);
create
or
replace
function
acs_object_type__create_type
(
varchar
,
varchar
,
varchar
,
varchar
,
varchar
,
varchar
,
varchar
,
boolean
,
varchar
,
varchar
,
boolean
,
boolean
)
returns
integer
as
'
declare
p_object_type alias for $1;
p_pretty_name alias for $2;
p_pretty_plural alias for $3;
p_supertype alias for $4;
p_table_name alias for $5; -- default null
p_id_column alias for $6; -- default null
p_package_name alias for $7; -- default null
p_abstract_p alias for $8; -- default
''
f
''
p_type_extension_table alias for $9; -- default null
p_name_method alias for $10; -- default null
p_create_table_p alias for $11;
p_dynamic_p alias for $12;
v_package_name acs_object_types.package_name%TYPE;
v_supertype acs_object_types.supertype%TYPE;
v_name_method varchar;
v_idx integer;
v_temp_p boolean;
v_supertype_table acs_object_types.table_name%TYPE;
v_id_column acs_object_types.id_column%TYPE;
v_table_name acs_object_types.table_name%TYPE;
begin
v_idx := position(
''
.
''
in p_name_method);
if v_idx <> 0 then
v_name_method := substr(p_name_method,1,v_idx - 1) ||
''
__
''
|| substr(p_name_method, v_idx + 1);
else
v_name_method := p_name_method;
end if;
-- If we are asked to create the table, provide reasonable default values for the
-- table name and id column. Traditionally OpenACS uses the plural form of the type
-- name. This code appends "_t" (for "table") because the use of english plural rules
-- does not work well for all languages.
if p_create_table_p and (p_table_name is null or p_table_name =
''''
) then
v_table_name := p_object_type ||
''
_t
''
;
else
v_table_name := p_table_name;
end if;
if p_create_table_p and (p_id_column is null or p_id_column =
''''
) then
v_id_column := p_object_type ||
''
_id
''
;
else
v_id_column := p_id_column;
end if;
if p_package_name is null or p_package_name =
''''
then
v_package_name := p_object_type;
else
v_package_name := p_package_name;
end if;
if p_supertype is null or p_supertype =
''''
then
v_supertype :=
''
acs_object
''
;
else
v_supertype := p_supertype;
if not acs_object_type__is_subtype_p(
''
acs_object
''
, p_supertype)
then
raise exception
''
%s is not a valid type
''
, p_supertype;
end if;
end if;
insert into acs_object_types
(object_type, pretty_name, pretty_plural, supertype, table_name,
id_column, abstract_p, type_extension_table, package_name,
name_method, dynamic_p)
values
(p_object_type, p_pretty_name,
p_pretty_plural, v_supertype,
v_table_name, v_id_column,
p_abstract_p, p_type_extension_table,
v_package_name, v_name_method, p_dynamic_p);
if p_create_table_p then
if exists (select 1
from pg_class
where relname = lower(v_table_name)) then
raise exception
''
Table "%" already exists
''
, v_table_name;
end if;
select table_name into v_supertype_table from acs_object_types
where object_type = p_supertype;
execute
''
create table
''
|| v_table_name ||
''
(
''
||
v_id_column ||
''
integer constraint
''
|| v_table_name ||
''
_pk primary key
''
||
''
constraint
''
|| v_table_name ||
''
_fk references
''
|| v_supertype_table ||
''
on delete cascade)
''
;
end if;
return 0;
end;'
language
'plpgsql'
;
-- DRB: backwards compatibility version, don't allow for table creation.
create
or
replace
function
acs_object_type__create_type
(
varchar
,
varchar
,
varchar
,
varchar
,
varchar
,
varchar
,
varchar
,
boolean
,
varchar
,
varchar
)
returns
integer
as
'
declare
p_object_type alias for $1;
p_pretty_name alias for $2;
p_pretty_plural alias for $3;
p_supertype alias for $4;
p_table_name alias for $5; -- default null
p_id_column alias for $6; -- default null
p_package_name alias for $7; -- default null
p_abstract_p alias for $8; -- default
''
f
''
p_type_extension_table alias for $9; -- default null
p_name_method alias for $10; -- default null
begin
return acs_object_type__create_type(p_object_type, p_pretty_name,
p_pretty_plural, p_supertype, p_table_name,
p_id_column, p_package_name, p_abstract_p,
p_type_extension_table, p_name_method,
''
f
''
,
''
f
''
);
end;'
language
'plpgsql'
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment