|
7 | 7 | * Portions Copyright (c) 1994, Regents of the University of California
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.70 2008/06/17 19:10:56 tgl Exp $ |
| 10 | + * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.71 2008/10/05 23:18:37 tgl Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -608,9 +608,10 @@ int8div(PG_FUNCTION_ARGS)
|
608 | 608 | /*
|
609 | 609 | * Overflow check. The only possible overflow case is for arg1 =
|
610 | 610 | * INT64_MIN, arg2 = -1, where the correct result is -INT64_MIN, which
|
611 |
| - * can't be represented on a two's-complement machine. |
| 611 | + * can't be represented on a two's-complement machine. Most machines |
| 612 | + * produce INT64_MIN but it seems some produce zero. |
612 | 613 | */
|
613 |
| - if (arg2 == -1 && arg1 < 0 && result < 0) |
| 614 | + if (arg2 == -1 && arg1 < 0 && result <= 0) |
614 | 615 | ereport(ERROR,
|
615 | 616 | (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
616 | 617 | errmsg("bigint out of range")));
|
@@ -830,9 +831,10 @@ int84div(PG_FUNCTION_ARGS)
|
830 | 831 | /*
|
831 | 832 | * Overflow check. The only possible overflow case is for arg1 =
|
832 | 833 | * INT64_MIN, arg2 = -1, where the correct result is -INT64_MIN, which
|
833 |
| - * can't be represented on a two's-complement machine. |
| 834 | + * can't be represented on a two's-complement machine. Most machines |
| 835 | + * produce INT64_MIN but it seems some produce zero. |
834 | 836 | */
|
835 |
| - if (arg2 == -1 && arg1 < 0 && result < 0) |
| 837 | + if (arg2 == -1 && arg1 < 0 && result <= 0) |
836 | 838 | ereport(ERROR,
|
837 | 839 | (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
838 | 840 | errmsg("bigint out of range")));
|
@@ -1008,9 +1010,10 @@ int82div(PG_FUNCTION_ARGS)
|
1008 | 1010 | /*
|
1009 | 1011 | * Overflow check. The only possible overflow case is for arg1 =
|
1010 | 1012 | * INT64_MIN, arg2 = -1, where the correct result is -INT64_MIN, which
|
1011 |
| - * can't be represented on a two's-complement machine. |
| 1013 | + * can't be represented on a two's-complement machine. Most machines |
| 1014 | + * produce INT64_MIN but it seems some produce zero. |
1012 | 1015 | */
|
1013 |
| - if (arg2 == -1 && arg1 < 0 && result < 0) |
| 1016 | + if (arg2 == -1 && arg1 < 0 && result <= 0) |
1014 | 1017 | ereport(ERROR,
|
1015 | 1018 | (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
1016 | 1019 | errmsg("bigint out of range")));
|
|
0 commit comments