Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit108e399

Browse files
committed
Display old and new values in pg_resetxlog -n output.
For extra clarity.Rajeev Rastogi, reviewed by Amit Kapila
1 parent22310b8 commit108e399

File tree

2 files changed

+76
-18
lines changed

2 files changed

+76
-18
lines changed

‎doc/src/sgml/ref/pg_resetxlog.sgml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ PostgreSQL documentation
177177
<para>
178178
The <option>-n</> (no operation) option instructs
179179
<command>pg_resetxlog</command> to print the values reconstructed from
180-
<filename>pg_control</> and then exit without modifying anything.
181-
This is mainly a debugging tool, but can be useful as a sanity check
182-
before allowing <command>pg_resetxlog</command> to proceed for real.
180+
<filename>pg_control</> and values about to be changed, and then exit
181+
without modifying anything. This is mainly a debugging tool, but can be
182+
useful as a sanity check before allowing <command>pg_resetxlog</command>
183+
to proceed for real.
183184
</para>
184185

185186
<para>

‎src/bin/pg_resetxlog/pg_resetxlog.c

Lines changed: 72 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,18 @@ static ControlFileData ControlFile;/* pg_control values */
6464
staticXLogSegNonewXlogSegNo;/* new XLOG segment # */
6565
staticboolguessed= false;/* T if we had to guess at any values */
6666
staticconstchar*progname;
67+
staticuint32set_xid_epoch= (uint32)-1;
68+
staticTransactionIdset_xid=0;
69+
staticOidset_oid=0;
70+
staticMultiXactIdset_mxid=0;
71+
staticMultiXactOffsetset_mxoff= (MultiXactOffset)-1;
72+
staticuint32minXlogTli=0;
73+
staticXLogSegNominXlogSegNo=0;
6774

6875
staticboolReadControlFile(void);
6976
staticvoidGuessControlValues(void);
7077
staticvoidPrintControlValues(boolguessed);
78+
staticvoidPrintNewControlValues(void);
7179
staticvoidRewriteControlFile(void);
7280
staticvoidFindEndOfXLOG(void);
7381
staticvoidKillExistingXLOG(void);
@@ -82,14 +90,7 @@ main(int argc, char *argv[])
8290
intc;
8391
boolforce= false;
8492
boolnoupdate= false;
85-
uint32set_xid_epoch= (uint32)-1;
86-
TransactionIdset_xid=0;
87-
Oidset_oid=0;
88-
MultiXactIdset_mxid=0;
8993
MultiXactIdset_oldestmxid=0;
90-
MultiXactOffsetset_mxoff= (MultiXactOffset)-1;
91-
uint32minXlogTli=0;
92-
XLogSegNominXlogSegNo=0;
9394
char*endptr;
9495
char*endptr2;
9596
char*DataDir;
@@ -301,6 +302,13 @@ main(int argc, char *argv[])
301302
*/
302303
FindEndOfXLOG();
303304

305+
/*
306+
* If we're not going to proceed with the reset, print the current control
307+
* file parameters.
308+
*/
309+
if ((guessed&& !force)||noupdate)
310+
PrintControlValues(guessed);
311+
304312
/*
305313
* Adjust fields if required by switches. (Do this now so that printout,
306314
* if any, includes these values.)
@@ -356,7 +364,7 @@ main(int argc, char *argv[])
356364
*/
357365
if ((guessed&& !force)||noupdate)
358366
{
359-
PrintControlValues(guessed);
367+
PrintNewControlValues();
360368
if (!noupdate)
361369
{
362370
printf(_("\nIf these values seem acceptable, use -f to force reset.\n"));
@@ -556,12 +564,11 @@ static void
556564
PrintControlValues(boolguessed)
557565
{
558566
charsysident_str[32];
559-
charfname[MAXFNAMELEN];
560567

561568
if (guessed)
562569
printf(_("Guessed pg_control values:\n\n"));
563570
else
564-
printf(_("pg_control values:\n\n"));
571+
printf(_("Currentpg_control values:\n\n"));
565572

566573
/*
567574
* Format system_identifier separately to keep platform-dependent format
@@ -570,10 +577,6 @@ PrintControlValues(bool guessed)
570577
snprintf(sysident_str,sizeof(sysident_str),UINT64_FORMAT,
571578
ControlFile.system_identifier);
572579

573-
XLogFileName(fname,ControlFile.checkPointCopy.ThisTimeLineID,newXlogSegNo);
574-
575-
printf(_("First log segment after reset: %s\n"),
576-
fname);
577580
printf(_("pg_control version number: %u\n"),
578581
ControlFile.pg_control_version);
579582
printf(_("Catalog version number: %u\n"),
@@ -631,6 +634,60 @@ PrintControlValues(bool guessed)
631634
}
632635

633636

637+
/*
638+
* Print the values to be changed.
639+
*/
640+
staticvoid
641+
PrintNewControlValues()
642+
{
643+
charfname[MAXFNAMELEN];
644+
645+
/* This will be always printed in order to keep format same. */
646+
printf(_("\n\nValues to be changed:\n\n"));
647+
648+
XLogFileName(fname,ControlFile.checkPointCopy.ThisTimeLineID,newXlogSegNo);
649+
printf(_("First log segment after reset: %s\n"),fname);
650+
651+
if (set_mxid!=0)
652+
{
653+
printf(_("NextMultiXactId: %u\n"),
654+
ControlFile.checkPointCopy.nextMulti);
655+
printf(_("OldestMultiXid: %u\n"),
656+
ControlFile.checkPointCopy.oldestMulti);
657+
printf(_("OldestMulti's DB: %u\n"),
658+
ControlFile.checkPointCopy.oldestMultiDB);
659+
}
660+
661+
if (set_mxoff!=-1)
662+
{
663+
printf(_("NextMultiOffset: %u\n"),
664+
ControlFile.checkPointCopy.nextMultiOffset);
665+
}
666+
667+
if (set_oid!=0)
668+
{
669+
printf(_("NextOID: %u\n"),
670+
ControlFile.checkPointCopy.nextOid);
671+
}
672+
673+
if (set_xid!=0)
674+
{
675+
printf(_("NextXID: %u\n"),
676+
ControlFile.checkPointCopy.nextXid);
677+
printf(_("OldestXID: %u\n"),
678+
ControlFile.checkPointCopy.oldestXid);
679+
printf(_("OldestXID's DB: %u\n"),
680+
ControlFile.checkPointCopy.oldestXidDB);
681+
}
682+
683+
if (set_xid_epoch!=-1)
684+
{
685+
printf(_("NextXID Epoch: %u\n"),
686+
ControlFile.checkPointCopy.nextXidEpoch);
687+
}
688+
}
689+
690+
634691
/*
635692
* Write out the new pg_control file.
636693
*/
@@ -1039,7 +1096,7 @@ usage(void)
10391096
printf(_(" -f force update to be done\n"));
10401097
printf(_(" -l XLOGFILE force minimum WAL starting location for new transaction log\n"));
10411098
printf(_(" -m MXID,MXID set next and oldest multitransaction ID\n"));
1042-
printf(_(" -n no update, just showextracted control values (for testing)\n"));
1099+
printf(_(" -n no update, just showwhat would be done (for testing)\n"));
10431100
printf(_(" -o OID set next OID\n"));
10441101
printf(_(" -O OFFSET set next multitransaction offset\n"));
10451102
printf(_(" -V, --version output version information, then exit\n"));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp