postgresql/src/bin
Tom Lane 15be274601 Avoid misleading psql password prompt when username is multiply specified.
When a password is needed, cases such as
	psql -d "postgresql://alice@localhost/testdb" -U bob
would incorrectly prompt for "Password for user bob: ", when actually the
connection will be attempted with username alice.  The priority order of
which name to use isn't that important here, but the misleading prompt is.

When we are prompting for a password after initial connection failure,
we can fix this reliably by looking at PQuser(conn) to see how libpq
interpreted the connection arguments.  But when we're doing a forced
password prompt because of a -W switch, we can't use that solution.
Fortunately, because the main use of -W is for noninteractive situations,
it's less critical to produce a helpful prompt in such cases.  I made
the startup prompt for -W just say "Password: " all the time, rather
than expending extra code on trying to identify which username to use.
In the case of a \c command (after -W has been given), there's already
logic in do_connect that determines whether the "dbname" is a connstring
or URI, so we can avoid lobotomizing the prompt except in cases that
are actually dubious.  (We could do similarly in startup.c if anyone
complains, but for now it seems not worthwhile, especially since that
would still be only a partial solution.)

Per bug #15025 from Akos Vandra.  Although this is arguably a bug fix,
it doesn't seem worth back-patching.  The case where it matters seems
like a very corner-case usage, and someone might complain that we'd
changed the behavior of -W in a minor release.

Discussion: https://postgr.es/m/20180123130013.7407.24749@wrigleys.postgresql.org
2018-01-29 12:57:09 -05:00
..
initdb Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_archivecleanup pg_archivecleanup: Add test suite 2017-09-14 22:23:00 -04:00
pg_basebackup Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_config Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_controldata Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_ctl Support huge pages on Windows 2018-01-21 15:40:46 +01:00
pg_dump Support --no-comments in pg_dump, pg_dumpall, pg_restore. 2018-01-25 15:27:24 -05:00
pg_resetwal Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_rewind Refactor subscription tests to use PostgresNode's wait_for_catchup 2018-01-11 13:35:38 -05:00
pg_test_fsync Make WAL segment size configurable at initdb time. 2017-09-19 22:03:48 -07:00
pg_test_timing pg_test_timing: Some NLS fixes 2017-08-26 09:25:19 -04:00
pg_upgrade Move handling of database properties from pg_dumpall into pg_dump. 2018-01-22 14:09:09 -05:00
pg_waldump Update copyright for 2018 2018-01-02 23:30:12 -05:00
pgbench pgbench: Remove accidental garbage in test file 2018-01-23 12:31:01 -05:00
pgevent Update copyright for 2018 2018-01-02 23:30:12 -05:00
psql Avoid misleading psql password prompt when username is multiply specified. 2018-01-29 12:57:09 -05:00
scripts Update copyright for 2018 2018-01-02 23:30:12 -05:00
Makefile Update copyright for 2018 2018-01-02 23:30:12 -05:00