[postgis-tickets] [SCM] PostGIS branch master updated. 3.2.0-591-g4cd780c1b
git at osgeo.org
git at osgeo.org
Wed Feb 23 00:07:59 PST 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 4cd780c1b40aac54a036c700dd3876d24be557c8 (commit)
via f5b476bf5d7a6c4c8e1fe0866eaad5549b1bb96c (commit)
via a0e25ba2f8a054120d6e3a3a0011554e4f09d7e0 (commit)
from 356a0ae05519717ac1f7e6a4bee123df0aced7c1 (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 4cd780c1b40aac54a036c700dd3876d24be557c8
Author: Sandro Santilli <strk at kbt.io>
Date: Tue Feb 22 14:35:51 2022 +0100
Add test for CopyTopology backward compatibility
diff --git a/topology/test/regress/hooks/hook-after-upgrade-topology.sql b/topology/test/regress/hooks/hook-after-upgrade-topology.sql
index c7e2e9ce8..248b6206f 100644
--- a/topology/test/regress/hooks/hook-after-upgrade-topology.sql
+++ b/topology/test/regress/hooks/hook-after-upgrade-topology.sql
@@ -1,2 +1,6 @@
+-- See https://trac.osgeo.org/postgis/ticket/5102
+SELECT topology.CopyTopology('upgrade_test', 'upgrade_test_copy');
+
SELECT topology.DropTopology('upgrade_test');
+SELECT topology.DropTopology('upgrade_test_copy');
commit f5b476bf5d7a6c4c8e1fe0866eaad5549b1bb96c
Author: Sandro Santilli <strk at kbt.io>
Date: Tue Feb 22 14:31:31 2022 +0100
Restore backward compatible order of fields in topology node table
Closes #5102
diff --git a/topology/topology.sql.in b/topology/topology.sql.in
index 0f9f8c433..0d92c8f39 100644
--- a/topology/topology.sql.in
+++ b/topology/topology.sql.in
@@ -1496,8 +1496,8 @@ BEGIN
CREATE TABLE %1$I.node(
node_id SERIAL,
- geom GEOMETRY(point%3$s, %2$L),
containing_face INTEGER,
+ geom GEOMETRY(point%3$s, %2$L),
CONSTRAINT node_primary_key
PRIMARY KEY(node_id),
CONSTRAINT face_exists
commit a0e25ba2f8a054120d6e3a3a0011554e4f09d7e0
Author: Sandro Santilli <strk at kbt.io>
Date: Tue Feb 22 14:30:24 2022 +0100
Use format() for CopyTopology body
diff --git a/topology/sql/manage/CopyTopology.sql.in b/topology/sql/manage/CopyTopology.sql.in
index 700af6c38..6f938836d 100644
--- a/topology/sql/manage/CopyTopology.sql.in
+++ b/topology/sql/manage/CopyTopology.sql.in
@@ -19,7 +19,7 @@
CREATE OR REPLACE FUNCTION topology.CopyTopology(atopology varchar, newtopo varchar)
RETURNS int
AS
-$$
+$BODY$
DECLARE
rec RECORD;
rec2 RECORD;
@@ -27,6 +27,7 @@ DECLARE
newtopo_id integer;
n int4;
ret text;
+ sql text;
BEGIN
SELECT * FROM topology.topology where name = atopology
@@ -37,35 +38,43 @@ BEGIN
SELECT topology.CreateTopology(newtopo, rec.SRID, rec.precision, rec.hasZ)
INTO strict newtopo_id;
- -- Copy faces
- EXECUTE 'INSERT INTO ' || quote_ident(newtopo)
- || '.face SELECT * FROM ' || quote_ident(atopology)
- || '.face WHERE face_id != 0';
- -- Update faces sequence
- EXECUTE 'SELECT setval(' || quote_literal(
- quote_ident(newtopo) || '.face_face_id_seq'
- ) || ', (SELECT last_value FROM '
- || quote_ident(atopology) || '.face_face_id_seq))';
+ sql := format(
+ $$
+ -- Copy faces
+ INSERT INTO %1$I.face
+ SELECT * FROM %2$I.face
+ WHERE face_id != 0;
- -- Copy nodes
- EXECUTE 'INSERT INTO ' || quote_ident(newtopo)
- || '.node SELECT * FROM ' || quote_ident(atopology)
- || '.node';
- -- Update node sequence
- EXECUTE 'SELECT setval(' || quote_literal(
- quote_ident(newtopo) || '.node_node_id_seq'
- ) || ', (SELECT last_value FROM '
- || quote_ident(atopology) || '.node_node_id_seq))';
+ -- Update face sequence
+ SELECT setval(
+ '%1$I.face_face_id_seq',
+ (SELECT last_value FROM %2$I.face_face_id_seq)
+ );
- -- Copy edges
- EXECUTE 'INSERT INTO ' || quote_ident(newtopo)
- || '.edge_data SELECT * FROM ' || quote_ident(atopology)
- || '.edge_data';
- -- Update edge sequence
- EXECUTE 'SELECT setval(' || quote_literal(
- quote_ident(newtopo) || '.edge_data_edge_id_seq'
- ) || ', (SELECT last_value FROM '
- || quote_ident(atopology) || '.edge_data_edge_id_seq))';
+ -- Copy nodes
+ INSERT INTO %1$I.node
+ SELECT * FROM %2$I.node;
+
+ -- Update node sequence
+ SELECT setval(
+ '%1$I.node_node_id_seq',
+ (SELECT last_value FROM %2$I.node_node_id_seq)
+ );
+
+ -- Copy edges
+ INSERT INTO %1$I.edge_data
+ SELECT * FROM %2$I.edge_data;
+
+ -- Update edge sequence
+ SELECT setval(
+ '%1$I.edge_data_edge_id_seq',
+ (SELECT last_value FROM %2$I.edge_data_edge_id_seq)
+ );
+ $$,
+ newtopo,
+ atopology
+ );
+ EXECUTE sql;
-- Copy layers and their TopoGeometry sequences
FOR rec IN SELECT * FROM topology.layer WHERE topology_id = oldtopo_id
@@ -75,25 +84,35 @@ BEGIN
VALUES (newtopo_id, rec.layer_id, rec.feature_type,
rec.level, rec.child_id, newtopo,
'LAYER' || rec.layer_id, '');
+
-- Create layer's TopoGeometry sequences
- EXECUTE 'SELECT last_value FROM '
- || quote_ident(atopology) || '.topogeo_s_' || rec.layer_id
- INTO STRICT n;
- EXECUTE 'CREATE SEQUENCE ' || quote_ident(newtopo)
- || '.topogeo_s_' || rec.layer_id;
- EXECUTE 'SELECT setval(' || quote_literal(
- quote_ident(newtopo) || '.topogeo_s_' || rec.layer_id
- ) || ', ' || n || ')';
+ EXECUTE format(
+ $$
+ CREATE SEQUENCE %1$I.topogeo_s_%2$s;
+ SELECT setval(
+ '%1$I.topogeo_s_%2$s',
+ (SELECT last_value FROM %3$I.topogeo_s_%2$s)
+ );
+ $$,
+ newtopo,
+ rec.layer_id,
+ atopology
+ );
END LOOP;
-- Copy TopoGeometry definitions
- EXECUTE 'INSERT INTO ' || quote_ident(newtopo)
- || '.relation SELECT * FROM ' || quote_ident(atopology)
- || '.relation';
+ EXECUTE format(
+ $$
+ INSERT INTO %1$I.relation
+ SELECT * FROM %2$I.relation
+ $$,
+ newtopo,
+ atopology
+ );
RETURN newtopo_id;
END
-$$
+$BODY$
LANGUAGE 'plpgsql' VOLATILE STRICT;
--} TopologySummary
-----------------------------------------------------------------------
Summary of changes:
topology/sql/manage/CopyTopology.sql.in | 99 +++++++++++++---------
.../regress/hooks/hook-after-upgrade-topology.sql | 4 +
topology/topology.sql.in | 2 +-
3 files changed, 64 insertions(+), 41 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list