MCPcopy Create free account
hub / github.com/ByConity/ByConity / logQuery

Function logQuery

src/Interpreters/executeQuery.cpp:420–460  ·  view source on GitHub ↗

Log query into text log (not into system table).

Source from the content-addressed store, hash-verified

418
419/// Log query into text log (not into system table).
420static void logQuery(const String & query, ContextPtr context, bool internal)
421{
422 if (internal)
423 {
424 LOG_DEBUG(&Poco::Logger::get("executeQuery"), "(internal) {}", joinLines(query));
425 }
426 else
427 {
428 const auto & client_info = context->getClientInfo();
429
430 const auto & current_query_id = client_info.current_query_id;
431 const auto & initial_query_id = client_info.initial_query_id;
432 const auto & current_user = client_info.current_user;
433
434 String comment = context->getSettingsRef().log_comment;
435 size_t max_query_size = context->getSettingsRef().max_query_size;
436
437 if (comment.size() > max_query_size)
438 comment.resize(max_query_size);
439
440 if (!comment.empty())
441 comment = fmt::format(" (comment: {})", comment);
442
443 LOG_DEBUG(
444 &Poco::Logger::get("executeQuery"),
445 "(from {}{}{}){} {}",
446 client_info.current_address.toString(),
447 (current_user != "default" ? ", user: " + current_user : ""),
448 (!initial_query_id.empty() && current_query_id != initial_query_id ? ", initial_query_id: " + initial_query_id : std::string()),
449 comment,
450 joinLines(query));
451
452 if (client_info.client_trace_context.trace_id != UUID())
453 {
454 LOG_TRACE(
455 &Poco::Logger::get("executeQuery"),
456 "OpenTelemetry traceparent '{}'",
457 client_info.client_trace_context.composeTraceparentHeader());
458 }
459 }
460}
461
462static void logQuery(ContextPtr context, const QueryLogElement & log_element)
463{

Callers 2

onExceptionBeforeStartFunction · 0.85
executeQueryImplFunction · 0.85

Calls 10

joinLinesFunction · 0.85
getQueryLogMethod · 0.80
getFunction · 0.50
sizeMethod · 0.45
resizeMethod · 0.45
emptyMethod · 0.45
toStringMethod · 0.45
addMethod · 0.45
getCnchQueryLogMethod · 0.45

Tested by

no test coverage detected