agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Nathan Bossart <nathan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix option argument lookup in in-tree getopt_long().
Date: Fri, 11 Sep 2026 20:20:00 +0000
Message-ID: <E1x57j5-00000004U1w-1LOh@gemulon.postgresql.org> (raw)

Fix option argument lookup in in-tree getopt_long().

The in-tree getopt_long() moves each non-option to the end of argv,
which might put it right where an option's argument lookup expects
to find the argument.  For example, "vacuumdb postgres --jobs"
takes "postgres" as the number of jobs instead of complaining that
--jobs is missing its argument.  To fix, stop the argument lookups
at the start of the moved non-options, which we already track to
know when to stop scanning.

Oversight in commit 411b720343.

Author: Sehrope Sarkuni <sehrope@jackdb.com>
Reviewed-by: solai v <solai.cdac@gmail.com>
Discussion: https://postgr.es/m/CAH7T-arxDuVCSkorO%3Dk7%2BM-_JV0JFzMpN_EtKMyD2K0RDqZ2OA%40mail.gmail.com
Backpatch-through: 17

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a160883053c3712af14c3035c7a1d5462a836a89

Modified Files
--------------
src/bin/scripts/t/100_vacuumdb.pl |  4 ++++
src/port/getopt_long.c            | 14 +++++++-------
2 files changed, 11 insertions(+), 7 deletions(-)



view thread (4+ messages)  latest in thread

Message-ID: <E1x57j5-00000004U1w-1LOh@gemulon.postgresql.org>
Permalink:  ../E1x57j5-00000004U1w-1LOh@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1x57j5-00000004U1w-1LOh@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: nathan@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix option argument lookup in in-tree getopt_long().
  In-Reply-To: <E1x57j5-00000004U1w-1LOh@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox