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

Method initialize

programs/benchmark/Benchmark.cpp:160–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158 }
159
160 void initialize(Poco::Util::Application & self [[maybe_unused]]) override
161 {
162 std::string home_path;
163 const char * home_path_cstr = getenv("HOME"); // NOLINT(concurrency-mt-unsafe)
164 if (home_path_cstr)
165 home_path = home_path_cstr;
166
167 std::optional<std::string> config_path;
168 if (config().has("config-file"))
169 config_path.emplace(config().getString("config-file"));
170 else
171 config_path = getClientConfigPath(home_path);
172 if (config_path.has_value())
173 {
174 ConfigProcessor config_processor(*config_path);
175 auto loaded_config = config_processor.loadConfig();
176 config().add(loaded_config.configuration);
177 }
178
179 if (connection_name.has_value())
180 {
181 std::string default_host;
182 if (connection_arguments.hosts.has_value())
183 default_host = connection_arguments.hosts->front();
184 else if (const char * env_host = getenv("CLICKHOUSE_HOST")) // NOLINT(concurrency-mt-unsafe)
185 default_host = env_host;
186 else
187 default_host = "localhost";
188
189 auto overrides = parseConnectionsCredentials(config(), default_host, connection_name);
190 if (overrides.hostname.has_value() && !connection_arguments.hosts.has_value())
191 connection_arguments.hosts.emplace({overrides.hostname.value()});
192 if (overrides.port.has_value() && !connection_arguments.ports.has_value())
193 connection_arguments.ports.emplace({overrides.port.value()});
194 if (overrides.secure.has_value() && !connection_arguments.secure.has_value())
195 connection_arguments.secure.emplace(overrides.secure.value());
196 if (overrides.accept_invalid_certificate.has_value() && !connection_arguments.accept_invalid_certificate.has_value())
197 connection_arguments.accept_invalid_certificate.emplace(overrides.accept_invalid_certificate.value());
198 if (overrides.user.has_value() && !connection_arguments.user.has_value())
199 connection_arguments.user.emplace(overrides.user.value());
200 if (overrides.password.has_value() && !connection_arguments.password.has_value())
201 connection_arguments.password.emplace(overrides.password.value());
202 if (overrides.database.has_value() && !connection_arguments.database.has_value())
203 connection_arguments.database.emplace(overrides.database.value());
204
205 if (connection_arguments.hosts.has_value())
206 {
207 if (isCloudEndpoint(connection_arguments.hosts->front()))
208 connection_arguments.secure.emplace(true);
209 }
210 }
211
212 if (connection_arguments.accept_invalid_certificate.value_or(false))
213 {
214 config().setString("openSSL.client.invalidCertificateHandler.name", "AcceptCertificateHandler");
215 config().setString("openSSL.client.verificationMode", "none");
216 }
217

Callers

nothing calls this directly

Calls 11

getClientConfigPathFunction · 0.85
isCloudEndpointFunction · 0.85
hasMethod · 0.45
emplaceMethod · 0.45
getStringMethod · 0.45
loadConfigMethod · 0.45
addMethod · 0.45
frontMethod · 0.45
valueMethod · 0.45
setStringMethod · 0.45

Tested by

no test coverage detected