Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eftgs-0004zV-Ig for pgsql-bugs@arkaria.postgresql.org; Sun, 28 Jan 2018 20:36:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eftgr-0004AO-8r for pgsql-bugs@arkaria.postgresql.org; Sun, 28 Jan 2018 20:36:37 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eftgq-0004AF-WD for pgsql-bugs@lists.postgresql.org; Sun, 28 Jan 2018 20:36:37 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eftgo-000229-EU for pgsql-bugs@lists.postgresql.org; Sun, 28 Jan 2018 20:36:35 +0000 Received: from bruce by momjian.us with local (Exim 4.84_2) (envelope-from ) id 1eftgn-0003Hg-9D; Sun, 28 Jan 2018 15:36:33 -0500 Date: Sun, 28 Jan 2018 15:36:33 -0500 From: Bruce Momjian To: Tom Lane Cc: akos@elegran.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15025: PSQL CLI - inconsistency when both -d and -U supplies a username Message-ID: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <14400.1517171454@sss.pgh.pa.us> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, Jan 28, 2018 at 03:30:54PM -0500, Tom Lane wrote: > Bruce Momjian writes: > > On Sun, Jan 28, 2018 at 02:38:46PM -0500, Tom Lane wrote: > >> Isn't it possible to get the URI parse > >> results back out of libpq? > > > Well, there is PQuser(), but you need to pass a connection struct to > > that, and before you connect you don't have one. > > Yeah, but we normally don't prompt for password till after a failed > connection attempt, at which point we can get the info. So I propose > something like the attached. > > There's room for debate about what we ought to do when -W (--password) is > specified, but I think that that's not really that exciting because the > only real use-cases for it are noninteractive applications that aren't > going to care what the prompt is. So in the startup.c case I have it > just offering the neutral "Password: " prompt always. In the \c case, > I left it using the same initial username as it was before, because the > odds that that's right seem considerably higher with \c. You can still > fool it by giving a URI dbname to \c, so maybe there's an argument for > lobotomizing the initial prompt in \c too, but I didn't do that here. Oh, I wasn't aware a failed login left us with a 'conn'. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription +