[postgis-tickets] [SCM] PostGIS branch main updated. 3.2.0beta2-11-g27f44ecf6

git at osgeo.org git at osgeo.org
Mon Nov 29 08:14:18 PST 2021


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, main has been updated
       via  27f44ecf69ac576c95ff649b2fb23aa3e1cce5c1 (commit)
      from  3731d5d461867280924948ba9f96641e818901cd (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 27f44ecf69ac576c95ff649b2fb23aa3e1cce5c1
Author: Sandro Santilli <strk at kbt.io>
Date:   Thu Nov 25 23:52:15 2021 +0100

    Allow droppping TopoGeometry columns in presence of UPDATE triggers
    
    References #5026 in main branch
    Includes regression test

diff --git a/topology/test/regress/droptopology.sql b/topology/test/regress/droptopology.sql
index 84f2ca4b4..0b63a6d71 100644
--- a/topology/test/regress/droptopology.sql
+++ b/topology/test/regress/droptopology.sql
@@ -1,19 +1,36 @@
 set client_min_messages to WARNING;
 
-SELECT topology.CreateTopology('t1') > 0;
-SELECT topology.CreateTopology('t2') > 0;
+SELECT NULL FROM topology.CreateTopology('t1');
+SELECT NULL FROM topology.CreateTopology('t2');
 
 CREATE TABLE t1f (id int);
-SELECT topology.AddTopoGeometryColumn('t1', 'public', 't1f', 'geom_t1', 'LINE') > 0;
+SELECT NULL FROM topology.AddTopoGeometryColumn('t1', 'public', 't1f', 'geom_t1', 'LINE');
 
 CREATE TABLE t2f (id int);
-SELECT topology.AddTopoGeometryColumn('t2', 'public', 't2f', 'geom_t2', 'LINE') > 0;
+SELECT NULL FROM topology.AddTopoGeometryColumn('t2', 'public', 't2f', 'geom_t2', 'LINE');
 
 SELECT topology.DropTopology('t1');
 SELECT topology.DropTopology('t2');
 DROP TABLE t2f;
 DROP TABLE t1f;
 
+SELECT NULL FROM topology.CreateTopology('t3');
+CREATE FUNCTION t3.bail_out() RETURNS trigger AS $BODY$
+BEGIN
+  RAISE EXCEPTION '%: trigger prevents % on %', TG_ARGV[0], TG_OP, TG_RELNAME;
+END;
+$BODY$ LANGUAGE 'plpgsql';
+
+-- Test DropTopology in presence of triggers
+-- See https://trac.osgeo.org/postgis/ticket/5026
+CREATE TABLE t3.f(id serial);
+SELECT NULL FROM topology.AddTopoGeometryColumn('t3', 't3', 'f', 'g', 'POINT');
+CREATE TRIGGER prevent_delete AFTER DELETE OR UPDATE ON t3.f
+FOR EACH STATEMENT EXECUTE PROCEDURE t3.bail_out('t3');
+INSERT INTO t3.f(g) VALUES (toTopoGeom('POINT(0 0)', 't3', 1));
+--SELECT topology.DropTopoGeometryColumn('t3', 'f', 'g');
+SELECT topology.DropTopology('t3');
+
 -- Exceptions
 SELECT topology.DropTopology('topology');
 SELECT topology.DropTopology('doesnotexist');
diff --git a/topology/test/regress/droptopology_expected b/topology/test/regress/droptopology_expected
index e8ef689d4..37905a4d3 100644
--- a/topology/test/regress/droptopology_expected
+++ b/topology/test/regress/droptopology_expected
@@ -1,8 +1,5 @@
-t
-t
-t
-t
 Topology 't1' dropped
 Topology 't2' dropped
+Topology 't3' dropped
 ERROR:  Topology 'topology' does not exist
 ERROR:  Topology 'doesnotexist' does not exist
diff --git a/topology/topology.sql.in b/topology/topology.sql.in
index 4956a880e..1f62c8a1e 100644
--- a/topology/topology.sql.in
+++ b/topology/topology.sql.in
@@ -724,7 +724,7 @@ DECLARE
   result text;
 BEGIN
 
-        -- Get layer and topology info
+  -- Get layer and topology info
   ok = false;
   FOR rec IN EXECUTE 'SELECT t.name as toponame, l.* FROM '
        'topology.topology t, topology.layer l '
@@ -774,12 +774,11 @@ BEGIN
   END LOOP;
 
   IF ok THEN
-    -- Set feature column to NULL to bypass referential integrity
-    -- checks
-    EXECUTE 'UPDATE ' || quote_ident(schema) || '.'
+    -- Drop the layer column
+    EXECUTE 'ALTER TABLE ' || quote_ident(schema) || '.'
       || quote_ident(tbl)
-      || ' SET ' || quote_ident(col)
-      || ' = NULL';
+      || ' DROP ' || quote_ident(col)
+      || ' cascade';
   END IF;
 
   -- Delete the layer record
@@ -787,13 +786,6 @@ BEGIN
        ' WHERE topology_id = ' || lyrinfo.topology_id
     || ' AND layer_id = ' || lyrinfo.layer_id;
 
-  IF ok THEN
-    -- Drop the layer column
-    EXECUTE 'ALTER TABLE ' || quote_ident(schema) || '.'
-      || quote_ident(tbl)
-      || ' DROP ' || quote_ident(col)
-      || ' cascade';
-  END IF;
 
   result = 'Layer ' || lyrinfo.layer_id || ' ('
     || schema || '.' || tbl || '.' || col

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

Summary of changes:
 topology/test/regress/droptopology.sql      | 25 +++++++++++++++++++++----
 topology/test/regress/droptopology_expected |  5 +----
 topology/topology.sql.in                    | 18 +++++-------------
 3 files changed, 27 insertions(+), 21 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list