Re: [BUGS] BUG #14244: wrong suffix for pg_size_pretty()
От | Pavel Stehule |
---|---|
Тема | Re: [BUGS] BUG #14244: wrong suffix for pg_size_pretty() |
Дата | |
Msg-id | CAFj8pRDYwgVikNEcE0f7do4W5inhs115si_7JyvfV5M_n6rgcg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [BUGS] BUG #14244: wrong suffix for pg_size_pretty() ("David G. Johnston" <david.g.johnston@gmail.com>) |
Ответы |
Re: [BUGS] BUG #14244: wrong suffix for pg_size_pretty()
|
Список | pgsql-hackers |
2016-07-30 3:47 GMT+02:00 David G. Johnston <david.g.johnston@gmail.com>:
On Tue, Jul 12, 2016 at 01:36:38PM +0000, thomas.berger@1und1.de wrote:
> The following bug has been logged on the website:
>
> Bug reference: 14244
> Logged by: Thomas Berger
> Email address: thomas.berger@1und1.de
> PostgreSQL version: 9.5.3
> Operating system: any
> Description:
>
> pg_size_pretty uses the suffix "kB" (kilobyte, 10^3 byte), but the returned
> value is "KB", or "KiB" ( kibibyte, 2^10 byte). This is missleading and
> should be fixed. See also https://en.wikipedia.org/wiki/Kibibyte
>
> =# select pg_size_pretty(1024000::bigint);
> pg_size_pretty
> ----------------
> 1000 kB
(Thread moved to hackers.)
Yes, we have redefined kB, and documented its use in postgresql.conf and
pg_size_pretty(), but it does not match any recognized standard.After bouncing on this for a bit I'm inclined to mark the bug itself "won't fix" but introduce a "to_binary_iso" function (I'm hopeful a better name will emerge...) that will output a number using ISO binary suffixes. I would document this under 9.8 "data type formatting functions" instead of within system functions.pg_size_pretty output can continue with a defined role to be used as input into a GUC variable; and to keep backward compatibility. Add a note near its definition to use "to_binary_iso" for a standard-conforming output string.
We talked about this issue, when I wrote function pg_size_bytes. It is hard to fix these functions after years of usage. The new set of functions can be better
pg_iso_size_pretty();
pg_iso_size_bytes();
or shorter name
pg_isize_pretty();
pg_isize_bytes();Regards
Pavel
David J.
В списке pgsql-hackers по дате отправления: