Blame SOURCES/postgresql-var-run-socket.patch

7686b4
Change the built-in default socket directory to be /var/run/postgresql.
7686b4
For backwards compatibility with (probably non-libpq-based) clients that
7686b4
might still expect to find the socket in /tmp, also create a socket in
7686b4
/tmp.  This is to resolve communication problems with clients operating
7686b4
under systemd's PrivateTmp environment, which won't be using the same
7686b4
global /tmp directory as the server; see bug #825448.
7686b4
7686b4
Note that we apply the socket directory change at the level of the
7686b4
hard-wired defaults in the C code, not by just twiddling the setting in
7686b4
postgresql.conf.sample; this is so that the change will take effect on
7686b4
server package update, without requiring any existing postgresql.conf
7686b4
to be updated.  (Of course, a user who dislikes this behavior can still
7686b4
override it via postgresql.conf.)
7686b4
7686b4
This patch must be applied after postgresql-multi-sockets.patch, at
7686b4
least until 9.3 when that will be part of the upstream package.
7686b4
7686b4
7686b4
diff -Naur postgresql-9.2.2.sockets/contrib/pg_upgrade/test.sh postgresql-9.2.2/contrib/pg_upgrade/test.sh
7686b4
--- postgresql-9.2.2.sockets/contrib/pg_upgrade/test.sh	2013-01-03 17:33:45.581567466 -0500
7686b4
+++ postgresql-9.2.2/contrib/pg_upgrade/test.sh	2013-01-03 17:40:22.923364917 -0500
7686b4
@@ -78,6 +78,12 @@
7686b4
 rm -rf "$logdir"
7686b4
 mkdir "$logdir"
7686b4
 
7686b4
+# we want the Unix sockets in $temp_root
7686b4
+PGHOST=$temp_root
7686b4
+export PGHOST
7686b4
+
7686b4
+POSTMASTER_OPTS="$POSTMASTER_OPTS -c unix_socket_directories='$PGHOST'"
7686b4
+
7686b4
 # enable echo so the user can see what is being executed
7686b4
 set -x
7686b4
 
7686b4
diff -Naur postgresql-9.2.2.sockets/src/backend/utils/misc/guc.c postgresql-9.2.2/src/backend/utils/misc/guc.c
7686b4
--- postgresql-9.2.2.sockets/src/backend/utils/misc/guc.c	2013-01-03 17:37:56.632977951 -0500
7686b4
+++ postgresql-9.2.2/src/backend/utils/misc/guc.c	2013-01-03 17:38:30.183271588 -0500
7686b4
@@ -2901,7 +2901,7 @@
7686b4
 		},
7686b4
 		&Unix_socket_directories,
7686b4
 #ifdef HAVE_UNIX_SOCKETS
7686b4
-		DEFAULT_PGSOCKET_DIR,
7686b4
+		DEFAULT_PGSOCKET_DIR ", /tmp",
7686b4
 #else
7686b4
 		"",
7686b4
 #endif
7686b4
diff -Naur postgresql-9.2.2.sockets/src/bin/initdb/initdb.c postgresql-9.2.2/src/bin/initdb/initdb.c
7686b4
--- postgresql-9.2.2.sockets/src/bin/initdb/initdb.c	2013-01-03 17:37:56.633977974 -0500
7686b4
+++ postgresql-9.2.2/src/bin/initdb/initdb.c	2013-01-03 17:38:30.185271611 -0500
7686b4
@@ -1007,7 +1007,7 @@
7686b4
 
7686b4
 #ifdef HAVE_UNIX_SOCKETS
7686b4
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = '%s'",
7686b4
-			 DEFAULT_PGSOCKET_DIR);
7686b4
+			 DEFAULT_PGSOCKET_DIR ", /tmp");
7686b4
 #else
7686b4
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''");
7686b4
 #endif
7686b4
diff -Naur postgresql-9.2.2.sockets/src/include/pg_config_manual.h postgresql-9.2.2/src/include/pg_config_manual.h
7686b4
--- postgresql-9.2.2.sockets/src/include/pg_config_manual.h	2012-12-03 15:16:10.000000000 -0500
7686b4
+++ postgresql-9.2.2/src/include/pg_config_manual.h	2013-01-03 17:38:30.185271611 -0500
7686b4
@@ -144,7 +144,7 @@
7686b4
  * here's where to twiddle it.  You can also override this at runtime
7686b4
  * with the postmaster's -k switch.
7686b4
  */
7686b4
-#define DEFAULT_PGSOCKET_DIR  "/tmp"
7686b4
+#define DEFAULT_PGSOCKET_DIR  "/var/run/postgresql"
7686b4
 
7686b4
 /*
7686b4
  * The random() function is expected to yield values between 0 and
7686b4
diff -Naur postgresql-9.2.2.sockets/src/test/regress/pg_regress.c postgresql-9.2.2/src/test/regress/pg_regress.c
7686b4
--- postgresql-9.2.2.sockets/src/test/regress/pg_regress.c	2012-12-03 15:16:10.000000000 -0500
7686b4
+++ postgresql-9.2.2/src/test/regress/pg_regress.c	2013-01-03 17:38:30.186271622 -0500
7686b4
@@ -772,7 +772,7 @@
7686b4
 		if (hostname != NULL)
7686b4
 			doputenv("PGHOST", hostname);
7686b4
 		else
7686b4
-			unsetenv("PGHOST");
7686b4
+			doputenv("PGHOST", "/tmp");
7686b4
 		unsetenv("PGHOSTADDR");
7686b4
 		if (port != -1)
7686b4
 		{
7686b4
@@ -2246,7 +2246,7 @@
7686b4
 		 */
7686b4
 		header(_("starting postmaster"));
7686b4
 		snprintf(buf, sizeof(buf),
7686b4
-				 SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
7686b4
+				 SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" -c \"unix_socket_directories=/tmp\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
7686b4
 				 bindir, temp_install,
7686b4
 				 debug ? " -d 5" : "",
7686b4
 				 hostname ? hostname : "",