Re: whats the deal with -u ? - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: whats the deal with -u ?
Date
Msg-id 200712101150.10325.peter_e@gmx.net
Whole thread Raw
In response to Re: whats the deal with -u ?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: whats the deal with -u ?  (Stephen Frost <sfrost@snowman.net>)
List pgsql-hackers
Am Montag, 10. Dezember 2007 schrieb Tom Lane:
> "Joshua D. Drake" <jd@commandprompt.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/


pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Release Note Changes
Next
From: NikhilS
Date:
Subject: Re: [BUGS] BUG #3811: Getting multiple values from a sequence generator