]>
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 @@ | |
0796510c | 4 | int i; |
5 | char portstr[32]; | |
6 | + char sockstr[256]; | |
7 | char *p; | |
f87558a0 | 8 | char *q; |
0796510c | 9 | |
10 | *portstr = '\0'; | |
11 | + *sockstr = '\0'; | |
12 | ||
13 | /* post_opts */ | |
14 | for (p = post_opts; *p;) | |
15 | @@ -400,7 +402,7 @@ | |
f87558a0 AM |
16 | * This parsing code isn't amazingly bright either, but it should be |
17 | * okay for valid port settings. | |
18 | */ | |
0796510c | 19 | - if (!*portstr) |
20 | + if (!*portstr || !*sockstr) | |
21 | { | |
22 | char **optlines; | |
23 | ||
62118e0f | 24 | @@ -432,8 +432,7 @@ |
0796510c | 25 | |
26 | while (isspace((unsigned char) *p)) | |
27 | p++; | |
f87558a0 | 28 | - if (strncmp(p, "port", 4) != 0) |
0796510c | 29 | - continue; |
62118e0f AM |
30 | + if (!strncmp(p, "port", 4) != 0) { |
31 | p += 4; | |
32 | while (isspace((unsigned char) *p)) | |
0796510c | 33 | p++; |
62118e0f AM |
34 | @@ -452,6 +451,26 @@ |
35 | /* and save the argument value */ | |
36 | StrNCpy(portstr, p, Min((q - p) + 1, sizeof(portstr))); | |
37 | /* keep looking, maybe there is another */ | |
38 | + } else if(!strncmp(p, "unix_socket_directory", 21)) { | |
39 | + p += 21; | |
0796510c | 40 | + while (isspace((unsigned char) *p)) |
41 | + p++; | |
42 | + if (*p != '=') | |
43 | + continue; | |
44 | + p++; | |
62118e0f | 45 | + /* advance past any whitespace/quoting */ |
0796510c | 46 | + while (isspace((unsigned char) *p) || *p == '\'' || *p == '"') |
47 | + p++; | |
62118e0f AM |
48 | + /* find end of value (not including any ending quote/comment!) */ |
49 | + q = p; | |
50 | + while (*q && | |
51 | + !(isspace((unsigned char) *q) || | |
52 | + *q == '\'' || *q == '"' || *q == '#')) | |
53 | + q++; | |
54 | + /* and save the argument value */ | |
55 | + StrNCpy(sockstr, p, Min((q - p) + 1, sizeof(portstr))); | |
56 | + /* keep looking, maybe there is another */ | |
0796510c | 57 | + } |
0796510c | 58 | } |
59 | } | |
62118e0f | 60 | } |
0796510c | 61 | @@ -440,7 +456,7 @@ |
62 | ||
63 | for (i = 0; i < wait_seconds; i++) | |
64 | { | |
65 | - if ((conn = PQsetdbLogin(NULL, portstr, NULL, NULL, | |
66 | + if ((conn = PQsetdbLogin((!*sockstr ? NULL : sockstr), portstr, NULL, NULL, | |
67 | "postgres", NULL, NULL)) != NULL && | |
68 | (PQstatus(conn) == CONNECTION_OK || | |
69 | (strcmp(PQerrorMessage(conn), |