#5036 closed defect (fixed)
PostGIS 3.2.0: ST_StartPoint with empty geometries
Reported by: | ezimanyi | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 3.2.1 |
Component: | postgis | Version: | master |
Keywords: | Cc: |
Description
While performing the regression tests for MobilityDB with the latest version PostGIS 3.2.0 we found out that maybe the function LWGEOM_startpoint_linestring
should test whether the argument is empty. Although the function correctly outputs a NULL value for empty geometries, it throws an error message as follows
test=# select ST_StartPoint(geometry 'linestring empty'); NOTICE: lwgeom_api.c [138] called with n=0 and npoints=0 st_startpoint --------------- (1 row)
It may be useful to test whether the input geometry is empty before calling lwgeom_from_gserialized
as suggested below.
Datum LWGEOM_startpoint_linestring(PG_FUNCTION_ARGS) { GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0); /* BEGIN NEW TEST */ if (gserialized_is_empty(geom)) { PG_RETURN_NULL(); } /* END NEW TEST */ GSERIALIZED *ret; LWGEOM *lwgeom = lwgeom_from_gserialized(geom); LWGEOM *lwpoint = NULL; POINT4D pt; if (lwgeom_startpoint(lwgeom, &pt) == LW_FAILURE) { PG_RETURN_NULL(); } [...] }
Change History (4)
comment:1 by , 3 years ago
Milestone: | PostGIS 3.1.5 → PostGIS 3.2.1 |
---|---|
Version: | 2.5.x → master |
Note:
See TracTickets
for help on using tickets.
This looks like a debug message left in, not an error one. I confirm I see it too.