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

Function executeQuery

src/Interpreters/executeQuery.cpp:2187–2274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2185
2186
2187std::pair<ASTPtr, BlockIO> executeQuery(
2188 std::string_view query,
2189 ContextMutablePtr context,
2190 QueryFlags flags,
2191 QueryProcessingStage::Enum stage)
2192{
2193 if (isCrashed())
2194 throw Exception(ErrorCodes::ABORTED, "The server is shutting down due to a fatal error");
2195
2196 ProfileEvents::checkCPUOverload(context->getServerSettings()[ServerSetting::os_cpu_busy_time_threshold],
2197 static_cast<double>(context->getSettingsRef()[Setting::min_os_cpu_wait_time_ratio_to_throw]),
2198 static_cast<double>(context->getSettingsRef()[Setting::max_os_cpu_wait_time_ratio_to_throw]),
2199 /*should_throw*/ true);
2200
2201 ASTPtr ast;
2202 BlockIO res;
2203 auto implicit_tcl_executor = std::make_shared<ImplicitTransactionControlExecutor>();
2204 ReadBufferUniquePtr no_input_buffer;
2205 QueryResultDetails result_details;
2206 res = executeQueryImpl(query.data(), query.data() + query.size(), context, flags, stage, no_input_buffer, ast, implicit_tcl_executor, {}, result_details);
2207 if (const auto * ast_query_with_output = dynamic_cast<const ASTQueryWithOutput *>(ast.get()))
2208 {
2209 String format_name = ast_query_with_output->format_ast
2210 ? getIdentifierName(ast_query_with_output->format_ast)
2211 : context->getDefaultFormat();
2212
2213 const bool ignore_null_for_explain = context->getSettingsRef()[Setting::ignore_format_null_for_explain];
2214 if (boost::iequals(format_name, "Null") && !(ast->as<ASTExplainQuery>() && ignore_null_for_explain))
2215 res.null_format = true;
2216 }
2217
2218 /// The 'SYSTEM ENABLE FAILPOINT terminate_with_exception' query itself should succeed.
2219 if (ast && !ast->as<ASTSystemQuery>())
2220 {
2221 fiu_do_on(FailPoints::terminate_with_exception,
2222 {
2223 try
2224 {
2225 throw Exception(ErrorCodes::FAULT_INJECTED, "Failpoint terminate_with_exception");
2226 }
2227 catch (...)
2228 {
2229 std::terminate();
2230 }
2231 });
2232
2233 fiu_do_on(FailPoints::terminate_with_std_exception,
2234 {
2235 try
2236 {
2237 throw std::runtime_error("Failpoint terminate_with_std_exception");
2238 }
2239 catch (...)
2240 {
2241 std::terminate();
2242 }
2243 });
2244

Callers 15

executeMethod · 0.70
getSelectResultMethod · 0.70
executeASTFuzzerQueriesFunction · 0.70
executeMethod · 0.70
executeMethod · 0.70
executeMethod · 0.70
tryExecuteQueryMethod · 0.70
executeSubqueryMethod · 0.70
executeMethod · 0.70
executeMethod · 0.70
dropDatabaseReplicaMethod · 0.70

Calls 15

isCrashedFunction · 0.85
checkCPUOverloadFunction · 0.85
executeQueryImplFunction · 0.85
executeASTFuzzerQueriesFunction · 0.85
wrapReadBufferReferenceFunction · 0.85
logQueryFunction · 0.85
copyDataFunction · 0.85
materializeBlockFunction · 0.85
flushQueryProgressFunction · 0.85
getDefaultFormatMethod · 0.80

Tested by

no test coverage detected