summaryrefslogtreecommitdiffstats
path: root/postgresql-var-run-socket.patch
blob: f95ade6b1a4539436ea844d4298f7a9dfd36a27b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Change the built-in default socket directory to be /var/run/postgresql.
For backwards compatibility with (probably non-libpq-based) clients that
might still expect to find the socket in /tmp, also create a socket in
/tmp.  This is to resolve communication problems with clients operating
under systemd's PrivateTmp environment, which won't be using the same
global /tmp directory as the server; see bug #825448.

Note that we apply the socket directory change at the level of the
hard-wired defaults in the C code, not by just twiddling the setting in
postgresql.conf.sample; this is so that the change will take effect on
server package update, without requiring any existing postgresql.conf
to be updated.  (Of course, a user who dislikes this behavior can still
override it via postgresql.conf.)

diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 2b6527f..8e178d4 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2971,7 +2971,7 @@ static struct config_string ConfigureNamesString[] =
 		},
 		&Unix_socket_directories,
 #ifdef HAVE_UNIX_SOCKETS
-		DEFAULT_PGSOCKET_DIR,
+		DEFAULT_PGSOCKET_DIR ", /tmp",
 #else
 		"",
 #endif
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index abf1586..8c01d48 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -1204,7 +1204,7 @@ setup_config(void)
 
 #ifdef HAVE_UNIX_SOCKETS
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = '%s'",
-			 DEFAULT_PGSOCKET_DIR);
+			 DEFAULT_PGSOCKET_DIR ", /tmp");
 #else
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''");
 #endif
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
index 9ee15d4..e278fa0 100644
--- a/src/include/pg_config_manual.h
+++ b/src/include/pg_config_manual.h
@@ -169,7 +169,7 @@
  * here's where to twiddle it.  You can also override this at runtime
  * with the postmaster's -k switch.
  */
-#define DEFAULT_PGSOCKET_DIR  "/tmp"
+#define DEFAULT_PGSOCKET_DIR  "/var/run/postgresql"
 
 /*
  * This is the default event source for Windows event log.