Index: openacs-4/packages/acs-kernel/sql/oracle/site-nodes-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/site-nodes-create.sql,v
diff -u -N -r1.11.2.1 -r1.11.2.2
--- openacs-4/packages/acs-kernel/sql/oracle/site-nodes-create.sql	14 Aug 2019 07:31:43 -0000	1.11.2.1
+++ openacs-4/packages/acs-kernel/sql/oracle/site-nodes-create.sql	24 Mar 2021 17:00:08 -0000	1.11.2.2
@@ -46,6 +46,15 @@
                         references acs_objects (object_id)
 );
 
+--
+-- Avoid potential loops on site_node parent_ids. A parent_id must be
+-- different from the node_id. 
+-- 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 site_nodes ADD CONSTRAINT site_nodes_parent_id_ck CHECK (node_id <> parent_id);
+
 create index site_nodes_object_id_idx on site_nodes (object_id);
 create index site_nodes_parent_obj_node_idx on site_nodes(parent_id, object_id, node_id);
 create index site_nodes_parent_id_idx on site_nodes(parent_id);
