Re: [PATCH] expand the units that pg_size_pretty supports on output

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, David Christensen <david(dot)christensen(at)crunchydata(dot)com>, Shinya11(dot)Kato(at)nttdata(dot)com, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] expand the units that pg_size_pretty supports on output
Date: 2021-07-08 01:31:23
Message-ID: CAApHDvp7qouw-P88vdT+O7L5ZHpWQO12oOtx1q3M3W+9v-XN9w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 8 Jul 2021 at 01:32, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
> Hmm, this looked easy, but...
>
> It occurred to me that there ought to be regression tests for the edge
> cases where it steps from one unit to the next. So, in the style of
> the existing regression tests, I tried the following:
>
> SELECT size, pg_size_pretty(size), pg_size_pretty(-1 * size) FROM
> (VALUES (10239::bigint), (10240::bigint),
> (10485247::bigint), (10485248::bigint),
> (10736893951::bigint), (10736893952::bigint),
> (10994579406847::bigint), (10994579406848::bigint),
> (11258449312612351::bigint), (11258449312612352::bigint)) x(size);

> 11258449312612352 | 10240 TB | -10239 TB

Hmm, yeah, I noticed that pg_size_pretty(bigint) vs
pg_size_pretty(numeric) didn't always match when I was testing this
patch, but I was more focused on having my results matching the
unpatched version than I was with making sure bigint and numeric
matched.

I imagine this must date back to 8a1fab36ab. Do you feel like it's
something this patch should fix? I was mostly hoping to keep this
patch about rewriting the code to both make it easier to add new units
and also to make it easier to keep all 3 functions in sync.

It feels like if we're going to fix this negative rounding thing then
we should maybe do it and backpatch a fix then rebase this work on top
of that.

What are your thoughts?

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Japin Li 2021-07-08 02:30:22 Re: Why ALTER SUBSCRIPTION ... SET (slot_name='none') requires subscription disabled?
Previous Message Greg Nancarrow 2021-07-08 01:03:34 Re: row filtering for logical replication