public inbox for [email protected]  
help / color / mirror / Atom feed
From: Adrian Klaver <[email protected]>
To: Atul Kumar <[email protected]>
To: pgsql-general <[email protected]>
Subject: Re: issue with reading hostname
Date: Mon, 22 Apr 2024 13:25:51 -0700
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+ONtZ4a9mJhBX2p4Ug8NSR+tHHuVvi-Vrcm3QyGMjkwNsuRPw@mail.gmail.com>
References: <CA+ONtZ4a9mJhBX2p4Ug8NSR+tHHuVvi-Vrcm3QyGMjkwNsuRPw@mail.gmail.com>

On 4/22/24 13:13, Atul Kumar wrote:
> Hi,
> 
> I have postgresql  version 15 running on centos7.
> 
> I have below query that reads hostname from /tmp directory:
> 
> psql postgres -A -t -p 5432 -h /tmp/ -c 'SELECT pg_is_in_recovery();'
> 
> 
> so below are my questions:
> 
> 1. Is the psql client reading the socket file that resides in the /tmp 
> directory to fetch the hostname ?
> 
> 2. I saw the socket file in /tmp and it is empty. Then how is the psql 
> client still reading the socket file successfully for hostname ?
> 
> 
> this is my socket looks ( the size is 0 as the file is empty):
> 
> srwxrwxrwx. 1 postgres postgres      0 Apr 22 12:47 .s.PGSQL.5432
> 
> 
> Please help me clarify these doubts.

https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS

"host

     Name of host to connect to. If a host name looks like an absolute 
path name, it specifies Unix-domain communication rather than TCP/IP 
communication; the value is the name of the directory in which the 
socket file is stored. (On Unix, an absolute path name begins with a 
slash. On Windows, paths starting with drive letters are also 
recognized.) If the host name starts with @, it is taken as a 
Unix-domain socket in the abstract namespace (currently supported on 
Linux and Windows). The default behavior when host is not specified, or 
is empty, is to connect to a Unix-domain socket in /tmp (or whatever 
socket directory was specified when PostgreSQL was built). On Windows, 
the default is to connect to localhost.

     A comma-separated list of host names is also accepted, in which 
case each host name in the list is tried in order; an empty item in the 
list selects the default behavior as explained above. See Section 
34.1.1.3 for details.
"

The simplistic explanation is that the socket is the "host".

> 
> 
> 
> Regards.
> 
> 
> 
> 
> 
> 

-- 
Adrian Klaver
[email protected]







view thread (6+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: issue with reading hostname
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox