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

Commite75d365

Browse files
committed
Fix int8mul so that overflow check is applied correctly for INT64_IS_BUSTED
case, per Florian Pflug.Not back-patched since it's unclear that anyone but me still cares ...
1 parentc9bfabe commite75d365

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

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

Lines changed: 13 additions & 9 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-
* $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.66 2007/06/05 21:31:06 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.67 2007/08/30 05:27:29 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -575,15 +575,19 @@ int8mul(PG_FUNCTION_ARGS)
575575
* Since the division is likely much more expensive than the actual
576576
* multiplication, we'd like to skip it where possible. The best bang for
577577
* the buck seems to be to check whether both inputs are in the int32
578-
* range; if so, no overflow is possible.
578+
* range; if so, no overflow is possible. (But that only works if we
579+
* really have a 64-bit int64 datatype...)
579580
*/
580-
if (!(arg1== (int64) ((int32)arg1)&&
581-
arg2== (int64) ((int32)arg2))&&
582-
arg2!=0&&
583-
(result /arg2!=arg1|| (arg2==-1&&arg1<0&&result<0)))
584-
ereport(ERROR,
585-
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
586-
errmsg("bigint out of range")));
581+
#ifndefINT64_IS_BUSTED
582+
if (arg1!= (int64) ((int32)arg1)||arg2!= (int64) ((int32)arg2))
583+
#endif
584+
{
585+
if (arg2!=0&&
586+
(result /arg2!=arg1|| (arg2==-1&&arg1<0&&result<0)))
587+
ereport(ERROR,
588+
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
589+
errmsg("bigint out of range")));
590+
}
587591
PG_RETURN_INT64(result);
588592
}
589593

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp