aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/startup.c7
-rw-r--r--src/interfaces/libpq/fe-connect.c12
2 files changed, 9 insertions, 10 deletions
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 656b9f11d75..4def5ccb944 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.106 2004/11/27 18:51:07 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.107 2004/12/28 23:17:41 tgl Exp $
*/
#include "postgres_fe.h"
@@ -159,11 +159,6 @@ main(int argc, char *argv[])
pset.getPassword = false;
#endif
-#ifndef HAVE_UNIX_SOCKETS
- /* default to localhost on platforms without unix sockets */
- options.host = "localhost";
-#endif
-
parse_psql_options(argc, argv, &options);
if (!pset.popt.topt.fieldSep)
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 57d7ee8e6ff..f28ca97e368 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.292 2004/12/02 23:20:19 tgl Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.293 2004/12/28 23:17:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -868,7 +868,7 @@ connectDBStart(PGconn *conn)
char portstr[128];
struct addrinfo *addrs = NULL;
struct addrinfo hint;
- const char *node = NULL;
+ const char *node;
int ret;
if (!conn)
@@ -907,15 +907,19 @@ connectDBStart(PGconn *conn)
node = conn->pghost;
hint.ai_family = AF_UNSPEC;
}
-#ifdef HAVE_UNIX_SOCKETS
else
{
+#ifdef HAVE_UNIX_SOCKETS
/* pghostaddr and pghost are NULL, so use Unix domain socket */
node = NULL;
hint.ai_family = AF_UNIX;
UNIXSOCK_PATH(portstr, portnum, conn->pgunixsocket);
- }
+#else
+ /* Without Unix sockets, default to localhost instead */
+ node = "localhost";
+ hint.ai_family = AF_UNSPEC;
#endif /* HAVE_UNIX_SOCKETS */
+ }
/* Use getaddrinfo_all() to resolve the address */
ret = getaddrinfo_all(node, portstr, &hint, &addrs);