pgbackrest.git / summary / log / commit / refs
commit dd708e6d27ac7b5917704fd07b40bb6fe2a2eee7
Author: David Steele <david@pgmasters.net>
Date: Mon Nov 09 21:37:05 2020 +0000
Fix override of user option reset.
If a user reset an option such as pg-default on the command-line then an override in the code would not take effect.
Ignore a reset when the code explicitly sets an option to prevent this.
src/config/exec.c | 2 +-
test/src/module/config/execTest.c | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/config/exec.c b/src/config/exec.c
index 56c9ac4b9..82b53ef9a 100644
--- a/src/config/exec.c
+++ b/src/config/exec.c
@@ -69,7 +69,7 @@ cfgExecParam(ConfigCommand commandId, ConfigCommandRole commandRoleId, const Key
}
// If the option was reset
- if (cfgOptionReset(optionId))
+ if (value == NULL && cfgOptionReset(optionId))
{
strLstAdd(result, strNewFmt("--reset-%s", cfgOptionName(optionId)));
}
diff --git a/test/src/module/config/execTest.c b/test/src/module/config/execTest.c
index 114cfafd2..85a70227d 100644
--- a/test/src/module/config/execTest.c
+++ b/test/src/module/config/execTest.c
@@ -58,6 +58,7 @@ testRun(void)
strLstAddZ(argList, "--db-include=2");
strLstAddZ(argList, "--recovery-option=a=b");
strLstAddZ(argList, "--recovery-option=c=d");
+ hrnCfgArgRawReset(argList, cfgOptLogPath);
strLstAddZ(argList, "restore");
setenv("PGBACKREST_REPO1_HOST", "bogus", true);
@@ -67,11 +68,12 @@ testRun(void)
KeyValue *optionReplace = kvNew();
kvPut(optionReplace, varNewStr(strNew("repo1-path")), varNewStr(strNew("/replace/path")));
kvPut(optionReplace, varNewStr(strNew("stanza")), NULL);
+ kvPut(optionReplace, VARSTRDEF(CFGOPT_LOG_PATH), VARSTRDEF("/log"));
TEST_RESULT_STR(
strLstJoin(cfgExecParam(cfgCmdRestore, cfgCmdRoleDefault, optionReplace, true, false), "|"),
strNewFmt(
- "--db-include=1|--db-include=2|--pg1-path=%s/db path|--recovery-option=a=b|--recovery-option=c=d"
+ "--db-include=1|--db-include=2|--log-path=/log|--pg1-path=%s/db path|--recovery-option=a=b|--recovery-option=c=d"
"|--repo1-path=/replace/path|restore",
testPath()),
"exec restore -> restore");
[parent: 6acd76b60ce9]