Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5035d7b

Browse files
committed
pg_atoi() does range check on int4 data only if
"HAS_LONG_LONG" is defined based on the assumption that strtol() would return ERANGE if a platform does not support 64-bit integers. In current PostgreSQL 6.5 (and 6.4.2) distribution, "HAS_LONG_LONG" is defined only if platform is "alpha". (See include/port/alpha.h) I think the int4 range check should apply to linux_alpha as well. (I have not tested yet but I guess this might be applicable to newer Linux/i386 distributions which includes new GCC which implements long int as 64-bit int.)
1 parent a6c688d commit 5035d7b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/backend/utils/adt/numutils.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.30 1999/05/25 16:12:14 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.31 1999/07/08 00:27:01 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -76,7 +76,7 @@ pg_atoi(char *s, int size, int c)
7676
switch (size)
7777
{
7878
case sizeof(int32):
79-
#ifdef HAS_LONG_LONG
79+
#if defined(HAVE_LONG_INT_64) || defined(HAVE_LONG_LONG_INT_64)
8080
/* won't get ERANGE on these with 64-bit longs... */
8181
if (l < INT_MIN)
8282
{
@@ -88,7 +88,7 @@ pg_atoi(char *s, int size, int c)
8888
errno = ERANGE;
8989
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
9090
}
91-
#endif /* HAS_LONG_LONG */
91+
#endif /* HAVE_LONG_INT_64 or HAVE_LONG_LONG_INT_64 */
9292
break;
9393
case sizeof(int16):
9494
if (l < SHRT_MIN)

0 commit comments

Comments
 (0)