Re: fix psql \conninfo & \connect when using hostaddr - Mailing list pgsql-hackers

From Fabien COELHO
Subject Re: fix psql \conninfo & \connect when using hostaddr
Date
Msg-id alpine.DEB.2.21.1906121430280.13288@lancre
Whole thread Raw
In response to Re: fix psql \conninfo & \connect when using hostaddr  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: fix psql \conninfo & \connect when using hostaddr
List pgsql-hackers
Hello,

> I got that. I'm working on it, and on the other issues you raised.
>
> The issue I see is what do we want when a name resolves to multiple 
> addresses. The answer is not fully obvious to me right now. I'll try to send 
> a patch over the week-end.

At Alvaro's request, here is a quick WIP patch, that does not do the right 
thing, because there is no simple way to know whether hostaddr was set at 
the libPQ level, so either we set it always, about which Noah complained, 
or we don't, about which someone else will complain quite easily, i.e. 
with this patch

   \c "host=foo hostaddr=ip"

connects to ip, but then

   \c

will reconnect to foo but ignore ip. Well, ISTM that this is back to the 
previous doubtful behavior, so at least it is not a regression, just the 
same bug:-)

A solution could be to have a PQdoestheconnectionuseshostaddr(conn) 
function, but I cannot say I'd be thrilled.

Another option would be to import PGconn full definition in 
"psql/command.c", but that would break the PQ interface, I cannot say I'd 
be thrilled either.

The patch returns host as defined by the user, but the regenerated 
hostaddr (aka connip), which is not an homogeneous behavior. PQhost should 
probably use connip if host was set as an ip, but that needs guessing.

The underlying issue is that the host/hostaddr stuff is not that easy to 
fix.

At least, after the patch the connection information (\conninfo) is still 
the right one, which is an improvement.

-- 
Fabien.
Attachment

pgsql-hackers by date:

Previous
From: Kuntal Ghosh
Date:
Subject: Re: Adaptive query optimization
Next
From: tushar
Date:
Subject: Re: [pg_rewind] cp: cannot stat ‘pg_wal/RECOVERYHISTORY’: No such file or directory