mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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:
@ -23,7 +23,7 @@ PostgreSQL documentation
|
|||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>pg_controldata</command>
|
<command>pg_controldata</command>
|
||||||
<arg choice="opt"><replaceable class="parameter">option</replaceable></arg>
|
<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>
|
</cmdsynopsis>
|
||||||
</refsynopsisdiv>
|
</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>-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>-O</option> <replaceable class="parameter">mxoff</replaceable></arg>
|
||||||
<arg choice="opt"><option>-l</option> <replaceable class="parameter">xlogfile</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>
|
</cmdsynopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ usage(const char *progname)
|
|||||||
{
|
{
|
||||||
printf(_("%s displays control information of a PostgreSQL database cluster.\n\n"), progname);
|
printf(_("%s displays control information of a PostgreSQL database cluster.\n\n"), progname);
|
||||||
printf(_("Usage:\n"));
|
printf(_("Usage:\n"));
|
||||||
printf(_(" %s [OPTION] [DATADIR]\n"), progname);
|
printf(_(" %s [OPTION] [[-D] DATADIR]\n"), progname);
|
||||||
printf(_("\nOptions:\n"));
|
printf(_("\nOptions:\n"));
|
||||||
printf(_(" -V, --version output version information, then exit\n"));
|
printf(_(" -V, --version output version information, then exit\n"));
|
||||||
printf(_(" -?, --help show this help, then exit\n"));
|
printf(_(" -?, --help show this help, then exit\n"));
|
||||||
|
@ -89,7 +89,7 @@ main(int argc, char *argv[])
|
|||||||
MultiXactId set_oldestmxid = 0;
|
MultiXactId set_oldestmxid = 0;
|
||||||
char *endptr;
|
char *endptr;
|
||||||
char *endptr2;
|
char *endptr2;
|
||||||
char *DataDir;
|
char *DataDir = NULL;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_resetxlog"));
|
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)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
case 'D':
|
||||||
|
DataDir = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
force = true;
|
force = true;
|
||||||
break;
|
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, _("%s: no data directory specified\n"), progname);
|
||||||
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
|
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
if (DataDir == NULL)
|
||||||
|
DataDir = argv[optind];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't allow pg_resetxlog to be run as root, to avoid overwriting the
|
* Don't allow pg_resetxlog to be run as root, to avoid overwriting the
|
||||||
@ -257,8 +263,6 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DataDir = argv[optind];
|
|
||||||
|
|
||||||
if (chdir(DataDir) < 0)
|
if (chdir(DataDir) < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, _("%s: could not change directory to \"%s\": %s\n"),
|
fprintf(stderr, _("%s: could not change directory to \"%s\": %s\n"),
|
||||||
@ -1077,7 +1081,7 @@ static void
|
|||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
printf(_("%s resets the PostgreSQL transaction log.\n\n"), progname);
|
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(_("Options:\n"));
|
||||||
printf(_(" -e XIDEPOCH set next transaction ID epoch\n"));
|
printf(_(" -e XIDEPOCH set next transaction ID epoch\n"));
|
||||||
printf(_(" -f force update to be done\n"));
|
printf(_(" -f force update to be done\n"));
|
||||||
|
Reference in New Issue
Block a user