[postgis-tickets] [SCM] PostGIS branch master updated. 3.2.0-658-gb6b188849

git at osgeo.org git at osgeo.org
Mon Mar 28 12:59:06 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, master has been updated
       via  b6b188849a2b9e1af37cd560a8fae8455e3db43b (commit)
      from  bb3842bfeef613f32e5dd032cad85599159ffb76 (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 b6b188849a2b9e1af37cd560a8fae8455e3db43b
Author: Sandro Santilli <strk at kbt.io>
Date:   Mon Mar 28 21:56:47 2022 +0200

    Fix missing TopoGeometries count with wrong layer_id in deploy tables
    
    Includes regress test

diff --git a/topology/sql/manage/TopologySummary.sql.in b/topology/sql/manage/TopologySummary.sql.in
index 8bc5b1f37..47c64496f 100644
--- a/topology/sql/manage/TopologySummary.sql.in
+++ b/topology/sql/manage/TopologySummary.sql.in
@@ -18,7 +18,7 @@
 CREATE OR REPLACE FUNCTION topology.TopologySummary(atopology varchar)
 RETURNS text
 AS
-$$
+$BODY$
 DECLARE
   rec RECORD;
   rec2 RECORD;
@@ -142,14 +142,26 @@ BEGIN
                   || quote_ident(rec.feature_column);
 
         IF n > 0 THEN
-          sql := 'SELECT count(*) FROM ( SELECT topogeo_id FROM '
-            || quote_ident(atopology)
-            || '.relation r WHERE r.layer_id = ' || rec.layer_id
-            || ' EXCEPT SELECT DISTINCT id('
-            || quote_ident(rec.feature_column) || ') FROM '
-            || quote_ident(rec.schema_name) || '.'
-            || quote_ident(rec.table_name) || ') as foo';
+          sql := format(
+            $$
+SELECT count(*) FROM (
+  SELECT topogeo_id
+  FROM %1$I.relation r
+  WHERE r.layer_id = %2$L
+    EXCEPT
+  SELECT DISTINCT id(%3$I)
+  FROM %4$I.%5$I
+  WHERE layer_id(%3$I) = %2$L
+) as foo
+            $$,
+            atopology,
+            rec.layer_id,
+            rec.feature_column,
+            rec.schema_name,
+            rec.table_name
+          );
           BEGIN
+            RAISE DEBUG 'Executing %', sql;
             EXECUTE sql INTO STRICT missing;
             IF missing > 0 THEN
               ret = ret || ' (' || missing || ' missing topogeoms)';
@@ -193,7 +205,7 @@ BEGIN
 
   RETURN ret;
 END
-$$
+$BODY$
 LANGUAGE 'plpgsql' STABLE STRICT;
 
 --} TopologySummary
diff --git a/topology/test/regress/topologysummary.sql b/topology/test/regress/topologysummary.sql
index 37df046b3..bce065cde 100644
--- a/topology/test/regress/topologysummary.sql
+++ b/topology/test/regress/topologysummary.sql
@@ -23,7 +23,9 @@ CREATE TABLE test.t(i int);
 SELECT E'--registered_missing_layer_column--\n' || TopologySummary('test');
 ALTER TABLE test.t ADD c TopoGeometry;
 SELECT E'--registered_layer_missing_topogeom--\n' || TopologySummary('test');
-INSERT INTO test.t(c) VALUES ( (1,1,1,1) );
+INSERT INTO test.t(c) VALUES ( (1,2,1,1) );
+SELECT E'--registered_layer_missing_topogeom_in_proper_layer--\n' || TopologySummary('test');
+UPDATE test.t SET c.layer_id = 1 WHERE layer_id(c) = 2;
 SELECT E'--registered_layer--\n' || TopologySummary('test');
 -- TODO: test hierarchical
 DROP TABLE test.t;
diff --git a/topology/test/regress/topologysummary_expected b/topology/test/regress/topologysummary_expected
index 573402f79..e5454d723 100644
--- a/topology/test/regress/topologysummary_expected
+++ b/topology/test/regress/topologysummary_expected
@@ -40,6 +40,11 @@ Layer 1, type Puntal (1), 1 topogeoms
 --registered_layer_missing_topogeom--
 Topology test (id 1, SRID 10, precision 20)
 0 nodes, 0 edges, 0 faces, 1 topogeoms in 1 layers
+Layer 1, type Puntal (1), 1 topogeoms
+ Deploy: test.t.c (1 missing topogeoms)
+--registered_layer_missing_topogeom_in_proper_layer--
+Topology test (id 1, SRID 10, precision 20)
+0 nodes, 0 edges, 0 faces, 1 topogeoms in 1 layers
 Layer 1, type Puntal (1), 1 topogeoms
  Deploy: test.t.c (1 missing topogeoms)
 --registered_layer--

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

Summary of changes:
 topology/sql/manage/TopologySummary.sql.in     | 30 ++++++++++++++++++--------
 topology/test/regress/topologysummary.sql      |  4 +++-
 topology/test/regress/topologysummary_expected |  5 +++++
 3 files changed, 29 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list