Skip to content

Commit e22b27f

Browse files
committed
Add long options to pg_resetwal and pg_controldata
We were running out of good single-letter options for some upcoming pg_resetwal functionality, so add long options to create more possibilities. Add to pg_controldata as well for symmetry. based on patch by Bossart, Nathan <bossartn@amazon.com>
1 parent 496d566 commit e22b27f

File tree

4 files changed

+77
-30
lines changed

4 files changed

+77
-30
lines changed

doc/src/sgml/ref/pg_controldata.sgml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ PostgreSQL documentation
2323
<cmdsynopsis>
2424
<command>pg_controldata</command>
2525
<arg choice="opt"><replaceable class="parameter">option</replaceable></arg>
26-
<arg choice="opt"><arg choice="opt"><option>-D</option></arg> <replaceable class="parameter">datadir</replaceable></arg>
26+
<group choice="opt">
27+
<group choice="opt">
28+
<arg choice="plain"><option>--pgdata</option></arg>
29+
<arg choice="plain"><option>-D</option></arg>
30+
</group>
31+
<replaceable class="parameter"> datadir</replaceable>
32+
</group>
2733
</cmdsynopsis>
2834
</refsynopsisdiv>
2935

doc/src/sgml/ref/pg_resetwal.sgml

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,22 @@ PostgreSQL documentation
2222
<refsynopsisdiv>
2323
<cmdsynopsis>
2424
<command>pg_resetwal</command>
25-
<arg choice="opt"><option>-f</option></arg>
26-
<arg choice="opt"><option>-n</option></arg>
25+
<group choice="opt">
26+
<arg choice="plain"><option>--force</option></arg>
27+
<arg choice="plain"><option>-f</option></arg>
28+
</group>
29+
<group choice="opt">
30+
<arg choice="plain"><option>--dry-run</option></arg>
31+
<arg choice="plain"><option>-n</option></arg>
32+
</group>
2733
<arg rep="repeat"><replaceable>option</replaceable></arg>
28-
<arg choice="req"><arg choice="opt"><option>-D</option></arg> <replaceable class="parameter">datadir</replaceable></arg>
34+
<group choice="plain">
35+
<group choice="opt">
36+
<arg choice="plain"><option>--pgdata</option></arg>
37+
<arg choice="plain"><option>-D</option></arg>
38+
</group>
39+
<replaceable class="parameter"> datadir</replaceable>
40+
</group>
2941
</cmdsynopsis>
3042
</refsynopsisdiv>
3143

@@ -78,6 +90,7 @@ PostgreSQL documentation
7890
<variablelist>
7991
<varlistentry>
8092
<term><option>-f</option></term>
93+
<term><option>--force</option></term>
8194
<listitem>
8295
<para>
8396
Force <command>pg_resetwal</command> to proceed even if it cannot determine
@@ -88,9 +101,10 @@ PostgreSQL documentation
88101

89102
<varlistentry>
90103
<term><option>-n</option></term>
104+
<term><option>--dry-run</option></term>
91105
<listitem>
92106
<para>
93-
The <option>-n</option> (no operation) option instructs
107+
The <option>-n</option>/<option>--dry-run</option> option instructs
94108
<command>pg_resetwal</command> to print the values reconstructed from
95109
<filename>pg_control</filename> and values about to be changed, and then exit
96110
without modifying anything. This is mainly a debugging tool, but can be
@@ -123,7 +137,8 @@ PostgreSQL documentation
123137

124138
<variablelist>
125139
<varlistentry>
126-
<term><option>-c</option> <replaceable class="parameter">xid</replaceable>,<replaceable class="parameter">xid</replaceable></term>
140+
<term><option>-c <replaceable class="parameter">xid</replaceable>,<replaceable class="parameter">xid</replaceable></option></term>
141+
<term><option>--commit-timestamp-ids=<replaceable class="parameter">xid</replaceable>,<replaceable class="parameter">xid</replaceable></option></term>
127142
<listitem>
128143
<para>
129144
Manually set the oldest and newest transaction IDs for which the commit
@@ -144,7 +159,8 @@ PostgreSQL documentation
144159
</varlistentry>
145160

146161
<varlistentry>
147-
<term><option>-e</option> <replaceable class="parameter">xid_epoch</replaceable></term>
162+
<term><option>-e <replaceable class="parameter">xid_epoch</replaceable></option></term>
163+
<term><option>--epoch=<replaceable class="parameter">xid_epoch</replaceable></option></term>
148164
<listitem>
149165
<para>
150166
Manually set the next transaction ID's epoch.
@@ -164,7 +180,8 @@ PostgreSQL documentation
164180
</varlistentry>
165181

166182
<varlistentry>
167-
<term><option>-l</option> <replaceable class="parameter">walfile</replaceable></term>
183+
<term><option>-l <replaceable class="parameter">walfile</replaceable></option></term>
184+
<term><option>--next-wal-file=<replaceable class="parameter">walfile</replaceable></option></term>
168185
<listitem>
169186
<para>
170187
Manually set the WAL starting location by specifying the name of the
@@ -203,7 +220,8 @@ PostgreSQL documentation
203220
</varlistentry>
204221

205222
<varlistentry>
206-
<term><option>-m</option> <replaceable class="parameter">mxid</replaceable>,<replaceable class="parameter">mxid</replaceable></term>
223+
<term><option>-m <replaceable class="parameter">mxid</replaceable>,<replaceable class="parameter">mxid</replaceable></option></term>
224+
<term><option>--multixact-ids=<replaceable class="parameter">mxid</replaceable>,<replaceable class="parameter">mxid</replaceable></option></term>
207225
<listitem>
208226
<para>
209227
Manually set the next and oldest multitransaction ID.
@@ -224,7 +242,8 @@ PostgreSQL documentation
224242
</varlistentry>
225243

226244
<varlistentry>
227-
<term><option>-o</option> <replaceable class="parameter">oid</replaceable></term>
245+
<term><option>-o <replaceable class="parameter">oid</replaceable></option></term>
246+
<term><option>--next-oid=<replaceable class="parameter">oid</replaceable></option></term>
228247
<listitem>
229248
<para>
230249
Manually set the next OID.
@@ -239,7 +258,8 @@ PostgreSQL documentation
239258
</varlistentry>
240259

241260
<varlistentry>
242-
<term><option>-O</option> <replaceable class="parameter">mxoff</replaceable></term>
261+
<term><option>-O <replaceable class="parameter">mxoff</replaceable></option></term>
262+
<term><option>--multixact-offset=<replaceable class="parameter">mxoff</replaceable></option></term>
243263
<listitem>
244264
<para>
245265
Manually set the next multitransaction offset.
@@ -256,7 +276,8 @@ PostgreSQL documentation
256276
</varlistentry>
257277

258278
<varlistentry>
259-
<term><option>-x</option> <replaceable class="parameter">xid</replaceable></term>
279+
<term><option>-x <replaceable class="parameter">xid</replaceable></option></term>
280+
<term><option>--next-transaction-id=<replaceable class="parameter">xid</replaceable></option></term>
260281
<listitem>
261282
<para>
262283
Manually set the next transaction ID.

src/bin/pg_controldata/pg_controldata.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ usage(const char *progname)
3434
printf(_("Usage:\n"));
3535
printf(_(" %s [OPTION] [DATADIR]\n"), progname);
3636
printf(_("\nOptions:\n"));
37-
printf(_(" [-D] DATADIR data directory\n"));
38-
printf(_(" -V, --version output version information, then exit\n"));
39-
printf(_(" -?, --help show this help, then exit\n"));
37+
printf(_(" [-D,--pgdata=]DATADIR data directory\n"));
38+
printf(_(" -V, --version output version information, then exit\n"));
39+
printf(_(" -?, --help show this help, then exit\n"));
4040
printf(_("\nIf no data directory (DATADIR) is specified, "
4141
"the environment variable PGDATA\nis used.\n\n"));
4242
printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n"));
@@ -85,6 +85,11 @@ wal_level_str(WalLevel wal_level)
8585
int
8686
main(int argc, char *argv[])
8787
{
88+
static struct option long_options[] = {
89+
{"pgdata", required_argument, NULL, 'D'},
90+
{NULL, 0, NULL, 0}
91+
};
92+
8893
ControlFileData *ControlFile;
8994
bool crc_ok;
9095
char *DataDir = NULL;
@@ -118,7 +123,7 @@ main(int argc, char *argv[])
118123
}
119124
}
120125

121-
while ((c = getopt(argc, argv, "D:")) != -1)
126+
while ((c = getopt_long(argc, argv, "D:", long_options, NULL)) != -1)
122127
{
123128
switch (c)
124129
{

src/bin/pg_resetwal/pg_resetwal.c

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ static void usage(void);
8888
int
8989
main(int argc, char *argv[])
9090
{
91+
static struct option long_options[] = {
92+
{"commit-timestamp-ids", required_argument, NULL, 'c'},
93+
{"pgdata", required_argument, NULL, 'D'},
94+
{"epoch", required_argument, NULL, 'e'},
95+
{"force", no_argument, NULL, 'f'},
96+
{"next-wal-file", required_argument, NULL, 'l'},
97+
{"multixact-ids", required_argument, NULL, 'm'},
98+
{"dry-run", no_argument, NULL, 'n'},
99+
{"next-oid", required_argument, NULL, 'o'},
100+
{"multixact-offset", required_argument, NULL, 'O'},
101+
{"next-transaction-id", required_argument, NULL, 'x'},
102+
{NULL, 0, NULL, 0}
103+
};
104+
91105
int c;
92106
bool force = false;
93107
bool noupdate = false;
@@ -117,7 +131,7 @@ main(int argc, char *argv[])
117131
}
118132

119133

120-
while ((c = getopt(argc, argv, "c:D:e:fl:m:no:O:x:")) != -1)
134+
while ((c = getopt_long(argc, argv, "c:D:e:fl:m:no:O:x:", long_options, NULL)) != -1)
121135
{
122136
switch (c)
123137
{
@@ -1251,18 +1265,19 @@ usage(void)
12511265
printf(_("%s resets the PostgreSQL write-ahead log.\n\n"), progname);
12521266
printf(_("Usage:\n %s [OPTION]... DATADIR\n\n"), progname);
12531267
printf(_("Options:\n"));
1254-
printf(_(" -c XID,XID set oldest and newest transactions bearing commit timestamp\n"));
1255-
printf(_(" (zero in either value means no change)\n"));
1256-
printf(_(" [-D] DATADIR data directory\n"));
1257-
printf(_(" -e XIDEPOCH set next transaction ID epoch\n"));
1258-
printf(_(" -f force update to be done\n"));
1259-
printf(_(" -l WALFILE force minimum WAL starting location for new write-ahead log\n"));
1260-
printf(_(" -m MXID,MXID set next and oldest multitransaction ID\n"));
1261-
printf(_(" -n no update, just show what would be done (for testing)\n"));
1262-
printf(_(" -o OID set next OID\n"));
1263-
printf(_(" -O OFFSET set next multitransaction offset\n"));
1264-
printf(_(" -V, --version output version information, then exit\n"));
1265-
printf(_(" -x XID set next transaction ID\n"));
1266-
printf(_(" -?, --help show this help, then exit\n"));
1268+
printf(_(" -c, --commit-timestamp-ids=XID,XID\n"
1269+
" set oldest and newest transactions bearing\n"
1270+
" commit timestamp (zero means no change)\n"));
1271+
printf(_(" [-D, --pgdata=]DATADIR data directory\n"));
1272+
printf(_(" -e, --epoch=XIDEPOCH set next transaction ID epoch\n"));
1273+
printf(_(" -f, --force force update to be done\n"));
1274+
printf(_(" -l, --next-wal-file=WALFILE set minimum starting location for new WAL\n"));
1275+
printf(_(" -m, --multixact-ids=MXID,MXID set next and oldest multitransaction ID\n"));
1276+
printf(_(" -n, --dry-run no update, just show what would be done\n"));
1277+
printf(_(" -o, --next-oid=OID set next OID\n"));
1278+
printf(_(" -O, --multixact-offset=OFFSET set next multitransaction offset\n"));
1279+
printf(_(" -V, --version output version information, then exit\n"));
1280+
printf(_(" -x, --next-transaction-id=XID set next transaction ID\n"));
1281+
printf(_(" -?, --help show this help, then exit\n"));
12671282
printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
12681283
}

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