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

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, 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 05:18:56
Message-ID: CAFj8pRDYwgVikNEcE0f7do4W5inhs115si_7JyvfV5M_n6rgcg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

2016-07-30 3:47 GMT+02:00 David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>:

> 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.
>

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.
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Greg Stark 2016-07-30 12:30:16 Re: [BUGS] BUG #14244: wrong suffix for pg_size_pretty()
Previous Message David G. Johnston 2016-07-30 01:47:33 Re: [BUGS] BUG #14244: wrong suffix for pg_size_pretty()

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Borodin 2016-07-30 11:00:12 Re: Re: GiST optimizing memmoves in gistplacetopage for fixed-size updates [PoC]
Previous 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)