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

Commit0fc7779

Browse files
committed
Revise overflow test in int84() to avoid codegen bug in some older
versions of gcc. We don't really need to explicitly test the limitsanyway, just reverse-convert and see if we get the same answer.
1 parentde77c55 commit0fc7779

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

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

Lines changed: 6 additions & 5 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.32 2001/08/24 14:07:49 petere Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.33 2001/09/07 01:33:44 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -67,7 +67,7 @@ int8in(PG_FUNCTION_ARGS)
6767
* Do our own scan, rather than relying on sscanf which might be
6868
* broken for long long.
6969
*/
70-
while (*ptr&&isspace((unsignedchar)*ptr))/* skip leading spaces */
70+
while (*ptr&&isspace((unsignedchar)*ptr))/* skip leading spaces */
7171
ptr++;
7272
if (*ptr=='-')/* handle sign */
7373
sign=-1,ptr++;
@@ -688,11 +688,12 @@ int84(PG_FUNCTION_ARGS)
688688
int64val=PG_GETARG_INT64(0);
689689
int32result;
690690

691-
if ((val<INT_MIN)|| (val>INT_MAX))
692-
elog(ERROR,"int8 conversion to int4 is out of range");
693-
694691
result= (int32)val;
695692

693+
/* Test for overflow by reverse-conversion. */
694+
if ((int64)result!=val)
695+
elog(ERROR,"int8 conversion to int4 is out of range");
696+
696697
PG_RETURN_INT32(result);
697698
}
698699

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp