From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Magnus Hagander <magnus(at)hagander(dot)net> |
Cc: | Thomas Kellerer <shammat(at)gmx(dot)net>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Parameter value from (mb/gb) to bytes |
Date: | 2020-10-14 15:23:20 |
Message-ID: | 3602055.1602689000@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Magnus Hagander <magnus(at)hagander(dot)net> writes:
> On Wed, Oct 14, 2020 at 5:10 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Jonathan Strong | 2020-10-14 15:28:45 | Re: What's your experience with using Postgres in IoT-contexts? |
Previous Message | Christoph Moench-Tegeder | 2020-10-14 15:17:26 | Re: Parameter value from (mb/gb) to bytes |