Re: [PATCH] Cleanup of GUC units code

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Stark <stark(at)enterprisedb(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Marko Kreen <markokr(at)gmail(dot)com>, Asko Oja <ascoja(at)gmail(dot)com>
Subject: Re: [PATCH] Cleanup of GUC units code
Date: 2008-09-09 16:55:33
Message-ID: 48C6AA85.8060206@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> "Greg Stark" <stark(at)enterprisedb(dot)com> writes:
>> On Mon, Sep 8, 2008 at 2:11 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> But of course case insensitivity isn't going to fix that example for you.
>>> So we're right back at the question of where we should draw the line in
>>> trying to accept variant input.
>
>> Well it's not a perfect precedent but for example, dd accepts:
>
>> G (2^30)
>> M (2^20)
>> k (2^10)
>> K (2^10)
>> Kb (10^3)
>> MB (10^6)
>> GB (10^9)
>> b (512)
>
> Hmm. I could get behind a proposal to allow single-letter abbreviations
> if it could be made to work across the board,

The SQL standard actually specifies something about that. You can
define the length of large object types (CLOB and BLOB) with multipliers
K, M, and G, as in

CREATE TABLE foo ( bar BLOB(5 M) );

These multipliers are case insensitive, of course. (And their are
1024-based, FWIW.)

So I could imagine that we generalize this approach to make these
multipliers available in other positions.

This would have definitional problems of its own, however. If you
interpret K, M, and G strictly as unit-less multipliers, then

SET shared_buffers = 2 G

would mean

SET shared_buffers = 2 * 1073741824

meaning

SET shared_buffers = 2147463648

which is not the same thing as the current

SET shared_buffer = '2GB'

This also affects the solution to another GUC units complaint that the
quotes are annoying, which I support.

We could possibly settle some of these arguments if we could redefine
all memory parameters to use one byte as base unit, and then allow some
ambiguity and unit omission from there. But that would probably cause
much havoc, so we are stuck with a certain degree of inconsistency anyhow.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2008-09-09 17:25:29 Re: Common Table Expressions (WITH RECURSIVE) patch
Previous Message Pavel Stehule 2008-09-09 16:51:55 Re: Common Table Expressions (WITH RECURSIVE) patch