Excerpts from Martijn van Oosterhout's message of Thu Nov 24 09:40:42 +0200 
2011:
> On Thu, Nov 24, 2011 at 08:59:56AM +0200, Alexander Shulgin wrote:
> > > How would you specifiy a local port/UNIX domain socket?
> > 
> > Missed that in my previous reply.
> > 
> > If host part of the URI points to localhost, the UNIX domain socket would 
> > be considered by libpq just as if you would pass "-h localhost -p 5433".
> 
> Uh, no it doesn't. "-h localhost" uses TCP/IP (try it). This is one
> piece of mysql magic we don't copy.  If you want to use the socket you
> need to specify "-h /tmp" or wherever you keep it.  Leaving out the -h
> parameter also uses UNIX domain sockets.

Oh, you're right -- I was under wrong impression (hacking in the wrong local 
install, you know.)

> Which does raise the valid question of how to represent that in URI
> syntax. SQLAlchemy (for example) doesn't try with it's URL syntax, to
> connect to a non-default UNIX socket, you need to create the URL object
> directly.

Well, whatever syntax we're going to invent here: it is not supported by the 
JDBC driver.

 "Because Java does not support using unix sockets the PostgreSQLâ„¢ server must 
be configured to allow TCP/IP connections."

  http://jdbc.postgresql.org/documentation/head/prepare.html

Or, this has to be done not in the URI syntax itself, but with the use of some 
external option.

Or maybe we can just add &unixsocket=... and hope that JDBC simply ignores 
that?  I think I will try the last option to see if that's the case.  (Looking 
at libpq code, I think we will also need to verify that host/hostaddr parameter 
is pointing to the local host and reset it to NULL, to actually make libpq 
consider UNIX sockets.)

> How about the "service" option, that's a nice way of handling
> non-default socket options.

The service handling isn't going to be affected with the proposed approach.  
So, if PGSERVICE is given, the options from the service file are applied after 
the URI is parsed, filling any parameters not set using previous methods.

--
Alex

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to