| 1236 | } |
| 1237 | |
| 1238 | void LocalServer::processConfig() |
| 1239 | { |
| 1240 | if (!queries.empty() && !queries_files.empty()) |
| 1241 | throw Exception(ErrorCodes::BAD_ARGUMENTS, "Options '--query' and '--queries-file' cannot be specified at the same time"); |
| 1242 | |
| 1243 | pager = getClientConfiguration().getString("pager", ""); |
| 1244 | |
| 1245 | delayed_interactive = getClientConfiguration().has("interactive") && (!queries.empty() || !queries_files.empty()); |
| 1246 | if (!is_interactive || delayed_interactive) |
| 1247 | { |
| 1248 | ignore_error = getClientConfiguration().getBool("ignore-error", false); |
| 1249 | |
| 1250 | query_id = getClientConfiguration().getString("query_id", ""); |
| 1251 | } |
| 1252 | |
| 1253 | /// `clickhouse-local` historically makes `--verbose` imply query echoing. |
| 1254 | setupEchoAndHighlightSettings(/* verbose_implies_echo */ true); |
| 1255 | |
| 1256 | print_stack_trace = getClientConfiguration().getBool("stacktrace", false); |
| 1257 | const std::string clickhouse_dialect{"clickhouse"}; |
| 1258 | load_suggestions = (is_interactive || delayed_interactive) && !getClientConfiguration().getBool("disable_suggestion", false) |
| 1259 | && getClientConfiguration().getString("dialect", clickhouse_dialect) == clickhouse_dialect; |
| 1260 | wait_for_suggestions_to_load = getClientConfiguration().getBool("wait_for_suggestions_to_load", false); |
| 1261 | |
| 1262 | auto logging = (getClientConfiguration().has("logger.console") |
| 1263 | || getClientConfiguration().has("logger.level") |
| 1264 | || getClientConfiguration().has("log-level") |
| 1265 | || getClientConfiguration().has("logger.log")); |
| 1266 | |
| 1267 | auto level = getClientConfiguration().getString("log-level", getClientConfiguration().getString("send_logs_level", "trace")); |
| 1268 | |
| 1269 | if (getClientConfiguration().has("server_logs_file")) |
| 1270 | { |
| 1271 | auto poco_logs_level = Poco::Logger::parseLevel(level); |
| 1272 | Poco::Logger::root().setLevel(poco_logs_level); |
| 1273 | Poco::AutoPtr<OwnPatternFormatter> pf = new OwnPatternFormatter; |
| 1274 | Poco::AutoPtr<OwnFormattingChannel> log = new OwnFormattingChannel(pf, new Poco::SimpleFileChannel(server_logs_file)); |
| 1275 | Poco::Logger::root().setChannel(log); |
| 1276 | } |
| 1277 | else |
| 1278 | { |
| 1279 | getClientConfiguration().setString("logger", "logger"); |
| 1280 | getClientConfiguration().setString("logger.level", logging ? level : "fatal"); |
| 1281 | buildLoggers(getClientConfiguration(), logger(), "clickhouse-local"); |
| 1282 | } |
| 1283 | |
| 1284 | shared_context = Context::createShared(); |
| 1285 | global_context = Context::createGlobal(shared_context.get()); |
| 1286 | global_context->makeGlobalContext(); |
| 1287 | global_context->setApplicationType(Context::ApplicationType::LOCAL); |
| 1288 | |
| 1289 | tryInitPath(); |
| 1290 | |
| 1291 | LoggerRawPtr log = &logger(); |
| 1292 | |
| 1293 | /// Maybe useless |
| 1294 | if (getClientConfiguration().has("macros")) |
| 1295 | global_context->setMacros(std::make_unique<Macros>(getClientConfiguration(), "macros", log)); |
nothing calls this directly
no test coverage detected