Re: Add support for unit "B" to pg_size_pretty() - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Add support for unit "B" to pg_size_pretty()
Date
Msg-id 4b4613ec-d2c2-a615-9e3f-9f36cf5897ed@enterprisedb.com
Whole thread Raw
In response to Re: Add support for unit "B" to pg_size_pretty()  (David Rowley <dgrowleyml@gmail.com>)
Responses Re: Add support for unit "B" to pg_size_pretty()  (David Rowley <dgrowleyml@gmail.com>)
List pgsql-hackers
On 02.03.23 20:58, David Rowley wrote:
> On Mon, 27 Feb 2023 at 21:34, Peter Eisentraut
> <peter.eisentraut@enterprisedb.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

pgsql-hackers by date:

Previous
From: Peter Smith
Date:
Subject: Re: [PATCH] Use indexes on the subscriber when REPLICA IDENTITY is full on the publisher
Next
From: David Rowley
Date:
Subject: Re: using memoize in in paralel query decreases performance