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