From: Sandro Santilli Date: Fri, 23 Jun 2017 22:57:38 +0000 (+0000) Subject: Fix lwgeom_cmp return code X-Git-Tag: 2.3.3~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=600d2f9f4585fa9af5265b9f29bbbd2f6688a80e;p=postgis Fix lwgeom_cmp return code Closes #3777 once again (for 2.3 branch) git-svn-id: http://svn.osgeo.org/postgis/branches/2.3@15451 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_btree.c b/postgis/lwgeom_btree.c index 062d1cd83..2ee935cdd 100644 --- a/postgis/lwgeom_btree.c +++ b/postgis/lwgeom_btree.c @@ -345,9 +345,20 @@ Datum lwgeom_cmp(PG_FUNCTION_ARGS) PG_FREE_IF_COPY(geom1, 0); PG_FREE_IF_COPY(geom2, 1); - if ( empty1 != empty2 ) + if ( empty1 || empty2 ) { - PG_RETURN_BOOL(FALSE); + if ( empty1 && empty2 ) + { + PG_RETURN_INT32(1); + } + else if ( empty1 ) + { + PG_RETURN_INT32(-1); + } + else + { + PG_RETURN_INT32(1); + } } if ( ! FPeq(box1.xmin , box2.xmin) ) diff --git a/regress/operators.sql b/regress/operators.sql index 5a2113dd1..21cc153d5 100644 --- a/regress/operators.sql +++ b/regress/operators.sql @@ -151,4 +151,13 @@ SELECT 'GEOMETRYCOLLECTION EMPTY'::geometry UNION ALL SELECT 'POINT EMPTY'::geometry ) foo GROUP BY geom ORDER BY 2; - +SELECT '#3777.1', ST_AsText(geom), count(*) FROM ( +SELECT 'POINT(0 0)'::geometry geom UNION ALL +SELECT 'POINT(0 0)'::geometry UNION ALL +SELECT 'POINT EMPTY'::geometry UNION ALL +SELECT 'POINT(0 0)'::geometry UNION ALL +SELECT 'POINT(0 1)'::geometry UNION ALL +SELECT 'LINESTRING(0 0,0 1)'::geometry UNION ALL +SELECT 'GEOMETRYCOLLECTION EMPTY'::geometry geom +) foo +GROUP BY geom ORDER BY 2; diff --git a/regress/operators_expected b/regress/operators_expected index b5b3761aa..1dfd63475 100644 --- a/regress/operators_expected +++ b/regress/operators_expected @@ -60,3 +60,7 @@ ndovm2|{1,2,4,6,7} #3777|LINESTRING(0 0,0 1)|1 #3777|POINT(0 0)|3 #3777|POINT(0 1)|1 +#3777.1|GEOMETRYCOLLECTION EMPTY|2 +#3777.1|LINESTRING(0 0,0 1)|1 +#3777.1|POINT(0 0)|3 +#3777.1|POINT(0 1)|1