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

Commit3cdafe4

Browse files
Adjust comment in .history file to match recovery target specified. Comment
present since 8.0 was never fully meaningful, since two recovery targetscannot be specified. Refactor recovery target type to make this changeand associated code easier to understand. No change in function.Bug report arising from internal support question.
1 parent5c73ae1 commit3cdafe4

File tree

2 files changed

+53
-30
lines changed

2 files changed

+53
-30
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.382 2010/03/18 09:17:18 heikki Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.383 2010/03/19 11:05:14 sriggs Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -172,8 +172,7 @@ static bool restoredFromArchive = false;
172172
staticchar*recoveryRestoreCommand=NULL;
173173
staticchar*recoveryEndCommand=NULL;
174174
staticchar*restartPointCommand=NULL;
175-
staticboolrecoveryTarget= false;
176-
staticboolrecoveryTargetExact= false;
175+
staticRecoveryTargetTyperecoveryTarget=RECOVERY_TARGET_UNSET;
177176
staticboolrecoveryTargetInclusive= true;
178177
staticTransactionIdrecoveryTargetXid;
179178
staticTimestampTzrecoveryTargetTime;
@@ -4224,14 +4223,32 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
42244223
*/
42254224
XLogFileName(xlogfname,endTLI,endLogId,endLogSeg);
42264225

4227-
snprintf(buffer,sizeof(buffer),
4228-
"%s%u\t%s\t%s transaction %u at %s\n",
4229-
(srcfd<0) ?"" :"\n",
4230-
parentTLI,
4231-
xlogfname,
4232-
recoveryStopAfter ?"after" :"before",
4233-
recoveryStopXid,
4234-
timestamptz_to_str(recoveryStopTime));
4226+
/*
4227+
* Write comment to history file to explain why and where timeline changed.
4228+
* Comment varies according to the recovery target used.
4229+
*/
4230+
if (recoveryTarget==RECOVERY_TARGET_XID)
4231+
snprintf(buffer,sizeof(buffer),
4232+
"%s%u\t%s\t%s transaction %u\n",
4233+
(srcfd<0) ?"" :"\n",
4234+
parentTLI,
4235+
xlogfname,
4236+
recoveryStopAfter ?"after" :"before",
4237+
recoveryStopXid);
4238+
if (recoveryTarget==RECOVERY_TARGET_TIME)
4239+
snprintf(buffer,sizeof(buffer),
4240+
"%s%u\t%s\t%s %s\n",
4241+
(srcfd<0) ?"" :"\n",
4242+
parentTLI,
4243+
xlogfname,
4244+
recoveryStopAfter ?"after" :"before",
4245+
timestamptz_to_str(recoveryStopTime));
4246+
else
4247+
snprintf(buffer,sizeof(buffer),
4248+
"%s%u\t%s\tno recovery target specified\n",
4249+
(srcfd<0) ?"" :"\n",
4250+
parentTLI,
4251+
xlogfname);
42354252

42364253
nbytes=strlen(buffer);
42374254
errno=0;
@@ -4978,19 +4995,17 @@ readRecoveryCommandFile(void)
49784995
ereport(DEBUG2,
49794996
(errmsg("recovery_target_xid = %u",
49804997
recoveryTargetXid)));
4981-
recoveryTarget= true;
4982-
recoveryTargetExact= true;
4998+
recoveryTarget=RECOVERY_TARGET_XID;
49834999
}
49845000
elseif (strcmp(tok1,"recovery_target_time")==0)
49855001
{
49865002
/*
49875003
* if recovery_target_xid specified, then this overrides
49885004
* recovery_target_time
49895005
*/
4990-
if (recoveryTargetExact)
5006+
if (recoveryTarget==RECOVERY_TARGET_XID)
49915007
continue;
4992-
recoveryTarget= true;
4993-
recoveryTargetExact= false;
5008+
recoveryTarget=RECOVERY_TARGET_TIME;
49945009

49955010
/*
49965011
* Convert the time string given by the user to TimestampTz form.
@@ -5265,13 +5280,13 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis)
52655280
return false;
52665281

52675282
/* Do we have a PITR target at all? */
5268-
if (!recoveryTarget)
5283+
if (recoveryTarget==RECOVERY_TARGET_UNSET)
52695284
{
52705285
recoveryLastXTime=recordXtime;
52715286
return false;
52725287
}
52735288

5274-
if (recoveryTargetExact)
5289+
if (recoveryTarget==RECOVERY_TARGET_XID)
52755290
{
52765291
/*
52775292
* there can be only one transaction end record with this exact
@@ -5665,17 +5680,14 @@ StartupXLOG(void)
56655680
if (StandbyMode)
56665681
ereport(LOG,
56675682
(errmsg("entering standby mode")));
5668-
elseif (recoveryTarget)
5669-
{
5670-
if (recoveryTargetExact)
5671-
ereport(LOG,
5672-
(errmsg("starting point-in-time recovery to XID %u",
5673-
recoveryTargetXid)));
5674-
else
5675-
ereport(LOG,
5676-
(errmsg("starting point-in-time recovery to %s",
5677-
timestamptz_to_str(recoveryTargetTime))));
5678-
}
5683+
elseif (recoveryTarget==RECOVERY_TARGET_XID)
5684+
ereport(LOG,
5685+
(errmsg("starting point-in-time recovery to XID %u",
5686+
recoveryTargetXid)));
5687+
elseif (recoveryTarget==RECOVERY_TARGET_TIME)
5688+
ereport(LOG,
5689+
(errmsg("starting point-in-time recovery to %s",
5690+
timestamptz_to_str(recoveryTargetTime))));
56795691
else
56805692
ereport(LOG,
56815693
(errmsg("starting archive recovery")));

‎src/include/access/xlog.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.103 2010/02/26 02:01:21 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.104 2010/03/19 11:05:15 sriggs Exp $
1010
*/
1111
#ifndefXLOG_H
1212
#defineXLOG_H
@@ -172,6 +172,17 @@ extern HotStandbyState standbyState;
172172

173173
#defineInHotStandby (standbyState >= STANDBY_SNAPSHOT_PENDING)
174174

175+
/*
176+
* Recovery target type.
177+
* Only set during a Point in Time recovery, not when standby_mode = on
178+
*/
179+
typedefenum
180+
{
181+
RECOVERY_TARGET_UNSET,
182+
RECOVERY_TARGET_XID,
183+
RECOVERY_TARGET_TIME
184+
}RecoveryTargetType;
185+
175186
externXLogRecPtrXactLastRecEnd;
176187

177188
/* these variables are GUC parameters related to XLOG */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp