Use option_parse_int() for pg_createsubscriber --recovery-timeout and pgbench --max-tries

From: Raja Sai pranav <rajasaipranav0(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Use option_parse_int() for pg_createsubscriber --recovery-timeout and pgbench --max-tries
Date: 2026-11-26 18:30:25
Message-ID: CAPHduZCSNYcPOmWgA5Kfo9DR-ShdOEw1SKg2dw_kXxx+zocZRA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Two integer options are still read with atoi(), so a non-numeric value
silently becomes 0:

pg_createsubscriber --recovery-timeout=abc timeout disabled (0 = none)
pgbench --max-tries=abc unlimited tries

pg_createsubscriber also accepts negative timeouts. The other client
programs moved to option_parse_int() in 2021 [1]. pg_ctl was left out
on purpose there (Windows event logging), but pg_createsubscriber did not
exist yet and uses the common logging.

The attached patch uses option_parse_int() for both, still allowing 0.
For --max-tries the error for a negative value changes from "invalid
number of maximum tries" to the usual "must be in range" message.
Tests are added in
https://www.google.com/url?q=http://040_pg_createsubscriber.pl&source=gmail&ust=1795804224713000&sa=E
and
https://www.google.com/url?q=http://002_pgbench_no_server.pl&source=gmail&ust=1795804224713000&sa=E.
They fail without the change and pass with it.

[1]
https://www.google.com/url?q=https://postgr.es/m/CALj2ACXqdG9WhqVoJ9zYf-iZt7sgK7Szv5USs%3Dhe6NnWQ2ofTA@mail.gmail.com&source=gmail&ust=1795804224713000&sa=E

Regards,
Sai Pranav

Attachment Content-Type Size
v1-0001-Use-option_parse_int-for-two-more-integer-options.patch text/x-patch 3.9 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Bohyun Lee 2026-11-26 18:46:43 Re: [PATCH] pg_upgrade: add --initdb option to create the new cluster automatically
Previous Message Raja Sai pranav 2026-11-26 18:30:23 Reject NaN and trailing garbage in client-side floating-point options