6cb03e
Change the built-in default socket directory to be /var/run/postgresql.
6cb03e
For backwards compatibility with (probably non-libpq-based) clients that
6cb03e
might still expect to find the socket in /tmp, also create a socket in
6cb03e
/tmp.  This is to resolve communication problems with clients operating
6cb03e
under systemd's PrivateTmp environment, which won't be using the same
6cb03e
global /tmp directory as the server; see bug #825448.
6cb03e
6cb03e
Note that we apply the socket directory change at the level of the
6cb03e
hard-wired defaults in the C code, not by just twiddling the setting in
6cb03e
postgresql.conf.sample; this is so that the change will take effect on
6cb03e
server package update, without requiring any existing postgresql.conf
6cb03e
to be updated.  (Of course, a user who dislikes this behavior can still
6cb03e
override it via postgresql.conf.)
6cb03e
6cb03e
This patch must be applied after postgresql-multi-sockets.patch, at
6cb03e
least until 9.3 when that will be part of the upstream package.
6cb03e
6cb03e
diff --git a/contrib/pg_upgrade/test.sh b/contrib/pg_upgrade/test.sh
6cb03e
index d44c599..845b417 100644
6cb03e
--- a/contrib/pg_upgrade/test.sh
6cb03e
+++ b/contrib/pg_upgrade/test.sh
6cb03e
@@ -121,6 +121,12 @@ logdir=$PWD/log
6cb03e
 rm -rf "$logdir"
6cb03e
 mkdir "$logdir"
6cb03e
 
6cb03e
+# we want the Unix sockets in $temp_root
6cb03e
+PGHOST=$temp_root
6cb03e
+export PGHOST
6cb03e
+
6cb03e
+POSTMASTER_OPTS="$POSTMASTER_OPTS -c unix_socket_directories='$PGHOST'"
6cb03e
+
6cb03e
 # enable echo so the user can see what is being executed
6cb03e
 set -x
6cb03e
 
6cb03e
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
6cb03e
index 1428cb6..3613732 100644
6cb03e
--- a/src/backend/utils/misc/guc.c
6cb03e
+++ b/src/backend/utils/misc/guc.c
6cb03e
@@ -2901,7 +2901,7 @@ static struct config_string ConfigureNamesString[] =
6cb03e
 		},
6cb03e
 		&Unix_socket_directories,
6cb03e
 #ifdef HAVE_UNIX_SOCKETS
6cb03e
-		DEFAULT_PGSOCKET_DIR,
6cb03e
+		DEFAULT_PGSOCKET_DIR ", /tmp",
6cb03e
 #else
6cb03e
 		"",
6cb03e
 #endif
6cb03e
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
6cb03e
index 452ac0b..ce6ca96 100644
6cb03e
--- a/src/bin/initdb/initdb.c
6cb03e
+++ b/src/bin/initdb/initdb.c
6cb03e
@@ -1015,7 +1015,7 @@ setup_config(void)
6cb03e
 
6cb03e
 #ifdef HAVE_UNIX_SOCKETS
6cb03e
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = '%s'",
6cb03e
-			 DEFAULT_PGSOCKET_DIR);
6cb03e
+			 DEFAULT_PGSOCKET_DIR ", /tmp");
6cb03e
 #else
6cb03e
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''");
6cb03e
 #endif
6cb03e
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
6cb03e
index ee7dab0..f3e3ed9 100644
6cb03e
--- a/src/include/pg_config_manual.h
6cb03e
+++ b/src/include/pg_config_manual.h
6cb03e
@@ -144,7 +144,7 @@
6cb03e
  * here's where to twiddle it.  You can also override this at runtime
6cb03e
  * with the postmaster's -k switch.
6cb03e
  */
6cb03e
-#define DEFAULT_PGSOCKET_DIR  "/tmp"
6cb03e
+#define DEFAULT_PGSOCKET_DIR  "/var/run/postgresql"
6cb03e
 
6cb03e
 /*
6cb03e
  * The random() function is expected to yield values between 0 and