[PATCH] psql: Make ParseVariableDouble reject values above max

From: Sven Klemm <sven(at)tigerdata(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: [PATCH] psql: Make ParseVariableDouble reject values above max
Date: 2026-05-08 15:39:29
Message-ID: CAMCrgp31p_5SDVi7dwnP39tTW5icQ0MWHA+N4kJdXgkL0PEy8w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

ParseVariableDouble() in src/bin/psql/variables.c is asymmetric in how
it handles the [min, max] bounds it documents. The lower-bound branch
correctly returns false, but the upper-bound branch logs the error and
then falls through to assign *result and return true. The function's
contract ("the value must be within the range [min,max] in order to be
considered valid"; "if unsuccessful, *result isn't clobbered") is
broken on the upper-bound path.

The only caller today is watch_interval_hook, so the user-visible
effect is that an out-of-range WATCH_INTERVAL is reported as invalid
yet still assigned.

Reproducer:

$ psql
# \set WATCH_INTERVAL 99999999
invalid value "99999999" for variable "WATCH_INTERVAL": must be less than
1000000.00
# \echo :WATCH_INTERVAL
99999999
The error is printed, but the variable is set anyway.

Regards,
Sven Klemm

Attachment Content-Type Size
0001-psql-Make-ParseVariableDouble-reject-values-above-ma.patch text/x-patch 1.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Bauman 2026-05-08 15:40:45 Re: Doc update proposal for the note on log_statement in the runtime config for logging page
Previous Message Paul A Jungwirth 2026-05-08 15:25:22 Re: FOR PORTION OF does not recompute GENERATED STORED columns that depend on the range column