Re: [PATCH] psql: Make ParseVariableDouble reject values above max

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Sven Klemm <sven(at)tigerdata(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] psql: Make ParseVariableDouble reject values above max
Date: 2026-05-18 15:41:01
Message-ID: B2F64B1B-DC26-43A5-9238-16190DD5FD15@yesql.se
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 9 May 2026, at 11:44, Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
>
>> On 8 May 2026, at 17:39, Sven Klemm <sven(at)tigerdata(dot)com> wrote:
>>
>> 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.
>
> Indeed, that's a silly bug, not sure how I could have missed that. We are
> currently in freeze for the upcoming minor releases but I have this staged to
> go in directly after. Thanks for the report.

Pushed and backpatched to v18, with the addition of a test for this behaviour.

--
Daniel Gustafsson

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-05-18 15:50:07 Re: remove obsolete comment in AtEOXact_Inval
Previous Message Jelte Fennema-Nio 2026-05-18 15:26:05 Re: meson: Make test output much more useful on failure (both in CI and locally)