pgsql: Fix our getopt_long's behavior for a command line argument of ju

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix our getopt_long's behavior for a command line argument of ju
Date: 2020-03-23 15:58:22
Message-ID: E1jGPT4-0008K1-MF@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix our getopt_long's behavior for a command line argument of just "-".

src/port/getopt_long.c failed on such an argument, always seeing it
as an unrecognized switch. This is unhelpful; better is to treat such
an item as a non-switch argument. That behavior is what we find in
GNU's getopt_long(); it's what src/port/getopt.c does; and it is
required by POSIX for getopt(), which getopt_long() ought to be
generally a superset of. Moreover, it's expected by ecpg, which
intends an argument of "-" to mean "read from stdin". So fix it.

Also add some documentation about ecpg's behavior in this area, since
that was miserably underdocumented. I had to reverse-engineer it
from the code.

Per bug #16304 from James Gray. Back-patch to all supported branches,
since this has been broken forever.

Discussion: https://postgr.es/m/16304-c662b00a1322db7f@postgresql.org

Branch
------
REL_11_STABLE

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

Modified Files
--------------
doc/src/sgml/ref/ecpg-ref.sgml | 31 ++++++++++++++++++++++++++-----
src/port/getopt_long.c | 14 +++++++++++---
2 files changed, 37 insertions(+), 8 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2020-03-23 16:42:33 pgsql: Doc: explain that LIKE et al can be used in ANY (sub-select) etc
Previous Message Tom Lane 2020-03-23 06:05:06 Re: pgsql: Disk-based Hash Aggregation.