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

Commit9fc6f4e

Browse files
committed
Win32 can't catch the exception thrown by INT_MIN / -1 or INT_MIN * -1,
so on that platform we test for those before the computation and throwan "out of range" error.Backpatch to 8.1.X.
1 parente71e02d commit9fc6f4e

File tree

1 file changed

+23
-1
lines changed
  • src/backend/utils/adt

1 file changed

+23
-1
lines changed

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.72 2006/03/11 01:19:22 neilc Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.73 2006/06/12 16:09:11 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -735,6 +735,17 @@ int4mul(PG_FUNCTION_ARGS)
735735
int32arg2=PG_GETARG_INT32(1);
736736
int32result;
737737

738+
#ifdefWIN32
739+
/*
740+
*Win32 doesn't throw a catchable exception for
741+
*SELECT -2147483648 /* INT_MIN */* (-1);
742+
*/
743+
if (arg2==-1&&arg1==INT_MIN)
744+
ereport(ERROR,
745+
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
746+
errmsg("integer out of range")));
747+
#endif
748+
738749
result=arg1*arg2;
739750

740751
/*
@@ -770,6 +781,17 @@ int4div(PG_FUNCTION_ARGS)
770781
(errcode(ERRCODE_DIVISION_BY_ZERO),
771782
errmsg("division by zero")));
772783

784+
#ifdefWIN32
785+
/*
786+
*Win32 doesn't throw a catchable exception for
787+
*SELECT -2147483648 /* INT_MIN */ / (-1);
788+
*/
789+
if (arg2==-1&&arg1==INT_MIN)
790+
ereport(ERROR,
791+
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
792+
errmsg("integer out of range")));
793+
#endif
794+
773795
result=arg1 /arg2;
774796

775797
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp