]>
Commit | Line | Data |
---|---|---|
0796510c | 1 | --- src/bin/pg_ctl/pg_ctl.c.orig 2006-04-04 15:52:48.000000000 +0000 |
2 | +++ src/bin/pg_ctl/pg_ctl.c 2006-04-04 16:43:27.000000000 +0000 | |
3 | @@ -373,9 +373,11 @@ | |
4 | bool success = false; | |
5 | int i; | |
6 | char portstr[32]; | |
7 | + char sockstr[256]; | |
8 | char *p; | |
9 | ||
10 | *portstr = '\0'; | |
11 | + *sockstr = '\0'; | |
12 | ||
13 | /* post_opts */ | |
14 | for (p = post_opts; *p;) | |
15 | @@ -400,7 +402,7 @@ | |
16 | } | |
17 | ||
18 | /* config file */ | |
19 | - if (!*portstr) | |
20 | + if (!*portstr || !*sockstr) | |
21 | { | |
22 | char **optlines; | |
23 | ||
24 | @@ -413,18 +415,32 @@ | |
25 | ||
26 | while (isspace((unsigned char) *p)) | |
27 | p++; | |
28 | - if (strncmp(p, "port", strlen("port")) != 0) | |
29 | - continue; | |
30 | - p += strlen("port"); | |
31 | - while (isspace((unsigned char) *p)) | |
32 | - p++; | |
33 | - if (*p != '=') | |
34 | - continue; | |
35 | - p++; | |
36 | - while (isspace((unsigned char) *p)) | |
37 | + if (strncmp(p, "port", strlen("port")) == 0) | |
38 | + { | |
39 | + p += strlen("port"); | |
40 | + while (isspace((unsigned char) *p)) | |
41 | + p++; | |
42 | + if (*p != '=') | |
43 | + continue; | |
44 | p++; | |
45 | - StrNCpy(portstr, p, Min(strcspn(p, "#" WHITESPACE) + 1, | |
46 | + while (isspace((unsigned char) *p)) | |
47 | + p++; | |
48 | + StrNCpy(portstr, p, Min(strcspn(p, "#" WHITESPACE) + 1, | |
49 | sizeof(portstr))); | |
50 | + } | |
51 | + if (strncmp(p, "unix_socket_directory", strlen("unix_socket_directory")) == 0) | |
52 | + { | |
53 | + p += strlen("unix_socket_directory"); | |
54 | + while (isspace((unsigned char) *p)) | |
55 | + p++; | |
56 | + if (*p != '=') | |
57 | + continue; | |
58 | + p++; | |
59 | + while (isspace((unsigned char) *p) || *p == '\'' || *p == '"') | |
60 | + p++; | |
61 | + StrNCpy(sockstr, p, Min(strcspn(p, "#\"'" WHITESPACE) + 1, | |
62 | + sizeof(sockstr))); | |
63 | + } | |
64 | /* keep looking, maybe there is another */ | |
65 | } | |
66 | } | |
67 | @@ -440,7 +456,7 @@ | |
68 | ||
69 | for (i = 0; i < wait_seconds; i++) | |
70 | { | |
71 | - if ((conn = PQsetdbLogin(NULL, portstr, NULL, NULL, | |
72 | + if ((conn = PQsetdbLogin((!*sockstr ? NULL : sockstr), portstr, NULL, NULL, | |
73 | "postgres", NULL, NULL)) != NULL && | |
74 | (PQstatus(conn) == CONNECTION_OK || | |
75 | (strcmp(PQerrorMessage(conn), |