From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Adjust the integer overflow tests in the numeric code. |
Date: | 2021-08-06 20:37:28 |
Message-ID: | E1mC6au-000222-LG@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Adjust the integer overflow tests in the numeric code.
Formerly, the numeric code tested whether an integer value of a larger
type would fit in a smaller type by casting it to the smaller type and
then testing if the reverse conversion produced the original value.
That's perfectly fine, except that it caused a test failure on
buildfarm animal castoroides, most likely due to a compiler bug.
Instead, do these tests by comparing against PG_INT16/32_MIN/MAX. That
matches existing code in other places, such as int84(), which is more
widely tested, and so is less likely to go wrong.
While at it, add regression tests covering the numeric-to-int8/4/2
conversions, and adjust the recently added tests to the style of
434ddfb79a (on the v11 branch) to make failures easier to diagnose.
Per buildfarm via Tom Lane, reviewed by Tom Lane.
Discussion: https://postgr.es/m/2394813.1628179479%40sss.pgh.pa.us
Branch
------
REL_10_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/f20b6bc96b78d50b597e28a22f58bb9240f948f9
Modified Files
--------------
src/backend/utils/adt/numeric.c | 26 +++++---------
src/test/regress/expected/numeric.out | 65 ++++++++++++++++++++++++++++++-----
src/test/regress/sql/numeric.sql | 22 +++++++++---
3 files changed, 84 insertions(+), 29 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2021-08-06 21:33:04 | pgsql: Don't elide casting to typmod -1. |
Previous Message | Peter Eisentraut | 2021-08-06 20:22:21 | pgsql: Add missing message punctuation |