]> granicus.if.org Git - postgis/commitdiff
Fix lwgeom_cmp return code
authorSandro Santilli <strk@kbt.io>
Fri, 23 Jun 2017 22:57:38 +0000 (22:57 +0000)
committerSandro Santilli <strk@kbt.io>
Fri, 23 Jun 2017 22:57:38 +0000 (22:57 +0000)
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

postgis/lwgeom_btree.c
regress/operators.sql
regress/operators_expected

index 062d1cd83f189e5603b08184252e482c29e14895..2ee935cddf72b39f81cfd47d17e13571dad48543 100644 (file)
@@ -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) )
index 5a2113dd12e09d0de71528aed527be2fb4a81772..21cc153d578f6d76ea0352ea680aa4aba05e4e10 100644 (file)
@@ -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;
index b5b3761aa06c700a3b63df8669671f4616e23f57..1dfd63475b7a9cb3102ea95e0e28637fbae0f565 100644 (file)
@@ -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