1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-16 16:42:29 +03:00

Make libpq default to localhost connections on machines without Unix-domain

sockets, rather than failing as it formerly did.  Revert the
thereby-obsoleted patch to make psql supply the localhost default.
This commit is contained in:
Tom Lane
2004-12-28 23:17:54 +00:00
parent 797c2b2501
commit d9236a69fc
4 changed files with 39 additions and 25 deletions

View File

@@ -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)

View File

@@ -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);