pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix incorrect return value for pg_size_pretty(bigint)
Date: Sun, 28 Jul 2024 10:24:31 +0000
Message-ID: <E1sY14p-001aUx-Bl@gemulon.postgresql.org> (raw)

Fix incorrect return value for pg_size_pretty(bigint)

pg_size_pretty(bigint) would return the value in bytes rather than PB
for the smallest-most bigint value.  This happened due to an incorrect
assumption that the absolute value of -9223372036854775808 could be
stored inside a signed 64-bit type.

Here we fix that by instead storing that value in an unsigned 64-bit type.

This bug does exist in versions prior to 15 but the code there is
sufficiently different and the bug seems sufficiently non-critical that
it does not seem worth risking backpatching further.

Author: Joseph Koshakow <koshy44@gmail.com>
Discussion: https://postgr.es/m/CAAvxfHdTsMZPWEHUrZ=h3cky9Ccc3Mtx2whUHygY+ABP-mCmUw@mail.gmail.com
Backpatch-through: 15

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0a80e88d902d3dfdeed03ede1880b8994a8d892b

Modified Files
--------------
src/backend/utils/adt/dbsize.c       | 8 ++++++--
src/test/regress/expected/dbsize.out | 8 ++++++++
src/test/regress/sql/dbsize.sql      | 4 ++++
3 files changed, 18 insertions(+), 2 deletions(-)



view thread (4+ messages)

Message-ID: <E1sY14p-001aUx-Bl@gemulon.postgresql.org>
Permalink:  ../E1sY14p-001aUx-Bl@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sY14p-001aUx-Bl@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 incorrect return value for pg_size_pretty(bigint)
  In-Reply-To: <E1sY14p-001aUx-Bl@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