[postgis-tickets] r15451 - Fix lwgeom_cmp return code

Sandro Santilli strk at kbt.io
Fri Jun 23 15:57:38 PDT 2017


Author: strk
Date: 2017-06-23 15:57:38 -0700 (Fri, 23 Jun 2017)
New Revision: 15451

Modified:
   branches/2.3/postgis/lwgeom_btree.c
   branches/2.3/regress/operators.sql
   branches/2.3/regress/operators_expected
Log:
Fix lwgeom_cmp return code

Closes #3777 once again (for 2.3 branch)

Modified: branches/2.3/postgis/lwgeom_btree.c
===================================================================
--- branches/2.3/postgis/lwgeom_btree.c	2017-06-23 22:16:59 UTC (rev 15450)
+++ branches/2.3/postgis/lwgeom_btree.c	2017-06-23 22:57:38 UTC (rev 15451)
@@ -345,9 +345,20 @@
 	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) )

Modified: branches/2.3/regress/operators.sql
===================================================================
--- branches/2.3/regress/operators.sql	2017-06-23 22:16:59 UTC (rev 15450)
+++ branches/2.3/regress/operators.sql	2017-06-23 22:57:38 UTC (rev 15451)
@@ -151,4 +151,13 @@
 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;

Modified: branches/2.3/regress/operators_expected
===================================================================
--- branches/2.3/regress/operators_expected	2017-06-23 22:16:59 UTC (rev 15450)
+++ branches/2.3/regress/operators_expected	2017-06-23 22:57:38 UTC (rev 15451)
@@ -60,3 +60,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



More information about the postgis-tickets mailing list