1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-24 09:27:52 +03:00

Allow building without default socket directory

We have code paths for Unix socket support and no Unix socket support.
Now add a third variant: Unix socket support but do not use a Unix
socket by default in the client or the server, only if you explicitly
specify one.  This will be useful when we enable Unix socket support
on Windows.

To implement this, tweak things so that setting DEFAULT_PGSOCKET_DIR
to "" has the desired effect.  This mostly already worked like that;
only a few places needed to be adjusted.  Notably, the reference to
DEFAULT_PGSOCKET_DIR in UNIXSOCK_PATH() could be removed because all
callers already resolve an empty socket directory setting with a
default if appropriate.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/75f72249-8ae6-322a-63df-4fe03eeccb9f@2ndquadrant.com
This commit is contained in:
Peter Eisentraut
2020-01-31 16:26:12 +01:00
parent 7c23bfd25c
commit a9cff89f7e
3 changed files with 18 additions and 8 deletions

View File

@@ -1095,12 +1095,17 @@ connectOptions2(PGconn *conn)
if (ch->host)
free(ch->host);
#ifdef HAVE_UNIX_SOCKETS
ch->host = strdup(DEFAULT_PGSOCKET_DIR);
ch->type = CHT_UNIX_SOCKET;
#else
ch->host = strdup(DefaultHost);
ch->type = CHT_HOST_NAME;
if (DEFAULT_PGSOCKET_DIR[0])
{
ch->host = strdup(DEFAULT_PGSOCKET_DIR);
ch->type = CHT_UNIX_SOCKET;
}
else
#endif
{
ch->host = strdup(DefaultHost);
ch->type = CHT_HOST_NAME;
}
if (ch->host == NULL)
goto oom_error;
}