Re: custom function for converting human readable sizes to bytes
Pavel Stehule <pavel.stehule@gmail.com>
From: Pavel Stehule <pavel.stehule@gmail.com>
To: Vitaly Burovoy <vitaly.burovoy@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-11T09:06:59Z
Lists: pgsql-hackers
2016-02-11 7:44 GMT+01:00 Vitaly Burovoy <vitaly.burovoy@gmail.com>: > On 2/10/16, Pavel Stehule <pavel.stehule@gmail.com> wrote: > > Hi Vitaly, > > > > please, can you send your version of this patch, how we talked about it > in > > Moscow? > > > > Thank you > > > > Pavel > > Hello, Pavel! > > Please find attached my version of the patch (it applies cleanly on > top of 64d89a9 which is current master). > > It is time to change oid. 3331 is used by "bytea_sortsupport", I set > 3334 to "pg_size_bytes". > > I got a code design of numbers checking from json_lex_number in > src/backend/utils/adt/json.c > For me it seems more structured. I adapted it a little and it allows > to add parsing an exponent (like '10е3 Mb') easily for full support of > numeric (if sometimes it is necessary). > yes, it is better structured > > When I added "trimming" for size units (playing with avoiding an extra > buffer), I found there is easy to support "bytes" unit (but "byte" is > still unsupported). > I am little bit unsure about support the unit unsupported by GUC parser. But for usage in custom space and for this current usage, it is acceptable. > > > Also this version includes all changes I mentioned in my last review[1]: > 1. parse_memory_unit returns value instead of using a pointer (return > zero if noting is found) for it; > 2. all messages are in a single style (nuances are in errdetails); > 3. "select"s are in uppercase, rephrased and moved a comment block in test; > 4. several tests are added (also with supporting of "bytes" unit); > 5. a sentence in a documentation is rephrased (numeric->fixed-point > number); "bytes" unit is added to both functions; > 6. fixed indentation a little; > 7. pfree is removed (it is easier than removing all other allocated > resources). > ok, thank you > > > I still think my changes are little and they are based on your work > (and research). > thank you very much - but you refactoring is significant and helpful. I'll reassign your version to opened commitfest. Regards Pavel > > [1] > http://www.postgresql.org/message-id/CAKOSWNk13WVDem06LRo-HucR0pR6Et29+dvqY6J5sKxzarUbRw@mail.gmail.com > > -- > Best regards, > Vitaly Burovoy >
Commits
-
Add pg_size_bytes() to parse human-readable size strings.
- 53874c5228fe 9.6.0 landed
-
Refactor check_functional_grouping() to use get_primary_key_attnos().
- f144f73242ac 9.6.0 cited
-
Correct comment in GetConflictingVirtualXIDs()
- 1129c2b0ad27 9.6.0 cited
-
Make extract() do something more reasonable with infinite datetimes.
- 647d87c56ab6 9.6.0 cited
-
pg_size_pretty: Format negative values similar to positive ones.
- 8a1fab36aba7 9.6.0 cited
-
pg_size_pretty(numeric)
- 4a2d7ad76f5f 9.2.0 cited