v2-keep-compiler-silence.patch
application/octet-stream
Filename: v2-keep-compiler-silence.patch
Type: application/octet-stream
Part: 0
Patch
Format: unified
Series: patch v2
| File | + | − |
|---|---|---|
| src/backend/utils/adt/timestamp.c | 7 | 1 |
| src/bin/pgbench/pgbench.c | 7 | 1 |
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index 84bc97d40c..3ef88cabad 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -3233,7 +3233,13 @@ interval_mul(PG_FUNCTION_ARGS)
/* cascade units down */
result->day += (int32) month_remainder_days;
result_double = rint(span->time * factor + sec_remainder * USECS_PER_SEC);
- if (result_double > PG_INT64_MAX || result_double < PG_INT64_MIN)
+ /*
+ * Since PG_INT64_MAX is not representable as a double-precision value, the
+ * cast result of (double) PG_INT64_MAX is 9223372036854775808. Therefore,
+ * we must use >= as a comparison operator when checking overflow.
+ */
+ if (result_double >= (double) PG_INT64_MAX
+ || result_double < (double) PG_INT64_MIN)
ereport(ERROR,
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
errmsg("interval out of range")));
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index ed7652bfbf..1f1eac5449 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -1654,7 +1654,13 @@ coerceToInt(PgBenchValue *pval, int64 *ival)
{
double dval = pval->u.dval;
- if (dval < PG_INT64_MIN || PG_INT64_MAX < dval)
+ /*
+ * Since PG_INT64_MAX is not representable as a double-precision value,
+ * the cast result of (double) PG_INT64_MAX is 9223372036854775808.
+ * Therefore, we must use <= as a comparison operator when checking
+ * overflow.
+ */
+ if (dval < (double) PG_INT64_MIN || (double) PG_INT64_MAX <= dval)
{
fprintf(stderr, "double to int overflow for %f\n", dval);
return false;