Re: whats the deal with -u ?

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Gregory Stark <stark(at)enterprisedb(dot)com>, Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: whats the deal with -u ?
Date: 2007-12-10 10:50:08
Message-ID: 200712101150.10325.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Am Montag, 10. Dezember 2007 schrieb Tom Lane:
> "Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
> > As I recall there was a bug under very specific circumstances that a
> > password prompt would not appear. Thus we added the option for -W.
>
> I don't see any evidence for that theory in the CVS logs ..
> Peter seems to have invented -W out of whole cloth.

Way back when, there was no way to set the user name on the psql command line.
The only way was to use the option -u and type it in. (Well, you could set
PGUSER, but that's obviously not quite fun.) But -u also forced a password
prompt, even if you didn't need a password. So the functionality of the -u
option was split into the -U and -W options. The only difference is that -U
does not prompt, but I don't think anyone wants to argue that prompting is
better than what -U does. Note that we don't have a way to prompt for host
name, database name, etc., and shell scripting this functionality is trivial.

Way back when, psql moreover did not have the capability to automatically
recognize when a password would be required. That is, if you did not specify
one, authentication would simply fail and psql would abort. If you were
aware that a password would be required, then the only ways to supply it
would be to set PGPASSWORD (which is obviously not quite fun) or use the -u
option, which would also prompt you for a user name, even if you did not want
to specify one. So the functionality of the -u option was split into the -U
and -W options. -W does exactly half of what -u used to do.

The functionality to automatically recognize when a password would be required
and prompt was added later (or perhaps around the same time) but it was
considered a hack (it was a string comparison of the error message). It has
obviously worked out quite well anyway. I believe the documentation of
the -W option has for its entire lifetime said that it "should" normally not
be necessary.

So as far as I can tell, the available options -U and -W serve all the
existing use cases. I would have no issue with getting rid of the -W option
if someone wants to take responsibility for ensuring that it will really
never be necessary. I see no technical or usability merit in reviving the -u
option. I hope the above explanations have shed some light on that.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gregory Stark 2007-12-10 11:19:14 Re: BUG #3811: Getting multiple values from a sequence generator
Previous Message Heikki Linnakangas 2007-12-10 10:08:42 Re: Release Note Changes