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