Re: BUG #4040: psql should provide option to not prompt for password - Mailing list pgsql-bugs

From Mika Fischer
Subject Re: BUG #4040: psql should provide option to not prompt for password
Date
Msg-id 20080317145753.GA17432@msgid.zoopnet.de
Whole thread Raw
In response to Re: BUG #4040: psql should provide option to not prompt for password  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
* Tom Lane <tgl@sss.pgh.pa.us> [2008-03-17 15:28]:
> Mika Fischer <mf+ubuntu@zoopnet.de> writes:
> > What the current code does is:
> > Run "psql -l" to get the list of local databases, and
> > run "psql -qtc 'select usename from pg_user' template1" to get the list
> > of users. If this fails the system users are used for completion.
>
> > I'm not at all a PostgreSQL expert so I can't even comment on whether
> > this is a smart thing to do or not.
>
> It's not, IMHO.  You don't even know if the local database is where the
> user is intending to connect to.

Well, if the user has already given a -h parameter I could notice and
disable the completion. If he has not and tries to complete for -U, but
later wants to supply a -h option, then there's not much I can do about
it but I don't think much harm is done.

> Moreover this presupposes some rather obsolete ideas about what
> connection parameters might need to be given on the command line.

What exactly do you mean by that?

Do you mean that this would be better?
psql -q -t -c 'select usename from pg_user' -d template1

> Something that might be more useful is to see if there's a connection
> service file
> http://developer.postgresql.org/pgdocs/postgres/libpq-pgservice.html
> and offer the names of service entries in it.

Yes, that also seems to be useful. What is the recommended way to use
these service names?

'psql "service=name"' or 'psql -d name'?

It would still be nice if for the local database you could do:
psql very<TAB>
and it would complete to very_long_database_name

But it seems impossible to do this nicely...

Regards,
 Mika

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #4040: psql should provide option to not prompt for password
Next
From: Mika Fischer
Date:
Subject: Re: BUG #4040: psql should provide option to not prompt for password