On Mon, Oct 12, 2015 at 08:07:37PM -0400, Tom Lane wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
> > On Fri, Oct 9, 2015 at 10:16 PM, Noah Misch <noah@leadboat.com> wrote:
> >> The listening side is in good shape today. This thread is about the address
> >> that pg_ctl uses in PQping("host=..."). Listening on 0.0.0.0 is portable.
> >> PQping("host='0.0.0.0'") relies on non-portable semantics in the underlying
> >> connect() syscall. PQping("host='127.0.0.1'") is a portable substitute.
>
> > Ah. So in this case 0.0.0.0 is interpreted to mean "any IP that's a
> > way to reach the local host", and using 127.0.0.1 makes sense because
> > we know that will always be one of them? I could buy that line of
> > reasoning.
>
> I do *not* buy that we can safely replace "localhost" by "127.0.0.1".
Nobody proposed that. The word "localhost" did not appear in this thread.
> Consider a system that's only set up with IPv6 local addressing.
>
> AFAICS the complaint in this bug is about a system with broken DNS (ie,
> unable to resolve "localhost" properly, which is something mandated by
> relevant RFCs, I believe).
The original post used only "0.0.0.0" and "::", not "localhost" or anything
else entailing name resolution. As I wrote above, Kondo proposed for pg_ctl
to use PQping("host='127.0.0.1'") in place of PQping("host='0.0.0.0'").
That's all. pg_ctl would continue to use PQping("host='localhost'") where
it's doing so today. A patch that changes the 0.0.0.0 case in this way should
also change PQping("host='::'") to PQping("host='::1'"); I suspect that was
implicit in the original proposal.
nm