Re: Tighten up range checks for pg_resetwal arguments

Heikki Linnakangas <hlinnaka@iki.fi>

From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Chao Li <li.evan.chao@gmail.com>
Cc: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2025-12-08T14:56:22Z
Lists: pgsql-hackers
On 05/12/2025 20:09, Heikki Linnakangas wrote:
> On 04/12/2025 03:08, Chao Li wrote:
>> I guess this function doesn’t have to check “-“ by itself, it leads 
>> some edge-case not to be well handled, for example “-0” is still 0, 
>> not a negative value. We can use strtoll() convert input string to a 
>> singed long long, and check if value is negative.
> 
> True. I originally wrote this for the 64-bit variant which will be used 
> in the 64-bit offsets patch. For that we can't use strtoll().

I think it's best to reject the "-0" case, so I kept the code so that 
it's rejected, and added a test for that.

Committed, thanks for the review!

- Heikki




Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. pg_resetwal: Use separate flags for whether an option is given

  2. pg_resetwal: Reject negative and out of range arguments

  3. Fix pg_upgrade around multixid and mxoff wraparound