PQHost() undefined behavior if connecting string contains both hostand hostaddr types - Mailing list pgsql-hackers

From Haribabu Kommi
Subject PQHost() undefined behavior if connecting string contains both hostand hostaddr types
Date
Msg-id CAJrrPGdrC4JTJQ4d7PT1Bi7K8nW91XPMPQ5kJ3GWK3ts+W-35g@mail.gmail.com
Whole thread Raw
Responses Re: PQHost() undefined behavior if connecting string contains bothhost and hostaddr types
Re: PQHost() undefined behavior if connecting string contains bothhost and hostaddr types
List pgsql-hackers

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.

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.

Attachment

pgsql-hackers by date:

Previous
From: Everaldo Canuto
Date:
Subject: Re: proposal: alternative psql commands quit and exit
Next
From: Chapman Flack
Date:
Subject: Re: proposal: alternative psql commands quit and exit