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 45893974-FBC4-4EF5-9900-3565C361F5CA@yesql.se
Whole thread Raw
In response to Re: pg_getaddrinfo_all() with hintp=NULL  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: pg_getaddrinfo_all() with hintp=NULL
List pgsql-hackers
> On 13 Nov 2025, at 01:17, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Daniel Gustafsson <daniel@yesql.se> writes:

>> It's still not clear to ne that we should make pg_getaddr_info() mimic the API
>> of getaddrinfo since it's not a thin wrapper over getaddrinfo.  The alternative
>> option would be to return EAI_FAIL on a null hint and force the caller to
>> provide an AF_UNSPEC if that is what is indeed asked for.
>
> We already reject null hints (by crashing), and have done for decades.
> I don't think there's anything very wrong with the current code, and I
> don't really see that the proposed patch is an improvement.  If
> anything, I'd just add a comment to pg_getaddrinfo_all saying that
> unlike bare getaddrinfo, we require a valid hintp.

That's my thinking as well, unless objected to I will apply the below which use
the same phrasing as the comment on pg_getnameinfo_all.

diff --git a/src/common/ip.c b/src/common/ip.c
index 0e7897a5c8f..71e5934557e 100644
--- a/src/common/ip.c
+++ b/src/common/ip.c
@@ -48,6 +48,9 @@ static int    getnameinfo_unix(const struct sockaddr_un *sa, int salen,

 /*
  *     pg_getaddrinfo_all - get address info for Unix, IPv4 and IPv6 sockets
+ *
+ * The API of this routine differs from the standard getaddrinfo() definition
+ * in that it requires a valid hintp, a null pointer is not allowed.
  */
 int
 pg_getaddrinfo_all(const char *hostname, const char *servname,

--
Daniel Gustafsson




pgsql-hackers by date:

Previous
From: Alexander Kukushkin
Date:
Subject: Re: Issue with logical replication slot during switchover
Next
From: Ivan Kovmir
Date:
Subject: Comment possible shared memory re-attach failure