You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Unify parsing logic for command-line integer options
Most of the integer options for command-line binaries now make use of asingle routine able to do the job, fixing issues with the detection ofsloppy values caused for example by the use of atoi(), that fails onstrings beginning with numerical characters with junk trailingcharacters.This commit cuts down the number of strings requiring translation by 26per my count, switching the code to have two error types for invalid andout-of-range values instead.Much more could be done here, with float or even int64 options, butint32 was the most appealing case as it is possible to rely on strtol()to do the job reliably. Note that there are some exceptions for now,like pg_ctl or pg_upgrade that use their own logging logic. A couple ofnegative TAP tests required some adjustments for the new errorsgenerated.pg_dump and pg_restore tracked the maximum number of parallel jobswithin the option parsing. The code is refactored a bit to track thatin the code dedicated to parallelism instead.Author: Kyotaro Horiguchi, Michael PaquierReviewed-by: David Rowley, Álvaro HerreraDiscussion:https://postgr.es/m/CALj2ACXqdG9WhqVoJ9zYf-iZt7sgK7Szv5USs=he6NnWQ2ofTA@mail.gmail.com