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
5 #include "postgres_fe.h"
7 +#include "pg_config_manual.h"
15 + char sockstr[MAXPGPATH];
17 - char connstr[128]; /* Should be way more than enough! */
18 + char connstr[MAXPGPATH+128];
24 for (p = post_opts; *p;)
30 + if (!*portstr || !*sockstr)
36 while (isspace((unsigned char) *p))
38 - if (strncmp(p, "port", strlen("port")) != 0)
40 - p += strlen("port");
41 - while (isspace((unsigned char) *p))
46 - while (isspace((unsigned char) *p))
47 + if (!*portstr && strncmp(p, "port", strlen("port")) == 0)
49 + p += strlen("port");
50 + while (isspace((unsigned char) *p))
55 - StrNCpy(portstr, p, Min(strcspn(p, "#" WHITESPACE) + 1,
56 + while (isspace((unsigned char) *p))
58 + StrNCpy(portstr, p, Min(strcspn(p, "#" WHITESPACE) + 1,
61 + if (!*sockstr && strncmp(p, "unix_socket_directory", strlen("unix_socket_directory")) == 0)
63 + p += strlen("unix_socket_directory");
64 + while (isspace((unsigned char) *p))
69 + while (isspace((unsigned char) *p) || *p == '\'' || *p == '"')
71 + StrNCpy(sockstr, p, Min(strcspn(p, "#\"'" WHITESPACE) + 1,
74 /* keep looking, maybe there is another */
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);
81 + /* path to directory containing the unix socket */
83 + strncat(connstr, " host=", sizeof(connstr) - strlen(connstr));
84 + strncat(connstr, sockstr, sizeof(connstr) - strlen(connstr));
87 for (i = 0; i < wait_seconds; i++)
89 if ((conn = PQconnectdb(connstr)) != NULL &&