]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
psql: Make ParseVariableDouble reject values above max
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Mon, 18 May 2026 15:33:36 +0000 (08:33 -0700)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Mon, 18 May 2026 15:33:36 +0000 (08:33 -0700)
ParseVariableDouble missed returning false after logging an error when
the parsed value exceeded max, making the value assigned rather than
rejected.  Backpatch down to v18 where this was introduced as part of
the \WATCH_INTERVAL.

Author: Sven Klemm <sven@tigerdata.com>
Co-authored-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAMCrgp31p_5SDVi7dwnP39tTW5icQ0MWHA+N4kJdXgkL0PEy8w@mail.gmail.com
Backpatch-through: 18

src/bin/psql/t/001_basic.pl
src/bin/psql/variables.c

index cf07a9dbd5ed63cc36be14877ef1cbf0af64345b..6f2341fcaa1df05eec481916e1cc5f23e1a1696a 100644 (file)
@@ -451,6 +451,8 @@ psql_fails_like(
        '\set WATCH_INTERVAL 1e500',
        qr/is out of range/,
        'WATCH_INTERVAL variable is out of range');
+psql_like($node, '\echo :WATCH_INTERVAL',
+       qr/^2$/m, 'WATCH_INTERVAL variable was not altered');
 
 # Test \g output piped into a program.
 # The program is perl -pe '' to simply copy the input to the output.
index 6b64302ebca86830c73dca03602642352e107a72..07f5e3f6f2dc555783b5b214f7a702a227639864 100644 (file)
@@ -224,6 +224,7 @@ ParseVariableDouble(const char *value, const char *name, double *result, double
                        if (name)
                                pg_log_error("invalid value \"%s\" for variable \"%s\": must be less than %.2f",
                                                         value, name, max);
+                       return false;
                }
                *result = dblval;
                return true;