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 -r1.11 -r1.12
--- openacs-4/packages/acs-kernel/sql/oracle/site-nodes-create.sql	1 May 2018 10:45:43 -0000	1.11
+++ openacs-4/packages/acs-kernel/sql/oracle/site-nodes-create.sql	3 Sep 2024 15:37:33 -0000	1.12
@@ -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);
@@ -76,7 +85,7 @@
 
   -- Return the node_id of a URL. If the url begins with '/' then the
   -- parent_id must be null. This will raise the no_data_found
-  -- exception if there is no mathing node in the site_nodes table.
+  -- exception if there is no matching node in the site_nodes table.
   -- This will match directories even if no trailing slash is included
   -- in the url.
 
