Re: PQHost() undefined behavior if connecting string contains bothhost and hostaddr types

Поиск
Список
Период
Сортировка
От Haribabu Kommi
Тема Re: PQHost() undefined behavior if connecting string contains bothhost and hostaddr types
Дата
Msg-id CAJrrPGegvjLY81JwmEDMSuADCcsAHx33fkpakSmBPszy8-tVAg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: PQHost() undefined behavior if connecting string contains bothhost and hostaddr types  (Michael Paquier <michael.paquier@gmail.com>)
Список pgsql-hackers


On Sun, Jan 14, 2018 at 9:44 PM, Michael Paquier <michael.paquier@gmail.com> wrote:
On Sun, Jan 14, 2018 at 02:19:26PM +1100, Haribabu Kommi wrote:
> While working on [1], we find out the inconsistency in PQHost() behavior
> if the connecting string that is passed to connect to the server contains
> multiple hosts with both host and hostaddr types. For example,
>
> host=host1,host2 hostaddr=127.0.0.1,127.0.0.1 port=5434,5432
>
> As the hostaddr is given preference when both host and hostaddr is
> specified, so the connection type for both addresses of the above
> conninfo is CHT_HOST_ADDRESS. So the PQhost() returns the
> conn->pghost value i.e "host1,host2" instead of the actual host that
> is connected.

During the discussion of adding the client-side connection parameters to
pg_stat_wal_receiver, which is useful when the client specifies multiple
hosts and ports, it has been discussed that introducing a new API in
libpq to get effective host, hostaddr and port values would be necessary
in order to get all the useful information wanted, however this has a
larger impact than initially thought as any user showing the host
information in psql's PROMPT would be equally confused. Any caller of
PQhost have the same problem.

> Instead of checking the connection type while returning the host
> details, it should check whether the host is NULL or not? with this
> change it returns the expected value for all the connection types.

I mentioned that on the other thread, but this seems like an improvement
to me, which leads to less confusion. See here for more details
regarding what we get today on HEAD:
https://www.postgresql.org/message-id/20180109011547.GE76418%40paquier.xyz


In the other thread of enhancing pg_stat_wal_receiver to display the remote
host, the details of why the hostaddr was added and reverted for and how it can be
changed now the PQhost() function to return the host and not the hostaddr is provided
in mail [1]. It will be useful to take some decision with the PQhost() function.

Added to the next open commitfest.



Regards,
Hari Babu
Fujitsu Australia

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

Предыдущее
От: Haribabu Kommi
Дата:
Сообщение: Re: [HACKERS] Pluggable storage
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] Parallel tuplesort (for parallel B-Tree index creation)