OSDN Git Service

The pg_atoi() function uses strtol() to convert the string to numbers. Some
authorBruce Momjian <bruce@momjian.us>
Sat, 12 Sep 1998 16:04:35 +0000 (16:04 +0000)
committerBruce Momjian <bruce@momjian.us>
Sat, 12 Sep 1998 16:04:35 +0000 (16:04 +0000)
commit786b1802c801eba347a42675ca0a09228b6588a1
tree4b77738dfed3759f08d7f28e13ddbe919281f595
parent5f7fb677893827bdd09eaac7f5148c8261e0af04
The pg_atoi() function uses strtol() to convert the string to numbers.  Some
implementations of strtol() treat empty strings ("") as invalid arguments
while others convert this (erroneously, IHMO) to zero (0).  Assuming that the
expected behaviour of pg_atoi() is to return 0 if it is passed an empty
string, I am supplying the following patch to explictly check for an empty
string in pg_atoi() and return 0 if the string is empty.  The patch will also
trap a NULL character pointer being passed to pg_atoi() and will use elog() to
print out an error message if the input char pointer is NULL.

Billy G. Allie
src/backend/utils/adt/numutils.c