Re: custom function for converting human readable sizes to bytes

Vitaly Burovoy <vitaly.burovoy@gmail.com>

From: Vitaly Burovoy <vitaly.burovoy@gmail.com>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: "Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de>, Robert Haas <robertmhaas@gmail.com>, Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>, Alvaro Herrera <alvherre@2ndquadrant.com>, Tom Lane <tgl@sss.pgh.pa.us>, Jim Nasby <Jim.Nasby@bluetreble.com>, Corey Huinker <corey.huinker@gmail.com>, Guillaume Lelarge <guillaume@lelarge.info>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2016-02-12T01:28:13Z
Lists: pgsql-hackers
Hello!

On 2/11/16, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> Hi
>
> assigned https://commitfest.postgresql.org/9/514/
>
> Regards
> Pavel


This patch was almost done by the end of the previous CF(2016-01):
there was few little flaws which are solved by now.

I have reviewed this patch.
It applies cleanly at the top of current master
(f144f73242acef574bc27a4c70e809a64806e4a4), compiles silently and
implements the behavior reached by consensus.

All size units (the same as used in the GUC) are supported.
In addition "bytes" is also supported that makes it be a inverse
function for the pg_size_pretty[1].

The documentation describes behavior of the function and possible size
units. I don't see what else needs to be said.

The code is clean and commented.

Regression tests cover possible use cases and corner cases.


Notes for a committer:
1. pg_proc.h has changed, so the CATALOG_VERSION_NO must also be changed.
2. Code comments, error message strings, DESCR in pg_proc.h and
changes in the documentation need proof-reading by a native English
speaker, which the Author and I are not.


[CF] https://commitfest.postgresql.org/9/514/
[1] http://www.postgresql.org/message-id/CA+TgmoZFomG4eYorZZGf7pzotG9PxpUhtQvxLfsKiM4iZH8KRQ@mail.gmail.com

-- 
Best regards,
Vitaly Burovoy


Commits

  1. Add pg_size_bytes() to parse human-readable size strings.

  2. Refactor check_functional_grouping() to use get_primary_key_attnos().

  3. Correct comment in GetConflictingVirtualXIDs()

  4. Make extract() do something more reasonable with infinite datetimes.

  5. pg_size_pretty: Format negative values similar to positive ones.

  6. pg_size_pretty(numeric)