@@ -64,6 +64,7 @@ static XLogSegNo newXlogSegNo; /* new XLOG segment # */
64
64
static bool guessed = false; /* T if we had to guess at any values */
65
65
static const char * progname ;
66
66
static uint32 set_xid_epoch = (uint32 ) - 1 ;
67
+ static TransactionId set_oldest_xid = 0 ;
67
68
static TransactionId set_xid = 0 ;
68
69
static TransactionId set_oldest_commit_ts_xid = 0 ;
69
70
static TransactionId set_newest_commit_ts_xid = 0 ;
@@ -101,6 +102,7 @@ main(int argc, char *argv[])
101
102
{"dry-run" , no_argument , NULL , 'n' },
102
103
{"next-oid" , required_argument , NULL , 'o' },
103
104
{"multixact-offset" , required_argument , NULL , 'O' },
105
+ {"oldest-transaction-id" , required_argument , NULL , 'u' },
104
106
{"next-transaction-id" , required_argument , NULL , 'x' },
105
107
{"wal-segsize" , required_argument , NULL , 1 },
106
108
{NULL , 0 , NULL , 0 }
@@ -135,7 +137,7 @@ main(int argc, char *argv[])
135
137
}
136
138
137
139
138
- while ((c = getopt_long (argc , argv , "c:D:e:fl:m:no:O:x:" , long_options , NULL )) != -1 )
140
+ while ((c = getopt_long (argc , argv , "c:D:e:fl:m:no:O:u: x:" , long_options , NULL )) != -1 )
139
141
{
140
142
switch (c )
141
143
{
@@ -168,6 +170,21 @@ main(int argc, char *argv[])
168
170
}
169
171
break ;
170
172
173
+ case 'u' :
174
+ set_oldest_xid = strtoul (optarg , & endptr , 0 );
175
+ if (endptr == optarg || * endptr != '\0' )
176
+ {
177
+ fprintf (stderr , _ ("invalid argument for option %s" ), "-u" );
178
+ fprintf (stderr , _ ("Try \"%s --help\" for more information.\n" ), progname );
179
+ exit (1 );
180
+ }
181
+ if (!TransactionIdIsNormal (set_oldest_xid ))
182
+ {
183
+ fprintf (stderr , _ ("oldest transaction ID (-u) must be greater or equal to %u" ), FirstNormalTransactionId );
184
+ exit (1 );
185
+ }
186
+ break ;
187
+
171
188
case 'x' :
172
189
set_xid = strtoul (optarg , & endptr , 0 );
173
190
if (endptr == optarg || * endptr != '\0' )
@@ -433,23 +450,15 @@ main(int argc, char *argv[])
433
450
if (set_xid_epoch != -1 )
434
451
ControlFile .checkPointCopy .nextXidEpoch = set_xid_epoch ;
435
452
436
- if (set_xid != 0 )
453
+ if (set_oldest_xid != 0 )
437
454
{
438
- ControlFile .checkPointCopy .nextXid = set_xid ;
439
-
440
- /*
441
- * For the moment, just set oldestXid to a value that will force
442
- * immediate autovacuum-for-wraparound. It's not clear whether adding
443
- * user control of this is useful, so let's just do something that's
444
- * reasonably safe. The magic constant here corresponds to the
445
- * maximum allowed value of autovacuum_freeze_max_age.
446
- */
447
- ControlFile .checkPointCopy .oldestXid = set_xid - 2000000000 ;
448
- if (ControlFile .checkPointCopy .oldestXid < FirstNormalTransactionId )
449
- ControlFile .checkPointCopy .oldestXid += FirstNormalTransactionId ;
455
+ ControlFile .checkPointCopy .oldestXid = set_oldest_xid ;
450
456
ControlFile .checkPointCopy .oldestXidDB = InvalidOid ;
451
457
}
452
458
459
+ if (set_xid != 0 )
460
+ ControlFile .checkPointCopy .nextXid = set_xid ;
461
+
453
462
if (set_oldest_commit_ts_xid != 0 )
454
463
ControlFile .checkPointCopy .oldestCommitTsXid = set_oldest_commit_ts_xid ;
455
464
if (set_newest_commit_ts_xid != 0 )
@@ -1311,19 +1320,20 @@ usage(void)
1311
1320
printf (_ ("Usage:\n %s [OPTION]... DATADIR\n\n" ), progname );
1312
1321
printf (_ ("Options:\n" ));
1313
1322
printf (_ (" -c, --commit-timestamp-ids=XID,XID\n"
1314
- " set oldest and newest transactions bearing\n"
1315
- " commit timestamp (zero means no change)\n" ));
1316
- printf (_ (" [-D, --pgdata=]DATADIR data directory\n" ));
1317
- printf (_ (" -e, --epoch=XIDEPOCH set next transaction ID epoch\n" ));
1318
- printf (_ (" -f, --force force update to be done\n" ));
1319
- printf (_ (" -l, --next-wal-file=WALFILE set minimum starting location for new WAL\n" ));
1320
- printf (_ (" -m, --multixact-ids=MXID,MXID set next and oldest multitransaction ID\n" ));
1321
- printf (_ (" -n, --dry-run no update, just show what would be done\n" ));
1322
- printf (_ (" -o, --next-oid=OID set next OID\n" ));
1323
- printf (_ (" -O, --multixact-offset=OFFSET set next multitransaction offset\n" ));
1324
- printf (_ (" -V, --version output version information, then exit\n" ));
1325
- printf (_ (" -x, --next-transaction-id=XID set next transaction ID\n" ));
1326
- printf (_ (" --wal-segsize=SIZE size of WAL segments, in megabytes\n" ));
1327
- printf (_ (" -?, --help show this help, then exit\n" ));
1323
+ " set oldest and newest transactions bearing\n"
1324
+ " commit timestamp (zero means no change)\n" ));
1325
+ printf (_ (" [-D, --pgdata=]DATADIR data directory\n" ));
1326
+ printf (_ (" -e, --epoch=XIDEPOCH set next transaction ID epoch\n" ));
1327
+ printf (_ (" -f, --force force update to be done\n" ));
1328
+ printf (_ (" -l, --next-wal-file=WALFILE set minimum starting location for new WAL\n" ));
1329
+ printf (_ (" -m, --multixact-ids=MXID,MXID set next and oldest multitransaction ID\n" ));
1330
+ printf (_ (" -n, --dry-run no update, just show what would be done\n" ));
1331
+ printf (_ (" -o, --next-oid=OID set next OID\n" ));
1332
+ printf (_ (" -O, --multixact-offset=OFFSET set next multitransaction offset\n" ));
1333
+ printf (_ (" -u, --oldest-transaction-id=XID set oldest transaction ID\n" ));
1334
+ printf (_ (" -V, --version output version information, then exit\n" ));
1335
+ printf (_ (" -x, --next-transaction-id=XID set next transaction ID\n" ));
1336
+ printf (_ (" --wal-segsize=SIZE size of WAL segments, in megabytes\n" ));
1337
+ printf (_ (" -?, --help show this help, then exit\n" ));
1328
1338
printf (_ ("\nReport bugs to <pgsql-bugs@postgresql.org>.\n" ));
1329
1339
}
0 commit comments