Remove HAVE_UNIX_SOCKETS.

Since HAVE_UNIX_SOCKETS is now defined unconditionally, remove the macro
and drop a small amount of dead code.

The last known systems not to have them (as far as I know at least) were
QNX, which we de-supported years ago, and Windows, which now has them.

If a new OS ever shows up with the POSIX sockets API but without working
AF_UNIX, it'll presumably still be able to compile the code, and fail at
runtime with an unsupported address family error.  We might want to
consider adding a HINT that you should turn off the option to use it if
your network stack doesn't support it at that point, but it doesn't seem
worth making the relevant code conditional at compile time.

Also adjust a couple of places in the docs and comments that referred to
builds without Unix-domain sockets, since there aren't any.  Windows
still gets a special mention in those places, though, because we don't
try to use them by default there yet.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Discussion: https://postgr.es/m/CA%2BhUKG%2BL_3brvh%3D8e0BW_VfX9h7MtwgN%3DnFHP5o7X2oZucY9dg%40mail.gmail.com
This commit is contained in:
Thomas Munro 2022-08-14 08:46:53 +12:00
parent e07ebd4b6e
commit f558088285
13 changed files with 12 additions and 130 deletions

View File

@ -1070,9 +1070,8 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
specified, or is empty, is to connect to a Unix-domain specified, or is empty, is to connect to a Unix-domain
socket<indexterm><primary>Unix domain socket</primary></indexterm> in socket<indexterm><primary>Unix domain socket</primary></indexterm> in
<filename>/tmp</filename> (or whatever socket directory was specified <filename>/tmp</filename> (or whatever socket directory was specified
when <productname>PostgreSQL</productname> was built). On Windows and when <productname>PostgreSQL</productname> was built). On Windows,
on machines without Unix-domain sockets, the default is to connect to the default is to connect to <literal>localhost</literal>.
<literal>localhost</literal>.
</para> </para>
<para> <para>
A comma-separated list of host names is also accepted, in which case A comma-separated list of host names is also accepted, in which case
@ -1152,8 +1151,8 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
<para> <para>
Without either a host name or host address, Without either a host name or host address,
<application>libpq</application> will connect using a local <application>libpq</application> will connect using a local
Unix-domain socket; or on Windows and on machines without Unix-domain Unix-domain socket; or on Windows, it will attempt to connect to
sockets, it will attempt to connect to <literal>localhost</literal>. <literal>localhost</literal>.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@ -656,7 +656,7 @@ EOF
of these options are required; there are useful defaults. If you omit the host of these options are required; there are useful defaults. If you omit the host
name, <application>psql</application> will connect via a Unix-domain socket name, <application>psql</application> will connect via a Unix-domain socket
to a server on the local host, or via TCP/IP to <literal>localhost</literal> on to a server on the local host, or via TCP/IP to <literal>localhost</literal> on
machines that don't have Unix-domain sockets. The default port number is Windows. The default port number is
determined at compile time. determined at compile time.
Since the database server uses the same default, you will not have Since the database server uses the same default, you will not have
to specify the port in most cases. The default user name is your to specify the port in most cases. The default user name is your

View File

@ -973,17 +973,7 @@ parse_hba_line(TokenizedAuthLine *tok_line, int elevel)
token = linitial(tokens); token = linitial(tokens);
if (strcmp(token->string, "local") == 0) if (strcmp(token->string, "local") == 0)
{ {
#ifdef HAVE_UNIX_SOCKETS
parsedline->conntype = ctLocal; parsedline->conntype = ctLocal;
#else
ereport(elevel,
(errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("local connections are not supported by this build"),
errcontext("line %d of configuration file \"%s\"",
line_num, HbaFileName)));
*err_msg = "local connections are not supported by this build";
return NULL;
#endif
} }
else if (strcmp(token->string, "host") == 0 || else if (strcmp(token->string, "host") == 0 ||
strcmp(token->string, "hostssl") == 0 || strcmp(token->string, "hostssl") == 0 ||

View File

@ -149,10 +149,8 @@ static void socket_putmessage_noblock(char msgtype, const char *s, size_t len);
static int internal_putbytes(const char *s, size_t len); static int internal_putbytes(const char *s, size_t len);
static int internal_flush(void); static int internal_flush(void);
#ifdef HAVE_UNIX_SOCKETS
static int Lock_AF_UNIX(const char *unixSocketDir, const char *unixSocketPath); static int Lock_AF_UNIX(const char *unixSocketDir, const char *unixSocketPath);
static int Setup_AF_UNIX(const char *sock_path); static int Setup_AF_UNIX(const char *sock_path);
#endif /* HAVE_UNIX_SOCKETS */
static const PQcommMethods PqCommSocketMethods = { static const PQcommMethods PqCommSocketMethods = {
socket_comm_reset, socket_comm_reset,
@ -334,10 +332,7 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
struct addrinfo hint; struct addrinfo hint;
int listen_index = 0; int listen_index = 0;
int added = 0; int added = 0;
#ifdef HAVE_UNIX_SOCKETS
char unixSocketPath[MAXPGPATH]; char unixSocketPath[MAXPGPATH];
#endif
#if !defined(WIN32) || defined(IPV6_V6ONLY) #if !defined(WIN32) || defined(IPV6_V6ONLY)
int one = 1; int one = 1;
#endif #endif
@ -348,7 +343,6 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
hint.ai_flags = AI_PASSIVE; hint.ai_flags = AI_PASSIVE;
hint.ai_socktype = SOCK_STREAM; hint.ai_socktype = SOCK_STREAM;
#ifdef HAVE_UNIX_SOCKETS
if (family == AF_UNIX) if (family == AF_UNIX)
{ {
/* /*
@ -369,7 +363,6 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
service = unixSocketPath; service = unixSocketPath;
} }
else else
#endif /* HAVE_UNIX_SOCKETS */
{ {
snprintf(portNumberStr, sizeof(portNumberStr), "%d", portNumber); snprintf(portNumberStr, sizeof(portNumberStr), "%d", portNumber);
service = portNumberStr; service = portNumberStr;
@ -427,11 +420,9 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
familyDesc = _("IPv6"); familyDesc = _("IPv6");
break; break;
#endif #endif
#ifdef HAVE_UNIX_SOCKETS
case AF_UNIX: case AF_UNIX:
familyDesc = _("Unix"); familyDesc = _("Unix");
break; break;
#endif
default: default:
snprintf(familyDescBuf, sizeof(familyDescBuf), snprintf(familyDescBuf, sizeof(familyDescBuf),
_("unrecognized address family %d"), _("unrecognized address family %d"),
@ -441,11 +432,9 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
} }
/* set up text form of address for log messages */ /* set up text form of address for log messages */
#ifdef HAVE_UNIX_SOCKETS
if (addr->ai_family == AF_UNIX) if (addr->ai_family == AF_UNIX)
addrDesc = unixSocketPath; addrDesc = unixSocketPath;
else else
#endif
{ {
pg_getnameinfo_all((const struct sockaddr_storage *) addr->ai_addr, pg_getnameinfo_all((const struct sockaddr_storage *) addr->ai_addr,
addr->ai_addrlen, addr->ai_addrlen,
@ -540,7 +529,6 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
continue; continue;
} }
#ifdef HAVE_UNIX_SOCKETS
if (addr->ai_family == AF_UNIX) if (addr->ai_family == AF_UNIX)
{ {
if (Setup_AF_UNIX(service) != STATUS_OK) if (Setup_AF_UNIX(service) != STATUS_OK)
@ -549,7 +537,6 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
break; break;
} }
} }
#endif
/* /*
* Select appropriate accept-queue length limit. PG_SOMAXCONN is only * Select appropriate accept-queue length limit. PG_SOMAXCONN is only
@ -572,13 +559,11 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
continue; continue;
} }
#ifdef HAVE_UNIX_SOCKETS
if (addr->ai_family == AF_UNIX) if (addr->ai_family == AF_UNIX)
ereport(LOG, ereport(LOG,
(errmsg("listening on Unix socket \"%s\"", (errmsg("listening on Unix socket \"%s\"",
addrDesc))); addrDesc)));
else else
#endif
ereport(LOG, ereport(LOG,
/* translator: first %s is IPv4 or IPv6 */ /* translator: first %s is IPv4 or IPv6 */
(errmsg("listening on %s address \"%s\", port %d", (errmsg("listening on %s address \"%s\", port %d",
@ -597,8 +582,6 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
} }
#ifdef HAVE_UNIX_SOCKETS
/* /*
* Lock_AF_UNIX -- configure unix socket file path * Lock_AF_UNIX -- configure unix socket file path
*/ */
@ -699,7 +682,6 @@ Setup_AF_UNIX(const char *sock_path)
} }
return STATUS_OK; return STATUS_OK;
} }
#endif /* HAVE_UNIX_SOCKETS */
/* /*

View File

@ -1297,7 +1297,6 @@ PostmasterMain(int argc, char *argv[])
} }
#endif #endif
#ifdef HAVE_UNIX_SOCKETS
if (Unix_socket_directories) if (Unix_socket_directories)
{ {
char *rawstring; char *rawstring;
@ -1347,7 +1346,6 @@ PostmasterMain(int argc, char *argv[])
list_free_deep(elemlist); list_free_deep(elemlist);
pfree(rawstring); pfree(rawstring);
} }
#endif
/* /*
* check that we have some socket to listen on * check that we have some socket to listen on

View File

@ -4452,11 +4452,7 @@ static struct config_string ConfigureNamesString[] =
GUC_LIST_INPUT | GUC_LIST_QUOTE | GUC_SUPERUSER_ONLY GUC_LIST_INPUT | GUC_LIST_QUOTE | GUC_SUPERUSER_ONLY
}, },
&Unix_socket_directories, &Unix_socket_directories,
#ifdef HAVE_UNIX_SOCKETS
DEFAULT_PGSOCKET_DIR, DEFAULT_PGSOCKET_DIR,
#else
"",
#endif
NULL, NULL, NULL NULL, NULL, NULL
}, },

View File

@ -242,9 +242,6 @@ static char backend_exec[MAXPGPATH];
static char **replace_token(char **lines, static char **replace_token(char **lines,
const char *token, const char *replacement); const char *token, const char *replacement);
#ifndef HAVE_UNIX_SOCKETS
static char **filter_lines_with_token(char **lines, const char *token);
#endif
static char **readfile(const char *path); static char **readfile(const char *path);
static void writefile(char *path, char **lines); static void writefile(char *path, char **lines);
static FILE *popen_check(const char *command, const char *mode); static FILE *popen_check(const char *command, const char *mode);
@ -418,36 +415,6 @@ replace_token(char **lines, const char *token, const char *replacement)
return result; return result;
} }
/*
* make a copy of lines without any that contain the token
*
* a sort of poor man's grep -v
*/
#ifndef HAVE_UNIX_SOCKETS
static char **
filter_lines_with_token(char **lines, const char *token)
{
int numlines = 1;
int i,
src,
dst;
char **result;
for (i = 0; lines[i]; i++)
numlines++;
result = (char **) pg_malloc(numlines * sizeof(char *));
for (src = 0, dst = 0; src < numlines; src++)
{
if (lines[src] == NULL || strstr(lines[src], token) == NULL)
result[dst++] = lines[src];
}
return result;
}
#endif
/* /*
* get the lines from a text file * get the lines from a text file
*/ */
@ -1045,12 +1012,8 @@ setup_config(void)
n_buffers * (BLCKSZ / 1024)); n_buffers * (BLCKSZ / 1024));
conflines = replace_token(conflines, "#shared_buffers = 128MB", repltok); conflines = replace_token(conflines, "#shared_buffers = 128MB", repltok);
#ifdef HAVE_UNIX_SOCKETS
snprintf(repltok, sizeof(repltok), "#unix_socket_directories = '%s'", snprintf(repltok, sizeof(repltok), "#unix_socket_directories = '%s'",
DEFAULT_PGSOCKET_DIR); DEFAULT_PGSOCKET_DIR);
#else
snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''");
#endif
conflines = replace_token(conflines, "#unix_socket_directories = '/tmp'", conflines = replace_token(conflines, "#unix_socket_directories = '/tmp'",
repltok); repltok);
@ -1210,11 +1173,7 @@ setup_config(void)
conflines = readfile(hba_file); conflines = readfile(hba_file);
#ifndef HAVE_UNIX_SOCKETS
conflines = filter_lines_with_token(conflines, "@remove-line-for-nolocal@");
#else
conflines = replace_token(conflines, "@remove-line-for-nolocal@", ""); conflines = replace_token(conflines, "@remove-line-for-nolocal@", "");
#endif
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6

View File

@ -444,7 +444,7 @@ adjust_data_dir(ClusterInfo *cluster)
void void
get_sock_dir(ClusterInfo *cluster, bool live_check) get_sock_dir(ClusterInfo *cluster, bool live_check)
{ {
#if defined(HAVE_UNIX_SOCKETS) && !defined(WIN32) #if !defined(WIN32)
if (!live_check) if (!live_check)
cluster->sockdir = user_opts.socketdir; cluster->sockdir = user_opts.socketdir;
else else
@ -490,7 +490,7 @@ get_sock_dir(ClusterInfo *cluster, bool live_check)
pg_log(PG_WARNING, "user-supplied old port number %hu corrected to %hu", pg_log(PG_WARNING, "user-supplied old port number %hu corrected to %hu",
orig_port, cluster->port); orig_port, cluster->port);
} }
#else /* !HAVE_UNIX_SOCKETS || WIN32 */ #else /* WIN32 */
cluster->sockdir = NULL; cluster->sockdir = NULL;
#endif #endif
} }

View File

@ -212,7 +212,7 @@ start_postmaster(ClusterInfo *cluster, bool report_and_exit_on_error)
socket_string[0] = '\0'; socket_string[0] = '\0';
#if defined(HAVE_UNIX_SOCKETS) && !defined(WIN32) #if !defined(WIN32)
/* prevent TCP/IP connections, restrict socket access */ /* prevent TCP/IP connections, restrict socket access */
strcat(socket_string, strcat(socket_string,
" -c listen_addresses='' -c unix_socket_permissions=0700"); " -c listen_addresses='' -c unix_socket_permissions=0700");

View File

@ -38,7 +38,6 @@
#ifdef HAVE_UNIX_SOCKETS
static int getaddrinfo_unix(const char *path, static int getaddrinfo_unix(const char *path,
const struct addrinfo *hintsp, const struct addrinfo *hintsp,
struct addrinfo **result); struct addrinfo **result);
@ -47,7 +46,6 @@ static int getnameinfo_unix(const struct sockaddr_un *sa, int salen,
char *node, int nodelen, char *node, int nodelen,
char *service, int servicelen, char *service, int servicelen,
int flags); int flags);
#endif
/* /*
@ -62,10 +60,8 @@ pg_getaddrinfo_all(const char *hostname, const char *servname,
/* not all versions of getaddrinfo() zero *result on failure */ /* not all versions of getaddrinfo() zero *result on failure */
*result = NULL; *result = NULL;
#ifdef HAVE_UNIX_SOCKETS
if (hintp->ai_family == AF_UNIX) if (hintp->ai_family == AF_UNIX)
return getaddrinfo_unix(servname, hintp, result); return getaddrinfo_unix(servname, hintp, result);
#endif
/* NULL has special meaning to getaddrinfo(). */ /* NULL has special meaning to getaddrinfo(). */
rc = getaddrinfo((!hostname || hostname[0] == '\0') ? NULL : hostname, rc = getaddrinfo((!hostname || hostname[0] == '\0') ? NULL : hostname,
@ -87,7 +83,6 @@ pg_getaddrinfo_all(const char *hostname, const char *servname,
void void
pg_freeaddrinfo_all(int hint_ai_family, struct addrinfo *ai) pg_freeaddrinfo_all(int hint_ai_family, struct addrinfo *ai)
{ {
#ifdef HAVE_UNIX_SOCKETS
if (hint_ai_family == AF_UNIX) if (hint_ai_family == AF_UNIX)
{ {
/* struct was built by getaddrinfo_unix (see pg_getaddrinfo_all) */ /* struct was built by getaddrinfo_unix (see pg_getaddrinfo_all) */
@ -101,7 +96,6 @@ pg_freeaddrinfo_all(int hint_ai_family, struct addrinfo *ai)
} }
} }
else else
#endif /* HAVE_UNIX_SOCKETS */
{ {
/* struct was built by getaddrinfo() */ /* struct was built by getaddrinfo() */
if (ai != NULL) if (ai != NULL)
@ -126,14 +120,12 @@ pg_getnameinfo_all(const struct sockaddr_storage *addr, int salen,
{ {
int rc; int rc;
#ifdef HAVE_UNIX_SOCKETS
if (addr && addr->ss_family == AF_UNIX) if (addr && addr->ss_family == AF_UNIX)
rc = getnameinfo_unix((const struct sockaddr_un *) addr, salen, rc = getnameinfo_unix((const struct sockaddr_un *) addr, salen,
node, nodelen, node, nodelen,
service, servicelen, service, servicelen,
flags); flags);
else else
#endif
rc = getnameinfo((const struct sockaddr *) addr, salen, rc = getnameinfo((const struct sockaddr *) addr, salen,
node, nodelen, node, nodelen,
service, servicelen, service, servicelen,
@ -151,8 +143,6 @@ pg_getnameinfo_all(const struct sockaddr_storage *addr, int salen,
} }
#if defined(HAVE_UNIX_SOCKETS)
/* ------- /* -------
* getaddrinfo_unix - get unix socket info using IPv6-compatible API * getaddrinfo_unix - get unix socket info using IPv6-compatible API
* *
@ -286,4 +276,3 @@ getnameinfo_unix(const struct sockaddr_un *sa, int salen,
return 0; return 0;
} }
#endif /* HAVE_UNIX_SOCKETS */

View File

@ -503,7 +503,4 @@ extern bool wait_result_is_any_signal(int exit_status, bool include_command_not_
#define HAVE_SYMLINK 1 #define HAVE_SYMLINK 1
#endif #endif
/* Interfaces that we assume that all systems have. */
#define HAVE_UNIX_SOCKETS 1
#endif /* PG_PORT_H */ #endif /* PG_PORT_H */

View File

@ -1102,10 +1102,8 @@ connectOptions2(PGconn *conn)
else if (ch->host != NULL && ch->host[0] != '\0') else if (ch->host != NULL && ch->host[0] != '\0')
{ {
ch->type = CHT_HOST_NAME; ch->type = CHT_HOST_NAME;
#ifdef HAVE_UNIX_SOCKETS
if (is_unixsock_path(ch->host)) if (is_unixsock_path(ch->host))
ch->type = CHT_UNIX_SOCKET; ch->type = CHT_UNIX_SOCKET;
#endif
} }
else else
{ {
@ -1115,14 +1113,12 @@ connectOptions2(PGconn *conn)
* This bit selects the default host location. If you change * This bit selects the default host location. If you change
* this, see also pg_regress. * this, see also pg_regress.
*/ */
#ifdef HAVE_UNIX_SOCKETS
if (DEFAULT_PGSOCKET_DIR[0]) if (DEFAULT_PGSOCKET_DIR[0])
{ {
ch->host = strdup(DEFAULT_PGSOCKET_DIR); ch->host = strdup(DEFAULT_PGSOCKET_DIR);
ch->type = CHT_UNIX_SOCKET; ch->type = CHT_UNIX_SOCKET;
} }
else else
#endif
{ {
ch->host = strdup(DefaultHost); ch->host = strdup(DefaultHost);
ch->type = CHT_HOST_NAME; ch->type = CHT_HOST_NAME;
@ -1684,7 +1680,6 @@ getHostaddr(PGconn *conn, char *host_addr, int host_addr_len)
static void static void
emitHostIdentityInfo(PGconn *conn, const char *host_addr) emitHostIdentityInfo(PGconn *conn, const char *host_addr)
{ {
#ifdef HAVE_UNIX_SOCKETS
if (conn->raddr.addr.ss_family == AF_UNIX) if (conn->raddr.addr.ss_family == AF_UNIX)
{ {
char service[NI_MAXHOST]; char service[NI_MAXHOST];
@ -1698,7 +1693,6 @@ emitHostIdentityInfo(PGconn *conn, const char *host_addr)
service); service);
} }
else else
#endif /* HAVE_UNIX_SOCKETS */
{ {
const char *displayed_host; const char *displayed_host;
const char *displayed_port; const char *displayed_port;
@ -1748,12 +1742,10 @@ connectFailureMessage(PGconn *conn, int errorno)
"%s\n", "%s\n",
SOCK_STRERROR(errorno, sebuf, sizeof(sebuf))); SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)));
#ifdef HAVE_UNIX_SOCKETS
if (conn->raddr.addr.ss_family == AF_UNIX) if (conn->raddr.addr.ss_family == AF_UNIX)
appendPQExpBufferStr(&conn->errorMessage, appendPQExpBufferStr(&conn->errorMessage,
libpq_gettext("\tIs the server running locally and accepting connections on that socket?\n")); libpq_gettext("\tIs the server running locally and accepting connections on that socket?\n"));
else else
#endif
appendPQExpBufferStr(&conn->errorMessage, appendPQExpBufferStr(&conn->errorMessage,
libpq_gettext("\tIs the server running on that host and accepting TCP/IP connections?\n")); libpq_gettext("\tIs the server running on that host and accepting TCP/IP connections?\n"));
} }
@ -2415,7 +2407,6 @@ keep_going: /* We will come back to here until there is
break; break;
case CHT_UNIX_SOCKET: case CHT_UNIX_SOCKET:
#ifdef HAVE_UNIX_SOCKETS
conn->addrlist_family = hint.ai_family = AF_UNIX; conn->addrlist_family = hint.ai_family = AF_UNIX;
UNIXSOCK_PATH(portstr, thisport, ch->host); UNIXSOCK_PATH(portstr, thisport, ch->host);
if (strlen(portstr) >= UNIXSOCK_PATH_BUFLEN) if (strlen(portstr) >= UNIXSOCK_PATH_BUFLEN)
@ -2440,9 +2431,6 @@ keep_going: /* We will come back to here until there is
portstr, gai_strerror(ret)); portstr, gai_strerror(ret));
goto keep_going; goto keep_going;
} }
#else
Assert(false);
#endif
break; break;
} }

View File

@ -99,11 +99,9 @@ static char *logfilename;
static FILE *logfile; static FILE *logfile;
static char *difffilename; static char *difffilename;
static const char *sockdir; static const char *sockdir;
#ifdef HAVE_UNIX_SOCKETS
static const char *temp_sockdir; static const char *temp_sockdir;
static char sockself[MAXPGPATH]; static char sockself[MAXPGPATH];
static char socklock[MAXPGPATH]; static char socklock[MAXPGPATH];
#endif
static _resultmap *resultmap = NULL; static _resultmap *resultmap = NULL;
@ -285,7 +283,6 @@ stop_postmaster(void)
} }
} }
#ifdef HAVE_UNIX_SOCKETS
/* /*
* Remove the socket temporary directory. pg_regress never waits for a * Remove the socket temporary directory. pg_regress never waits for a
* postmaster exit, so it is indeterminate whether the postmaster has yet to * postmaster exit, so it is indeterminate whether the postmaster has yet to
@ -360,7 +357,6 @@ make_temp_sockdir(void)
return temp_sockdir; return temp_sockdir;
} }
#endif /* HAVE_UNIX_SOCKETS */
/* /*
* Check whether string matches pattern * Check whether string matches pattern
@ -683,7 +679,6 @@ initialize_environment(void)
/* PGPORT, see below */ /* PGPORT, see below */
/* PGHOST, see below */ /* PGHOST, see below */
#ifdef HAVE_UNIX_SOCKETS
if (hostname != NULL) if (hostname != NULL)
setenv("PGHOST", hostname, 1); setenv("PGHOST", hostname, 1);
else else
@ -693,10 +688,6 @@ initialize_environment(void)
sockdir = make_temp_sockdir(); sockdir = make_temp_sockdir();
setenv("PGHOST", sockdir, 1); setenv("PGHOST", sockdir, 1);
} }
#else
Assert(hostname != NULL);
setenv("PGHOST", hostname, 1);
#endif
unsetenv("PGHOSTADDR"); unsetenv("PGHOSTADDR");
if (port != -1) if (port != -1)
{ {
@ -746,11 +737,9 @@ initialize_environment(void)
if (!pghost) if (!pghost)
{ {
/* Keep this bit in sync with libpq's default host location: */ /* Keep this bit in sync with libpq's default host location: */
#ifdef HAVE_UNIX_SOCKETS
if (DEFAULT_PGSOCKET_DIR[0]) if (DEFAULT_PGSOCKET_DIR[0])
/* do nothing, we'll print "Unix socket" below */ ; /* do nothing, we'll print "Unix socket" below */ ;
else else
#endif
pghost = "localhost"; /* DefaultHost in fe-connect.c */ pghost = "localhost"; /* DefaultHost in fe-connect.c */
} }
@ -2068,14 +2057,11 @@ regression_main(int argc, char *argv[],
atexit(stop_postmaster); atexit(stop_postmaster);
#if !defined(HAVE_UNIX_SOCKETS) #if defined(WIN32)
use_unix_sockets = false;
#elif defined(WIN32)
/* /*
* We don't use Unix-domain sockets on Windows by default, even if the * We don't use Unix-domain sockets on Windows by default (see comment at
* build supports them. (See comment at remove_temp() for a reason.) * remove_temp() for a reason). Override at your own risk.
* Override at your own risk.
*/ */
use_unix_sockets = getenv("PG_TEST_USE_UNIX_SOCKETS") ? true : false; use_unix_sockets = getenv("PG_TEST_USE_UNIX_SOCKETS") ? true : false;
#else #else
@ -2209,7 +2195,7 @@ regression_main(int argc, char *argv[],
/* /*
* To reduce chances of interference with parallel installations, use * To reduce chances of interference with parallel installations, use
* a port number starting in the private range (49152-65535) * a port number starting in the private range (49152-65535)
* calculated from the version number. This aids !HAVE_UNIX_SOCKETS * calculated from the version number. This aids non-Unix socket mode
* systems; elsewhere, the use of a private socket directory already * systems; elsewhere, the use of a private socket directory already
* prevents interference. * prevents interference.
*/ */
@ -2329,8 +2315,6 @@ regression_main(int argc, char *argv[],
snprintf(buf, sizeof(buf), "%s/data", temp_instance); snprintf(buf, sizeof(buf), "%s/data", temp_instance);
config_sspi_auth(buf, NULL); config_sspi_auth(buf, NULL);
} }
#elif !defined(HAVE_UNIX_SOCKETS)
#error Platform has no means to secure the test installation.
#endif #endif
/* /*