> [] 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@host1,host2:5450';
EXEC SQL CONNECT TO 'postgres@host1,host2:5450,5450';

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

port=5450  # and port=5450,5450 case

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 

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; ERROR: syntax error at or near ","


Takayuki Tsunakawa

Sent via pgsql-hackers mailing list (
To make changes to your subscription:

Reply via email to