pgsql: Fix corner-case 64-bit integer subtraction bug on some platforms

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix corner-case 64-bit integer subtraction bug on some platforms
Date: 2023-11-09 10:02:08
Message-ID: E1r11rU-004dYQ-DU@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix corner-case 64-bit integer subtraction bug on some platforms.

When computing "0 - INT64_MIN", most platforms would report an
overflow error, which is correct. However, platforms without integer
overflow builtins or 128-bit integers would fail to spot the overflow,
and incorrectly return INT64_MIN.

Back-patch to all supported branches.

Patch be me. Thanks to Jian He for initial investigation, and Laurenz
Albe and Tom Lane for review.

Discussion: https://postgr.es/m/CAEZATCUNK-AZSD0jVdgkk0N%3DNcAXBWeAEX-QU9AnJPensikmdQ%40mail.gmail.com

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c396aca2b712f7872dcc4641a2a0fa553f232f76

Modified Files
--------------
src/include/common/int.h | 6 +++++-
src/test/regress/expected/int8.out | 2 ++
src/test/regress/sql/int8.sql | 1 +
3 files changed, 8 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2023-11-09 11:16:32 pgsql: Ensure we use the correct spelling of "ensure"
Previous Message Amit Kapila 2023-11-09 04:08:20 pgsql: Fix uninitialized slot array access during the upgrade.