Commit 2ec95872 authored by Tom Lane's avatar Tom Lane

Tweak int8in to accept -9223372036854775808, per recent discussion in

pgsql-patches.
parent 215f0964
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.75 2001/11/21 21:12:34 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.76 2001/11/24 19:57:06 tgl Exp $
--> -->
<chapter id="datatype"> <chapter id="datatype">
...@@ -385,7 +385,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.75 2001/11/21 21:12:34 tg ...@@ -385,7 +385,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.75 2001/11/21 21:12:34 tg
<entry><type>bigint</></entry> <entry><type>bigint</></entry>
<entry>8 bytes</entry> <entry>8 bytes</entry>
<entry>Very large range fixed-precision</entry> <entry>Very large range fixed-precision</entry>
<entry>-9223372036854775807 to 9223372036854775807</entry> <entry>-9223372036854775808 to 9223372036854775807</entry>
</row> </row>
<row> <row>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.35 2001/10/25 14:10:06 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.36 2001/11/24 19:57:06 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -26,6 +26,12 @@ ...@@ -26,6 +26,12 @@
#define INT64_FORMAT "%ld" #define INT64_FORMAT "%ld"
#endif #endif
#ifdef HAVE_LL_CONSTANTS
#define INT64CONST(x) ((int64) x##LL)
#else
#define INT64CONST(x) ((int64) x)
#endif
#define MAXINT8LEN 25 #define MAXINT8LEN 25
#ifndef INT_MAX #ifndef INT_MAX
...@@ -69,8 +75,23 @@ int8in(PG_FUNCTION_ARGS) ...@@ -69,8 +75,23 @@ int8in(PG_FUNCTION_ARGS)
*/ */
while (*ptr && isspace((unsigned char) *ptr)) /* skip leading spaces */ while (*ptr && isspace((unsigned char) *ptr)) /* skip leading spaces */
ptr++; ptr++;
if (*ptr == '-') /* handle sign */ /* handle sign */
sign = -1, ptr++; if (*ptr == '-')
{
ptr++;
sign = -1;
/*
* Do an explicit check for INT64_MIN. Ugly though this is, it's
* cleaner than trying to get the loop below to handle it portably.
*/
#ifndef INT64_IS_BUSTED
if (strcmp(ptr, "9223372036854775808") == 0)
{
result = - INT64CONST(0x7fffffffffffffff) - 1;
PG_RETURN_INT64(result);
}
#endif
}
else if (*ptr == '+') else if (*ptr == '+')
ptr++; ptr++;
if (!isdigit((unsigned char) *ptr)) /* require at least one digit */ if (!isdigit((unsigned char) *ptr)) /* require at least one digit */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment