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

From: David Christensen <david(dot)christensen(at)crunchydata(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: 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-07 17:44:55
Message-ID: lzeecauig8.fsf@veeddrois.attlocal.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


David Rowley writes:

> On Wed, 7 Jul 2021 at 02:46, David Christensen
> <david(dot)christensen(at)crunchydata(dot)com> wrote:
>> if we do decide to expand the units table there will be a
>> few additional changes (most significantly, the return value of `pg_size_bytes()` will need to switch
>> to `numeric`).
>
> I wonder if it's worth changing pg_size_bytes() to return NUMERIC
> regardless of if we add any additional units or not.
>
> Would you like to create 2 patches, one to change the return type and
> another to add the new units, both based on top of the v2 patch I sent
> earlier?
>
> David

Enclosed is the patch to change the return type to numeric, as well as one for expanding units to
add PB and EB.

If we decide to expand further, the current implementation will need to change, as
ZB and YB have 70 and 80 bits needing to be shifted accordingly, so int64 isn't enough to hold
it. (I fixed this particular issue in the original version of this patch, so there is at least a
blueprint of how to fix.)

I figured that PB and EB are probably good enough additions at this point, so we can debate whether
to add the others.

Best,

David

Attachment Content-Type Size
pg_size_bytes-numeric.patch text/x-patch 4.0 KB
pg_size-EB.patch text/x-patch 12.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhihong Yu 2021-07-07 18:02:31 Re: Numeric x^y for negative x
Previous Message Dean Rasheed 2021-07-07 17:36:56 Re: Numeric x^y for negative x