Re: fix psql \conninfo & \connect when using hostaddr

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Arthur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: fix psql \conninfo & \connect when using hostaddr
Date: 2019-06-12 12:44:49
Message-ID: alpine.DEB.2.21.1906121430280.13288@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
connect-fix-1.patch text/x-diff 2.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message tushar 2019-06-12 13:11:44 Re: [pg_rewind] cp: cannot stat ‘pg_wal/RECOVERYHISTORY’: No such file or directory
Previous Message Kuntal Ghosh 2019-06-12 12:44:41 Re: Adaptive query optimization