pg_size_pretty, SHOW, and spaces

From: Christoph Berg <myon(at)debian(dot)org>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <stark(at)mit(dot)edu>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, thomas(dot)berger(at)1und1(dot)de, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_size_pretty, SHOW, and spaces
Date: 2016-08-01 11:35:53
Message-ID: 20160801113552.ntkqnz77l6yvwpjx@msg.df7cb.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Re: Bruce Momjian 2016-07-30 <20160730181643(dot)GD22405(at)momjian(dot)us>
> I also just applied a doc patch that increases case and spacing
> consistency in the use of kB/MB/GB/TB.

Hi,

PostgreSQL uses the spaces inconsistently, though. pg_size_pretty uses spaces:

# select pg_size_pretty((2^20)::bigint);
pg_size_pretty
────────────────
1024 kB

SHOW does not:

# show work_mem;
work_mem
──────────
1MB

The SHOW output is formatted by _ShowOption() using 'INT64_FORMAT "%s"',
via convert_from_base_unit(). The latter has a comment attached...
/*
* Convert a value in some base unit to a human-friendly unit. The output
* unit is chosen so that it's the greatest unit that can represent the value
* without loss. For example, if the base unit is GUC_UNIT_KB, 1024 is
* converted to 1 MB, but 1025 is represented as 1025 kB.
*/
... where the spaces are present again.

General typesetting standard seems to be "1 MB", i.e. to include a
space between value and unit. (This would also be my preference.)

Opinions? (I'd opt to insert spaces in the docs now, and then see if
inserting a space in the SHOW output is acceptable for 10.0.)

Christoph

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2016-08-01 15:39:13 Re: missing comment in lwlock.c
Previous Message Jens.Wilke 2016-08-01 08:43:43 missing comment in lwlock.c

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2016-08-01 11:54:27 Re: Oddity in EXPLAIN for foreign/custom join pushdown plans
Previous Message Ashutosh Bapat 2016-08-01 11:31:35 Re: Oddity in EXPLAIN for foreign/custom join pushdown plans