Add pg_size_bytes() to parse human-readable size strings.
Dean Rasheed <dean.a.rasheed@gmail.com>
Add pg_size_bytes() to parse human-readable size strings.
This will parse strings in the format produced by pg_size_pretty() and
return sizes in bytes. This allows queries to be written with clauses
like "pg_total_relation_size(oid) > pg_size_bytes('10 GB')".
Author: Pavel Stehule with various improvements by Vitaly Burovoy
Discussion: http://www.postgresql.org/message-id/CAFj8pRD-tGoDKnxdYgECzA4On01_uRqPrwF-8LdkSE-6bDHp0w@mail.gmail.com
Reviewed-by: Vitaly Burovoy, Oleksandr Shulgin, Kyotaro Horiguchi,
Michael Paquier and Robert Haas
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/func.sgml | modified | +30 −2 |
| src/backend/utils/adt/dbsize.c | modified | +149 −0 |
| src/include/catalog/catversion.h | modified | +1 −1 |
| src/include/catalog/pg_proc.h | modified | +2 −0 |
| src/include/utils/builtins.h | modified | +1 −0 |
| src/test/regress/expected/dbsize.out | modified | +109 −0 |
| src/test/regress/sql/dbsize.sql | modified | +39 −0 |
Documentation touched
Discussion
- custom function for converting human readable sizes to bytes 94 messages · 2015-11-21 → 2016-02-20