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

Method processParsedSingleQuery

src/Client/ClientBase.cpp:2433–2682  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2431}
2432
2433void ClientBase::processParsedSingleQuery(
2434 std::string_view query_,
2435 ASTPtr parsed_query,
2436 bool & is_async_insert_with_inlined_data,
2437 size_t insert_query_without_data_length)
2438{
2439 resetOutput();
2440 have_error = false;
2441 error_code = 0;
2442 cancelled = false;
2443 cancelled_printed = false;
2444 client_exception.reset();
2445 server_exception.reset();
2446 client_context->setInsertionTable(StorageID::createEmpty());
2447
2448 /// Generate a fresh query_id for each query, unless the user fixed it with `--query_id`.
2449 /// In batch mode we only do this when we are going to print the query_id, so that the printed
2450 /// value matches the one actually used for execution (otherwise the server generates its own).
2451 if (is_interactive || (echo_query_id && query_id.empty()))
2452 client_context->setCurrentQueryId("");
2453
2454 if (echo_query_id)
2455 {
2456 for (const auto & query_id_format : query_id_formats)
2457 {
2458 writeString(query_id_format.first, *std_out);
2459 writeString(fmt::format(fmt::runtime(query_id_format.second), fmt::arg("query_id", client_context->getCurrentQueryId())), *std_out);
2460 writeChar('\n', *std_out);
2461 std_out->next();
2462 }
2463 }
2464
2465 if (const auto * create_user_query = parsed_query->as<ASTCreateUserQuery>())
2466 {
2467 if (!create_user_query->attach && !create_user_query->authentication_methods.empty())
2468 {
2469 for (const auto & authentication_method : create_user_query->authentication_methods)
2470 {
2471 auto password = authentication_method->getPassword();
2472
2473 if (password)
2474 client_context->getAccessControl().checkPasswordComplexityRules(*password);
2475 }
2476 }
2477 }
2478
2479 processed_rows_from_blocks = 0;
2480 processed_rows_from_progress = 0;
2481 written_first_block = false;
2482 progress_indication.resetProgress();
2483 progress_table.resetTable();
2484 profile_events.watch.restart();
2485
2486 {
2487 /// Temporarily apply query settings to context.
2488 Settings old_settings = client_context->getSettingsRef();
2489 SCOPE_EXIT_SAFE({
2490 try

Callers

nothing calls this directly

Calls 15

createEmptyFunction · 0.85
writeCharFunction · 0.85
getCurrentExceptionCodeFunction · 0.85
getFormatSettingsFunction · 0.85
connectFunction · 0.85
isStdinNotEmptyAndValidFunction · 0.85
setCurrentQueryIdMethod · 0.80
getCurrentQueryIdMethod · 0.80
resetProgressMethod · 0.80
tryFindInputFunctionMethod · 0.80
hasInlinedDataMethod · 0.80

Tested by

no test coverage detected