Merge pull request #12652 from amosbird/qld

Add current_database to system.query_log
This commit is contained in:
alexey-milovidov 2020-07-22 16:35:41 +03:00 committed by GitHub
commit 89fcdeb979
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 0 deletions

View File

@ -48,6 +48,7 @@ Block QueryLogElement::createBlock()
{std::make_shared<DataTypeUInt64>(), "result_bytes"},
{std::make_shared<DataTypeUInt64>(), "memory_usage"},
{std::make_shared<DataTypeString>(), "current_database"},
{std::make_shared<DataTypeString>(), "query"},
{std::make_shared<DataTypeInt32>(), "exception_code"},
{std::make_shared<DataTypeString>(), "exception"},
@ -104,6 +105,7 @@ void QueryLogElement::appendToBlock(MutableColumns & columns) const
columns[i++]->insert(memory_usage);
columns[i++]->insertData(current_database.data(), current_database.size());
columns[i++]->insertData(query.data(), query.size());
columns[i++]->insert(exception_code);
columns[i++]->insertData(exception.data(), exception.size());

View File

@ -48,6 +48,7 @@ struct QueryLogElement
UInt64 memory_usage{};
String current_database;
String query;
Int32 exception_code{}; // because ErrorCodes are int

View File

@ -195,6 +195,7 @@ static void onExceptionBeforeStart(const String & query_for_logging, Context & c
elem.event_time = current_time;
elem.query_start_time = current_time;
elem.current_database = context.getCurrentDatabase();
elem.query = query_for_logging;
elem.exception_code = getCurrentExceptionCode();
elem.exception = getCurrentExceptionMessage(false);
@ -462,6 +463,7 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
elem.event_time = current_time;
elem.query_start_time = current_time;
elem.current_database = context.getCurrentDatabase();
elem.query = query_for_logging;
elem.client_info = context.getClientInfo();