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 1efsmy-0008Ez-7k for pgsql-bugs@arkaria.postgresql.org; Sun, 28 Jan 2018 19:38:52 +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 1efsmw-0000rm-Ni for pgsql-bugs@arkaria.postgresql.org; Sun, 28 Jan 2018 19:38:50 +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 1efsmw-0000rd-Ek for pgsql-bugs@lists.postgresql.org; Sun, 28 Jan 2018 19:38:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1efsmu-0000mA-45 for pgsql-bugs@lists.postgresql.org; Sun, 28 Jan 2018 19:38:49 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w0SJckwn029203; Sun, 28 Jan 2018 14:38:46 -0500 From: Tom Lane To: Bruce Momjian cc: akos@elegran.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15025: PSQL CLI - inconsistency when both -d and -U supplies a username In-reply-to: <20180128034832.GD9153@momjian.us> References: <20180123130013.7407.24749@wrigleys.postgresql.org> <20180128034832.GD9153@momjian.us> Comments: In-reply-to Bruce Momjian message dated "Sat, 27 Jan 2018 22:48:32 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <29201.1517168326.1@sss.pgh.pa.us> Date: Sun, 28 Jan 2018 14:38:46 -0500 Message-ID: <29202.1517168326@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Bruce Momjian writes: > psql -d "postgresql://user2@momjian.us/test" -U user1 > --> Password for user user1: > but it wants the user2 password. > It doesn't matter whether -U is first or last, it always prompts for the > -U user, but connects as the -d user. Bleah. > Because the URI is parsed by libpq, I don't think we can do any better > than just suppress the user name in the password prompt when a URI is > used. That doesn't seem very user-friendly at all. I think that the most correct behavior in this case would be to throw an error because of the conflicting command line parameters. Now admittedly, psql doesn't throw an error for psql -U alice -U bob so maybe just silently making a choice is OK, but we need to be clear as to which choice we made. Isn't it possible to get the URI parse results back out of libpq? regards, tom lane