Re: [COMMITTERS] pgsql: libpq: Allow connection strings and URIs to specify multiple hos - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: [COMMITTERS] pgsql: libpq: Allow connection strings and URIs to specify multiple hos
Date
Msg-id CAB7nPqRuLH6YFrKWygLRLO=Fb6gznAHHzTH68ZtC51vtD6HM=w@mail.gmail.com
Whole thread Raw
List pgsql-hackers
On Thu, Nov 3, 2016 at 10:46 PM, Robert Haas <rhaas@postgresql.org> wrote:
> libpq: Allow connection strings and URIs to specify multiple hosts.
>
> It's also possible to specify a separate port for each host.
>
> Previously, we'd loop over every address returned by looking up the
> host name; now, we'll try every address for every host name.
>
> Patch by me.  Victor Wagner wrote an earlier patch for this feature,
> which I read, but I didn't use any of his code.  Review by Mithun Cy.

While testing this feature I have bumped into the following restrictions:
$ psql -d "port=5432,5433"
psql: could not match 2 port numbers to 1 hosts
$ psql -d "port=5432,5433 host=/tmp"
psql: could not match 2 port numbers to 1 hosts

However this works:
$ psql -d "port=5432,5433 host=/tmp,/tmp"
psql: could not connect to server: Connection refused   Is the server running locally and accepting   connections on
Unixdomain socket "/tmp/.s.PGSQL.5432"?
 
could not connect to server: Connection refused   Is the server running locally and accepting   connections on Unix
domainsocket "/tmp/.s.PGSQL.5433"?
 

That's really user-unfriendly. Shouldn't libpq try in both cases to
use the single entry provided by the user or the default available? I
would imagine that for most users it would make sense to specify a
single PGHOST but try to different ports, not all users run a single
instance by server (though they should not).

This makes me think that we should have a set of regression tests to
test libpq URIs and connection strings, and the multi-host support in
connection strings gives a stronger reason to have one IMO.
-- 
Michael



pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: HASH_CHUNK_SIZE vs malloc rounding
Next
From: Jim Nasby
Date:
Subject: Re: Wrong order of tests in findDependentObjects()