From d5d1ec6f6f4820808f30f4e9015bf22f2534de4e Mon Sep 17 00:00:00 2001 From: David Steele Date: Wed, 4 Nov 2020 11:09:05 -0500 Subject: [PATCH] Use a constant to check restore target action. Checking the default here was fragile. If the default were to change the code would break. This also removes the only dependency on cfgOptionDefault() outside of the help command. --- src/command/restore/restore.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/command/restore/restore.c b/src/command/restore/restore.c index e7b56b6bf..e9b9e1fd4 100644 --- a/src/command/restore/restore.c +++ b/src/command/restore/restore.c @@ -40,6 +40,8 @@ Recovery constants #define RECOVERY_TARGET_XID "recovery_target_xid" #define RECOVERY_TARGET_ACTION "recovery_target_action" +#define RECOVERY_TARGET_ACTION_PAUSE "pause" + STRING_STATIC(RECOVERY_TARGET_ACTION_PAUSE_STR, RECOVERY_TARGET_ACTION_PAUSE); #define RECOVERY_TARGET_ACTION_SHUTDOWN "shutdown" STRING_STATIC(RECOVERY_TARGET_ACTION_SHUTDOWN_STR, RECOVERY_TARGET_ACTION_SHUTDOWN); @@ -1409,7 +1411,7 @@ restoreRecoveryOption(unsigned int pgVersion) { const String *targetAction = cfgOptionStr(cfgOptTargetAction); - if (!strEq(targetAction, varStr(cfgOptionDefault(cfgOptTargetAction)))) + if (!strEq(targetAction, RECOVERY_TARGET_ACTION_PAUSE_STR)) { // Write recovery_target on supported PostgreSQL versions if (pgVersion >= PG_VERSION_RECOVERY_TARGET_ACTION)