[postgis-tickets] [SCM] PostGIS branch stable-3.1 updated. 3.1.4-19-g44deec454
git at osgeo.org
git at osgeo.org
Mon Nov 29 08:37:58 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, stable-3.1 has been updated
via 44deec454fabf94e93858234f12c43d98fc56942 (commit)
from 4179657dec003baf9933599768ee8f928f9d974e (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 44deec454fabf94e93858234f12c43d98fc56942
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 3.1 branch (3.1.5dev)
Includes regression test
diff --git a/NEWS b/NEWS
index 455bd8b2a..91254cd02 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PostGIS 3.1.5
- #4994, Random missing INSERT in shp2pgsql (Sandro Santilli)
- #5016, loader (shp2pgsq): Respect LDFLAGS (Greg Troxel)
- #5018, pgsql2shp basic support for WITH CTE clause (Regina Obe)
+ - #5026, fix DropTopology in presence of UPDATE triggers on
+ topology layers (Sandro Santilli)
PostGIS 3.1.4
2021/09/04
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 3c8086653..11fb1f3b8 100644
--- a/topology/topology.sql.in
+++ b/topology/topology.sql.in
@@ -733,7 +733,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 '
@@ -783,12 +783,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
@@ -796,13 +795,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:
NEWS | 2 ++
topology/test/regress/droptopology.sql | 25 +++++++++++++++++++++----
topology/test/regress/droptopology_expected | 5 +----
topology/topology.sql.in | 18 +++++-------------
4 files changed, 29 insertions(+), 21 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list