0993ae
Change the built-in default socket directory to be /var/run/postgresql.
0993ae
For backwards compatibility with (probably non-libpq-based) clients that
0993ae
might still expect to find the socket in /tmp, also create a socket in
0993ae
/tmp.  This is to resolve communication problems with clients operating
0993ae
under systemd's PrivateTmp environment, which won't be using the same
0993ae
global /tmp directory as the server; see bug #825448.
0993ae
0993ae
Note that we apply the socket directory change at the level of the
0993ae
hard-wired defaults in the C code, not by just twiddling the setting in
0993ae
postgresql.conf.sample; this is so that the change will take effect on
0993ae
server package update, without requiring any existing postgresql.conf
0993ae
to be updated.  (Of course, a user who dislikes this behavior can still
0993ae
override it via postgresql.conf.)
0993ae
0993ae
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
0993ae
index 9481f2d..75532c7 100644
0993ae
--- a/src/backend/utils/misc/guc.c
0993ae
+++ b/src/backend/utils/misc/guc.c
0993ae
@@ -3196,7 +3196,7 @@ static struct config_string ConfigureNamesString[] =
0993ae
 		},
0993ae
 		&Unix_socket_directories,
0993ae
 #ifdef HAVE_UNIX_SOCKETS
0993ae
-		DEFAULT_PGSOCKET_DIR,
0993ae
+		DEFAULT_PGSOCKET_DIR ", /tmp",
0993ae
 #else
0993ae
 		"",
0993ae
 #endif
0993ae
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
0993ae
index feeff9e..3e3d784 100644
0993ae
--- a/src/bin/initdb/initdb.c
0993ae
+++ b/src/bin/initdb/initdb.c
0993ae
@@ -1234,7 +1234,7 @@ setup_config(void)
0993ae
 
0993ae
 #ifdef HAVE_UNIX_SOCKETS
0993ae
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = '%s'",
0993ae
-			 DEFAULT_PGSOCKET_DIR);
0993ae
+			 DEFAULT_PGSOCKET_DIR ", /tmp");
0993ae
 #else
0993ae
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''");
0993ae
 #endif
0993ae
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
0993ae
index e278fa0..9ee15d4 100644
0993ae
--- a/src/include/pg_config_manual.h
0993ae
+++ b/src/include/pg_config_manual.h
0993ae
@@ -201,7 +201,7 @@
0993ae
  * support them yet.
0993ae
  */
0993ae
 #ifndef WIN32
0993ae
-#define DEFAULT_PGSOCKET_DIR  "/tmp"
0993ae
+#define DEFAULT_PGSOCKET_DIR  "/var/run/postgresql"
0993ae
 #else
0993ae
 #define DEFAULT_PGSOCKET_DIR ""
0993ae
 #endif