*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.82 2008/06/17 19:10:56 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.83 2008/10/05 23:18:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/*
* Overflow check. The only possible overflow case is for arg1 = INT_MIN,
* arg2 = -1, where the correct result is -INT_MIN, which can't be
- * represented on a two's-complement machine.
+ * represented on a two's-complement machine. Most machines produce
+ * INT_MIN but it seems some produce zero.
*/
- if (arg2 == -1 && arg1 < 0 && result < 0)
+ if (arg2 == -1 && arg1 < 0 && result <= 0)
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("integer out of range")));
/*
* Overflow check. The only possible overflow case is for arg1 =
* SHRT_MIN, arg2 = -1, where the correct result is -SHRT_MIN, which can't
- * be represented on a two's-complement machine.
+ * be represented on a two's-complement machine. Most machines produce
+ * SHRT_MIN but it seems some produce zero.
*/
- if (arg2 == -1 && arg1 < 0 && result < 0)
+ if (arg2 == -1 && arg1 < 0 && result <= 0)
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("smallint out of range")));
/*
* Overflow check. The only possible overflow case is for arg1 = INT_MIN,
* arg2 = -1, where the correct result is -INT_MIN, which can't be
- * represented on a two's-complement machine.
+ * represented on a two's-complement machine. Most machines produce
+ * INT_MIN but it seems some produce zero.
*/
- if (arg2 == -1 && arg1 < 0 && result < 0)
+ if (arg2 == -1 && arg1 < 0 && result <= 0)
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("integer out of range")));
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.70 2008/06/17 19:10:56 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.71 2008/10/05 23:18:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/*
* Overflow check. The only possible overflow case is for arg1 =
* INT64_MIN, arg2 = -1, where the correct result is -INT64_MIN, which
- * can't be represented on a two's-complement machine.
+ * can't be represented on a two's-complement machine. Most machines
+ * produce INT64_MIN but it seems some produce zero.
*/
- if (arg2 == -1 && arg1 < 0 && result < 0)
+ if (arg2 == -1 && arg1 < 0 && result <= 0)
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("bigint out of range")));
/*
* Overflow check. The only possible overflow case is for arg1 =
* INT64_MIN, arg2 = -1, where the correct result is -INT64_MIN, which
- * can't be represented on a two's-complement machine.
+ * can't be represented on a two's-complement machine. Most machines
+ * produce INT64_MIN but it seems some produce zero.
*/
- if (arg2 == -1 && arg1 < 0 && result < 0)
+ if (arg2 == -1 && arg1 < 0 && result <= 0)
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("bigint out of range")));
/*
* Overflow check. The only possible overflow case is for arg1 =
* INT64_MIN, arg2 = -1, where the correct result is -INT64_MIN, which
- * can't be represented on a two's-complement machine.
+ * can't be represented on a two's-complement machine. Most machines
+ * produce INT64_MIN but it seems some produce zero.
*/
- if (arg2 == -1 && arg1 < 0 && result < 0)
+ if (arg2 == -1 && arg1 < 0 && result <= 0)
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("bigint out of range")));