Re: Patch: Implement failover on libpq connect level.

From: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>
To: 'Robert Haas' <robertmhaas(at)gmail(dot)com>, Mithun Cy <mithun(dot)cy(at)enterprisedb(dot)com>
Cc: Peter van Hardenberg <pvh(at)pvh(dot)ca>, Peter Eisentraut <peter_e(at)gmx(dot)net>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Patch: Implement failover on libpq connect level.
Date: 2016-11-11 07:03:49
Message-ID: 0A3221C70F24FB45833433255569204D1F63F38B@G01JPEXMBYT05
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

From: pgsql-hackers-owner(at)postgresql(dot)org
> [mailto:pgsql-hackers-owner(at)postgresql(dot)org] On Behalf Of Robert Haas
> Great, committed. There's still potentially more work to be done here,
> because my patch omits some features that were present in Victor's original
> submission, like setting the failover timeout, optionally randomizing the
> order of the hosts, and distinguishing between master and standby servers;
> Victor, or anyone, please feel free to submit separate patches for those
> things.

I did a few tests with ECPG. I'm satisfied with the current behavior, but someone says different. I'd like to share the result.

The following literal connection strings succeeded. host1 is a server where PostgreSQL is not running, and host2 is where it's running. I could connect to the database server on host2.

EXEC SQL CONNECT TO 'tcp:postgresql://host1,host2:5450/postgres';
EXEC SQL CONNECT TO 'tcp:postgresql://host1,host2:5450,5450/postgres';

EXEC SQL CONNECT TO 'postgres(at)host1,host2:5450';
EXEC SQL CONNECT TO 'postgres(at)host1,host2:5450,5450';

EXEC SQL CONNECT TO 'tcp:postgresql://?service=my_service';

~/.pg_service.conf
[my_service]
host=host1,host2
port=5450 # and port=5450,5450 case
dbname=postgres

But this one makes PQconnectdbParams() fail, because the passed "host" is "host1:5450,host2" and "port" is "5450". ECPGconnect()'s parser is different from libpq's. However, the tcp:postgresql:// syntax is not described a URL in the manual, so I think it's sufficient to just describe the syntax in the ECPG article.

EXEC SQL CONNECT TO 'tcp:postgresql://host1:5450,host2:5450/postgres';

And without the single quote like below, ecpg fails to precompile the source file. I also think it's enough to state in the manual "quote the connection target if you specify multiple hosts or ports".

EXEC SQL CONNECT TO tcp:postgresql://host1,host2:5450,5450/postgres;

connect.ec:12: ERROR: syntax error at or near ","

Comments?

Regards
Takayuki Tsunakawa

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2016-11-11 07:09:35 Re: postgres_fdw : altering foreign table not invalidating prepare statement execution plan.
Previous Message Ashutosh Bapat 2016-11-11 07:00:40 Re: Calculation of param_source_rels in add_paths_to_joinrel

Browse pgsql-jdbc by date

  From Date Subject
Next Message Peter Eisentraut 2016-11-11 14:03:55 Re: Patch: Implement failover on libpq connect level.
Previous Message Tsunakawa, Takayuki 2016-11-11 06:25:13 Re: Patch: Implement failover on libpq connect level.