|
7 | 7 | * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group |
8 | 8 | * Portions Copyright (c) 1994, Regents of the University of California |
9 | 9 | * |
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 $ |
11 | 11 | * |
12 | 12 | *------------------------------------------------------------------------- |
13 | 13 | */ |
@@ -172,8 +172,7 @@ static bool restoredFromArchive = false; |
172 | 172 | staticchar*recoveryRestoreCommand=NULL; |
173 | 173 | staticchar*recoveryEndCommand=NULL; |
174 | 174 | staticchar*restartPointCommand=NULL; |
175 | | -staticboolrecoveryTarget= false; |
176 | | -staticboolrecoveryTargetExact= false; |
| 175 | +staticRecoveryTargetTyperecoveryTarget=RECOVERY_TARGET_UNSET; |
177 | 176 | staticboolrecoveryTargetInclusive= true; |
178 | 177 | staticTransactionIdrecoveryTargetXid; |
179 | 178 | staticTimestampTzrecoveryTargetTime; |
@@ -4224,14 +4223,32 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI, |
4224 | 4223 | */ |
4225 | 4224 | XLogFileName(xlogfname,endTLI,endLogId,endLogSeg); |
4226 | 4225 |
|
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); |
4235 | 4252 |
|
4236 | 4253 | nbytes=strlen(buffer); |
4237 | 4254 | errno=0; |
@@ -4978,19 +4995,17 @@ readRecoveryCommandFile(void) |
4978 | 4995 | ereport(DEBUG2, |
4979 | 4996 | (errmsg("recovery_target_xid = %u", |
4980 | 4997 | recoveryTargetXid))); |
4981 | | -recoveryTarget= true; |
4982 | | -recoveryTargetExact= true; |
| 4998 | +recoveryTarget=RECOVERY_TARGET_XID; |
4983 | 4999 | } |
4984 | 5000 | elseif (strcmp(tok1,"recovery_target_time")==0) |
4985 | 5001 | { |
4986 | 5002 | /* |
4987 | 5003 | * if recovery_target_xid specified, then this overrides |
4988 | 5004 | * recovery_target_time |
4989 | 5005 | */ |
4990 | | -if (recoveryTargetExact) |
| 5006 | +if (recoveryTarget==RECOVERY_TARGET_XID) |
4991 | 5007 | continue; |
4992 | | -recoveryTarget= true; |
4993 | | -recoveryTargetExact= false; |
| 5008 | +recoveryTarget=RECOVERY_TARGET_TIME; |
4994 | 5009 |
|
4995 | 5010 | /* |
4996 | 5011 | * Convert the time string given by the user to TimestampTz form. |
@@ -5265,13 +5280,13 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) |
5265 | 5280 | return false; |
5266 | 5281 |
|
5267 | 5282 | /* Do we have a PITR target at all? */ |
5268 | | -if (!recoveryTarget) |
| 5283 | +if (recoveryTarget==RECOVERY_TARGET_UNSET) |
5269 | 5284 | { |
5270 | 5285 | recoveryLastXTime=recordXtime; |
5271 | 5286 | return false; |
5272 | 5287 | } |
5273 | 5288 |
|
5274 | | -if (recoveryTargetExact) |
| 5289 | +if (recoveryTarget==RECOVERY_TARGET_XID) |
5275 | 5290 | { |
5276 | 5291 | /* |
5277 | 5292 | * there can be only one transaction end record with this exact |
@@ -5665,17 +5680,14 @@ StartupXLOG(void) |
5665 | 5680 | if (StandbyMode) |
5666 | 5681 | ereport(LOG, |
5667 | 5682 | (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)))); |
5679 | 5691 | else |
5680 | 5692 | ereport(LOG, |
5681 | 5693 | (errmsg("starting archive recovery"))); |
|