pgbackrest.git / summary / log / commit / refs
commit 2cddbbdee01391ef0885f9262f3acc488382eee2
Author: David Steele <david@pgmasters.net>
Date: Mon Jan 10 22:20:48 2022 +0000
Remove obsolete cfgOptionHostPort()/cfgOptionIdxHostPort().
These functions were made obsolete by the refactor in 6a124584.
doc/xml/release.xml | 1 +
src/config/config.c | 91 --------------------------------------
src/config/config.h | 4 --
test/src/module/config/parseTest.c | 34 ++------------
4 files changed, 4 insertions(+), 126 deletions(-)
diff --git a/doc/xml/release.xml b/doc/xml/release.xml
index d245283c2..e26dec8bf 100644
--- a/doc/xml/release.xml
+++ b/doc/xml/release.xml
@@ -48,6 +48,7 @@
<commit subject="Replace cfgOptionGroupIdxToKey() with cfgOptionGroupName()."/>
<commit subject="Improve implementation of cfgOptionIdxName()."/>
<commit subject="Refactor option and option group config structs."/>
+ <commit subject="Remove obsolete cfgOptionHostPort()/cfgOptionIdxHostPort()."/>
<release-item-contributor-list>
<release-item-contributor id="david.steele"/>
diff --git a/src/config/config.c b/src/config/config.c
index bc94f1e41..fc93385d1 100644
--- a/src/config/config.c
+++ b/src/config/config.c
@@ -548,97 +548,6 @@ cfgOptionDisplay(const ConfigOption optionId)
FUNCTION_TEST_RETURN(cfgOptionIdxDisplay(optionId, cfgOptionIdxDefault(optionId)));
}
-/**********************************************************************************************************************************/
-String *
-cfgOptionHostPort(ConfigOption optionId, unsigned int *port)
-{
- FUNCTION_TEST_BEGIN();
- FUNCTION_TEST_PARAM(ENUM, optionId);
- FUNCTION_TEST_PARAM_P(UINT, port);
- FUNCTION_TEST_END();
-
- FUNCTION_TEST_RETURN(cfgOptionIdxHostPort(optionId, cfgOptionIdxDefault(optionId), port));
-}
-
-String *
-cfgOptionIdxHostPort(ConfigOption optionId, unsigned int optionIdx, unsigned int *port)
-{
- FUNCTION_TEST_BEGIN();
- FUNCTION_TEST_PARAM(ENUM, optionId);
- FUNCTION_TEST_PARAM(UINT, optionIdx);
- FUNCTION_TEST_PARAM_P(UINT, port);
- FUNCTION_TEST_END();
-
- ASSERT(optionId < CFG_OPTION_TOTAL);
- ASSERT(configLocal != NULL);
- ASSERT(
- (!configLocal->option[optionId].group && optionIdx == 0) ||
- (configLocal->option[optionId].group && optionIdx <
- configLocal->optionGroup[configLocal->option[optionId].groupId].indexTotal));
- ASSERT(port != NULL);
-
- String *result = NULL;
-
- // Proceed if option is valid and has a value
- if (cfgOptionIdxTest(optionId, optionIdx))
- {
- MEM_CONTEXT_TEMP_BEGIN()
- {
- const String *host = cfgOptionIdxStr(optionId, optionIdx);
-
- // If the host contains a colon then it has a port appended
- if (strChr(host, ':') != -1)
- {
- const StringList *hostPart = strLstNewSplitZ(host, ":");
-
- // More than one colon is invalid
- if (strLstSize(hostPart) > 2)
- {
- THROW_FMT(
- OptionInvalidError,
- "'%s' is not valid for option '%s'"
- "\nHINT: is more than one port specified?",
- strZ(host), cfgOptionIdxName(optionId, optionIdx));
- }
-
- // Set the host
- MEM_CONTEXT_PRIOR_BEGIN()
- {
- result = strDup(strLstGet(hostPart, 0));
- }
- MEM_CONTEXT_PRIOR_END();
-
- // Set the port and error if it is not a positive integer
- TRY_BEGIN()
- {
- *port = cvtZToUInt(strZ(strLstGet(hostPart, 1)));
- }
- CATCH(FormatError)
- {
- THROW_FMT(
- OptionInvalidError,
- "'%s' is not valid for option '%s'"
- "\nHINT: port is not a positive integer.",
- strZ(host), cfgOptionIdxName(optionId, optionIdx));
- }
- TRY_END();
- }
- // Else there is no port and just copy the host
- else
- {
- MEM_CONTEXT_PRIOR_BEGIN()
- {
- result = strDup(host);
- }
- MEM_CONTEXT_PRIOR_END();
- }
- }
- MEM_CONTEXT_TEMP_END();
- }
-
- FUNCTION_TEST_RETURN(result);
-}
-
/***********************************************************************************************************************************
Get option name by id
***********************************************************************************************************************************/
diff --git a/src/config/config.h b/src/config/config.h
index 5d754169b..f405f144e 100644
--- a/src/config/config.h
+++ b/src/config/config.h
@@ -252,10 +252,6 @@ const String *cfgExe(void);
// more efficient to generate them when they are requested. Some defaults are (e.g. the exe path) are set at runtime.
void cfgOptionDefaultSet(ConfigOption optionId, const Variant *defaultValue);
-// Parse a host option and extract the host and port (if it exists)
-String *cfgOptionHostPort(ConfigOption optionId, unsigned int *port);
-String *cfgOptionIdxHostPort(ConfigOption optionId, unsigned int optionIdx, unsigned int *port);
-
// Was the option negated?
bool cfgOptionNegate(ConfigOption optionId);
bool cfgOptionIdxNegate(ConfigOption optionId, unsigned int optionIdx);
diff --git a/test/src/module/config/parseTest.c b/test/src/module/config/parseTest.c
index d25b3a537..65e8bcbf3 100644
--- a/test/src/module/config/parseTest.c
+++ b/test/src/module/config/parseTest.c
@@ -1551,37 +1551,6 @@ testRun(void)
hrnCfgEnvKeyRemoveRaw(cfgOptRepoS3Key, 1);
hrnCfgEnvKeyRemoveRaw(cfgOptRepoS3KeySecret, 1);
- // -------------------------------------------------------------------------------------------------------------------------
- TEST_TITLE("port can be parsed from hostname");
-
- unsigned int port = 55555;
-
- cfgOptionSet(cfgOptRepoStorageHost, cfgSourceConfig, varNewStrZ("host.com")) ;
- TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoStorageHost, &port), "host.com", "check plain host");
- TEST_RESULT_UINT(port, 55555, "check that port was not updated");
-
- cfgOptionSet(cfgOptRepoStorageHost, cfgSourceConfig, varNewStrZ("myhost.com:777")) ;
- TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoStorageHost, &port), "myhost.com", "check host with port");
- TEST_RESULT_UINT(port, 777, "check that port was updated");
-
- cfgOptionSet(cfgOptRepoS3Endpoint, cfgSourceConfig, NULL);
- TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Endpoint, &port), NULL, "check null host");
- TEST_RESULT_UINT(port, 777, "check that port was not updated");
-
- cfgOptionSet(cfgOptRepoStorageHost, cfgSourceConfig, varNewStrZ("myhost.com:777:888")) ;
- TEST_ERROR(
- cfgOptionHostPort(cfgOptRepoStorageHost, &port), OptionInvalidError,
- "'myhost.com:777:888' is not valid for option 'repo1-storage-host'"
- "\nHINT: is more than one port specified?");
- TEST_RESULT_UINT(port, 777, "check that port was not updated");
-
- cfgOptionSet(cfgOptRepoS3Endpoint, cfgSourceConfig, varNewStrZ("myendpoint.com:ZZZ"));
- TEST_ERROR(
- cfgOptionHostPort(cfgOptRepoS3Endpoint, &port), OptionInvalidError,
- "'myendpoint.com:ZZZ' is not valid for option 'repo1-s3-endpoint'"
- "\nHINT: port is not a positive integer.");
- TEST_RESULT_UINT(port, 777, "check that port was not updated");
-
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("global is a valid stanza prefix");
@@ -1974,6 +1943,9 @@ testRun(void)
TEST_RESULT_VOID(cfgOptionIdxSet(cfgOptPgPath, 0, cfgSourceParam, VARSTRDEF("/new")), "set pg1-path");
TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgPath, 0), "/new", "check pg1-path");
+ TEST_RESULT_VOID(cfgOptionIdxSet(cfgOptPgPath, 0, cfgSourceParam, NULL), "set pg1-path to NULL");
+ TEST_RESULT_STR_Z(cfgOptionIdxStrNull(cfgOptPgPath, 0), NULL, "check pg1-path");
+
TEST_RESULT_VOID(cfgOptionIdxSet(cfgOptType, 0, cfgSourceParam, VARUINT64(STRID5("preserve", 0x2da45996500))), "set type");
TEST_RESULT_UINT(cfgOptionIdxStrId(cfgOptType, 0), STRID5("preserve", 0x2da45996500), "check type");
[parent: 7c627c12b735]