Re: LibPQ doesn't say host=* translates to localhost

Поиск
Список
Период
Сортировка
От Francisco Olarte
Тема Re: LibPQ doesn't say host=* translates to localhost
Дата
Msg-id CA+bJJby53rMtH_4EQeKxXuedFedTgHQSH64+ik=_mCuai9J5mA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: LibPQ doesn't say host=* translates to localhost  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On Fri, 28 Jun 2024 at 18:56, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "David G. Johnston" <david.g.johnston@gmail.com> writes:
> > ping '*'
> > ping: *: Name or service not known
> > This is Ubuntu.
> Yeah, I see the same on a couple different Red Hat versions.  Very
> interesting, since it implies that ping is using something other than
> getaddrinfo(3) to resolve the hostname.  I'm not quite interested
> enough to go find out what, though.

Same in Debian, as expected.

But it picked my curiosity, so I did an ltrace:

$ sudo ltrace ping '*' |& fgrep addrinfo
getaddrinfo("*", nil, 0x7ffde84578c0, 0x7ffde84578a8) = -2

And did this little perl experiment....
>>> addrinfo.pl
use strict;
use Socket qw(:addrinfo);

sub U($) { $_[0] // 'undef'; }
sub M($) {
    my $h = shift;
    join ';', map { "$_=>".U($h->{$_}) }  sort keys %$h;
}

sub pai {
    my ($host, $service, $hints)=@_;
    printf "gai(%s,%s,{%s})\n",
    $host, U $service, M $hints;
    my ($err, @addr) = getaddrinfo($host, $service, $hints);
    printf "  err=%s\n", $err//'UNDEF';
    while(my ($i, $v)=each @addr) {
    printf "  a[%d]={%s},addr=%s\n",
        $i, M $v,
        unpack("h*",$v->{addr});
    }
}


pai('*',undef,{});
pai('*',undef,{family=>Socket::AF_INET});
pai('*',5432, {family=>Socket::AF_INET});
<<<
Which gives:
>>>
$ perl -w addrinfo.pl
gai(*,undef,{})
  err=Name or service not known
gai(*,undef,{family=>2})
  err=Name or service not known
gai(*,5432,{family=>2})
  err=
  a[0]={addr=>8;canonname=>undef;family=>2;protocol=>6;socktype=>1},addr=20005183f70000100000000000000000
  a[1]={addr=>8;canonname=>undef;family=>2;protocol=>17;socktype=>2},addr=20005183f70000100000000000000000
  a[2]={addr=>8;canonname=>undef;family=>2;protocol=>0;socktype=>3},addr=20005183f70000100000000000000000
<<<
I am not sure how to follow, or if perl uses glibc, and have to go
AFK, and I am not sure if it relates, but getaddrinfo may be doing
strange things.

Francisco Olarte.



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Laurenz Albe
Дата:
Сообщение: Re: BUG #18500: Detaching a partition with an index manually attached to the parent's index triggers Assert