@@ -1012,7 +1012,7 @@ connectFailureMessage(PGconn *conn, int errorno)
10121012#endif /* HAVE_UNIX_SOCKETS */
10131013{
10141014char host_addr [NI_MAXHOST ];
1015- bool display_host_addr ;
1015+ const char * displayed_host ;
10161016struct sockaddr_storage * addr = & conn -> raddr .addr ;
10171017
10181018/*
@@ -1042,30 +1042,36 @@ connectFailureMessage(PGconn *conn, int errorno)
10421042else
10431043strcpy (host_addr , "???");
10441044
1045+ if (conn -> pghostaddr && conn -> pghostaddr [0 ]!= '\0' )
1046+ displayed_host = conn -> pghostaddr ;
1047+ else if (conn -> pghost && conn -> pghost [0 ]!= '\0' )
1048+ displayed_host = conn -> pghost ;
1049+ else
1050+ displayed_host = DefaultHost ;
1051+
10451052/*
10461053 * If the user did not supply an IP address using 'hostaddr', and
10471054 * 'host' was missing or does not match our lookup, display the
10481055 * looked-up IP address.
10491056 */
1050- display_host_addr = (conn -> pghostaddr == NULL )&&
1051- ((conn -> pghost == NULL )||
1052- (strcmp (conn -> pghost ,host_addr )!= 0 ));
1053-
1054- appendPQExpBuffer (& conn -> errorMessage ,
1055- libpq_gettext ("could not connect to server: %s\n"
1056- "\tIs the server running on host \"%s\"%s%s%s and accepting\n"
1057- "\tTCP/IP connections on port %s?\n" ),
1058- SOCK_STRERROR (errorno ,sebuf ,sizeof (sebuf )),
1059- (conn -> pghostaddr && conn -> pghostaddr [0 ]!= '\0' )
1060- ?conn -> pghostaddr
1061- : (conn -> pghost && conn -> pghost [0 ]!= '\0' )
1062- ?conn -> pghost
1063- :DefaultHost ,
1064- /* display the IP address only if not already output */
1065- display_host_addr ?" (" :"" ,
1066- display_host_addr ?host_addr :"" ,
1067- display_host_addr ?")" :"" ,
1068- conn -> pgport );
1057+ if ((conn -> pghostaddr == NULL )&&
1058+ (conn -> pghost == NULL || strcmp (conn -> pghost ,host_addr )!= 0 ))
1059+ appendPQExpBuffer (& conn -> errorMessage ,
1060+ libpq_gettext ("could not connect to server: %s\n"
1061+ "\tIs the server running on host \"%s\" (%s) and accepting\n"
1062+ "\tTCP/IP connections on port %s?\n" ),
1063+ SOCK_STRERROR (errorno ,sebuf ,sizeof (sebuf )),
1064+ displayed_host ,
1065+ host_addr ,
1066+ conn -> pgport );
1067+ else
1068+ appendPQExpBuffer (& conn -> errorMessage ,
1069+ libpq_gettext ("could not connect to server: %s\n"
1070+ "\tIs the server running on host \"%s\" and accepting\n"
1071+ "\tTCP/IP connections on port %s?\n" ),
1072+ SOCK_STRERROR (errorno ,sebuf ,sizeof (sebuf )),
1073+ displayed_host ,
1074+ conn -> pgport );
10691075}
10701076}
10711077