Re: [HACKERS] Proposed patch to getaddrinfo.c to support - Mailing list pgsql-patches

From Andrew Dunstan
Subject Re: [HACKERS] Proposed patch to getaddrinfo.c to support
Date
Msg-id 430F982F.2030509@dunslane.net
Whole thread Raw
In response to Re: [HACKERS] Proposed patch to getaddrinfo.c to support  (Petr Jelinek <pjmodos@seznam.cz>)
Responses Re: [HACKERS] Proposed patch to getaddrinfo.c to support  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches

Petr Jelinek wrote:

>
> So I hope IPv6 episode is finally over :)
>

Almost :-)

The initdb code is failing because we didn't call WSAStartup() - this
just took me ages to track down. All the rest works.

The attached patch seems to do the trick.

cheers

andrew


Index: initdb.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/initdb/initdb.c,v
retrieving revision 1.96
diff -c -r1.96 initdb.c
*** initdb.c    25 Aug 2005 02:22:59 -0000    1.96
--- initdb.c    26 Aug 2005 22:28:48 -0000
***************
*** 1221,1226 ****
--- 1221,1237 ----
      {
          struct addrinfo *gai_result;
          struct addrinfo hints;
+         int err = 0;
+
+ #ifdef WIN32
+         /* need to call this before calling getaddrinfo */
+
+         WSADATA    wsaData;
+
+         err = WSAStartup(MAKEWORD(2,2),&wsaData);
+
+ #endif;
+

          /* for best results, this code should match parse_hba() */
          hints.ai_flags = AI_NUMERICHOST;
***************
*** 1232,1238 ****
          hints.ai_addr = NULL;
          hints.ai_next = NULL;

!         if (getaddrinfo("::1", NULL, &hints, &gai_result) != 0)
              conflines = replace_token(conflines,
                                        "host    all         all         ::1",
                                        "#host    all         all         ::1");
--- 1243,1249 ----
          hints.ai_addr = NULL;
          hints.ai_next = NULL;

!         if ( err != 0 || getaddrinfo("::1", NULL, &hints, &gai_result) != 0)
              conflines = replace_token(conflines,
                                        "host    all         all         ::1",
                                        "#host    all         all         ::1");

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: force C locale for temp regression installations
Next
From: "Matt A."
Date:
Subject: insert into table (column) values (nullif('',''));