From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bruce Momjian <bruce@momjian.us>
Cc: akos@elegran.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15025: PSQL CLI - inconsistency when both -d and -U supplies a username
Date: Sun, 28 Jan 2018 16:05:40 -0500
Message-ID: <16151.1517173540@sss.pgh.pa.us> (raw)
In-Reply-To: <20180128203633.GC4380@momjian.us>
References: <20180123130013.7407.24749@wrigleys.postgresql.org>
<20180128034832.GD9153@momjian.us>
<29202.1517168326@sss.pgh.pa.us>
<20180128200418.GA4380@momjian.us>
<14400.1517171454@sss.pgh.pa.us>
<20180128203633.GC4380@momjian.us>
Bruce Momjian <bruce@momjian.us> writes:
> Oh, I wasn't aware a failed login left us with a 'conn'.
Sure, it's what's carrying the error message. But it's also got all
the actual connection parameters filled in.
After further experimentation it seems like the has_connection_string
logic in do_connect() causes the \c case to behave pretty much as you'd
want:
$ psql -U user1 -d "postgresql://user2@localhost/postgres" -W
Password:
postgres=> \c -
Password for user user2:
You are now connected to database "postgres" as user "user2".
postgres=> \c postgresql://user1@localhost/postgres
Password:
You are now connected to database "postgres" as user "user1".
So I now think the comment I added to do_connect() is unduly pessimistic,
and it's fine to keep using "prompt_for_password(user)" for a forced
password prompt there. There may still be use-cases where it gets it
wrong, but they're too narrow to be worth giving up the helpful prompt
altogether.
regards, tom lane
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, bruce@momjian.us, akos@elegran.com
Subject: Re: BUG #15025: PSQL CLI - inconsistency when both -d and -U supplies a username
In-Reply-To: <16151.1517173540@sss.pgh.pa.us>
References: <20180123130013.7407.24749@wrigleys.postgresql.org> <20180128034832.GD9153@momjian.us> <29202.1517168326@sss.pgh.pa.us> <20180128200418.GA4380@momjian.us> <14400.1517171454@sss.pgh.pa.us> <20180128203633.GC4380@momjian.us> <16151.1517173540@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox