mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-11 19:20:40 +08:00
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 throw an "out of range" error. Backpatch to 8.1.X.
This commit is contained in:
parent
e71e02d926
commit
9fc6f4e1ae
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.72 2006/03/11 01:19:22 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.73 2006/06/12 16:09:11 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -735,6 +735,17 @@ int4mul(PG_FUNCTION_ARGS)
|
|||||||
int32 arg2 = PG_GETARG_INT32(1);
|
int32 arg2 = PG_GETARG_INT32(1);
|
||||||
int32 result;
|
int32 result;
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
/*
|
||||||
|
* Win32 doesn't throw a catchable exception for
|
||||||
|
* SELECT -2147483648 /* INT_MIN */ * (-1);
|
||||||
|
*/
|
||||||
|
if (arg2 == -1 && arg1 == INT_MIN)
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||||
|
errmsg("integer out of range")));
|
||||||
|
#endif
|
||||||
|
|
||||||
result = arg1 * arg2;
|
result = arg1 * arg2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -770,6 +781,17 @@ int4div(PG_FUNCTION_ARGS)
|
|||||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||||
errmsg("division by zero")));
|
errmsg("division by zero")));
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
/*
|
||||||
|
* Win32 doesn't throw a catchable exception for
|
||||||
|
* SELECT -2147483648 /* INT_MIN */ / (-1);
|
||||||
|
*/
|
||||||
|
if (arg2 == -1 && arg1 == INT_MIN)
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||||
|
errmsg("integer out of range")));
|
||||||
|
#endif
|
||||||
|
|
||||||
result = arg1 / arg2;
|
result = arg1 / arg2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user