[postgis-tickets] [SCM] PostGIS branch master updated. 3.2.0-657-gbb3842bfe

git at osgeo.org git at osgeo.org
Mon Mar 28 06:23:57 PDT 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  bb3842bfeef613f32e5dd032cad85599159ffb76 (commit)
      from  1ba6bccae13bfd37383e35f8c0678b08393f6726 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit bb3842bfeef613f32e5dd032cad85599159ffb76
Author: Sandro Santilli <strk at kbt.io>
Date:   Mon Mar 28 14:30:39 2022 +0200

    Allow dropping topologies with missing layer topogeom sequences
    
    Closes #5118 in master branch
    Includes regression test

diff --git a/NEWS b/NEWS
index deaefa28a..173815cd2 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PostGIS 3.3.0dev
   - Drop support for PostgreSQL 9.6 and 10 (Regina Obe)
 
  * Enhancements *
+  - #5118, Allow dropping topologies with missing topogeometry sequences
+    (Sandro Santilli)
   - #5111, faster topology face MBR computation (Sandro Santilli)
   - postgis_extensions_upgrade() support for upgrades from any PostGIS
     version, including yet to be released ones (Sandro Santilli)
diff --git a/topology/test/regress/droptopogeometrycolumn.sql b/topology/test/regress/droptopogeometrycolumn.sql
index 77046b4f9..19ad43699 100644
--- a/topology/test/regress/droptopogeometrycolumn.sql
+++ b/topology/test/regress/droptopogeometrycolumn.sql
@@ -1,10 +1,24 @@
 set client_min_messages to ERROR;
+
 -- Drop corrupted topology (with missing layer tables)
 -- See http://trac.osgeo.org/postgis/ticket/3016
-SELECT topology.CreateTopology('t1') > 0;
-CREATE TABLE t1f (id int);
-SELECT topology.AddTopoGeometryColumn('t1', 'public', 't1f', 'geom_t1', 'LINE') > 0;
-DROP TABLE t1.relation;
-SELECT topology.DropTopoGeometryColumn('public','t1f','geom_t1');
-DROP TABLE t1f;
-SELECT topology.DropTopology('t1');
+SELECT NULL FROM topology.CreateTopology('t3016');
+CREATE TABLE t3016f (id int);
+SELECT NULL FROM topology.AddTopoGeometryColumn('t3016', 'public', 't3016f', 'g', 'LINE');
+DROP TABLE t3016.relation;
+SELECT 't3016.drop', topology.DropTopoGeometryColumn('public','t3016f','g');
+SELECT 't3016', 'UNEXPECTED LAYER', * FROM topology.layer WHERE table_name = 't5118f';
+DROP TABLE t3016f;
+SELECT NULL FROM topology.DropTopology('t3016');
+
+-- Drop corrupted topology (with missing layer sequence)
+-- See http://trac.osgeo.org/postgis/ticket/5118
+SELECT NULL FROM topology.CreateTopology('t5118');
+CREATE TABLE t5118f (id int);
+SELECT NULL FROM topology.AddTopoGeometryColumn('t5118', 'public', 't5118f', 'g', 'LINE');
+INSERT INTO t5118f(g) SELECT toTopoGeom('LINESTRING(0 0, 10 0)', 't5118', 1);
+DROP SEQUENCE t5118.topogeo_s_1;
+SELECT 't5118.drop', topology.DropTopoGeometryColumn('public','t5118f','g');
+SELECT 't5118', 'UNEXPECTED LAYER', * FROM topology.layer WHERE table_name = 't5118f';
+DROP TABLE t5118f;
+SELECT NULL FROM topology.DropTopology('t5118');
diff --git a/topology/test/regress/droptopogeometrycolumn_expected b/topology/test/regress/droptopogeometrycolumn_expected
index 65dc643d9..cc45dde87 100644
--- a/topology/test/regress/droptopogeometrycolumn_expected
+++ b/topology/test/regress/droptopogeometrycolumn_expected
@@ -1,4 +1,2 @@
-t
-t
-Layer 1 (public.t1f.geom_t1) dropped
-Topology 't1' dropped
+t3016.drop|Layer 1 (public.t3016f.g) dropped
+t5118.drop|Layer 1 (public.t5118f.g) dropped
diff --git a/topology/topology.sql.in b/topology/topology.sql.in
index a522cbcf2..c7f4e3063 100644
--- a/topology/topology.sql.in
+++ b/topology/topology.sql.in
@@ -749,22 +749,13 @@ BEGIN
       schema,tbl,col;
   END IF;
 
-  -- Clean up the topology schema
+  -- Cleanup the relation table (if it exists)
   BEGIN
-    -- Cleanup the relation table
     sql := format(
       'DELETE FROM %I.relation WHERE layer_id = $1',
       lyrinfo.toponame
     );
     EXECUTE sql USING lyrinfo.layer_id;
-
-    -- Drop the sequence for topogeoms in this layer
-    sql := format(
-      'DROP SEQUENCE %I.topogeo_s_%s',
-      lyrinfo.toponame,
-      lyrinfo.layer_id
-    );
-    EXECUTE sql;
   EXCEPTION
     WHEN UNDEFINED_TABLE THEN
       RAISE NOTICE '%', SQLERRM;
@@ -772,6 +763,14 @@ BEGIN
       RAISE EXCEPTION 'Got % (%)', SQLERRM, SQLSTATE;
   END;
 
+  -- Drop the sequence for topogeoms in this layer
+  sql := format(
+    'DROP SEQUENCE IF EXISTS %I.topogeo_s_%s',
+    lyrinfo.toponame,
+    lyrinfo.layer_id
+  );
+  EXECUTE sql;
+
   ok = false;
   FOR rec IN SELECT * FROM pg_namespace n, pg_class c, pg_attribute a
     WHERE text(n.nspname) = schema

-----------------------------------------------------------------------

Summary of changes:
 NEWS                                               |  2 ++
 topology/test/regress/droptopogeometrycolumn.sql   | 28 ++++++++++++++++------
 .../test/regress/droptopogeometrycolumn_expected   |  6 ++---
 topology/topology.sql.in                           | 19 +++++++--------
 4 files changed, 34 insertions(+), 21 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list