]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix corner-case 64-bit integer subtraction bug on some platforms.
authorDean Rasheed <dean.a.rasheed@gmail.com>
Thu, 9 Nov 2023 09:55:39 +0000 (09:55 +0000)
committerDean Rasheed <dean.a.rasheed@gmail.com>
Thu, 9 Nov 2023 09:55:39 +0000 (09:55 +0000)
commitdea12b40d5210332453f4350e1653048b43fdb7a
tree407fadbe36dfda43b3884060815acbb0206527e5
parent99fa98766fa59270083606d9386386c3e7131a7a
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
src/include/common/int.h
src/test/regress/expected/int8.out
src/test/regress/sql/int8.sql