Re: pg_getaddrinfo_all() with hintp=NULL - Mailing list pgsql-hackers

From Daniel Gustafsson
Subject Re: pg_getaddrinfo_all() with hintp=NULL
Date
Msg-id F0184841-2D72-463A-8D0A-BCECA8DAE66F@yesql.se
Whole thread Raw
In response to pg_getaddrinfo_all() with hintp=NULL  (Sergey Tatarintsev <s.tatarintsev@postgrespro.ru>)
Responses Re: pg_getaddrinfo_all() with hintp=NULL
List pgsql-hackers
> On 10 Nov 2025, at 06:14, Sergey Tatarintsev <s.tatarintsev@postgrespro.ru> wrote:

> I'm trying to use pg_getaddrinfo_all() with NULL hints, but got segfault.
> According to man(3) getaddrinfo, hints may be passed as NULL. In this case af_family
> is equivalent to AF_UNSPEC.

Right, but pg_getaddrinfo_all isn't getaddrinfo and doesn't claim to be.  Since
pg_getaddrinfo_all can return AF_UNIX as opposed to getaddrinfo, it's not clear
why hints == NULL should mean ipv4|ipv6 here.

Accepting NULL or also (subtly) breaks the API for pg_freeaddrinfo_all which is
defined to take ai_family from the hints passed to pg_getaddrinfo_all.  Now,
reading the code makes it obvious that it will work anyways, but at the very
least a patch to accept a NULL hint should update the function comment for
pg_freeaddrinfo_all.

--
Daniel Gustafsson




pgsql-hackers by date:

Previous
From: Florin Irion
Date:
Subject: Re: [PATCH] pg_get_domain_ddl: DDL reconstruction function for CREATE DOMAIN statement
Next
From: "Joel Jacobson"
Date:
Subject: Re: Optimize LISTEN/NOTIFY