Re: [PATCH] Add PQconninfoParseParams and PQconninfodefaultsMerge to libpq - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: [PATCH] Add PQconninfoParseParams and PQconninfodefaultsMerge to libpq
Date
Msg-id 008501ce0db5$b0e914f0$12bb3ed0$@kapila@huawei.com
Whole thread Raw
In response to Re: [PATCH] Add PQconninfoParseParams and PQconninfodefaultsMerge to libpq  (Heikki Linnakangas <hlinnakangas@vmware.com>)
List pgsql-hackers
On Monday, February 18, 2013 1:41 PM Heikki Linnakangas wrote:
> On 18.02.2013 06:07, Amit Kapila wrote:
> > On Sunday, February 17, 2013 8:44 PM Phil Sorber wrote:
> >> On Sun, Feb 17, 2013 at 1:35 AM, Amit kapila<amit.kapila@huawei.com>
> >> wrote:
> >>> Now the patch of Phil Sober provides 2 new API's
> >> PQconninfoParseParams(), and PQconninfodefaultsMerge(),
> >>> using these API's I can think of below way for patch "pass a
> >> connection string to pg_basebackup, ..."
> >>>
> >>> 1. Call existing function PQconinfoParse() with connection string
> >> input by user and get PQconninfoOption.
> >>>
> >>> 2. Now use the existing keywords (individual options specified by
> >> user) and extract the keywords from
> >>>     PQconninfoOption structure and call new API
> >> PQconninfoParseParams() which will return PQconninfoOption.
> >>>     The PQconninfoOption structure returned in this step will
> contain
> >> all keywords
> >>>
> >>> 3. Call PQconninfodefaultsMerge() to merge any default values if
> >> exist. Not sure if this step is required?
> >>>
> >>> 4. Extract individual keywords from PQconninfoOption structure and
> >> call PQconnectdbParams.
> >>>
> >>> Is this inline with what you have in mind or you have thought of
> some
> >> other simpler way of using new API's?
> 
> Yep, that's roughly what I had in mind. I don't think it's necessary to
> merge defaults in step 3, but it needs to add the "replication=true"
> and
> "dbname=replication" options.
> 
> >> I think what would be nice is an additional connect function that
> took
> >> PQconninfoOption as a parameter. Or at least something that can
> >> convert from PQconninfoOption to a connection string or
> keyword/value
> >> arrays.
> >
> > Yes, it would be better if we would like to use new API's, I think it
> can
> > save step-4 and some part in step-2.
> 
> pg_basebackup needs to add options to the array, so I don't think a new
> connect function would help much. It's not a lot of code to iterate
> through the PGconnInfoOption array and turn it back into keywords and
> values arrays, so I'd just do that straight in the client code.

Okay, got the point.

Phil, I will try to finish the combined patch. Is it possible for you to
complete
the documentation for the new API's.

With Regards,
Amit Kapila.




pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: [PATCH] Add PQconninfoParseParams and PQconninfodefaultsMerge to libpq
Next
From: Alvaro Herrera
Date:
Subject: Re: Materialized views WIP patch