]> granicus.if.org Git - postgis/commitdiff
Handle invalid topology names (#3196)
authorSandro Santilli <strk@keybit.net>
Mon, 20 Jul 2015 17:08:03 +0000 (17:08 +0000)
committerSandro Santilli <strk@keybit.net>
Mon, 20 Jul 2015 17:08:03 +0000 (17:08 +0000)
Updates regressions for changes.

Patch by Mike Toews <mwtoews@gmail.com>

git-svn-id: http://svn.osgeo.org/postgis/trunk@13818 b70326c6-7e19-0410-871a-916f4a2858ee

topology/test/regress/addtopogeometrycolumn.sql
topology/test/regress/addtopogeometrycolumn_expected
topology/test/regress/createtopology.sql
topology/test/regress/createtopology_expected
topology/test/regress/droptopology.sql
topology/test/regress/droptopology_expected
topology/topology.sql.in

index 628e273cb439ab5f78e5b3293798a1ec1ddbe0f3..b5223ff5f585057d7223d87818ac65d89b2ef87d 100644 (file)
@@ -1,6 +1,7 @@
 set client_min_messages to WARNING;
 \set VERBOSITY terse
 
+select addtopogeometrycolumn('tt','public','feature','tg','POINT'); -- fail
 select createtopology('tt') > 0;
 select addtopogeometrycolumn('tt','public','feature','tg','POINT'); -- fail
 create table feature(id integer);
index c893a2484f9a418d26a2169c15c79c59b50cdf90..38f786eff2938bf35f0ba66e1ba8905702507b55 100644 (file)
@@ -1,3 +1,4 @@
+ERROR:  Topology 'tt' does not exist
 t
 ERROR:  relation "public.feature" does not exist
 ERROR:  Layer type must be one of POINT,LINE,POLYGON,COLLECTION
index fc441767f89443ef6ddd4216759e024c5b8ac0ec..9ac06b6676220bbda9f3dd699e25c64c95b6707a 100644 (file)
@@ -26,3 +26,7 @@ SELECT topology.AddNode('2d', 'POINT(2 2)');
 SELECT topology.DropTopology('2d');
 SELECT topology.DropTopology('2dAgain');
 SELECT topology.DropTopology('3d');
+
+-- Exceptions
+SELECT topology.CreateTopology('public');
+SELECT topology.CreateTopology('topology');
index 5f39466fa905bf2856ea92a1ee905d2415e9e176..e08c967b4134de16dac5d5b8e8aa8177df2ac378 100644 (file)
@@ -14,3 +14,5 @@ ERROR:  Geometry has Z dimension but column does not
 Topology '2d' dropped
 Topology '2dAgain' dropped
 Topology '3d' dropped
+ERROR:  schema "public" already exists
+ERROR:  schema "topology" already exists
index ec578a9b6a32c51e6057adf6466056a09cdbc2c5..84f2ca4b46fe0c96985aab0b844189f7afed6de5 100644 (file)
@@ -13,3 +13,7 @@ SELECT topology.DropTopology('t1');
 SELECT topology.DropTopology('t2');
 DROP TABLE t2f;
 DROP TABLE t1f;
+
+-- Exceptions
+SELECT topology.DropTopology('topology');
+SELECT topology.DropTopology('doesnotexist');
index c590ed37104d56276ec9629c6e810a63dd1e2214..e8ef689d4844e31a48dd77b0c45e6476927a768b 100644 (file)
@@ -4,3 +4,5 @@ t
 t
 Topology 't1' dropped
 Topology 't2' dropped
+ERROR:  Topology 'topology' does not exist
+ERROR:  Topology 'doesnotexist' does not exist
index 09c89921d164607eea8a40166347d2d7ec85dc06..df0417fb0ec84a105d6ba1d2fcf00608ec08f8d4 100644 (file)
@@ -560,12 +560,12 @@ DECLARE
   query text;
 BEGIN
 
-        -- Get topology id
-        SELECT id FROM topology.topology into topoid
-                WHERE name = toponame;
+  -- Get topology id
+  SELECT id INTO topoid
+    FROM topology.topology WHERE name = toponame;
 
-  IF topoid IS NULL THEN
-    RAISE EXCEPTION 'Topology % does not exist', toponame;
+  IF NOT FOUND THEN
+    RAISE EXCEPTION 'Topology % does not exist', quote_literal(toponame);
   END IF;
 
   IF ltype ILIKE '%POINT%' OR ltype ILIKE 'PUNTAL' THEN
@@ -861,8 +861,12 @@ BEGIN
   END IF;
 
   -- Get topology id into return TopoGeometry
-  SELECT id FROM topology.topology into ret.topology_id
-    WHERE name = toponame;
+  SELECT id INTO ret.topology_id
+    FROM topology.topology WHERE name = toponame;
+
+  IF NOT FOUND THEN
+    RAISE EXCEPTION 'Topology % does not exist', quote_literal(toponame);
+  END IF;
 
   --
   -- Get layer info
@@ -995,8 +999,13 @@ $$
 DECLARE
   ret integer;
 BEGIN
-        SELECT id FROM topology.topology into ret
-                WHERE name = toponame;
+  SELECT id INTO ret
+    FROM topology.topology WHERE name = toponame;
+
+  IF NOT FOUND THEN
+    RAISE EXCEPTION 'Topology % does not exist', quote_literal(toponame);
+  END IF;
+
   RETURN ret;
 END
 $$
@@ -1920,37 +1929,34 @@ DECLARE
   topoid integer;
   rec RECORD;
 BEGIN
-
   -- Get topology id
-        SELECT id FROM topology.topology into topoid
-                WHERE name = atopology;
-
-
-  IF topoid IS NOT NULL THEN
+  SELECT id INTO topoid
+    FROM topology.topology WHERE name = atopology;
 
-    RAISE NOTICE 'Dropping all layers from topology % (%)',
-      atopology, topoid;
+  IF NOT FOUND THEN
+    RAISE EXCEPTION 'Topology % does not exist', quote_literal(atopology);
+  END IF;
 
-    -- Drop all layers in the topology
-    FOR rec IN EXECUTE 'SELECT * FROM topology.layer WHERE '
-         ' topology_id = ' || topoid
-    LOOP
+  RAISE NOTICE 'Dropping all layers from topology % (%)',
+    quote_literal(atopology), topoid;
 
-      EXECUTE 'SELECT topology.DropTopoGeometryColumn('
-        || quote_literal(rec.schema_name)
-        || ','
-        || quote_literal(rec.table_name)
-        || ','
-        || quote_literal(rec.feature_column)
-        || ')';
-    END LOOP;
-
-    -- Delete record from topology.topology
-    EXECUTE 'DELETE FROM topology.topology WHERE id = '
-      || topoid;
+  -- Drop all layers in the topology
+  FOR rec IN EXECUTE 'SELECT * FROM topology.layer WHERE '
+    || ' topology_id = ' || topoid
+  LOOP
 
-  END IF;
+    EXECUTE 'SELECT topology.DropTopoGeometryColumn('
+      || quote_literal(rec.schema_name)
+      || ','
+      || quote_literal(rec.table_name)
+      || ','
+      || quote_literal(rec.feature_column)
+      || ')';
+  END LOOP;
 
+  -- Delete record from topology.topology
+  EXECUTE 'DELETE FROM topology.topology WHERE id = '
+    || topoid;
 
   -- Drop the schema (if it exists)
   FOR rec IN SELECT * FROM pg_namespace WHERE text(nspname) = atopology