* Tom Lane <tgl@sss.pgh.pa.us> [2008-03-17 14:44]:
> "Mika Fischer" <mf+ubuntu@zoopnet.de> writes:
> > I'm currently working on the bash-completion package. The problem with
> > postgresql is that psql cannot safely be called because there is no way to
> > know whether it will prompt for a password and there is also no way to avoid
> > the prompt.
>
> > Needless to say a password prompt is very bad in the context of
> > tab-completion.
>
> > Ideally, psql should provide an option --no-password which would cause it to
> > never promt for a password, and in case one is needed, fail as if a wrong
> > one was given.
>
> Are you suggesting that the shell should invoke psql without any idea of
> appropriate connection parameters? This seems utterly foolish.
Well, this is a best-effort kind of thing. If it doesn't work nothing's
lost. If it does work, it's convenient for the user. So I don't see much
wrong with it. If you think this is a bad idea for some reason please
elaborate.
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. But is does work if the user is not
prompted for a password.
Any suggestions and comments are appreciated.
Regards,
Mika