Index: openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql,v
diff -u -r1.26.2.1 -r1.26.2.2
--- openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql	14 Aug 2019 07:31:43 -0000	1.26.2.1
+++ openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql	24 Mar 2021 10:16:17 -0000	1.26.2.2
@@ -158,6 +158,14 @@
 	unique (context_id, object_id) disable
 );
 
+--
+-- Avoid potential loops on context_ids. A context_id must be
+-- different from the object_id. If no context_id should be checked, its
+-- value must be NULL. Note that this constraint is not guaranteed to
+-- avoid all loops; it is still possible to create indirect recursive
+-- loops but excludes some real-world problems.
+ALTER TABLE acs_objects ADD CONSTRAINT acs_objects_context_id_ck CHECK (context_id != object_id);
+
 create index acs_objects_context_object_idx on acs_objects (context_id, object_id);
 
 alter table acs_objects modify constraint acs_objects_context_object_un enable;
