Re: BUG #4040: psql should provide option to not prompt for password

From: Mika Fischer <mf+ubuntu(at)zoopnet(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4040: psql should provide option to not prompt for password
Date: 2008-03-17 13:55:27
Message-ID: 20080317135527.GA11554@msgid.zoopnet.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

* Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> [2008-03-17 14:44]:
> "Mika Fischer" <mf+ubuntu(at)zoopnet(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Martin Pitt 2008-03-17 14:04:35 Re: BUG #4040: psql should provide option to not prompt for password
Previous Message Tom Lane 2008-03-17 13:44:27 Re: BUG #4040: psql should provide option to not prompt for password