agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix missing money overflow checks for INT64_MIN / -1
Date: Tue, 04 Aug 2026 06:02:18 +0000
Message-ID: <E1wr8EE-000000007Y8-0CGL@gemulon.postgresql.org> (raw)
Fix missing money overflow checks for INT64_MIN / -1
Similar to what 1f7cb5c30 did for the INT types, protect against
overflow when dividing the lowest possible money value by -1. This
cannot be represented on a two's complement machine.
Without this check, the result depends on the machine, and in the worst
case, could result in a crash. With the fix installed, this will now
result in:
ERROR: money out of range
Bug: #19585
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>
Reported-by: Michael Malis <malis@pgrust.com>
Reviewed-by: Tristan Partin <tristan@partin.io>
Reviewed-by: Rafia Sabih <rafia.pghackers@gmail.com>
Discussion: https://postgr.es/m/19586-bb603bf5ad9934dd%40postgresql.org
Discussion: https://postgr.es/m/CAB8bMisnXJVXte6s3kUOpuuAY9%3D9kehG6MMX-%2BTQoFsSGan22Q%40mail.gmail.com
Backpatch-through: 14
Branch
------
REL_14_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/fec40878c8702ff4e58241d00a1914d8568bec03
Modified Files
--------------
src/backend/utils/adt/cash.c | 16 ++++++++++++++++
src/test/regress/expected/money.out | 8 ++++++++
src/test/regress/sql/money.sql | 4 ++++
3 files changed, 28 insertions(+)
view thread (7+ messages)
Message-ID: <E1wr8EE-000000007Y8-0CGL@gemulon.postgresql.org>
Permalink: ../E1wr8EE-000000007Y8-0CGL@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1wr8EE-000000007Y8-0CGL@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: drowley@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix missing money overflow checks for INT64_MIN / -1
In-Reply-To: <E1wr8EE-000000007Y8-0CGL@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox