You've already forked pgbackrest
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:
committed by
David Steele
parent
213724907b
commit
00e9aca872
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
112
src/perl/exec.c
112
src/perl/exec.c
@ -66,69 +66,77 @@ 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
|
||||
{
|
||||
strCat(result, "\"value\":");
|
||||
// If option is reset then add indicator
|
||||
if (cfgOptionReset(optionId))
|
||||
strCatFmt(result, "\"reset\":%s", strPtr(varStrForce(varNewBool(true))));
|
||||
|
||||
switch (cfgDefOptionType(cfgOptionDefIdFromId(optionId)))
|
||||
// Else not negated and has a value
|
||||
if (cfgOption(optionId) != NULL)
|
||||
{
|
||||
case cfgDefOptTypeBoolean:
|
||||
case cfgDefOptTypeFloat:
|
||||
case cfgDefOptTypeInteger:
|
||||
// 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)))
|
||||
{
|
||||
strCat(result, strPtr(varStrForce(cfgOption(optionId))));
|
||||
break;
|
||||
}
|
||||
|
||||
case cfgDefOptTypeString:
|
||||
{
|
||||
strCatFmt(result, "\"%s\"", strPtr(cfgOptionStr(optionId)));
|
||||
break;
|
||||
}
|
||||
|
||||
case cfgDefOptTypeHash:
|
||||
{
|
||||
const KeyValue *valueKv = cfgOptionKv(optionId);
|
||||
const VariantList *keyList = kvKeyList(valueKv);
|
||||
|
||||
strCat(result, "{");
|
||||
|
||||
for (unsigned int listIdx = 0; listIdx < varLstSize(keyList); listIdx++)
|
||||
case cfgDefOptTypeBoolean:
|
||||
case cfgDefOptTypeFloat:
|
||||
case cfgDefOptTypeInteger:
|
||||
{
|
||||
if (listIdx != 0)
|
||||
strCat(result, ",");
|
||||
|
||||
strCatFmt(
|
||||
result, "\"%s\":\"%s\"", strPtr(varStr(varLstGet(keyList, listIdx))),
|
||||
strPtr(varStr(kvGet(valueKv, varLstGet(keyList, listIdx)))));
|
||||
strCat(result, strPtr(varStrForce(cfgOption(optionId))));
|
||||
break;
|
||||
}
|
||||
|
||||
strCat(result, "}");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case cfgDefOptTypeList:
|
||||
{
|
||||
StringList *valueList = strLstNewVarLst(cfgOptionLst(optionId));
|
||||
|
||||
strCat(result, "{");
|
||||
|
||||
for (unsigned int listIdx = 0; listIdx < strLstSize(valueList); listIdx++)
|
||||
case cfgDefOptTypeString:
|
||||
{
|
||||
if (listIdx != 0)
|
||||
strCat(result, ",");
|
||||
|
||||
strCatFmt(result, "\"%s\":true", strPtr(strLstGet(valueList, listIdx)));
|
||||
strCatFmt(result, "\"%s\"", strPtr(cfgOptionStr(optionId)));
|
||||
break;
|
||||
}
|
||||
|
||||
strCat(result, "}");
|
||||
case cfgDefOptTypeHash:
|
||||
{
|
||||
const KeyValue *valueKv = cfgOptionKv(optionId);
|
||||
const VariantList *keyList = kvKeyList(valueKv);
|
||||
|
||||
break;
|
||||
strCat(result, "{");
|
||||
|
||||
for (unsigned int listIdx = 0; listIdx < varLstSize(keyList); listIdx++)
|
||||
{
|
||||
if (listIdx != 0)
|
||||
strCat(result, ",");
|
||||
|
||||
strCatFmt(
|
||||
result, "\"%s\":\"%s\"", strPtr(varStr(varLstGet(keyList, listIdx))),
|
||||
strPtr(varStr(kvGet(valueKv, varLstGet(keyList, listIdx)))));
|
||||
}
|
||||
|
||||
strCat(result, "}");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case cfgDefOptTypeList:
|
||||
{
|
||||
StringList *valueList = strLstNewVarLst(cfgOptionLst(optionId));
|
||||
|
||||
strCat(result, "{");
|
||||
|
||||
for (unsigned int listIdx = 0; listIdx < strLstSize(valueList); listIdx++)
|
||||
{
|
||||
if (listIdx != 0)
|
||||
strCat(result, ",");
|
||||
|
||||
strCatFmt(result, "\"%s\":true", strPtr(strLstGet(valueList, listIdx)));
|
||||
}
|
||||
|
||||
strCat(result, "}");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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},"
|
||||
|
Reference in New Issue
Block a user