Index: openacs-4/packages/acs-kernel/acs-kernel.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/acs-kernel.info,v
diff -u -r1.131 -r1.132
--- openacs-4/packages/acs-kernel/acs-kernel.info 27 Oct 2014 16:39:35 -0000 1.131
+++ openacs-4/packages/acs-kernel/acs-kernel.info 2 May 2015 16:47:49 -0000 1.132
@@ -7,15 +7,15 @@
t
t
-
+
OpenACS Core Team
Routines and data models providing the foundation for OpenACS-based Web services.
2013-09-08
OpenACS
The OpenACS kernel contains the core datamodel create and drop scripts for such things as objects, groups, partiies and the supporting PL/SQL and PL/pgSQL procedures.
3
-
+
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.65 -r1.66
--- openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql 27 Oct 2014 16:39:35 -0000 1.65
+++ openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql 2 May 2015 16:47:50 -0000 1.66
@@ -938,40 +938,29 @@
select define_function_args('acs_object__delete','object_id');
-
-
--
-- procedure acs_object__delete/1
--
CREATE OR REPLACE FUNCTION acs_object__delete(
delete__object_id integer
) RETURNS integer AS $$
DECLARE
- obj_type record;
+ obj_type record;
BEGIN
- -- Delete dynamic/generic attributes
- delete from acs_attribute_values where object_id = delete__object_id;
+ -- GN: the following deletion operation iterates over the id_columns
+ -- of the acs_object_types of the type tree for the obejct and
+ -- performs manual deletions in these tables by trying to delete the
+ -- delete__object_id from the id_column. This deletion includes as
+ -- well the deletion in acs_objects.
+ --
+ -- In the best of all possible worlds, this would not
+ -- be necessary, when the objects would have specified "on delete
+ -- cascade" for the id_columns.
- -- Delete direct permissions records.
- delete from acs_permissions
- where object_id = delete__object_id
- or grantee_id = delete__object_id;
-
- -- select table_name, id_column
- -- from acs_object_types
- -- start with object_type = (select object_type
- -- from acs_objects o
- -- where o.object_id = delete__object_id)
- -- connect by object_type = prior supertype
-
- -- There was a gratuitous join against the objects table here,
- -- probably a leftover from when this was a join, and not a subquery.
- -- Functionally, this was working, but time taken was O(n) where n is the
- -- number of objects. OUCH. Fixed. (ben)
for obj_type
in select o2.table_name, o2.id_column
- from acs_object_types o1, acs_object_types o2
+ from acs_object_types o1, acs_object_types o2
where o1.object_type = (select object_type
from acs_objects o
where o.object_id = delete__object_id)
@@ -984,9 +973,10 @@
-- because the table names appear to be stored in upper case. Quoting
-- causes them to not match the actual lower or potentially mixed-case
-- table names. We will just forbid squirrely names that include quotes.
--- daveB
--- ETP is creating a new object, but not a table, although it does specify a
--- table name, so we need to check if the table exists. Wp-slim does this too
+
+ -- daveB
+ -- ETP is creating a new object, but not a table, although it does specify a
+ -- table name, so we need to check if the table exists. Wp-slim does this too
if table_exists(obj_type.table_name) then
execute 'delete from ' || obj_type.table_name ||
Index: openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.9.0d1-5.9.0d2.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.9.0d1-5.9.0d2.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.9.0d1-5.9.0d2.sql 2 May 2015 16:47:50 -0000 1.1
@@ -0,0 +1,50 @@
+--
+-- procedure acs_object__delete/1
+--
+CREATE OR REPLACE FUNCTION acs_object__delete(
+ delete__object_id integer
+) RETURNS integer AS $$
+DECLARE
+ obj_type record;
+BEGIN
+
+ -- GN: the following deletion operation iterates over the id_columns
+ -- of the acs_object_types of the type tree for the obejct and
+ -- performs manual deletions in these tables by trying to delete the
+ -- delete__object_id from the id_column. This deletion includes as
+ -- well the deletion in acs_objects.
+ --
+ -- In the best of all possible worlds, this would not
+ -- be necessary, when the objects would have specified "on delete
+ -- cascade" for the id_columns.
+
+ for obj_type
+ in select o2.table_name, o2.id_column
+ from acs_object_types o1, acs_object_types o2
+ where o1.object_type = (select object_type
+ from acs_objects o
+ where o.object_id = delete__object_id)
+ and o1.tree_sortkey between o2.tree_sortkey and tree_right(o2.tree_sortkey)
+ order by o2.tree_sortkey desc
+ loop
+ -- Delete from the table.
+
+ -- DRB: I removed the quote_ident calls that DanW originally included
+ -- because the table names appear to be stored in upper case. Quoting
+ -- causes them to not match the actual lower or potentially mixed-case
+ -- table names. We will just forbid squirrely names that include quotes.
+
+ -- daveB
+ -- ETP is creating a new object, but not a table, although it does specify a
+ -- table name, so we need to check if the table exists. Wp-slim does this too
+
+ if table_exists(obj_type.table_name) then
+ execute 'delete from ' || obj_type.table_name ||
+ ' where ' || obj_type.id_column || ' = ' || delete__object_id;
+ end if;
+ end loop;
+
+ return 0;
+END;
+$$ LANGUAGE plpgsql;
+