Re: change the value of "unix_socket_directories" , must used "-h /xx/xx" to use the Unix domain socket - Mailing list pgsql-general

From Steve Atkins
Subject Re: change the value of "unix_socket_directories" , must used "-h /xx/xx" to use the Unix domain socket
Date
Msg-id 10DDF9B3-9ED1-40D6-99DC-7E733A8E1D26@blighty.com
Whole thread Raw
In response to Re: change the value of "unix_socket_directories" , must used "-h /xx/xx" to use the Unix domain socket  (Nick Guenther <nguenthe@uwaterloo.ca>)
Responses Re: change the value of "unix_socket_directories" , must used "-h /xx/xx" to use the Unix domain socket  (John R Pierce <pierce@hogranch.com>)
List pgsql-general
On Aug 16, 2014, at 9:01 AM, Nick Guenther <nguenthe@uwaterloo.ca> wrote:

>
>
> On August 16, 2014 11:41:02 AM EDT, lin <jluwln@163.com> wrote:
>> Hi all,
>> I change the value of "unix_socket_directories" in postgresql.conf ,
>> then restart the database, but it cannot connect the database used like
>> this
>> "psql -d postgres -p 5432" ,  it must given the parameter " -h /xx/xx"
>> to use the Unix domain socket。
>>   how to fix   this issue ?
>
> I'll start by saying that your test case is very clear, and thank you for it. I am unsure what your goal is, however.
Iassume you are trying to set up parallel postgres processes, for debugging. I've done this recently, for that reason. 
>
> First thing to point out is that you need only one of -h and -p.  They are redundant options, because you only
connectto postgres either over TCP (-p) or with a unix domain socket (-h). 

Not really. In the case of a TCP connection you need -h for the hostname and -p for the port. For a unix socket
connectionyou use -h to specify the directory the unix socket is in, and -p is used to generate the name of the socket
withinthat directory. If you omit one or both then the compiled-in defaults will be used, but it still uses both values
toconnect. 

>
> Second, what you're seeing is necessary. If you change the default, then psql doesn't know where to look. However,
youcan recover the old behaviour with shell tricks: 
> $ alias psql='psql -h /xx/xx'
> $ psql -d postgres

Setting environment variables to point to your preferred instance will also work - and it'll work with any client that
useslibpq (which is probably almost everything that's not java). 

Cheers,
  Steve

>
> (Personally, I wrote a short wrapper script called "client.sh" which depth-first searches for a postgres db directory
andthe runs 'psql -h' with the first one it finds; equally well you could have this script install an alias) 
>
> Are you perhaps confused about what a unix domain socket is? Why are you changing it? This is a decent description of
it: 
> http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man4/unix.4
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general



pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: change the value of "unix_socket_directories" , must used "-h /xx/xx" to use the Unix domain socket
Next
From: John R Pierce
Date:
Subject: Re: change the value of "unix_socket_directories" , must used "-h /xx/xx" to use the Unix domain socket