Re: Connection string - Mailing list pgsql-general

From Michael Fuhr
Subject Re: Connection string
Date
Msg-id 20060811130155.GA23630@winnie.fuhr.org
Whole thread Raw
In response to Re: Connection string  (Michael Meskes <meskes@postgresql.org>)
Responses Re: Connection string  (Michael Meskes <meskes@postgresql.org>)
List pgsql-general
On Fri, Aug 11, 2006 at 11:58:16AM +0200, Michael Meskes wrote:
> >     EXEC SQL CONNECT TO  'tcp:postgresql://192.168.0.123/xyz' USER jsb
>
> The correct syntax would be:
>
> EXEC SQL CONNECT TO  tcp:postgresql://192.168.0.123/xyz USER jsb;

The ECPG "Connecting to the Database Server" documentation does
have an example for Unix sockets with quotes:

 EXEC SQL CONNECT TO 'unix:postgresql://sql.mydomain.com/mydb' AS myconnection USER john;

Should that be changed?  It's wrong on two counts as far as
I can tell: with quotes the connection fails with a server
error of

 FATAL:  database "'unix:postgresql://sql.mydomain.com/mydb'" does not exist

Without quotes the ECPG preprocessor fails with

 ERROR: unix domain sockets only work on 'localhost' but not on 'sql.mydom'

I'm thinking that example should be:

 EXEC SQL CONNECT TO unix:postgresql://localhost/mydb AS myconnection USER john;

Also, among the target formats the documentation includes:

 * an SQL string literal containing one of the above forms

and the following paragraph says:

 In practice, it is probably less error-prone to use a (single-quoted)
 string literal or a variable reference.

which might be the source of confusion here.

--
Michael Fuhr

pgsql-general by date:

Previous
From: Brent Wood
Date:
Subject: Re: How to do auto numbering on INT column
Next
From: Christopher Browne
Date:
Subject: Re: database file encryption