[postgis-tickets] [SCM] PostGIS branch stable-3.0 updated. 3.0.5-3-g5c1acb662
git at osgeo.org
git at osgeo.org
Fri Mar 18 16:50:43 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.0 has been updated
via 5c1acb6629ee2fb5f03e9fe10270525770e2c41f (commit)
from 22cb43bc3e200f221ca5cdb15d149cb3bbc0f371 (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 5c1acb6629ee2fb5f03e9fe10270525770e2c41f
Author: Sandro Santilli <strk at kbt.io>
Date: Fri Mar 18 21:32:36 2022 +0100
Execute pending constraints before dropping topology
Closes #5115 in 3.0 branch (3.0.6dev)
Includes test and NEWS item
diff --git a/NEWS b/NEWS
index 74f138fc0..7c9b46afb 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,11 @@
PostGIS 3.0.6
2022/XX/XX
+
* Bug Fixes and Enhancements *
- #5087, Prevent configure for PostgreSQL >= 14
and note in docs, PostgreSQL > 13 major
is not supported (Regina Obe)
+ - #5115, Allow dropping topologies with pending constraints (Sandro Santilli)
PostGIS 3.0.5
2022/02/02
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 38e92ce8b..a12c2c31c 100644
--- a/topology/topology.sql.in
+++ b/topology/topology.sql.in
@@ -1999,6 +1999,9 @@ $$
DECLARE
topoid integer;
rec RECORD;
+ sql TEXT;
+ toposchema REGNAMESPACE;
+ deferred_constraints TEXT[];
BEGIN
-- Get topology id
SELECT id INTO topoid
@@ -2030,10 +2033,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