[postgis-tickets] [SCM] PostGIS branch stable-3.2 updated. 3.2.1-8-gad7dc374f
git at osgeo.org
git at osgeo.org
Fri Mar 18 16:35:23 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, stable-3.2 has been updated
via ad7dc374fb5db5fc61bfb204cc7f59a663036203 (commit)
from efe02efd87d17cb1cfe09ae3003fb0b8ea5e3f79 (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 ad7dc374fb5db5fc61bfb204cc7f59a663036203
Author: Sandro Santilli <strk at kbt.io>
Date: Fri Mar 18 21:32:36 2022 +0100
Execute pending constraints before dropping topology
References #5115 in 3.2 branch (3.2.2dev)
Includes test and NEWS item
diff --git a/NEWS b/NEWS
index 74299d9de..8f393f631 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ PostGIS 3.2.2dev
2022/MM/DD
* Bug Fixes *
+ - #5115, Allow dropping topologies with pending constraints
+ (Sandro Santilli)
- #5105, Fix false invalidity report from ValidateTopology
(Sandro Santilli)
- #5097, Ensure spatial index is used during topology population
diff --git a/topology/test/regress/droptopology.sql b/topology/test/regress/droptopology.sql
index 0b63a6d71..7f12a2b34 100644
--- a/topology/test/regress/droptopology.sql
+++ b/topology/test/regress/droptopology.sql
@@ -31,6 +31,14 @@ INSERT INTO t3.f(g) VALUES (toTopoGeom('POINT(0 0)', 't3', 1));
--SELECT topology.DropTopoGeometryColumn('t3', 'f', 'g');
SELECT topology.DropTopology('t3');
+-- Test DropTopology with pending deferred triggers
+-- See https://trac.osgeo.org/postgis/ticket/5115
+BEGIN;
+SELECT 't5115.create' FROM topology.CreateTopology('t5115');
+SELECT 't5115.addline' FROM topology.TopoGeo_addLineString('t5115', 'LINESTRING(0 0, 10 0)');
+SELECT 't5115.drop' FROM topology.DropTopology('t5115');
+ROLLBACK;
+
-- Exceptions
SELECT topology.DropTopology('topology');
SELECT topology.DropTopology('doesnotexist');
diff --git a/topology/test/regress/droptopology_expected b/topology/test/regress/droptopology_expected
index 37905a4d3..3c5f8570a 100644
--- a/topology/test/regress/droptopology_expected
+++ b/topology/test/regress/droptopology_expected
@@ -1,5 +1,8 @@
Topology 't1' dropped
Topology 't2' dropped
Topology 't3' dropped
+t5115.create
+t5115.addline
+t5115.drop
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 1f62c8a1e..897d42207 100644
--- a/topology/topology.sql.in
+++ b/topology/topology.sql.in
@@ -1723,6 +1723,9 @@ $$
DECLARE
topoid integer;
rec RECORD;
+ sql TEXT;
+ toposchema REGNAMESPACE;
+ deferred_constraints TEXT[];
BEGIN
-- Get topology id
SELECT id INTO topoid
@@ -1754,10 +1757,37 @@ BEGIN
|| topoid;
-- Drop the schema (if it exists)
- FOR rec IN SELECT * FROM pg_namespace WHERE text(nspname) = atopology
- LOOP
- EXECUTE 'DROP SCHEMA '||quote_ident(atopology)||' CASCADE';
- END LOOP;
+ SELECT oid FROM pg_namespace WHERE text(nspname) = atopology
+ INTO toposchema;
+
+ IF toposchema IS NOT NULL THEN --{
+
+ -- Give immediate execution to pending constraints
+ -- in the topology schema.
+ --
+ -- See https://trac.osgeo.org/postgis/ticket/5115
+ SELECT array_agg(format('%I.%I', atopology, conname))
+ FROM pg_constraint c
+ WHERE connamespace = toposchema AND condeferred
+ INTO deferred_constraints;
+
+ IF deferred_constraints IS NOT NULL THEN --{
+ sql := format(
+ 'SET constraints %s IMMEDIATE',
+ array_to_string(deferred_constraints, ',')
+ );
+#ifdef POSTGIS_TOPOLOGY_DEBUG
+ RAISE DEBUG 'Executing: %', sql;
+#endif
+ EXECUTE sql;
+ END IF; --}
+
+ sql := format('DROP SCHEMA %I CASCADE', atopology);
+#ifdef POSTGIS_TOPOLOGY_DEBUG
+ RAISE DEBUG 'Executing: %', sql;
+#endif
+ EXECUTE sql;
+ END IF; --}
RETURN 'Topology ' || quote_literal(atopology) || ' dropped';
END
-----------------------------------------------------------------------
Summary of changes:
NEWS | 2 ++
topology/test/regress/droptopology.sql | 8 ++++++
topology/test/regress/droptopology_expected | 3 +++
topology/topology.sql.in | 38 ++++++++++++++++++++++++++---
4 files changed, 47 insertions(+), 4 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list