Re: [BUGS] BUG #14244: wrong suffix for pg_size_pretty()

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: thomas(dot)berger(at)1und1(dot)de, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [BUGS] BUG #14244: wrong suffix for pg_size_pretty()
Date: 2016-07-30 01:47:33
Message-ID: CAKFQuwabqqy-R76GnaCL+KWOmipC0mio=mFoZqoXqDQSw+YwTg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Fri, Jul 29, 2016 at 8:18 PM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:

> On Tue, Jul 12, 2016 at 01:36:38PM +0000, thomas(dot)berger(at)1und1(dot)de wrote:
> > The following bug has been logged on the website:
> >
> > Bug reference: 14244
> > Logged by: Thomas Berger
> > Email address: thomas(dot)berger(at)1und1(dot)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.

​David J.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Pavel Stehule 2016-07-30 05:18:56 Re: [BUGS] BUG #14244: wrong suffix for pg_size_pretty()
Previous Message Peter Geoghegan 2016-07-30 00:37:21 Re: BUG #14150: Attempted to delete invisible tuple

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2016-07-30 04:49:05 Re: [Patch] Temporary tables that do not bloat pg_catalog (a.k.a fast temp tables)
Previous Message Bruce Momjian 2016-07-30 00:26:25 Re: [BUGS] BUG #14244: wrong suffix for pg_size_pretty()