]> git.pld-linux.org Git - packages/postgresql.git/blob - postgresql-pg_ctl-fix.patch
- Release: 5
[packages/postgresql.git] / postgresql-pg_ctl-fix.patch
1 --- postgresql-8.3.1/src/bin/pg_ctl/pg_ctl.c.orig       2008-03-01 00:31:42.000000000 +0100
2 +++ postgresql-8.3.1/src/bin/pg_ctl/pg_ctl.c    2008-03-20 22:59:22.658133220 +0100
3 @@ -412,12 +412,12 @@
4         PGconn     *conn;
5         bool            success = false;
6         int                     i;
7 -       char            portstr[32];
8 +       char            portstr[32], sockstr[MAXPGPATH];
9         char       *p;
10         char       *q;
11 -       char            connstr[128];   /* Should be way more than enough! */
12 +       char            connstr[128+MAXPGPATH]; /* Should be way more than enough! */
13  
14 -       *portstr = '\0';
15 +       *portstr = *sockstr = '\0';
16  
17         /*
18          * Look in post_opts for a -p switch.
19 @@ -448,6 +448,21 @@
20                         strlcpy(portstr, p, Min((q - p) + 1, sizeof(portstr)));
21                         /* keep looking, maybe there is another -p */
22                         p = q;
23 +               } else if (strncmp(p, "-k", strlen("-k")) == 0)
24 +               {
25 +                       p += 2;
26 +                       /* advance past whitespace/quoting */
27 +                       while (isspace((unsigned char) *p) || *p == '\'' || *p == '"')
28 +                               p++;
29 +                       /* find end of value (not including any ending quote!) */
30 +                       q = p;
31 +                       while (*q &&
32 +                                  !(isspace((unsigned char) *q) || *q == '\'' || *q == '"'))
33 +                               q++;
34 +                       /* and save the argument value */
35 +                       strlcpy(sockstr, p, Min(q - p + 1, sizeof(sockstr)));
36 +                       /* keep looking, maybe there is another -k */
37 +                       p = q;
38                 }
39                 /* Advance to next whitespace */
40                 while (*p && !isspace((unsigned char) *p))
41 @@ -460,7 +475,7 @@
42          * This parsing code isn't amazingly bright either, but it should be
43          * okay for valid port settings.
44          */
45 -       if (!*portstr)
46 +       if (!*portstr || !*sockstr)
47         {
48                 char      **optlines;
49  
50 @@ -473,8 +488,7 @@
51  
52                                 while (isspace((unsigned char) *p))
53                                         p++;
54 -                               if (strncmp(p, "port", 4) != 0)
55 -                                       continue;
56 +                               if (!strncmp(p, "port", 4)) {
57                                 p += 4;
58                                 while (isspace((unsigned char) *p))
59                                         p++;
60 @@ -493,6 +507,26 @@
61                                 /* and save the argument value */
62                                 strlcpy(portstr, p, Min((q - p) + 1, sizeof(portstr)));
63                                 /* keep looking, maybe there is another */
64 +                               } else if(!strncmp(p, "unix_socket_directory", 21)) {
65 +                                       p += 21;
66 +                                       while (isspace((unsigned char) *p))
67 +                                               p++;
68 +                                       if (*p != '=')
69 +                                               continue;
70 +                                       p++;
71 +                                       /* advance past any whitespace/quoting */
72 +                                       while (isspace((unsigned char) *p) || *p == '\'' || *p == '"')
73 +                                               p++;
74 +                                       /* find end of value (not including any ending quote/comment!) */
75 +                                       q = p;
76 +                                       while (*q &&
77 +                                                  !(isspace((unsigned char) *q) ||
78 +                                                        *q == '\'' || *q == '"' || *q == '#'))
79 +                                               q++;
80 +                                       /* and save the argument value */
81 +                                       strlcpy(sockstr, p, Min((q - p) + 1, sizeof(sockstr)));
82 +                                       /* keep looking, maybe there is another */
83 +                               }
84                         }
85                 }
86         }
87 @@ -510,7 +544,8 @@
88          * probably timeout first
89          */
90         snprintf(connstr, sizeof(connstr),
91 -                        "dbname=postgres port=%s connect_timeout=5", portstr);
92 +                        "dbname=postgres port=%s connect_timeout=5%s%s", portstr,
93 +                        (*sockstr ? " host=" : ""), sockstr);
94  
95         for (i = 0; i < wait_seconds; i++)
96         {
This page took 0.027987 seconds and 3 git commands to generate.