]>
Commit | Line | Data |
---|---|---|
f450a970 | 1 | --- postgresql-8.2.5/src/bin/pg_ctl/pg_ctl.c.orig 2007-09-18 22:08:39.757996485 +0100 |
2 | +++ postgresql-8.2.5/src/bin/pg_ctl/pg_ctl.c 2007-09-18 22:43:12.441795575 +0100 | |
3 | @@ -19,6 +19,7 @@ | |
4 | ||
5 | #include "postgres_fe.h" | |
6 | #include "libpq-fe.h" | |
7 | +#include "pg_config_manual.h" | |
8 | ||
9 | #include <locale.h> | |
10 | #include <signal.h> | |
11 | @@ -404,10 +405,12 @@ | |
0796510c | 12 | bool success = false; |
13 | int i; | |
14 | char portstr[32]; | |
f450a970 | 15 | + char sockstr[MAXPGPATH]; |
0796510c | 16 | char *p; |
f450a970 | 17 | - char connstr[128]; /* Should be way more than enough! */ |
18 | + char connstr[MAXPGPATH+128]; | |
0796510c | 19 | |
20 | *portstr = '\0'; | |
f450a970 | 21 | + *sockstr = '\0'; |
0796510c | 22 | |
23 | /* post_opts */ | |
24 | for (p = post_opts; *p;) | |
f450a970 | 25 | @@ -432,7 +435,7 @@ |
0796510c | 26 | } |
27 | ||
28 | /* config file */ | |
29 | - if (!*portstr) | |
30 | + if (!*portstr || !*sockstr) | |
31 | { | |
32 | char **optlines; | |
33 | ||
f450a970 | 34 | @@ -445,18 +448,32 @@ |
0796510c | 35 | |
36 | while (isspace((unsigned char) *p)) | |
37 | p++; | |
38 | - if (strncmp(p, "port", strlen("port")) != 0) | |
39 | - continue; | |
40 | - p += strlen("port"); | |
41 | - while (isspace((unsigned char) *p)) | |
42 | - p++; | |
43 | - if (*p != '=') | |
44 | - continue; | |
45 | - p++; | |
46 | - while (isspace((unsigned char) *p)) | |
f450a970 | 47 | + if (!*portstr && strncmp(p, "port", strlen("port")) == 0) |
0796510c | 48 | + { |
49 | + p += strlen("port"); | |
50 | + while (isspace((unsigned char) *p)) | |
51 | + p++; | |
52 | + if (*p != '=') | |
53 | + continue; | |
54 | p++; | |
55 | - StrNCpy(portstr, p, Min(strcspn(p, "#" WHITESPACE) + 1, | |
56 | + while (isspace((unsigned char) *p)) | |
57 | + p++; | |
58 | + StrNCpy(portstr, p, Min(strcspn(p, "#" WHITESPACE) + 1, | |
59 | sizeof(portstr))); | |
60 | + } | |
f450a970 | 61 | + if (!*sockstr && strncmp(p, "unix_socket_directory", strlen("unix_socket_directory")) == 0) |
0796510c | 62 | + { |
63 | + p += strlen("unix_socket_directory"); | |
64 | + while (isspace((unsigned char) *p)) | |
65 | + p++; | |
66 | + if (*p != '=') | |
67 | + continue; | |
68 | + p++; | |
69 | + while (isspace((unsigned char) *p) || *p == '\'' || *p == '"') | |
70 | + p++; | |
71 | + StrNCpy(sockstr, p, Min(strcspn(p, "#\"'" WHITESPACE) + 1, | |
72 | + sizeof(sockstr))); | |
73 | + } | |
74 | /* keep looking, maybe there is another */ | |
75 | } | |
76 | } | |
f450a970 | 77 | @@ -473,6 +490,12 @@ |
78 | /* We need to set a connect timeout otherwise on Windows the SCM will probably timeout first */ | |
79 | snprintf(connstr, sizeof(connstr), "dbname=postgres port=%s connect_timeout=5", portstr); | |
0796510c | 80 | |
f450a970 | 81 | + /* path to directory containing the unix socket */ |
82 | + if (*sockstr) { | |
83 | + strncat(connstr, " host=", sizeof(connstr) - strlen(connstr)); | |
84 | + strncat(connstr, sockstr, sizeof(connstr) - strlen(connstr)); | |
85 | + } | |
86 | + | |
0796510c | 87 | for (i = 0; i < wait_seconds; i++) |
88 | { | |
f450a970 | 89 | if ((conn = PQconnectdb(connstr)) != NULL && |