You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-17 01:12:23 +02:00
Replace strCatFmt() with strCat()/strCatZ() where appropriate.
Most of these looked like copy/paste from a prior required strCatFmt() call. There is no issue here since strCatFmt() works the same in these cases, but using strCat()/strCatZ() is more efficient.
This commit is contained in:
@ -552,7 +552,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg)
|
|||||||
|
|
||||||
// Command parse rules
|
// Command parse rules
|
||||||
// -----------------------------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------------------------
|
||||||
strCatFmt(
|
strCatZ(
|
||||||
config,
|
config,
|
||||||
"\n"
|
"\n"
|
||||||
COMMENT_BLOCK_BEGIN "\n"
|
COMMENT_BLOCK_BEGIN "\n"
|
||||||
@ -566,7 +566,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg)
|
|||||||
STRDEF("PARSE_RULE_VAL_CMD(value)"),
|
STRDEF("PARSE_RULE_VAL_CMD(value)"),
|
||||||
strNewFmt("PARSE_RULE_U32_%zu(value)", bldCfgRenderVar128Size(lstSize(bldCfg.cmdList) - 1)))));
|
strNewFmt("PARSE_RULE_U32_%zu(value)", bldCfgRenderVar128Size(lstSize(bldCfg.cmdList) - 1)))));
|
||||||
|
|
||||||
strCatFmt(
|
strCatZ(
|
||||||
config,
|
config,
|
||||||
"\n"
|
"\n"
|
||||||
"static const ParseRuleCommand parseRuleCommand[CFG_COMMAND_TOTAL] =\n"
|
"static const ParseRuleCommand parseRuleCommand[CFG_COMMAND_TOTAL] =\n"
|
||||||
@ -602,7 +602,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg)
|
|||||||
if (cmd->parameterAllowed)
|
if (cmd->parameterAllowed)
|
||||||
strCatZ(config, " PARSE_RULE_COMMAND_PARAMETER_ALLOWED(true),\n");
|
strCatZ(config, " PARSE_RULE_COMMAND_PARAMETER_ALLOWED(true),\n");
|
||||||
|
|
||||||
strCatFmt(
|
strCatZ(
|
||||||
config,
|
config,
|
||||||
"\n"
|
"\n"
|
||||||
" PARSE_RULE_COMMAND_ROLE_VALID_LIST\n"
|
" PARSE_RULE_COMMAND_ROLE_VALID_LIST\n"
|
||||||
@ -628,7 +628,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg)
|
|||||||
|
|
||||||
// Option group rules
|
// Option group rules
|
||||||
// -----------------------------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------------------------
|
||||||
strCatFmt(
|
strCatZ(
|
||||||
config,
|
config,
|
||||||
"\n"
|
"\n"
|
||||||
COMMENT_BLOCK_BEGIN "\n"
|
COMMENT_BLOCK_BEGIN "\n"
|
||||||
@ -659,7 +659,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg)
|
|||||||
|
|
||||||
// Option rules
|
// Option rules
|
||||||
// -----------------------------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------------------------
|
||||||
strCatFmt(
|
strCatZ(
|
||||||
config,
|
config,
|
||||||
"\n"
|
"\n"
|
||||||
COMMENT_BLOCK_BEGIN "\n"
|
COMMENT_BLOCK_BEGIN "\n"
|
||||||
@ -673,7 +673,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg)
|
|||||||
STRDEF("PARSE_RULE_VAL_OPT(value)"),
|
STRDEF("PARSE_RULE_VAL_OPT(value)"),
|
||||||
strNewFmt("PARSE_RULE_U32_%zu(value)", bldCfgRenderVar128Size(lstSize(bldCfg.optList) - 1)))));
|
strNewFmt("PARSE_RULE_U32_%zu(value)", bldCfgRenderVar128Size(lstSize(bldCfg.optList) - 1)))));
|
||||||
|
|
||||||
strCatFmt(
|
strCatZ(
|
||||||
config,
|
config,
|
||||||
"\n"
|
"\n"
|
||||||
"static const ParseRuleOption parseRuleOption[CFG_OPTION_TOTAL] =\n"
|
"static const ParseRuleOption parseRuleOption[CFG_OPTION_TOTAL] =\n"
|
||||||
@ -1079,7 +1079,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg)
|
|||||||
|
|
||||||
// Order for option parse resolution
|
// Order for option parse resolution
|
||||||
// -----------------------------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------------------------
|
||||||
strCatFmt(
|
strCatZ(
|
||||||
config,
|
config,
|
||||||
"\n"
|
"\n"
|
||||||
COMMENT_BLOCK_BEGIN "\n"
|
COMMENT_BLOCK_BEGIN "\n"
|
||||||
@ -1104,7 +1104,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg)
|
|||||||
|
|
||||||
strLstSort(ruleStrList, sortOrderAsc);
|
strLstSort(ruleStrList, sortOrderAsc);
|
||||||
|
|
||||||
strCatFmt(
|
strCatZ(
|
||||||
configVal,
|
configVal,
|
||||||
"\n"
|
"\n"
|
||||||
COMMENT_BLOCK_BEGIN "\n"
|
COMMENT_BLOCK_BEGIN "\n"
|
||||||
@ -1118,7 +1118,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg)
|
|||||||
STRDEF("PARSE_RULE_VAL_STR(value)"),
|
STRDEF("PARSE_RULE_VAL_STR(value)"),
|
||||||
strNewFmt("PARSE_RULE_U32_%zu(value)", bldCfgRenderVar128Size(strLstSize(ruleStrList) - 1)))));
|
strNewFmt("PARSE_RULE_U32_%zu(value)", bldCfgRenderVar128Size(strLstSize(ruleStrList) - 1)))));
|
||||||
|
|
||||||
strCatFmt(
|
strCatZ(
|
||||||
configVal,
|
configVal,
|
||||||
"\n"
|
"\n"
|
||||||
"static const StringPub parseRuleValueStr[] =\n"
|
"static const StringPub parseRuleValueStr[] =\n"
|
||||||
@ -1148,7 +1148,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg)
|
|||||||
// -----------------------------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------------------------
|
||||||
strLstSort(ruleStrIdList, sortOrderAsc);
|
strLstSort(ruleStrIdList, sortOrderAsc);
|
||||||
|
|
||||||
strCatFmt(
|
strCatZ(
|
||||||
configVal,
|
configVal,
|
||||||
"\n"
|
"\n"
|
||||||
COMMENT_BLOCK_BEGIN "\n"
|
COMMENT_BLOCK_BEGIN "\n"
|
||||||
@ -1162,7 +1162,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg)
|
|||||||
STRDEF("PARSE_RULE_VAL_STRID(value)"),
|
STRDEF("PARSE_RULE_VAL_STRID(value)"),
|
||||||
strNewFmt("PARSE_RULE_U32_%zu(value)", bldCfgRenderVar128Size(strLstSize(ruleStrIdList) - 1)))));
|
strNewFmt("PARSE_RULE_U32_%zu(value)", bldCfgRenderVar128Size(strLstSize(ruleStrIdList) - 1)))));
|
||||||
|
|
||||||
strCatFmt(
|
strCatZ(
|
||||||
configVal,
|
configVal,
|
||||||
"\n"
|
"\n"
|
||||||
"static const StringId parseRuleValueStrId[] =\n"
|
"static const StringId parseRuleValueStrId[] =\n"
|
||||||
@ -1188,7 +1188,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg)
|
|||||||
// -----------------------------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------------------------
|
||||||
strLstSort(ruleIntList, sortOrderAsc);
|
strLstSort(ruleIntList, sortOrderAsc);
|
||||||
|
|
||||||
strCatFmt(
|
strCatZ(
|
||||||
configVal,
|
configVal,
|
||||||
"\n"
|
"\n"
|
||||||
COMMENT_BLOCK_BEGIN "\n"
|
COMMENT_BLOCK_BEGIN "\n"
|
||||||
@ -1202,7 +1202,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg)
|
|||||||
STRDEF("PARSE_RULE_VAL_INT(value)"),
|
STRDEF("PARSE_RULE_VAL_INT(value)"),
|
||||||
strNewFmt("PARSE_RULE_U32_%zu(value)", bldCfgRenderVar128Size(strLstSize(ruleIntList) - 1)))));
|
strNewFmt("PARSE_RULE_U32_%zu(value)", bldCfgRenderVar128Size(strLstSize(ruleIntList) - 1)))));
|
||||||
|
|
||||||
strCatFmt(
|
strCatZ(
|
||||||
configVal,
|
configVal,
|
||||||
"\n"
|
"\n"
|
||||||
"static const int64_t parseRuleValueInt[] =\n"
|
"static const int64_t parseRuleValueInt[] =\n"
|
||||||
|
@ -312,7 +312,7 @@ bldHlpRenderHelpAutoC(const Storage *const storageRepo, const BldCfg bldCfg, con
|
|||||||
|
|
||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
strCatFmt(help, " ");
|
strCatZ(help, " ");
|
||||||
lineSize = 0;
|
lineSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,14 +52,14 @@ cmdOption(void)
|
|||||||
|
|
||||||
if (!strLstEmpty(commandParamList))
|
if (!strLstEmpty(commandParamList))
|
||||||
{
|
{
|
||||||
strCatFmt(cmdOptionStr, " [");
|
strCatZ(cmdOptionStr, " [");
|
||||||
|
|
||||||
for (unsigned int commandParamIdx = 0; commandParamIdx < strLstSize(commandParamList); commandParamIdx++)
|
for (unsigned int commandParamIdx = 0; commandParamIdx < strLstSize(commandParamList); commandParamIdx++)
|
||||||
{
|
{
|
||||||
const String *commandParam = strLstGet(commandParamList, commandParamIdx);
|
const String *commandParam = strLstGet(commandParamList, commandParamIdx);
|
||||||
|
|
||||||
if (commandParamIdx != 0)
|
if (commandParamIdx != 0)
|
||||||
strCatFmt(cmdOptionStr, ", ");
|
strCatZ(cmdOptionStr, ", ");
|
||||||
|
|
||||||
if (strchr(strZ(commandParam), ' ') != NULL)
|
if (strchr(strZ(commandParam), ' ') != NULL)
|
||||||
commandParam = strNewFmt("\"%s\"", strZ(commandParam));
|
commandParam = strNewFmt("\"%s\"", strZ(commandParam));
|
||||||
@ -67,7 +67,7 @@ cmdOption(void)
|
|||||||
strCat(cmdOptionStr, commandParam);
|
strCat(cmdOptionStr, commandParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
strCatFmt(cmdOptionStr, "]");
|
strCatZ(cmdOptionStr, "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop though options and add the ones that are interesting
|
// Loop though options and add the ones that are interesting
|
||||||
|
@ -1440,7 +1440,7 @@ infoRender(void)
|
|||||||
|
|
||||||
// Add a carriage return between stanzas
|
// Add a carriage return between stanzas
|
||||||
if (stanzaIdx > 0)
|
if (stanzaIdx > 0)
|
||||||
strCatFmt(resultStr, "\n");
|
strCatZ(resultStr, "\n");
|
||||||
|
|
||||||
// Stanza name and status
|
// Stanza name and status
|
||||||
strCatFmt(resultStr, "stanza: %s\n status: ", strZ(stanzaName));
|
strCatFmt(resultStr, "stanza: %s\n status: ", strZ(stanzaName));
|
||||||
|
@ -1825,7 +1825,7 @@ restoreRecoveryWriteAutoConf(unsigned int pgVersion, const String *restoreLabel)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strCatFmt(content, "%s", strZ(restoreRecoveryConf(pgVersion, restoreLabel)));
|
strCat(content, restoreRecoveryConf(pgVersion, restoreLabel));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO_FMT(
|
LOG_INFO_FMT(
|
||||||
|
@ -373,7 +373,7 @@ cfgLoadLogFile(void)
|
|||||||
if (cfgCommandRole() == cfgCmdRoleLocal || cfgCommandRole() == cfgCmdRoleRemote)
|
if (cfgCommandRole() == cfgCmdRoleLocal || cfgCommandRole() == cfgCmdRoleRemote)
|
||||||
{
|
{
|
||||||
if (cfgOptionValid(cfgOptArchiveAsync) && cfgOptionBool(cfgOptArchiveAsync))
|
if (cfgOptionValid(cfgOptArchiveAsync) && cfgOptionBool(cfgOptArchiveAsync))
|
||||||
strCatFmt(logFile, "-async");
|
strCatZ(logFile, "-async");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add command role if it is not main
|
// Add command role if it is not main
|
||||||
|
16
src/db/db.c
16
src/db/db.c
@ -330,18 +330,18 @@ dbBackupStartQuery(unsigned int pgVersion, bool startFast)
|
|||||||
// Start backup after immediate checkpoint
|
// Start backup after immediate checkpoint
|
||||||
if (startFast)
|
if (startFast)
|
||||||
{
|
{
|
||||||
strCatFmt(result, ", " TRUE_Z);
|
strCatZ(result, ", " TRUE_Z);
|
||||||
}
|
}
|
||||||
// Else start backup at the next scheduled checkpoint
|
// Else start backup at the next scheduled checkpoint
|
||||||
else
|
else
|
||||||
strCatFmt(result, ", " FALSE_Z);
|
strCatZ(result, ", " FALSE_Z);
|
||||||
|
|
||||||
// Use non-exclusive backup mode when available
|
// Use non-exclusive backup mode when available
|
||||||
if (pgVersion >= PG_VERSION_96)
|
if (pgVersion >= PG_VERSION_96)
|
||||||
strCatFmt(result, ", " FALSE_Z);
|
strCatZ(result, ", " FALSE_Z);
|
||||||
|
|
||||||
// Complete query
|
// Complete query
|
||||||
strCatFmt(result, ") as lsn");
|
strCatZ(result, ") as lsn");
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(result);
|
FUNCTION_TEST_RETURN(result);
|
||||||
}
|
}
|
||||||
@ -501,17 +501,17 @@ dbBackupStopQuery(unsigned int pgVersion)
|
|||||||
|
|
||||||
// Use non-exclusive backup mode when available
|
// Use non-exclusive backup mode when available
|
||||||
if (pgVersion >= PG_VERSION_96)
|
if (pgVersion >= PG_VERSION_96)
|
||||||
strCatFmt(result, FALSE_Z);
|
strCatZ(result, FALSE_Z);
|
||||||
|
|
||||||
// Disable archive checking in pg_stop_backup() since we do this elsewhere
|
// Disable archive checking in pg_stop_backup() since we do this elsewhere
|
||||||
if (pgVersion >= PG_VERSION_10)
|
if (pgVersion >= PG_VERSION_10)
|
||||||
strCatFmt(result, ", " FALSE_Z);
|
strCatZ(result, ", " FALSE_Z);
|
||||||
|
|
||||||
// Complete query
|
// Complete query
|
||||||
strCatFmt(result, ")");
|
strCatZ(result, ")");
|
||||||
|
|
||||||
if (pgVersion < PG_VERSION_96)
|
if (pgVersion < PG_VERSION_96)
|
||||||
strCatFmt(result, " as lsn");
|
strCatZ(result, " as lsn");
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(result);
|
FUNCTION_TEST_RETURN(result);
|
||||||
}
|
}
|
||||||
|
@ -99,9 +99,9 @@ testRequest(IoWrite *write, Storage *s3, const char *verb, const char *path, Tes
|
|||||||
if (s3 != NULL)
|
if (s3 != NULL)
|
||||||
{
|
{
|
||||||
if (driver->uriStyle == storageS3UriStyleHost)
|
if (driver->uriStyle == storageS3UriStyleHost)
|
||||||
strCatFmt(request, "host:bucket." S3_TEST_HOST "\r\n");
|
strCatZ(request, "host:bucket." S3_TEST_HOST "\r\n");
|
||||||
else
|
else
|
||||||
strCatFmt(request, "host:" S3_TEST_HOST "\r\n");
|
strCatZ(request, "host:" S3_TEST_HOST "\r\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strCatFmt(request, "host:%s\r\n", strZ(hrnServerHost()));
|
strCatFmt(request, "host:%s\r\n", strZ(hrnServerHost()));
|
||||||
|
Reference in New Issue
Block a user