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 CAB7nPqQTPujBV9a1bZMNGQ1VAUTAYfZTNnM6Yb6c2TZHva_MvQ@mail.gmail.com
Whole thread Raw
In response to Re: BUG #13741: vacuumdb does not accept valid password  (Haribabu Kommi <kommi.haribabu@gmail.com>)
Responses Re: BUG #13741: vacuumdb does not accept valid password  (Haribabu Kommi <kommi.haribabu@gmail.com>)
List pgsql-bugs
On Tue, Nov 3, 2015 at 6:10 AM, Haribabu Kommi <kommi.haribabu@gmail.com> wrote:
> On Tue, Nov 3, 2015 at 6:26 AM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>> Michael Paquier wrote:
>>> On Mon, Nov 2, 2015 at 8:10 PM, Haribabu Kommi wrote:
>>> > Here I attached modified patch that gets the password from parent connection
>>> > if exists and use it for the child connection also.
>>>
>>> Meh? Why the parent connection? You could simply have the password as
>>> an argument of connectDatabase, per se the attached. That looks just
>>> more simple.
>>
>> Thanks!  This is almost there, but there's an important missing piece --
>> vacuumdb --all will ask you for a password for each database.  I think
>> vacuum_one_database needs to receive a password from its caller too.

Argh, right.

> Here I attached a separate patch to handle the reuse of password for
> vacuumdb -all
> case. The same behavior exists in all supported branches.

Sure. Still you don't actually need a double pointer as you do. You
could just reuse the password from the connection obtained via
connectMaintenanceDatabase and pass the password from this connection
as the argument to vacuum_one_database. Something like the attached
seems more elegant IMO.

>> (Also, please use pg_strdup.)
> The simple_prompt function in connectDatabase allocates memory for password
> using malloc. Because of this reason he used strdup instead of pstrdup to avoid
> adding a separate code to handle both the cases.

Yep. That's the deal.
--
Michael

Attachment

pgsql-bugs by date:

Previous
From: Julien Rouhaud
Date:
Subject: Re: [HACKERS] BUG #12989: pg_size_pretty with negative values
Next
From: Jeremiah Reinmiller
Date:
Subject: Re: BUG #13752: Incorrect RPM Version on 9.0.23 Release