[postgis-tickets] [SCM] PostGIS branch stable-3.2 updated. 3.2.1-5-ge8d1e8672

git at osgeo.org git at osgeo.org
Fri Feb 18 22:36:53 PST 2022


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.2 has been updated
       via  e8d1e86725deb0700dc3e02af3e88837a417e980 (commit)
      from  f7a8918f33550edf54790d8350ea4d3bc7647b8f (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 e8d1e86725deb0700dc3e02af3e88837a417e980
Author: Regina Obe <lr at pcorp.us>
Date:   Sat Feb 19 01:36:33 2022 -0500

    Fix PG 15 building pg_atoi removed.  References #5100 for PostGIS 3.2.2

diff --git a/NEWS b/NEWS
index 76cb5f35c..cde01c996 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PostGIS 3.2.2dev
   - #5097, Ensure spatial index is used during topology population
            at the getClosestEdge step (Sandro Santilli)
   - #5091, Fix --without-protobuf builds (Tobias Bussmann)
+  - #5100, Don't use pg_atoi (removed in PG15) (Laurenz Albe)
+
 
 PostGIS 3.2.1
 2022/02/12
diff --git a/postgis/geography_inout.c b/postgis/geography_inout.c
index 7dae289bc..4e62e0b10 100644
--- a/postgis/geography_inout.c
+++ b/postgis/geography_inout.c
@@ -34,7 +34,7 @@
 
 #include "utils/elog.h"
 #include "utils/array.h"
-#include "utils/builtins.h"  /* for pg_atoi */
+#include "utils/builtins.h"  /* for text_to_cstring */
 #include "lib/stringinfo.h"  /* For binary input */
 #include "catalog/pg_type.h" /* for CSTRINGOID, INT4OID */
 
diff --git a/postgis/gserialized_typmod.c b/postgis/gserialized_typmod.c
index 9d8119084..aae44bef5 100644
--- a/postgis/gserialized_typmod.c
+++ b/postgis/gserialized_typmod.c
@@ -31,10 +31,11 @@
 #include <float.h>
 #include <string.h>
 #include <stdio.h>
+#include <errno.h>
 
 #include "utils/elog.h"
 #include "utils/array.h"
-#include "utils/builtins.h"  /* for pg_atoi */
+#include "utils/builtins.h"  /* for cstring_to_text */
 #include "lib/stringinfo.h"  /* For binary input */
 #include "catalog/pg_type.h" /* for CSTRINGOID */
 
@@ -272,8 +273,33 @@ static uint32 gserialized_typmod_in(ArrayType *arr, int is_geography)
 		}
 		if ( i == 1 ) /* SRID */
 		{
-			int32_t srid = pg_atoi(DatumGetCString(elem_values[i]), sizeof(int32), '\0');
-			srid = clamp_srid(srid);
+			char *int_string = DatumGetCString(elem_values[i]);
+			char *endp;
+			long l;
+			int32_t srid;
+
+			errno = 0;
+			l = strtol(int_string, &endp, 10);
+
+			if (int_string == endp)
+				ereport(ERROR,
+						(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+						 errmsg("invalid input syntax for type %s: \"%s\"",
+								"integer", int_string)));
+
+			if (errno == ERANGE || l < INT_MIN || l > INT_MAX)
+				ereport(ERROR,
+						(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
+						 errmsg("value \"%s\" is out of range for type %s", int_string,
+								"integer")));
+
+			if (*endp != '\0')
+				ereport(ERROR,
+						(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+						 errmsg("invalid input syntax for type %s: \"%s\"",
+								"integer", int_string)));
+
+			srid = clamp_srid(l);
 			POSTGIS_DEBUGF(3, "srid: %d", srid);
 			if ( srid != SRID_UNKNOWN )
 			{
diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c
index 499f95c58..99b9f47c9 100644
--- a/postgis/lwgeom_geos.c
+++ b/postgis/lwgeom_geos.c
@@ -2956,8 +2956,8 @@ Datum clusterintersecting_garray(PG_FUNCTION_ARGS)
 	char elmalign;
 
 	/* Null array, null geometry (should be empty?) */
-    if (PG_ARGISNULL(0))
-        PG_RETURN_NULL();
+	if (PG_ARGISNULL(0))
+		PG_RETURN_NULL();
 
 	array = PG_GETARG_ARRAYTYPE_P(0);
     nelems = array_nelems_not_null(array);

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

Summary of changes:
 NEWS                         |  2 ++
 postgis/geography_inout.c    |  2 +-
 postgis/gserialized_typmod.c | 32 +++++++++++++++++++++++++++++---
 postgis/lwgeom_geos.c        |  4 ++--
 4 files changed, 34 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list