1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-04 20:11:56 +03:00

Enable Unix-domain sockets support on Windows

As of Windows 10 version 1803, Unix-domain sockets are supported on
Windows.  But it's not automatically detected by configure because it
looks for struct sockaddr_un and Windows doesn't define that.  So we
just make our own definition on Windows and override the configure
result.

Set DEFAULT_PGSOCKET_DIR to empty on Windows so by default no
Unix-domain socket is used, because there is no good standard
location.

In pg_upgrade, we have to do some extra tweaking to preserve the
existing behavior of not using Unix-domain sockets on Windows.  Adding
support would be desirable, but it needs further work, in particular a
way to select whether to use Unix-domain sockets from the command-line
or with a run-time test.

The pg_upgrade test script needs a fix.  The previous code passed
"localhost" to postgres -k, which only happened to work because
Windows used to ignore the -k argument value altogether.  We instead
need to pass an empty string to get the desired effect.

The test suites will continue to not use Unix-domain sockets on
Windows.  This requires a small tweak in pg_regress.c.  The TAP tests
don't need to be changed because they decide by the operating system
rather than HAVE_UNIX_SOCKETS.

Reviewed-by: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
Discussion: https://www.postgresql.org/message-id/flat/54bde68c-d134-4eb8-5bd3-8af33b72a010@2ndquadrant.com
This commit is contained in:
Peter Eisentraut
2020-03-28 13:01:42 +01:00
parent 87779aa474
commit 8f3ec75de4
11 changed files with 50 additions and 25 deletions

View File

@@ -135,13 +135,6 @@
#define EXEC_BACKEND
#endif
/*
* Disable UNIX sockets for certain operating systems.
*/
#if defined(WIN32)
#undef HAVE_UNIX_SOCKETS
#endif
/*
* USE_POSIX_FADVISE controls whether Postgres will attempt to use the
* posix_fadvise() kernel call. Usually the automatic configure tests are
@@ -202,8 +195,16 @@
* server will not create an AF_UNIX socket unless the run-time configuration
* is changed, a client will connect via TCP/IP by default and will only use
* an AF_UNIX socket if one is explicitly specified.
*
* This is done by default on Windows because there is no good standard
* location for AF_UNIX sockets and many installations on Windows don't
* support them yet.
*/
#ifndef WIN32
#define DEFAULT_PGSOCKET_DIR "/tmp"
#else
#define DEFAULT_PGSOCKET_DIR ""
#endif
/*
* This is the default event source for Windows event log.