[SCM] PostGIS branch master updated. 3.6.0rc2-166-gd0cfdb0e9

git at osgeo.org git at osgeo.org
Thu Oct 30 09:21:41 PDT 2025


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  d0cfdb0e97f065e1ecbdb70b0de908760b5858ab (commit)
      from  520c80895c27a4720e9bf58d044f3c3de8db7d94 (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 d0cfdb0e97f065e1ecbdb70b0de908760b5858ab
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Thu Oct 30 20:21:29 2025 +0400

    geometry_columns handles NOT VALID SRID checks without errors
    
    Closes #4828

diff --git a/NEWS b/NEWS
index 5ba9497a8..d4e6baf0c 100644
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,7 @@ xxxx/xx/xx
 * Bug Fixes *
 
  - #5959, Prevent histogram target overflow when analysing massive tables (Darafei Praliaskouski)
+ - #4828, geometry_columns handles NOT VALID SRID checks without errors (Darafei Praliaskouski)
 
 
 PostGIS 3.6.0
diff --git a/postgis/postgis.sql.in b/postgis/postgis.sql.in
index c1a57bc0d..dee9101c4 100644
--- a/postgis/postgis.sql.in
+++ b/postgis/postgis.sql.in
@@ -6398,6 +6398,14 @@ LANGUAGE 'sql' STABLE STRICT PARALLEL SAFE _COST_MEDIUM;
 -- Changed: 2.5.2 replace use of pg_constraint.consrc with pg_get_constraintdef, consrc removed pg12
 
 CREATE OR REPLACE VIEW geometry_columns AS
+WITH constraint_defs AS (
+    -- Trim trailing NOT VALID so metadata inference works before constraint validation (#4828).
+    SELECT connamespace,
+           conrelid,
+           conkey,
+           regexp_replace(pg_get_constraintdef(oid), $$\s+NOT\s+VALID$$, '', 'i') AS consrc
+      FROM pg_constraint
+)
 SELECT current_database()::character varying(256) AS f_table_catalog,
     n.nspname AS f_table_schema,
     c.relname AS f_table_name,
@@ -6409,32 +6417,30 @@ SELECT current_database()::character varying(256) AS f_table_catalog,
      JOIN pg_attribute a ON a.attrelid = c.oid AND NOT a.attisdropped
      JOIN pg_namespace n ON c.relnamespace = n.oid
      JOIN pg_type t ON a.atttypid = t.oid
-     LEFT JOIN ( SELECT s.connamespace,
-            s.conrelid,
-            s.conkey,
-            (regexp_match(s.consrc, $$geometrytype\(\w+\)\s*=\s*'(\w+)'$$, 'i'))[1]::text AS type
-           FROM (SELECT connamespace, conrelid, conkey, pg_get_constraintdef(oid) As consrc
-                FROM pg_constraint) AS s
-          WHERE s.consrc ~* $$geometrytype\(\w+\)\s*=\s*'\w+'$$::text
-
-) st ON st.connamespace = n.oid AND st.conrelid = c.oid AND (a.attnum = ANY (st.conkey))
-     LEFT JOIN ( SELECT s.connamespace,
-            s.conrelid,
-            s.conkey,
-            (regexp_match(s.consrc, $$ndims\(\w+\)\s*=\s*(\d+)$$, 'i'))[1]::integer AS ndims
-           FROM (SELECT connamespace, conrelid, conkey, pg_get_constraintdef(oid) As consrc
-            FROM pg_constraint) AS s
-          WHERE s.consrc ~* $$ndims\(\w+\)\s*=\s*\d+$$::text
-) sn ON sn.connamespace = n.oid AND sn.conrelid = c.oid AND (a.attnum = ANY (sn.conkey))
-     LEFT JOIN ( SELECT s.connamespace,
-            s.conrelid,
-            s.conkey,
-            (regexp_match(s.consrc, $$srid\(\w+\)\s*=\s*(\d+)$$, 'i'))[1]::integer As srid
-           FROM (SELECT connamespace, conrelid, conkey, pg_get_constraintdef(oid) As consrc
-            FROM pg_constraint) AS s
-          WHERE s.consrc ~* $$srid\(\w+\)\s*=\s*\d+$$::text
-
-) sr ON sr.connamespace = n.oid AND sr.conrelid = c.oid AND (a.attnum = ANY (sr.conkey))
+     LEFT JOIN (
+           SELECT s.connamespace,
+                  s.conrelid,
+                  s.conkey,
+                  (regexp_match(s.consrc, $$geometrytype\(\w+\)\s*=\s*'(\w+)'$$, 'i'))[1]::text AS type
+             FROM constraint_defs AS s
+            WHERE s.consrc ~* $$geometrytype\(\w+\)\s*=\s*'\w+'$$::text
+     ) st ON st.connamespace = n.oid AND st.conrelid = c.oid AND (a.attnum = ANY (st.conkey))
+     LEFT JOIN (
+           SELECT s.connamespace,
+                  s.conrelid,
+                  s.conkey,
+                  (regexp_match(s.consrc, $$ndims\(\w+\)\s*=\s*(\d+)$$, 'i'))[1]::integer AS ndims
+             FROM constraint_defs AS s
+            WHERE s.consrc ~* $$ndims\(\w+\)\s*=\s*\d+$$::text
+     ) sn ON sn.connamespace = n.oid AND sn.conrelid = c.oid AND (a.attnum = ANY (sn.conkey))
+     LEFT JOIN (
+           SELECT s.connamespace,
+                  s.conrelid,
+                  s.conkey,
+                  (regexp_match(s.consrc, $$srid\(\w+\)\s*=\s*(\d+)$$, 'i'))[1]::integer As srid
+             FROM constraint_defs AS s
+            WHERE s.consrc ~* $$srid\(\w+\)\s*=\s*\d+$$::text
+     ) sr ON sr.connamespace = n.oid AND sr.conrelid = c.oid AND (a.attnum = ANY (sr.conkey))
   WHERE (c.relkind = ANY (ARRAY['r'::"char", 'v'::"char", 'm'::"char", 'f'::"char", 'p'::"char"]))
   AND NOT c.relname = 'raster_columns'::name AND t.typname = 'geometry'::name
   AND NOT pg_is_other_temp_schema(c.relnamespace) AND has_table_privilege(c.oid, 'SELECT'::text);
diff --git a/regress/core/tickets.sql b/regress/core/tickets.sql
index 6fd77a19d..e24bcef05 100644
--- a/regress/core/tickets.sql
+++ b/regress/core/tickets.sql
@@ -1619,6 +1619,19 @@ SELECT f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, t
  ORDER BY f_table_name, f_geometry_column;
 DROP TABLE IF EXISTS test5829, test5978;
 
+-- -------------------------------------------------------------------------------------
+-- #4828, geometry_columns should ignore pending NOT VALID SRID checks
+CREATE TABLE test4828 (
+  geom geometry
+);
+ALTER TABLE test4828
+  ADD CONSTRAINT test4828_srid CHECK (ST_SRID(geom) = 4326) NOT VALID;
+SELECT '#4828', srid
+  FROM geometry_columns
+ WHERE f_table_name = 'test4828'
+   AND f_geometry_column = 'geom';
+DROP TABLE IF EXISTS test4828;
+
 -- -------------------------------------------------------------------------------------
 -- #5987, ST_GeometryN broken on unitary geoms
 CREATE TABLE test5987 (geom geometry(Geometry,4326));
diff --git a/regress/core/tickets_expected b/regress/core/tickets_expected
index c39981696..6637f2d89 100644
--- a/regress/core/tickets_expected
+++ b/regress/core/tickets_expected
@@ -492,6 +492,7 @@ public.test5978.geometry SRID:4326 TYPE:POINT DIMS:2
 public|test5829|geom|2|4326|GEOMETRY
 public|test5978|geometry|2|4326|POINT
 public|test5978|shape|2|4326|POINT
+#4828|4326
 #5987|LINESTRING(20 20,20.1 20,20.2 19.9)|LINESTRING(20 20,20.1 20,20.2 19.9)
 #5962|MULTIPOINT((1 1),(3 4))|POINT(1 1)
 #5754|LINESTRING(0 0,1 1,2 0,3 1,4 0)|LINESTRING(0 0,1 1,2 0,3 1,4 0)|POLYGON((0 0,1 0,1 1,0 1,0 0))|POLYGON((0 0,10 0,10 10,0 10,0 0),(1 1,1 2,2 2,2 1,1 1))

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

Summary of changes:
 NEWS                          |  1 +
 postgis/postgis.sql.in        | 58 ++++++++++++++++++++++++-------------------
 regress/core/tickets.sql      | 13 ++++++++++
 regress/core/tickets_expected |  1 +
 4 files changed, 47 insertions(+), 26 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list