]> git.pld-linux.org Git - packages/postgresql.git/blob - postgresql-pg_ctl-fix.patch
- release 2: added -825_planner_regression.patch
[packages/postgresql.git] / postgresql-pg_ctl-fix.patch
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 @@
12         bool            success = false;
13         int                     i;
14         char            portstr[32];
15 +       char            sockstr[MAXPGPATH];
16         char       *p;
17 -       char            connstr[128]; /* Should be way more than enough! */
18 +       char            connstr[MAXPGPATH+128];
19  
20         *portstr = '\0';
21 +       *sockstr = '\0';
22  
23         /* post_opts */
24         for (p = post_opts; *p;)
25 @@ -432,7 +435,7 @@
26         }
27  
28         /* config file */
29 -       if (!*portstr)
30 +       if (!*portstr || !*sockstr)
31         {
32                 char      **optlines;
33  
34 @@ -445,18 +448,32 @@
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))
47 +                               if (!*portstr && strncmp(p, "port", strlen("port")) == 0)
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 +                               }
61 +                               if (!*sockstr && strncmp(p, "unix_socket_directory", strlen("unix_socket_directory")) == 0)
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                 }
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);
80  
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 +
87         for (i = 0; i < wait_seconds; i++)
88         {
89                 if ((conn = PQconnectdb(connstr)) != NULL &&
This page took 0.296777 seconds and 3 git commands to generate.