Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nb3JI-0003pq-Bt for pgsql-bugs@arkaria.postgresql.org; Sun, 03 Apr 2022 16:42:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nb3JH-0000ST-2j for pgsql-bugs@arkaria.postgresql.org; Sun, 03 Apr 2022 16:42:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nb3JG-0000SK-RU for pgsql-bugs@lists.postgresql.org; Sun, 03 Apr 2022 16:42:38 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nb3JE-0002sk-HL for pgsql-bugs@lists.postgresql.org; Sun, 03 Apr 2022 16:42:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 233GgYbH1646106; Sun, 3 Apr 2022 12:42:34 -0400 From: Tom Lane To: Francisco Olarte cc: "David G. Johnston" , Wong Simon , "pgsql-bugs@lists.postgresql.org" Subject: Re: BUG #17454: Using psql without ipv4 address,the inet_server_port do not return PORT. In-reply-to: References: <17454-f120d78fa9c3013d@postgresql.org> Comments: In-reply-to Francisco Olarte message dated "Sun, 03 Apr 2022 18:28:46 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1646104.1649004154.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 03 Apr 2022 12:42:34 -0400 Message-ID: <1646105.1649004154@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Francisco Olarte writes: >> On Sun, 3 Apr 2022 at 16:50, Wong Simon wrote: >>> If I run multiple instances on one server with local socket, how can I= distinguish them?I think the port is need. > Port is single valued, what I meant is I'm not sure if using > socket_dir=3D/socka, listen_addr=3D127.0.0.1, data_dir=3D/dataA and > port=3D5432 plus socket_dir=3D/sockb, listen_addr=3D127.0.0.2, > data_dir=3D/datab and port=3D5432 would let you start two correctly > functioning instances in the same machine. I think relying on port for this purpose is misguided anyway. We've had requests in the past to let one postmaster listen on multiple different port numbers; I think the only reason it's not happened yet is nobody got excited enough to write a patch. Likewise, inet_server_addr() seems a bit shaky as a server identity value, since it's already possible to have a postmaster listening on multiple IP addresses. If you're trying to identify an installation uniquely, the machine name and data_directory are probably the best key. Getting a suitably unique machine name might be tricky. For localhost connections, though, you could ignore that. regards, tom lane