MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / extractConfigValue

Function extractConfigValue

programs/docker-init/docker-init.cpp:241–254  ·  view source on GitHub ↗

Extract a single value from a ClickHouse config key via `clickhouse extract-from-config`. Returns an empty string if the key is absent (--try flag suppresses errors).

Source from the content-addressed store, hash-verified

239/// Extract a single value from a ClickHouse config key via `clickhouse extract-from-config`.
240/// Returns an empty string if the key is absent (--try flag suppresses errors).
241std::string extractConfigValue(const std::string & config_file, const std::string & key, bool use_users = false)
242{
243 std::vector<std::string> args = {
244 g_clickhouse_binary, "extract-from-config",
245 "--config-file", config_file,
246 "--key", key,
247 "--try",
248 };
249 if (use_users)
250 args.emplace_back("--users");
251
252 auto [code, lines] = captureCommand(args);
253 return (code == 0 && !lines.empty()) ? lines[0] : std::string{};
254}
255
256/// Extract multiple values from a ClickHouse config key (wildcard patterns return multiple lines).
257std::vector<std::string> extractConfigValues(const std::string & config_file, const std::string & key)

Callers 3

manageClickHouseUserFunction · 0.85
initClickHouseDBFunction · 0.85

Calls 3

captureCommandFunction · 0.85
emplace_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected