Re: Passing connection string to pg_basebackup - Mailing list pgsql-hackers

From Hari Babu
Subject Re: Passing connection string to pg_basebackup
Date
Msg-id 005501cdfa45$6b0eec80$412cc580$@kommi@huawei.com
Whole thread Raw
In response to Re: [BUGS] BUG #7534: walreceiver takes long time to detect n/w breakdown  (Heikki Linnakangas <hlinnakangas@vmware.com>)
List pgsql-hackers
On Tue, Jan 22, 2013 3:27 PM Hari Babu wrote:
>On Saturday, January 19, 2013 5:49 PM Magnus Hagander wrote:
>>On Fri, Jan 18, 2013 at 1:05 PM, Heikki Linnakangas
>><hlinnakangas@vmware.com> wrote:
>>> On 18.01.2013 13:41, Amit Kapila wrote:
>>>>
>>>> On Friday, January 18, 2013 3:46 PM Heikki Linnakangas wrote:
>>>>>
>>>>> On 18.01.2013 08:50, Amit Kapila wrote:
>>>> So to solve this problem below can be done:
>>>> 1. Support connection string in pg_basebackup and mention keepalives or
>>>> connection_timeout
>>>> 2. Support recv_timeout separately to provide a way to users who are
not
>>>> comfortable tcp keepalives
>>>>
>>>> a. 1 can be done alone
>>>> b. 2 can be done alone
>>>> c. both 1 and 2.
>>>
>>>
>>> Right. Let's do just 1 for now. An general application level, non-TCP,
>>> keepalive message at the libpq level might be a good idea, but that's a
much
>>> larger patch, definitely not 9.3 material.
>>
>>+1 for doing 1 now. But actually, I think we can just keep it that way
>>in the future as well. If you need to specify these fairly advanced
>>options, using a connection string really isn't a problem.
>>
>>I think it would be more worthwhile to go through the rest of the
>>tools in bin/ and make sure they *all* support connection strings.
>>And, an important point,  do it the same way.
>
>Presently I am trying to implement the option-1 by adding an extra command
line
>Option -C "connection_string" to pg_basebackup and pg_receivexlog.
>This option can be used with all the tools in bin folder.
>
>The existing command line options to the tools are not planned to remove as
of now.
>
>To handle both options, we can follow these approaches.
>
>1. To make the code simpler, the connection string is formed inside with
the existing
>command line options, if the user is not provided the "connection_string"
option.
>which is used for further processing.
>
>2. The connection_string and existing command line options are handled
separately.
>
>I feel approach-1 is better. Please provide your suggestions on the same.

Here is the patch which handles taking of connection string as an argument
to pg_basebackup and pg_receivexlog. 

Description of changes: 

1. New command line "-C connection-string"option is added for passing the
connection string. 
2. Used "PQconnectdb" function for connecting to server instead of existing
function "PQconnectdbParams". 
3. The existing command line parameters are formed in a string and passed to
"PQconnectdb" function. 
4. With the connection string, if user provides additional options with
existing command line options, higher priority is given for the additional
options. 
5. "conninfo_parse" function is modified to handle of single quote in the
password provided as input. 


please provide your suggestions.


Regards, 
Hari babu.

pgsql-hackers by date:

Previous
From: Claudio Freire
Date:
Subject: Re: [PATCH 1/3] Fix x + y < x overflow checks
Next
From: Amit Kapila
Date:
Subject: Re: Proposal for Allow postgresql.conf values to be changed via SQL [review]