Add -D option to specify data directory to pg_controldata and pg_resetxlog.
It was confusing that to other commands, like initdb and postgres, you would pass the data directory with "-D datadir", but pg_controldata and pg_resetxlog would take just plain path, without the "-D". With this patch, pg_controldata and pg_resetxlog also accept "-D datadir". Abhijit Menon-Sen, with minor kibitzing by me
This commit is contained in:
parent
afd1d95f5b
commit
b0d81adea6
@ -23,7 +23,7 @@ PostgreSQL documentation
|
||||
<cmdsynopsis>
|
||||
<command>pg_controldata</command>
|
||||
<arg choice="opt"><replaceable class="parameter">option</replaceable></arg>
|
||||
<arg choice="opt"><replaceable class="parameter">datadir</replaceable></arg>
|
||||
<arg choice="opt"><arg choice="opt"><option>-D</option></arg> <replaceable class="parameter">datadir</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
|
@ -30,7 +30,7 @@ PostgreSQL documentation
|
||||
<arg choice="opt"><option>-m</option> <replaceable class="parameter">mxid</replaceable>,<replaceable class="parameter">mxid</replaceable></arg>
|
||||
<arg choice="opt"><option>-O</option> <replaceable class="parameter">mxoff</replaceable></arg>
|
||||
<arg choice="opt"><option>-l</option> <replaceable class="parameter">xlogfile</replaceable></arg>
|
||||
<arg choice="plain"><replaceable>datadir</replaceable></arg>
|
||||
<arg choice="req"><arg choice="opt"><option>-D</option></arg> <replaceable class="parameter">datadir</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
|
@ -33,7 +33,7 @@ usage(const char *progname)
|
||||
{
|
||||
printf(_("%s displays control information of a PostgreSQL database cluster.\n\n"), progname);
|
||||
printf(_("Usage:\n"));
|
||||
printf(_(" %s [OPTION] [DATADIR]\n"), progname);
|
||||
printf(_(" %s [OPTION] [[-D] DATADIR]\n"), progname);
|
||||
printf(_("\nOptions:\n"));
|
||||
printf(_(" -V, --version output version information, then exit\n"));
|
||||
printf(_(" -?, --help show this help, then exit\n"));
|
||||
|
@ -89,7 +89,7 @@ main(int argc, char *argv[])
|
||||
MultiXactId set_oldestmxid = 0;
|
||||
char *endptr;
|
||||
char *endptr2;
|
||||
char *DataDir;
|
||||
char *DataDir = NULL;
|
||||
int fd;
|
||||
|
||||
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_resetxlog"));
|
||||
@ -111,10 +111,14 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
while ((c = getopt(argc, argv, "fl:m:no:O:x:e:")) != -1)
|
||||
while ((c = getopt(argc, argv, "D:fl:m:no:O:x:e:")) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'D':
|
||||
DataDir = optarg;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
force = true;
|
||||
break;
|
||||
@ -233,12 +237,14 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (optind == argc)
|
||||
if (DataDir == NULL && optind == argc)
|
||||
{
|
||||
fprintf(stderr, _("%s: no data directory specified\n"), progname);
|
||||
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
|
||||
exit(1);
|
||||
}
|
||||
if (DataDir == NULL)
|
||||
DataDir = argv[optind];
|
||||
|
||||
/*
|
||||
* Don't allow pg_resetxlog to be run as root, to avoid overwriting the
|
||||
@ -257,8 +263,6 @@ main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
DataDir = argv[optind];
|
||||
|
||||
if (chdir(DataDir) < 0)
|
||||
{
|
||||
fprintf(stderr, _("%s: could not change directory to \"%s\": %s\n"),
|
||||
@ -1077,7 +1081,7 @@ static void
|
||||
usage(void)
|
||||
{
|
||||
printf(_("%s resets the PostgreSQL transaction log.\n\n"), progname);
|
||||
printf(_("Usage:\n %s [OPTION]... DATADIR\n\n"), progname);
|
||||
printf(_("Usage:\n %s [OPTION]... {[-D] DATADIR}\n\n"), progname);
|
||||
printf(_("Options:\n"));
|
||||
printf(_(" -e XIDEPOCH set next transaction ID epoch\n"));
|
||||
printf(_(" -f force update to be done\n"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user