Skip to content

Commit 872aad6

Browse files
committed
Per Tom, do full reset on -x flag.
1 parent f6e603c commit 872aad6

File tree

1 file changed

+26
-42
lines changed

1 file changed

+26
-42
lines changed

contrib/pg_resetxlog/pg_resetxlog.c

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
2424
* Portions Copyright (c) 1994, Regents of the University of California
2525
*
26-
* $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/pg_resetxlog.c,v 1.11 2002/01/10 17:51:52 momjian Exp $
26+
* $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/pg_resetxlog.c,v 1.12 2002/01/10 18:08:29 momjian Exp $
2727
*
2828
*-------------------------------------------------------------------------
2929
*/
@@ -714,32 +714,30 @@ RewriteControlFile(TransactionId set_xid)
714714
int fd;
715715
char buffer[BLCKSZ]; /* need not be aligned */
716716

717-
if (set_xid == 0)
718-
{
719-
/*
720-
* Adjust fields as needed to force an empty XLOG starting at the next
721-
* available segment.
722-
*/
723-
newXlogId = ControlFile.logId;
724-
newXlogSeg = ControlFile.logSeg;
725-
/* be sure we wrap around correctly at end of a logfile */
726-
NextLogSeg(newXlogId, newXlogSeg);
727-
728-
ControlFile.checkPointCopy.redo.xlogid = newXlogId;
729-
ControlFile.checkPointCopy.redo.xrecoff =
730-
newXlogSeg * XLogSegSize + SizeOfXLogPHD;
731-
ControlFile.checkPointCopy.undo = ControlFile.checkPointCopy.redo;
732-
ControlFile.checkPointCopy.time = time(NULL);
733-
734-
ControlFile.state = DB_SHUTDOWNED;
735-
ControlFile.time = time(NULL);
736-
ControlFile.logId = newXlogId;
737-
ControlFile.logSeg = newXlogSeg + 1;
738-
ControlFile.checkPoint = ControlFile.checkPointCopy.redo;
739-
ControlFile.prevCheckPoint.xlogid = 0;
740-
ControlFile.prevCheckPoint.xrecoff = 0;
741-
}
742-
else
717+
/*
718+
* Adjust fields as needed to force an empty XLOG starting at the next
719+
* available segment.
720+
*/
721+
newXlogId = ControlFile.logId;
722+
newXlogSeg = ControlFile.logSeg;
723+
/* be sure we wrap around correctly at end of a logfile */
724+
NextLogSeg(newXlogId, newXlogSeg);
725+
726+
ControlFile.checkPointCopy.redo.xlogid = newXlogId;
727+
ControlFile.checkPointCopy.redo.xrecoff =
728+
newXlogSeg * XLogSegSize + SizeOfXLogPHD;
729+
ControlFile.checkPointCopy.undo = ControlFile.checkPointCopy.redo;
730+
ControlFile.checkPointCopy.time = time(NULL);
731+
732+
ControlFile.state = DB_SHUTDOWNED;
733+
ControlFile.time = time(NULL);
734+
ControlFile.logId = newXlogId;
735+
ControlFile.logSeg = newXlogSeg + 1;
736+
ControlFile.checkPoint = ControlFile.checkPointCopy.redo;
737+
ControlFile.prevCheckPoint.xlogid = 0;
738+
ControlFile.prevCheckPoint.xrecoff = 0;
739+
740+
if (set_xid != 0)
743741
ControlFile.checkPointCopy.nextXid = set_xid;
744742

745743
/* Contents are protected with a CRC */
@@ -1011,20 +1009,6 @@ main(int argc, char **argv)
10111009
if (!ReadControlFile())
10121010
GuessControlValues();
10131011

1014-
/*
1015-
* Set XID in pg_control and exit
1016-
*/
1017-
if (set_xid)
1018-
{
1019-
if (guessed)
1020-
{
1021-
printf("\npg_control appears corrupt. Can not update XID.\n");
1022-
exit(1);
1023-
}
1024-
RewriteControlFile(set_xid);
1025-
exit(0);
1026-
}
1027-
10281012
/*
10291013
* If we had to guess anything, and -f was not given, just print the
10301014
* guessed values and exit. Also print if -n is given.
@@ -1051,7 +1035,7 @@ main(int argc, char **argv)
10511035
/*
10521036
* Else, do the dirty deed.
10531037
*/
1054-
RewriteControlFile(0);
1038+
RewriteControlFile(set_xid);
10551039
KillExistingXLOG();
10561040
WriteEmptyXLOG();
10571041

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