1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-15 01:04:37 +02:00

Fixed issue where --reset-* was not passing the default value to Perl.

Contributed by Cynthia Shang.
This commit is contained in:
Cynthia Shang
2018-02-13 15:58:14 -05:00
committed by David Steele
parent 213724907b
commit 00e9aca872
5 changed files with 76 additions and 58 deletions

View File

@ -2171,7 +2171,7 @@ foreach my $strKey (sort(keys(%hConfigDefine)))
{
$hConfigDefine{$strKey}{&CFGDEF_RESET} = true;
}
elsif (!$hConfigDefine{$strKey}{&CFGDEF_RESET})
elsif (!defined($hConfigDefine{$strKey}{&CFGDEF_RESET}))
{
$hConfigDefine{$strKey}{&CFGDEF_RESET} = false;
}

View File

@ -139,14 +139,15 @@ sub configLoad
$oOption{$strOptionName}{value} = false;
}
}
# Else reset the option
elsif ($rhOption->{$strOptionName}{reset})
{
$oOption{$strOptionName}{reset} = true;
}
# Else set the value
else
{
# If option is reset, then indicate --reset should be prepended when passing the option to child processes
if ($rhOption->{$strOptionName}{reset})
{
$oOption{$strOptionName}{reset} = true;
}
if (defined($rhOption->{$strOptionName}{value}))
{
if (cfgDefOptionType($iOptionId) eq CFGDEF_TYPE_BOOLEAN)

View File

@ -66,12 +66,19 @@ perlOptionJson()
// If option was negated
if (cfgOptionNegate(optionId))
strCatFmt(result, "\"negate\":%s", strPtr(varStrForce(varNewBool(true))));
// Else if option was reset
else if (cfgOptionReset(optionId))
strCatFmt(result, "\"reset\":%s", strPtr(varStrForce(varNewBool(true))));
// Else not negated and has a value
else if (cfgOption(optionId) != NULL)
else
{
// If option is reset then add indicator
if (cfgOptionReset(optionId))
strCatFmt(result, "\"reset\":%s", strPtr(varStrForce(varNewBool(true))));
// Else not negated and has a value
if (cfgOption(optionId) != NULL)
{
// If option is reset, then add a comma separator before setting the value
if (cfgOptionReset(optionId))
strCat(result, ",");
strCat(result, "\"value\":");
switch (cfgDefOptionType(cfgOptionDefIdFromId(optionId)))
@ -132,6 +139,7 @@ perlOptionJson()
}
}
}
}
strCat(result, "}");
}

View File

@ -370,6 +370,7 @@ testRun()
strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile)));
strLstAdd(argList, strNew("--no-online"));
strLstAdd(argList, strNew("--reset-pg1-host"));
strLstAdd(argList, strNew("--reset-backup-standby"));
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
storagePut(storageLocal(), configFile, bufNewStr(strNew(
@ -384,6 +385,7 @@ testRun()
"archive-copy=y\n"
"online=y\n"
"pg1-path=/not/path/to/db\n"
"backup-standby=y\n"
"\n"
"[db:backup]\n"
"compress=n\n"
@ -420,6 +422,8 @@ testRun()
TEST_RESULT_INT(cfgOptionSource(cfgOptRepoHardlink), cfgSourceConfig, " repo-hardlink is source config");
TEST_RESULT_INT(cfgOptionInt(cfgOptCompressLevel), 3, " compress-level is set");
TEST_RESULT_INT(cfgOptionSource(cfgOptCompressLevel), cfgSourceConfig, " compress-level is source config");
TEST_RESULT_BOOL(cfgOptionBool(cfgOptBackupStandby), false, " backup-standby not is set");
TEST_RESULT_INT(cfgOptionSource(cfgOptBackupStandby), cfgSourceDefault, " backup-standby is source default");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();

View File

@ -49,6 +49,10 @@ testRun()
cfgOptionValidSet(cfgOptPgHost, true);
cfgOptionResetSet(cfgOptPgHost, true);
cfgOptionValidSet(cfgOptBackupStandby, true);
cfgOptionResetSet(cfgOptBackupStandby, true);
cfgOptionSet(cfgOptBackupStandby, cfgSourceDefault, varNewBool(false));
cfgOptionValidSet(cfgOptProtocolTimeout, true);
cfgOptionSet(cfgOptProtocolTimeout, cfgSourceParam, varNewDbl(1.1));
@ -65,6 +69,7 @@ testRun()
strPtr(strLstJoin(perlCommand(), "|")),
TEST_ENV_EXE "|" TEST_PERL_EXE "|" TEST_PERL_MAIN "','backup','{"
"\"archive-queue-max\":{\"source\":\"param\",\"value\":999999999999},"
"\"backup-standby\":{\"reset\":true,\"value\":false},"
"\"compress\":{\"source\":\"param\",\"value\":true},"
"\"compress-level\":{\"source\":\"config\",\"value\":3},"
"\"online\":{\"source\":\"param\",\"negate\":true},"