[postgis-tickets] [SCM] PostGIS branch stable-3.3 updated. 3.3.4-7-g71fefd690

git at osgeo.org git at osgeo.org
Mon Aug 14 08:32:05 PDT 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, stable-3.3 has been updated
       via  71fefd690fbc887a7399518ea56f17797faf1c11 (commit)
      from  a514af682b38c7b329ec50dd7ffa15d3e3bcbacd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 71fefd690fbc887a7399518ea56f17797faf1c11
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Aug 11 09:30:28 2023 -0700

    Add an explicit <> operator, closes #5175

diff --git a/postgis/lwgeom_btree.c b/postgis/lwgeom_btree.c
index bf3dd4922..df3fee1f6 100644
--- a/postgis/lwgeom_btree.c
+++ b/postgis/lwgeom_btree.c
@@ -43,6 +43,7 @@
 Datum lwgeom_lt(PG_FUNCTION_ARGS);
 Datum lwgeom_le(PG_FUNCTION_ARGS);
 Datum lwgeom_eq(PG_FUNCTION_ARGS);
+Datum lwgeom_neq(PG_FUNCTION_ARGS);
 Datum lwgeom_ge(PG_FUNCTION_ARGS);
 Datum lwgeom_gt(PG_FUNCTION_ARGS);
 Datum lwgeom_cmp(PG_FUNCTION_ARGS);
@@ -55,10 +56,7 @@ Datum lwgeom_lt(PG_FUNCTION_ARGS)
 	int cmp = gserialized_cmp(g1, g2);
 	PG_FREE_IF_COPY(g1, 0);
 	PG_FREE_IF_COPY(g2, 1);
-	if (cmp < 0)
-		PG_RETURN_BOOL(true);
-	else
-		PG_RETURN_BOOL(false);
+	PG_RETURN_BOOL(cmp < 0);
 }
 
 PG_FUNCTION_INFO_V1(lwgeom_le);
@@ -69,10 +67,7 @@ Datum lwgeom_le(PG_FUNCTION_ARGS)
 	int cmp = gserialized_cmp(g1, g2);
 	PG_FREE_IF_COPY(g1, 0);
 	PG_FREE_IF_COPY(g2, 1);
-	if (cmp <= 0)
-		PG_RETURN_BOOL(true);
-	else
-		PG_RETURN_BOOL(false);
+	PG_RETURN_BOOL(cmp <= 0);
 }
 
 PG_FUNCTION_INFO_V1(lwgeom_eq);
@@ -83,10 +78,18 @@ Datum lwgeom_eq(PG_FUNCTION_ARGS)
 	int cmp = gserialized_cmp(g1, g2);
 	PG_FREE_IF_COPY(g1, 0);
 	PG_FREE_IF_COPY(g2, 1);
-	if (cmp == 0)
-		PG_RETURN_BOOL(true);
-	else
-		PG_RETURN_BOOL(false);
+	PG_RETURN_BOOL(cmp == 0);
+}
+
+PG_FUNCTION_INFO_V1(lwgeom_neq);
+Datum lwgeom_neq(PG_FUNCTION_ARGS)
+{
+	GSERIALIZED *g1 = PG_GETARG_GSERIALIZED_P(0);
+	GSERIALIZED *g2 = PG_GETARG_GSERIALIZED_P(1);
+	int cmp = gserialized_cmp(g1, g2);
+	PG_FREE_IF_COPY(g1, 0);
+	PG_FREE_IF_COPY(g2, 1);
+	PG_RETURN_BOOL(cmp != 0);
 }
 
 PG_FUNCTION_INFO_V1(lwgeom_ge);
@@ -97,10 +100,7 @@ Datum lwgeom_ge(PG_FUNCTION_ARGS)
 	int cmp = gserialized_cmp(g1, g2);
 	PG_FREE_IF_COPY(g1, 0);
 	PG_FREE_IF_COPY(g2, 1);
-	if (cmp >= 0)
-		PG_RETURN_BOOL(true);
-	else
-		PG_RETURN_BOOL(false);
+	PG_RETURN_BOOL(cmp >= 0);
 }
 
 PG_FUNCTION_INFO_V1(lwgeom_gt);
@@ -111,10 +111,7 @@ Datum lwgeom_gt(PG_FUNCTION_ARGS)
 	int cmp = gserialized_cmp(g1, g2);
 	PG_FREE_IF_COPY(g1, 0);
 	PG_FREE_IF_COPY(g2, 1);
-	if (cmp > 0)
-		PG_RETURN_BOOL(true);
-	else
-		PG_RETURN_BOOL(false);
+	PG_RETURN_BOOL(cmp > 0);
 }
 
 PG_FUNCTION_INFO_V1(lwgeom_cmp);
diff --git a/postgis/postgis.sql.in b/postgis/postgis.sql.in
index 88a246d33..cd6750f85 100644
--- a/postgis/postgis.sql.in
+++ b/postgis/postgis.sql.in
@@ -398,6 +398,12 @@ CREATE OR REPLACE FUNCTION geometry_eq(geom1 geometry, geom2 geometry)
 	LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE
 	_COST_DEFAULT;
 
+CREATE OR REPLACE FUNCTION geometry_neq(geom1 geometry, geom2 geometry)
+	RETURNS bool
+	AS 'MODULE_PATHNAME', 'lwgeom_neq'
+	LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE
+	_COST_DEFAULT;
+
 CREATE OR REPLACE FUNCTION geometry_cmp(geom1 geometry, geom2 geometry)
 	RETURNS integer
 	AS 'MODULE_PATHNAME', 'lwgeom_cmp'
@@ -431,7 +437,14 @@ CREATE OPERATOR <= (
 -- Availability: 0.9.0
 CREATE OPERATOR = (
 	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_eq,
-	COMMUTATOR = '=', -- we might implement a faster negator here
+	COMMUTATOR = '=', NEGATOR = '<>',
+	RESTRICT = contsel, JOIN = contjoinsel, HASHES, MERGES
+);
+
+-- Availability: 3.5.0
+CREATE OPERATOR <> (
+	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_neq,
+	COMMUTATOR = '<>', NEGATOR = '=',
 	RESTRICT = contsel, JOIN = contjoinsel, HASHES, MERGES
 );
 

-----------------------------------------------------------------------

Summary of changes:
 postgis/lwgeom_btree.c | 37 +++++++++++++++++--------------------
 postgis/postgis.sql.in | 15 ++++++++++++++-
 2 files changed, 31 insertions(+), 21 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list