Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit38f4328

Browse files
committed
Fix pg_isready to handle -d option properly.
Previously, -d option for pg_isready was broken. When the name of thedatabase was specified by -d option, pg_isready failed with an error.When the conninfo specified by -d option contained the setting of thehost name but not Numeric IP address (i.e., hostaddr), pg_isreadydisplayed wrong connection message. -d option could not handle a validURI prefix at all. This commit fixes these bugs of pg_isready.Backpatch to 9.3, where pg_isready was introduced.Per report from Josh Berkus and Robert Haas.Original patch by Fabrízio de Royes Mello, heavily modified by me.
1 parent04eee1f commit38f4328

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

‎src/bin/scripts/pg_isready.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ main(int argc, char **argv)
3131
constchar*connect_timeout=DEFAULT_CONNECT_TIMEOUT;
3232

3333
constchar*pghost_str=NULL;
34+
constchar*pghostaddr_str=NULL;
3435
constchar*pgport_str=NULL;
3536

3637
#definePARAMS_ARRAY_SIZE7
@@ -130,7 +131,10 @@ main(int argc, char **argv)
130131
/*
131132
* Get the host and port so we can display them in our output
132133
*/
133-
if (pgdbname)
134+
if (pgdbname&&
135+
(strncmp(pgdbname,"postgresql://",13)==0||
136+
strncmp(pgdbname,"postgres://",11)==0||
137+
strchr(pgdbname,'=')!=NULL))
134138
{
135139
opts=PQconninfoParse(pgdbname,&errmsg);
136140
if (opts==NULL)
@@ -149,8 +153,7 @@ main(int argc, char **argv)
149153

150154
for (opt=opts,def=defs;def->keyword;def++)
151155
{
152-
if (strcmp(def->keyword,"hostaddr")==0||
153-
strcmp(def->keyword,"host")==0)
156+
if (strcmp(def->keyword,"host")==0)
154157
{
155158
if (opt&&opt->val)
156159
pghost_str=opt->val;
@@ -161,6 +164,13 @@ main(int argc, char **argv)
161164
else
162165
pghost_str=DEFAULT_PGSOCKET_DIR;
163166
}
167+
elseif (strcmp(def->keyword,"hostaddr")==0)
168+
{
169+
if (opt&&opt->val)
170+
pghostaddr_str=opt->val;
171+
elseif (def->val)
172+
pghostaddr_str=def->val;
173+
}
164174
elseif (strcmp(def->keyword,"port")==0)
165175
{
166176
if (opt&&opt->val)
@@ -179,7 +189,9 @@ main(int argc, char **argv)
179189

180190
if (!quiet)
181191
{
182-
printf("%s:%s - ",pghost_str,pgport_str);
192+
printf("%s:%s - ",
193+
pghostaddr_str!=NULL ?pghostaddr_str :pghost_str,
194+
pgport_str);
183195

184196
switch (rv)
185197
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp