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

From: Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: PQHost() undefined behavior if connecting string contains both host and hostaddr types
Date: 2018-03-23 14:49:28
Message-ID: CAJrrPGeS3N4COLqysJAcsEnmcX6zLKMHZbf2e7PWHPcEAQC+vg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 22, 2018 at 12:28 AM, Peter Eisentraut <
peter(dot)eisentraut(at)2ndquadrant(dot)com> wrote:

> On 3/21/18 03:40, Michael Paquier wrote:
> >>> Moreover, I wonder whether we shouldn't remove the branch where
> >>> conn->connhost is NULL. When would that be the case? The current
> >>> behavior is to sometimes return the actual host connected to, and
> >>> sometimes the host list. That doesn't make sense.
> >> Scenarios where the connection is not yet established, in that scenario
> >> the PQhost() can return the provided connection host information.
> >>
> >> Other than the above, it always returns the proper host details.
> > That remark is from me upthread. In the case of a non-established
> > connection, I think that we ought to return that.
>
> So, if the connection object is NULL, PQhost() returns NULL. While the
> connection is being established (whatever that means), it returns
> whatever was specified as host. And when the connection is established,
> it returns the host actually connected to. That seems pretty crazy. It
> should do only one or the other. Especially since there is, AFAICT, no
> way to know at run time whether the value it returned just then is one
> or the other.

OK.

Here I attached the updated patch that returns either the connected
host/hostaddr
or NULL in case if the connection is not established.

I removed the returning default host details, because the default host
details are also available with the connhost member itself.

Regards,
Hari Babu
Fujitsu Australia

Attachment Content-Type Size
PQhost-to-return-connected-host-and-hostaddr-details_v3.patch application/octet-stream 1.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Steele 2018-03-23 14:54:08 Re: [PATCH] Verify Checksums during Basebackups
Previous Message Julian Markwort 2018-03-23 14:45:15 Re: [PATCH] pg_hba.conf : new auth option : clientcert=verify-full