Re: BUG #17454: Using psql without ipv4 address,the inet_server_port do not return PORT. - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: BUG #17454: Using psql without ipv4 address,the inet_server_port do not return PORT.
Date
Msg-id CAKFQuwZy=KscPcsXbRsutx5AcAxJSYMjku_avuP=LmNoGAxpsA@mail.gmail.com
Whole thread Raw
In response to Re: BUG #17454: Using psql without ipv4 address,the inet_server_port do not return PORT.  (Francisco Olarte <folarte@peoplecall.com>)
Responses Re: BUG #17454: Using psql without ipv4 address,the inet_server_port do not return PORT.
List pgsql-bugs
On Sun, Apr 3, 2022 at 8:36 AM Francisco Olarte <folarte@peoplecall.com> wrote:
On Sun, 3 Apr 2022 at 16:50, Wong Simon <thbytwo@live.cn> wrote:
> If I run multiple instances on one server with local socket, how can I distinguish them?I think the port is need.

You distinguish them by the socket NAME whose "extension" is the port
as a decimal string. The socket name is derived from the port option,
but it is not a port. It's clearly specified:

Resorting to string parsing is never desirable, nor is it necessary here.

But if you just need to distinguish instance on diferent ports, query
the "port" configuration parameter, IIRC this is unique ( although may
be you can somehow reuse it with careful usage of listen_addresses and
unix_socket_directories ).


Per the docs It is indeed single-valued.  I don't know what "reuse" would mean in this context but both sockets and IP have a specific usage of this setting's value that the DBA cannot alter.

One could also inspect data_directory, it has the same "unique per cluster on the same machine" property.

The function inet_server_addr() can help to distinguish which machine if there are multiple.  Though what "local" means may be a problem.  I suppose what is useful depends on "why" one needs to distinguish them.

David J.

pgsql-bugs by date:

Previous
From: Francisco Olarte
Date:
Subject: Re: BUG #17454: Using psql without ipv4 address,the inet_server_port do not return PORT.
Next
From: Francisco Olarte
Date:
Subject: Re: BUG #17454: Using psql without ipv4 address,the inet_server_port do not return PORT.