[Fdo-trac] [fdo-trac] #1024: Queries with coalesced geometries fails
FDO
trac_fdo at osgeo.org
Mon Nov 2 03:52:08 PST 2026
#1024: Queries with coalesced geometries fails
---------------------------------+----------------------
Reporter: jng | Owner: jng
Type: defect | Status: closed
Priority: major | Milestone: 4.2.0
Component: PostgreSQL Provider | Version:
Severity: 3 | Resolution: fixed
Keywords: | External ID:
---------------------------------+----------------------
Changes (by jng):
* resolution: => fixed
* status: assigned => closed
Comment:
In [changeset:"8431" 8431]:
{{{#!CommitTicketReference repository="" revision="8431"
PostgreSQL provider: spatial filters on a geometry column whose SRID is
unknown
geometry_columns does not describe a geometry column that carries no
typmod: a column
declared as bare "geometry", and every view over an expression -
COALESCE(point, line)
being the natural way to merge two geometry types into one column - is
reported there as
SRID 0, while the rows it returns keep the SRID they were written with.
FdoRdbmsPostGisFilterProcessor::ProcessSpatialDistanceCondition took the
spatial filter's
SRID from that metadata (FdoSmPhPostGisColumnGeom::GetSRID() reports it as
-1), so the
exact predicate compared an SRID-0 literal with a row carrying a real
SRID:
"geom" && $1::geometry AND _ST_Intersects("geom", $1::geometry)
PostGIS rejects that comparison - "ST_Intersects: Operation on mixed SRID
geometries
(Point, 4326) != (Polygon, 0)" - as soon as the bounding boxes overlap, so
the whole
select fails. The rejection comes from the first FETCH rather than from
Execute, so a
caller that is already streaming the result set sees an empty result
instead of an error;
MapGuide's SELECTFEATURES over such a view returned no features for either
geometry type,
which is what MapGuide ticket 2841 reports
(https://trac.osgeo.org/mapguide/ticket/2841). A view that selects one
geometry column
directly is unaffected, because a plain column reference keeps the typmod
- which is why
the report looked like a schema-cache problem.
When the column's SRID is unknown, the exact spatial predicate - and
ST_Distance() in the
distance filter, which takes the same bind and applies the same check -
now compare by
coordinate: the column operand is wrapped in ST_SetSRID(...,0) so both
operands carry the
same unknown SRID. The && pre-filter deliberately stays on the raw column,
because it
ignores SRIDs and needs the cached envelope, so the spatial index still
prunes; columns
with a known SRID keep the SQL they had.
Tests:
* PostGisFdoSelectTest::TestSpatialFilterWithoutColumnSrid covers a
COALESCE view over
point and line columns, a bare geometry column holding SRID-4326 rows,
and a
typmod-preserving view as the control case. The filtered view must
return both geometry
types, and every advertised spatial predicate plus ST_Distance must keep
working.
Without the change it fails with the mixed-SRID error above.
Verified on ubuntu22 amd64 against the dbs/docker-compose.yml postgis_pg16
fixture
(PostGIS 3.4), Debug (ASan/LSan) and Release, through UnitTestPostGis
initfiletest=...:
* FdoSelectTest with the provider unfixed: Run: 25, Failure total: 1, that
failure being
TestSpatialFilterWithoutColumnSrid; OK (25) with the change.
* UnitTestPostGis whole suite: OK (141) in both configurations, 140 tests
before this
change, and no LeakSanitizer report in the Debug run.
Fixes #1024
}}}
--
Ticket URL: <https://trac.osgeo.org/fdo/ticket/1024#comment:1>
FDO <http://fdo.osgeo.org/>
Feature Data Objects
More information about the fdo-trac
mailing list