From: Tom Lane <tgl@sss.pgh.pa.us>
To: Magnus Hagander <magnus@hagander.net>
Cc: Thomas Kellerer <shammat@gmx.net>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Parameter value from (mb/gb) to bytes
Date: Wed, 14 Oct 2020 11:23:20 -0400
Message-ID: <3602055.1602689000@sss.pgh.pa.us> (raw)
In-Reply-To: <CABUevEz3Ya0eWPJPvU5ymHPbK1OTtaFUMbzV2u7ULS9d_ORtyg@mail.gmail.com>
References: <6cbca2bcda734464a1be9f7d7380ff33@rik.ee>
<f95d954f-6467-a50a-f8fc-8bf4bb80e902@gmx.net>
<dd335965-b92d-2ea8-5d46-6e6477ea0361@gmx.net>
<CABUevEyfWsWTUu67v+t2pE+mU2YUxQXmpw60AwhX=Ew5AveH4A@mail.gmail.com>
<3601486.1602688239@sss.pgh.pa.us>
<CABUevEz3Ya0eWPJPvU5ymHPbK1OTtaFUMbzV2u7ULS9d_ORtyg@mail.gmail.com>
Magnus Hagander <magnus@hagander.net> writes:
> On Wed, Oct 14, 2020 at 5:10 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> It's fairly annoying that this doesn't work:
>> regression=# select pg_size_bytes(setting||' '||unit) from pg_settings
>> where name = 'shared_buffers';
> Actually thinking though, surely *this* particular case can be spelled as:
> SELECT pg_size_bytes(current_setting('shared_buffers'))
Yeah, that might be the most recommendable way.
> Or if doing it off pg_settings:
> SELECT setting::bigint * pg_size_bytes(unit) from pg_settings where
> name='shared_buffers'
No, because that will fail for any unit other than '8kB', eg
regression=# select pg_size_bytes('MB');
ERROR: invalid size: "MB"
> I'm not sure having pg_size_bytes() parse "16384 8kB" is reasonable, I have
> a feeling that could lead to a lot of accidental entries giving the wrong
> results.
Yeah, that's definitely a risk. Given that current_setting() already does
what's needed, that's probably a better answer.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, magnus@hagander.net, shammat@gmx.net
Subject: Re: Parameter value from (mb/gb) to bytes
In-Reply-To: <3602055.1602689000@sss.pgh.pa.us>
References: <6cbca2bcda734464a1be9f7d7380ff33@rik.ee> <f95d954f-6467-a50a-f8fc-8bf4bb80e902@gmx.net> <dd335965-b92d-2ea8-5d46-6e6477ea0361@gmx.net> <CABUevEyfWsWTUu67v+t2pE+mU2YUxQXmpw60AwhX=Ew5AveH4A@mail.gmail.com> <3601486.1602688239@sss.pgh.pa.us> <CABUevEz3Ya0eWPJPvU5ymHPbK1OTtaFUMbzV2u7ULS9d_ORtyg@mail.gmail.com> <3602055.1602689000@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox