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