mirror of
https://github.com/postgres/postgres.git
synced 2025-05-24 00:03:23 -04:00
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.)
This commit is contained in:
parent
a6c688d9cd
commit
5035d7b985
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.30 1999/05/25 16:12:14 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.31 1999/07/08 00:27:01 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -76,7 +76,7 @@ pg_atoi(char *s, int size, int c)
|
|||||||
switch (size)
|
switch (size)
|
||||||
{
|
{
|
||||||
case sizeof(int32):
|
case sizeof(int32):
|
||||||
#ifdef HAS_LONG_LONG
|
#if defined(HAVE_LONG_INT_64) || defined(HAVE_LONG_LONG_INT_64)
|
||||||
/* won't get ERANGE on these with 64-bit longs... */
|
/* won't get ERANGE on these with 64-bit longs... */
|
||||||
if (l < INT_MIN)
|
if (l < INT_MIN)
|
||||||
{
|
{
|
||||||
@ -88,7 +88,7 @@ pg_atoi(char *s, int size, int c)
|
|||||||
errno = ERANGE;
|
errno = ERANGE;
|
||||||
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
|
elog(ERROR, "pg_atoi: error reading \"%s\": %m", s);
|
||||||
}
|
}
|
||||||
#endif /* HAS_LONG_LONG */
|
#endif /* HAVE_LONG_INT_64 or HAVE_LONG_LONG_INT_64 */
|
||||||
break;
|
break;
|
||||||
case sizeof(int16):
|
case sizeof(int16):
|
||||||
if (l < SHRT_MIN)
|
if (l < SHRT_MIN)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user