Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rz0El-001Th9-PD for pgsql-general@arkaria.postgresql.org; Mon, 22 Apr 2024 20:26:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rz0Ej-00FjGn-Vf for pgsql-general@arkaria.postgresql.org; Mon, 22 Apr 2024 20:26:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rz0Ej-00FjEY-KM for pgsql-general@lists.postgresql.org; Mon, 22 Apr 2024 20:26:01 +0000 Received: from fhigh4-smtp.messagingengine.com ([103.168.172.155]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rz0Ec-002Onb-Iz for pgsql-general@lists.postgresql.org; Mon, 22 Apr 2024 20:26:01 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 1A2891140121; Mon, 22 Apr 2024 16:25:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 22 Apr 2024 16:25:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1713817553; x=1713903953; bh=i/uToj1C+6plOSkcEqoiGrzjl39pmufu2nUa6a9TmzA=; b= kgwcicm9bqaiEcsW7ihigZyQj3VJJzq8APucbztd/K+vGeanQzl6gE69SpLXEcRk kNA3G2X4BG7CTXkf+LuZZXfaMcK6q+wheb0f9Q/DiGpKAeZP53u3lu8bKMktvH61 avw0lXilhKfVyl/rgZaSjkLmH2+I7HI57OOpexiOY/OsG59myWJD/81kl00DqHfD yG4yXp49J6PWp/GPStVyWczH3Kk7i7NP+XDLTiIyjkqqPEJlfKJKxwLisC797NIz 15JeOMJzwIWrRwsAwqb3eXMgj71X9p84CZLCizmo5IhXKpHqum8c73WJPA6g4Der ll7I4u+SkJ68+iKWXgk9ng== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1713817553; x= 1713903953; bh=i/uToj1C+6plOSkcEqoiGrzjl39pmufu2nUa6a9TmzA=; b=j x0JrYyPa9b/jCB04RxrYgjqPrcqkmNXXi7NyJmMZh1ScC+5lo7X9KisLjZHKWPRD EPYUUEpcBbn7ikiC+9KKfaVhLy+zh+oiMS/50uafKxBMf9zANX4rUXMlNwO/Ippr nTs57sfpmQg7T8NyFxva+eqCPlmVF9nVHyxmqgHgkb2vAVf8U111MmaoK+/grZL0 kvE66SorJwrv2XoQXx7olJqX0at2oEYFRK0DzzUnVe+gxNcDeN7t2feQX3nO+KMG PwmPz33LOThn4eCWK5J7jRXthUz6kwZ9B8FkjWnRXnPJtS7umd6DsMu471tifcgr PckQkXBYYyRp6AVvRGdmA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudekledgudehtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuggftrfgrthhtvghrnhepleegveekkeekueeigfdtveeileeuhfefudefteek jeffkeejueejheegheegkedtnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrgh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughr ihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 22 Apr 2024 16:25:52 -0400 (EDT) Message-ID: <80e27b89-6a78-4191-a32c-0b7daf596880@aklaver.com> Date: Mon, 22 Apr 2024 13:25:51 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: issue with reading hostname To: Atul Kumar , pgsql-general References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 adrian.klaver@aklaver.com