Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2ec9587

Browse files
committed
Tweak int8in to accept -9223372036854775808, per recent discussion in
pgsql-patches.
1 parent215f096 commit2ec9587

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

‎doc/src/sgml/datatype.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.75 2001/11/21 21:12:34 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.76 2001/11/24 19:57:06 tgl Exp $
33
-->
44

55
<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
385385
<entry><type>bigint</></entry>
386386
<entry>8 bytes</entry>
387387
<entry>Very large range fixed-precision</entry>
388-
<entry>-9223372036854775807 to 9223372036854775807</entry>
388+
<entry>-9223372036854775808 to 9223372036854775807</entry>
389389
</row>
390390

391391
<row>

‎src/backend/utils/adt/int8.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.35 2001/10/25 14:10:06 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.36 2001/11/24 19:57:06 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -26,6 +26,12 @@
2626
#defineINT64_FORMAT "%ld"
2727
#endif
2828

29+
#ifdefHAVE_LL_CONSTANTS
30+
#defineINT64CONST(x) ((int64) x##LL)
31+
#else
32+
#defineINT64CONST(x) ((int64) x)
33+
#endif
34+
2935
#defineMAXINT8LEN25
3036

3137
#ifndefINT_MAX
@@ -69,8 +75,23 @@ int8in(PG_FUNCTION_ARGS)
6975
*/
7076
while (*ptr&&isspace((unsignedchar)*ptr))/* skip leading spaces */
7177
ptr++;
72-
if (*ptr=='-')/* handle sign */
73-
sign=-1,ptr++;
78+
/* handle sign */
79+
if (*ptr=='-')
80+
{
81+
ptr++;
82+
sign=-1;
83+
/*
84+
* Do an explicit check for INT64_MIN. Ugly though this is, it's
85+
* cleaner than trying to get the loop below to handle it portably.
86+
*/
87+
#ifndefINT64_IS_BUSTED
88+
if (strcmp(ptr,"9223372036854775808")==0)
89+
{
90+
result=-INT64CONST(0x7fffffffffffffff)-1;
91+
PG_RETURN_INT64(result);
92+
}
93+
#endif
94+
}
7495
elseif (*ptr=='+')
7596
ptr++;
7697
if (!isdigit((unsignedchar)*ptr))/* require at least one digit */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp