From: Daniel Gustafsson Date: Mon, 18 May 2026 15:33:36 +0000 (-0700) Subject: psql: Make ParseVariableDouble reject values above max X-Git-Tag: REL_19_BETA1~78 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=e04910a9a2a3f20c8139efd4fa4a6cdf00f3d3bd;p=thirdparty%2Fpostgresql.git psql: Make ParseVariableDouble reject values above max 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 Co-authored-by: Daniel Gustafsson Reviewed-by: Daniel Gustafsson Discussion: https://postgr.es/m/CAMCrgp31p_5SDVi7dwnP39tTW5icQ0MWHA+N4kJdXgkL0PEy8w@mail.gmail.com Backpatch-through: 18 --- diff --git a/src/bin/psql/t/001_basic.pl b/src/bin/psql/t/001_basic.pl index 3961e69e1cc..bbd330216ae 100644 --- a/src/bin/psql/t/001_basic.pl +++ b/src/bin/psql/t/001_basic.pl @@ -452,6 +452,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. diff --git a/src/bin/psql/variables.c b/src/bin/psql/variables.c index f2a28bc9820..8060f2959cc 100644 --- a/src/bin/psql/variables.c +++ b/src/bin/psql/variables.c @@ -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;