pg_atoi patch for postgreSQL 6.3.
Started by Billy G. Alliealmost 28 years ago1 messages
The attached patch will ensure that pg_atoi will return 0 when passed an empty
string regardless of what strtol will do with an empty string. Some
implementations of strtol will generate an error if passed an emtpy string.
Attachments:
patch.02text/plain; charset=us-ascii; name=patch.02Download
*** src/backend/utils/adt/numutils.c.orig Sun Mar 1 00:58:32 1998
--- src/backend/utils/adt/numutils.c Sun Mar 1 01:00:44 1998
***************
*** 55,60 ****
--- 55,67 ----
Assert(s);
+ /* Some versions of strtol treat the empty string as an error. This
+ * code will make those versions of strtol return 0 for an empty string.
+ */
+
+ if (s == (char *)NULL || *s == 0)
+ return ((int32)0);
+
errno = 0;
l = strtol(s, &badp, 10);
if (errno) /* strtol must set ERANGE */