pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix corner-case 64-bit integer subtraction bug on some platforms
Date: Thu, 09 Nov 2023 10:02:08 +0000
Message-ID: <E1r11rU-004dYT-Ds@gemulon.postgresql.org> (raw)

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_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/308a69a9878212bc2f96279023ce16070dac9214

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(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1r11rU-004dYT-Ds@gemulon.postgresql.org>
Permalink:  ../E1r11rU-004dYT-Ds@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1r11rU-004dYT-Ds@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: dean.a.rasheed@gmail.com, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix corner-case 64-bit integer subtraction bug on some platforms
  In-Reply-To: <E1r11rU-004dYT-Ds@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox