Re: BUG #17454: Using psql without ipv4 address,the inet_server_port do not return PORT.

Поиск
Список
Период
Сортировка
От Francisco Olarte
Тема Re: BUG #17454: Using psql without ipv4 address,the inet_server_port do not return PORT.
Дата
Msg-id CA+bJJbzPYe4py-dnzoKEQ9_m_rvduTs_8BSThwWPUUamSK18dQ@mail.gmail.com
обсуждение исходный текст
Ответ на 回复: BUG #17454: Using psql without ipv4 address,the inet_server_port do not return PORT.  (Wong Simon <thbytwo@live.cn>)
Ответы Re: BUG #17454: Using psql without ipv4 address,the inet_server_port do not return PORT.
Список pgsql-bugs
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:

inet_server_addr () → inet
Returns the IP address on which the server accepted the current
connection, or NULL if the current connection is via a Unix-domain
socket.

inet_server_port () → integer
Returns the IP port number on which the server accepted the current
connection, or NULL if the current connection is via a Unix-domain
socket.

I do not know if there is  an "unix_socket_path" option, as there can
be multiple sockets, may be those functions predate
unix_socket_directories being multivalued ( in TCP, with a single
socket listening on 0.0.0.0, you can have connection on different
local address, so it getsockname(2) is needed more ).

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 ).

Francisco Olarte.



В списке pgsql-bugs по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #17454: Using psql without ipv4 address,the inet_server_port do not return PORT.
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #17454: Using psql without ipv4 address,the inet_server_port do not return PORT.