Opened 5 months ago
Closed 8 weeks ago
#5829 closed defect (fixed)
SELECT geometry_columns returns unexpected error when there are constraints after SRID constraint.
Reported by: | nbvfgh | Owned by: | pramsey |
---|---|---|---|
Priority: | critical | Milestone: | PostGIS 3.3.9 |
Component: | postgis | Version: | 3.5.x |
Keywords: | Cc: |
Description
DROP TABLE IF EXISTS test; create table test (geom geometry); ALTER TABLE test ADD CONSTRAINT c1 CHECK (ST_SRID(geom)=4326 and ST_IsValid(geom)); SELECT * FROM geometry_columns; -- ERROR: invalid type integer input syntax: "4326 AND st_isvalidgeom"
If the order of the two constraints is reversed:
DROP TABLE IF EXISTS test; create table test (geom geometry); ALTER TABLE test ADD CONSTRAINT c1 CHECK (ST_IsValid(geom) and ST_SRID(geom)=4326); SELECT * FROM geometry_columns; -- normal result
Change History (10)
follow-up: 2 comment:1 by , 8 weeks ago
comment:2 by , 8 weeks ago
Replying to pramsey:
I come at this with two impulses:
- One is just to remove the constraint-reading bits of the view, since they date back to pre-2.0 postgis, when we didn't have typmods.
- The other is to replace the string manipulation stuff with a single regex.
# select pg_get_constraintdef(177252); pg_get_constraintdef ------------------------------------------------------- CHECK (((st_srid(geom) = 4326) AND st_isvalid(geom))) ^ # select regexp_match( pg_get_constraintdef(177252), 'st_srid\(\w+\)\s*=\s*(\d+)', 'i'); regexp_match -------------- {4326}That would be more reliable than the current code and leave in place the constraint support, for those 15 year old legacy systems we care about.
I suppose removing it entirely would make the view faster. Though I don't like its a breaking change and hard to tell how many rely on that. I know for one my tiger geocoder still uses constraints, but I personally don't rely on that view for anything I don't think, not sure if there are any that do.
I'm not sure your regex is non-standard conforming.
comment:3 by , 8 weeks ago
I think it's something that if enough people complain we can always put back so +0 to remove the constraint and see how many complain about it. Just make sure to mark it as a breaking change.
follow-up: 8 comment:7 by , 8 weeks ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Master is updated to remove constraints as an input to geometry_columns, and stable branches updated to use regex approach to fix this bug.
comment:8 by , 8 weeks ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Replying to pramsey:
Master is updated to remove constraints as an input to geometry_columns, and stable branches updated to use regex approach to fix this bug.
comment:9 by , 8 weeks ago
Failing non-standard conforming check — put an E in front should fix it - https://woodie.osgeo.org/repos/30/pipeline/2992/6
comment:10 by , 8 weeks ago
Milestone: | PostGIS 3.6.0 → PostGIS 3.3.9 |
---|---|
Resolution: | → fixed |
Status: | reopened → closed |
I think this is all fixed now @pramsey right? I'm going to reclose and assume you pushed thru 3.3.
I come at this with two impulses:
That would be more reliable than the current code and leave in place the constraint support, for those 15 year old legacy systems we care about.