Skip to content

Commit 22b743b

Browse files
committed
Oops, the commit accept pg_controldata -D datadir missed code changes.
I updated the docs and usage blurp, but forgot to commit the code changes required. Spotted by Michael Paquier.
1 parent 85bb81d commit 22b743b

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

src/bin/pg_controldata/pg_controldata.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ main(int argc, char *argv[])
9090
ControlFileData ControlFile;
9191
int fd;
9292
char ControlFilePath[MAXPGPATH];
93-
char *DataDir;
93+
char *DataDir = NULL;
9494
pg_crc32 crc;
9595
time_t time_tmp;
9696
char pgctime_str[128];
@@ -100,6 +100,7 @@ main(int argc, char *argv[])
100100
const char *progname;
101101
XLogSegNo segno;
102102
char xlogfilename[MAXFNAMELEN];
103+
int c;
103104

104105
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_controldata"));
105106

@@ -119,10 +120,28 @@ main(int argc, char *argv[])
119120
}
120121
}
121122

122-
if (argc > 1)
123-
DataDir = argv[1];
124-
else
125-
DataDir = getenv("PGDATA");
123+
while ((c = getopt(argc, argv, "D:")) != -1)
124+
{
125+
switch (c)
126+
{
127+
case 'D':
128+
DataDir = optarg;
129+
break;
130+
131+
default:
132+
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
133+
exit(1);
134+
}
135+
}
136+
137+
if (DataDir == NULL)
138+
{
139+
if (optind < argc)
140+
DataDir = argv[optind++];
141+
else
142+
DataDir = getenv("PGDATA");
143+
}
144+
126145
if (DataDir == NULL)
127146
{
128147
fprintf(stderr, _("%s: no data directory specified\n"), progname);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy