Ticket #1078 (closed defect: invalid)
ST_Difference with NULL as second argument
| Reported by: | nicklas | Owned by: | nicklas |
|---|---|---|---|
| Priority: | medium | Milestone: | PostGIS 2.0.0 |
| Component: | postgis | Version: | trunk |
| Keywords: | Cc: |
Description
I think that ST_Difference should return the first argument if the second argument is NULL. Now it returns NULL or nothing.
This is specially interesting in situation like the one described here, with a left or right join to catch the none intersecting ones:
http://gis.stackexchange.com/questions/11592/difference-between-two-layers-in-postgis
So I would like to commit this:
Index: postgis.sql.in.c =================================================================== --- postgis.sql.in.c (revision 7521) +++ postgis.sql.in.c (working copy) @@ -3199,7 +3199,7 @@ CREATE OR REPLACE FUNCTION ST_Difference(geometry,geometry) RETURNS geometry AS 'MODULE_PATHNAME','difference' - LANGUAGE 'C' IMMUTABLE STRICT; + LANGUAGE 'C' IMMUTABLE; -- PostGIS equivalent function: boundary(geometry) CREATE OR REPLACE FUNCTION ST_Boundary(geometry) Index: lwgeom_geos.c =================================================================== --- lwgeom_geos.c (revision 7521) +++ lwgeom_geos.c (working copy) @@ -1493,8 +1493,12 @@ int is3d; int srid; - PROFSTART(PROF_QRUN); - + /* Return the first geom if the second geom is null */ + if (PG_ARGISNULL(1)) + PG_RETURN_DATUM(PG_GETARG_DATUM(0)); + + PROFSTART(PROF_QRUN); + geom1 = (PG_LWGEOM *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); geom2 = (PG_LWGEOM *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
Any objections?
/Nicklas
Change History
Note: See
TracTickets for help on using
tickets.
