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

Commit4fe8dcd

Browse files
committed
Extract code to describe recovery stop reason to a function.
StartupXLOG() is very long, this makes it a little bit more readable.Reviewed-by: Andres FreundDiscussion:https://www.postgresql.org/message-id/b3b71061-4919-e882-4857-27e370ab134a%40iki.fi
1 parent6b16532 commit4fe8dcd

File tree

1 file changed

+39
-28
lines changed
  • src/backend/access/transam

1 file changed

+39
-28
lines changed

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

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ static void validateRecoveryParameters(void);
901901
staticvoidexitArchiveRecovery(TimeLineIDendTLI,XLogRecPtrendOfLog);
902902
staticboolrecoveryStopsBefore(XLogReaderState*record);
903903
staticboolrecoveryStopsAfter(XLogReaderState*record);
904+
staticchar*getRecoveryStopReason(void);
904905
staticvoidConfirmRecoveryPaused(void);
905906
staticvoidrecoveryPausesHere(boolendOfRecovery);
906907
staticboolrecoveryApplyDelay(XLogReaderState*record);
@@ -6059,6 +6060,42 @@ recoveryStopsAfter(XLogReaderState *record)
60596060
return false;
60606061
}
60616062

6063+
/*
6064+
* Create a comment for the history file to explain why and where
6065+
* timeline changed.
6066+
*/
6067+
staticchar*
6068+
getRecoveryStopReason(void)
6069+
{
6070+
charreason[200];
6071+
6072+
if (recoveryTarget==RECOVERY_TARGET_XID)
6073+
snprintf(reason,sizeof(reason),
6074+
"%s transaction %u",
6075+
recoveryStopAfter ?"after" :"before",
6076+
recoveryStopXid);
6077+
elseif (recoveryTarget==RECOVERY_TARGET_TIME)
6078+
snprintf(reason,sizeof(reason),
6079+
"%s %s\n",
6080+
recoveryStopAfter ?"after" :"before",
6081+
timestamptz_to_str(recoveryStopTime));
6082+
elseif (recoveryTarget==RECOVERY_TARGET_LSN)
6083+
snprintf(reason,sizeof(reason),
6084+
"%s LSN %X/%X\n",
6085+
recoveryStopAfter ?"after" :"before",
6086+
LSN_FORMAT_ARGS(recoveryStopLSN));
6087+
elseif (recoveryTarget==RECOVERY_TARGET_NAME)
6088+
snprintf(reason,sizeof(reason),
6089+
"at restore point \"%s\"",
6090+
recoveryStopName);
6091+
elseif (recoveryTarget==RECOVERY_TARGET_IMMEDIATE)
6092+
snprintf(reason,sizeof(reason),"reached consistency");
6093+
else
6094+
snprintf(reason,sizeof(reason),"no recovery target specified");
6095+
6096+
returnpstrdup(reason);
6097+
}
6098+
60626099
/*
60636100
* Wait until shared recoveryPauseState is set to RECOVERY_NOT_PAUSED.
60646101
*
@@ -7756,7 +7793,7 @@ StartupXLOG(void)
77567793
PrevTimeLineID=ThisTimeLineID;
77577794
if (ArchiveRecoveryRequested)
77587795
{
7759-
charreason[200];
7796+
char*reason;
77607797
charrecoveryPath[MAXPGPATH];
77617798

77627799
Assert(InArchiveRecovery);
@@ -7765,33 +7802,7 @@ StartupXLOG(void)
77657802
ereport(LOG,
77667803
(errmsg("selected new timeline ID: %u",ThisTimeLineID)));
77677804

7768-
/*
7769-
* Create a comment for the history file to explain why and where
7770-
* timeline changed.
7771-
*/
7772-
if (recoveryTarget==RECOVERY_TARGET_XID)
7773-
snprintf(reason,sizeof(reason),
7774-
"%s transaction %u",
7775-
recoveryStopAfter ?"after" :"before",
7776-
recoveryStopXid);
7777-
elseif (recoveryTarget==RECOVERY_TARGET_TIME)
7778-
snprintf(reason,sizeof(reason),
7779-
"%s %s\n",
7780-
recoveryStopAfter ?"after" :"before",
7781-
timestamptz_to_str(recoveryStopTime));
7782-
elseif (recoveryTarget==RECOVERY_TARGET_LSN)
7783-
snprintf(reason,sizeof(reason),
7784-
"%s LSN %X/%X\n",
7785-
recoveryStopAfter ?"after" :"before",
7786-
LSN_FORMAT_ARGS(recoveryStopLSN));
7787-
elseif (recoveryTarget==RECOVERY_TARGET_NAME)
7788-
snprintf(reason,sizeof(reason),
7789-
"at restore point \"%s\"",
7790-
recoveryStopName);
7791-
elseif (recoveryTarget==RECOVERY_TARGET_IMMEDIATE)
7792-
snprintf(reason,sizeof(reason),"reached consistency");
7793-
else
7794-
snprintf(reason,sizeof(reason),"no recovery target specified");
7805+
reason=getRecoveryStopReason();
77957806

77967807
/*
77977808
* We are now done reading the old WAL. Turn off archive fetching if

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp