Re: BUG #13741: vacuumdb does not accept valid password - Mailing list pgsql-bugs

From Michael Paquier
Subject Re: BUG #13741: vacuumdb does not accept valid password
Date
Msg-id CAB7nPqR8h98JM-k0NM-DPpf=zrBDjtg4-poqr0ppwiX4pS7sVw@mail.gmail.com
Whole thread Raw
In response to Re: BUG #13741: vacuumdb does not accept valid password  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: BUG #13741: vacuumdb does not accept valid password
List pgsql-bugs
On Mon, Nov 2, 2015 at 3:56 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:
> On Thu, Oct 29, 2015 at 9:13 AM, Haribabu Kommi
> <kommi.haribabu@gmail.com> wrote:
>> On Wed, Oct 28, 2015 at 4:07 PM, Haribabu Kommi
>> <kommi.haribabu@gmail.com> wrote:
>>> Here I attached a patch that saves the password provided by the user
>>> from the connectDatabase function and reuse it for connecting all clients
>>> to the same database.
>>
>> Attached a wrong patch, it is having some compilation problems,
>> Here is the new version with the fixed problems.
>
> I have added an entry in this CF:
> https://commitfest.postgresql.org/7/417/
> Let's not lose track of this patch.

Regarding this patch, wouldn't it be clearer to pass the password as a
variable of connectDatabase()? Then we could use NULL at the first
call of connectDatabase so as we enforce the prompt if requested by
the user. For successive calls of connectDatabase for each worker, we
then fetch the password from the parent connection using that:
if (PQconnectionUsedPassword(con))
    password = PQpass(conn);
And pass it as an argument of connectDatabase. In short, I think that
this approach would make a more portable routine because one could
enforce a password at the first call of connectDatabase() without
having to save it once.
--
Michael

pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #13741: vacuumdb does not accept valid password
Next
From: Haribabu Kommi
Date:
Subject: Re: BUG #13741: vacuumdb does not accept valid password