Opened 12 years ago
Closed 12 years ago
#1078 closed defect (invalid)
ST_Difference with NULL as second argument
|Reported by:||nicklas||Owned by:||nicklas|
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:
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));
Change History (3)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
I'm against this. See my note to the guy on forum.
comment:3 by , 12 years ago
|Status:||new → closed|
Ok, I see the logic.
I haven't thought that much about the null-usage before.
Thanks and sorry for the noise
Take this to the devel list. It's ok for st_difference(geometry, empty). But NULL has special expectations in a database. See the difference between
for an analogue to your case.