Tom Lane wrote:
Andrew Dunstan <[EMAIL PROTECTED]> writes:
Tom Lane wrote:
If you like, you can improve initdb to comment that line out if
getaddrinfo chokes on "::1", rather than believing HAVE_IPV6.
Good idea. Here's a patch for that. Rather than commenting it out I used
the slightly newer initdb facility to remove it and the associated
comment line altogether.
Hm, is that really better than just commenting it out? Particularly
on Windows, where we could imagine someone installing a newer version
of the relevant DLL and then wanting to use IPv6. Seems to me that
leaving the line present but commented out is the right thing, because
it documents how things should look for IPv6.
Seemed to me slightly less potentially confusing, but I don't feel
strongly. Try this instead if you prefer.
cheers
andrew
Index: src/bin/initdb/initdb.c
===================================================================
RCS file: /home/cvsmirror/pgsql/src/bin/initdb/initdb.c,v
retrieving revision 1.94
diff -c -r1.94 initdb.c
*** src/bin/initdb/initdb.c 2 Aug 2005 15:16:27 -0000 1.94
--- src/bin/initdb/initdb.c 22 Aug 2005 13:35:22 -0000
***************
*** 1157,1162 ****
--- 1157,1174 ----
char **conflines;
char repltok[100];
char path[MAXPGPATH];
+
+ struct addrinfo *gai_result;
+ struct addrinfo hints;
+
+ hints.ai_flags = AI_NUMERICHOST;
+ hints.ai_family = PF_UNSPEC;
+ hints.ai_socktype = 0;
+ hints.ai_protocol = 0;
+ hints.ai_addrlen = 0;
+ hints.ai_canonname = NULL;
+ hints.ai_addr = NULL;
+ hints.ai_next = NULL;
fputs(_("creating configuration files ... "), stdout);
fflush(stdout);
***************
*** 1210,1220 ****
conflines = replace_token(conflines,"@remove-line-for-nolocal@","");
#endif
! #ifndef HAVE_IPV6
! conflines = replace_token(conflines,
! "host all
all ::1",
! "#host all
all ::1");
! #endif
/* Replace default authentication methods */
conflines = replace_token(conflines,
--- 1222,1239 ----
conflines = replace_token(conflines,"@remove-line-for-nolocal@","");
#endif
!
! /*
! * runtime test for IPv6 support (previously compile time test).
! * this lets us build on hosts with IPv6 support and run
! * on hosts without, especially on Windows.
! *
! */
! if (getaddrinfo("::1", NULL, &hints, &gai_result) != 0)
! conflines = replace_token(conflines,
! "host all
all ::1",
! "#host all
all ::1");
!
/* Replace default authentication methods */
conflines = replace_token(conflines,
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend