Real config values for bytes needs quotes?

Started by Kyotaro Horiguchiover 3 years ago3 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

appliessuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t47534
psql -h localhost -U postgres

Built from patchset v3 (message #3), September 20, 2026 at 05:27 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t47534_3 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t47534_3 && git checkout t47534_3

Patchset v3 (message #3) is on t47534_3

Jump to latest
#1Kyotaro Horiguchi
horikyota.ntt@gmail.com

Hello.

I found it frustrating that the line "shared_buffers = 0.1GB" in
postgresql.conf postgresql.conf was causing an error and that the
value required (additional) surrounding single quotes. The attached
patch makes the parser accept the use of non-quoted real values
followed by a unit for such variables. I'm not sure if that syntax
fully covers the input syntax of strtod, but I beieve it is suffucient
for most use cases.

Is the following a correct English sentense?

Do you folks think this makes sense?

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachments:

guc-accept-real-values-follows-by-unit.patchtext/x-patch; charset=us-asciiDownload+1-1
#2Peter Eisentraut
peter_e@gmx.net
In reply to: Kyotaro Horiguchi (#1)
Re: Real config values for bytes needs quotes?

On 27.02.23 09:32, Kyotaro Horiguchi wrote:

I found it frustrating that the line "shared_buffers = 0.1GB" in
postgresql.conf postgresql.conf was causing an error and that the
value required (additional) surrounding single quotes. The attached
patch makes the parser accept the use of non-quoted real values
followed by a unit for such variables. I'm not sure if that syntax
fully covers the input syntax of strtod, but I beieve it is suffucient
for most use cases.

This seems sensible to fix. If you're not sure about the details, write
some test cases. :)

#3Kyotaro Horiguchi
horikyota.ntt@gmail.com
In reply to: Peter Eisentraut (#2)
Re: Real config values for bytes needs quotes?

At Thu, 2 Mar 2023 11:54:10 +0100, Peter Eisentraut <peter.eisentraut@enterprisedb.com> wrote in

On 27.02.23 09:32, Kyotaro Horiguchi wrote:

I found it frustrating that the line "shared_buffers = 0.1GB" in
postgresql.conf postgresql.conf was causing an error and that the
value required (additional) surrounding single quotes. The attached
patch makes the parser accept the use of non-quoted real values
followed by a unit for such variables. I'm not sure if that syntax
fully covers the input syntax of strtod, but I beieve it is suffucient
for most use cases.

This seems sensible to fix. If you're not sure about the details,
write some test cases. :)

Thanks. I initially intended to limit the change for REAL to accept
units following a value. However, actually I also modified it to
accept '1e1'.

man strtod says it accepts the following format.

The expected form of the (initial portion of the) string is optional
leading white space as recognized by isspace(3), an optional plus ('+')
or minus sign ('-') and then either (i) a decimal number, or (ii) a
hexadecimal number, or (iii) an infinity, or (iv) a NAN (not-a-number).

A decimal number consists of a nonempty sequence of decimal digits pos‐
sibly containing a radix character (decimal point, locale-dependent,
usually '.'), optionally followed by a decimal exponent. A decimal
exponent consists of an 'E' or 'e', followed by an optional plus or
minus sign, followed by a nonempty sequence of decimal digits, and
indicates multiplication by a power of 10.

It is written in regexp as
'\s*[-+]?(\.\d+|\d+(\.\d*)?)([Ee][-+]?\d+)?'. The leading whitespace
is unnecessary in this specific usage, and we also need to exclude
INTERGER from this set of matches. Therefore, it should be modified to
'[-+]?((\.\d+|\d+\.\d*)([Ee][-+]?\d+)?|\d+([Ee][-+]?\d+))'.

It is translated to the following BNF notation. UNIT_LETTER is also
needed.

{SIGN}?(("."{DIGIT}+|{DIGIT}+"."{DIGIT}*){EXPONENT}?|{DIGIT}+{EXPONENT}){UNIT_LETTER}*

The attached patch applies aforementioned change to guc-file.l and
includes tests for values in certain patters.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachments:

t47534_3
v1-0001-Widen-unquoted-value-acceptance-in-configuration-.patchtext/x-patch; charset=us-asciiDownload+42-2