[postgis-tickets] r14434 - Fix handling of hierarchical topo layers with multiple topologies

Sandro Santilli strk at keybit.net
Thu Nov 26 01:08:18 PST 2015


Author: strk
Date: 2015-11-26 01:08:17 -0800 (Thu, 26 Nov 2015)
New Revision: 14434

Modified:
   branches/2.2/topology/topology.sql.in
Log:
Fix handling of hierarchical topo layers with multiple topologies

Different layers with same id in different topologies confused
GetTopoGeomElements and AddTopoGeometryColumn.

See #3378

Modified: branches/2.2/topology/topology.sql.in
===================================================================
--- branches/2.2/topology/topology.sql.in	2015-11-26 09:08:10 UTC (rev 14433)
+++ branches/2.2/topology/topology.sql.in	2015-11-26 09:08:17 UTC (rev 14434)
@@ -595,6 +595,7 @@
   IF child IS NOT NULL THEN
     SELECT level + 1 FROM topology.layer
       WHERE layer_id = child
+        AND topology_id = topoid
       INTO newlevel;
     IF newlevel IS NULL THEN
       RAISE EXCEPTION 'Child layer % does not exist in topology "%"', child, toponame;
@@ -1105,13 +1106,21 @@
   query2 text;
   lyr RECORD;
   ok bool;
+  topoid INTEGER;
 BEGIN
 
+  -- Get topology id
+  SELECT id INTO topoid
+    FROM topology.topology WHERE name = toponame;
+  IF NOT FOUND THEN
+    RAISE EXCEPTION 'Topology % does not exist', quote_literal(toponame);
+  END IF;
+
   -- Get layer info
   ok = false;
-  FOR rec IN EXECUTE 'SELECT * FROM '
-       ' topology.layer '
-       ' WHERE layer_id = ' || layerid
+  FOR rec IN EXECUTE 'SELECT * FROM topology.layer '
+       ' WHERE layer_id = $1 AND topology_id = $2'
+       USING layerid, topoid
   LOOP
     lyr = rec;
     ok = true;



More information about the postgis-tickets mailing list