Re: Add support for unit "B" to pg_size_pretty()

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Justin Pryzby <pryzby(at)telsasoft(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Add support for unit "B" to pg_size_pretty()
Date: 2023-03-06 08:13:41
Message-ID: 4b4613ec-d2c2-a615-9e3f-9f36cf5897ed@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 02.03.23 20:58, David Rowley wrote:
> On Mon, 27 Feb 2023 at 21:34, Peter Eisentraut
> <peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:
>>
>> On 22.02.23 03:39, David Rowley wrote:
>>> I think you'll need to find another way to make the aliases work.
>>> Maybe another array with the name and an int to reference the
>>> corresponding index in size_pretty_units.
>>
>> Ok, here is a new patch with a separate table of aliases. (Might look
>> like overkill, but I think the "PiB" etc. example you had could actually
>> be a good use case for this as well.)
>
> I think I'd prefer to see the size_bytes_unit_alias struct have an
> index into size_pretty_units[] array. i.e:

Ok, done that way. (I had thought about that, but I was worried that
that would be too error-prone to maintain. But I suppose the tables
don't change that often, and test cases would easily catch mistakes.)

I also updated the documentation a bit more.

Attachment Content-Type Size
v4-0001-Add-support-for-unit-B-to-pg_size_bytes.patch text/plain 7.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2023-03-06 08:16:41 Re: using memoize in in paralel query decreases performance
Previous Message Peter Smith 2023-03-06 08:10:17 Re: [PATCH] Use indexes on the subscriber when REPLICA IDENTITY is full on the publisher