Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created column exception_code in query_log table #8770

Merged
merged 6 commits into from Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions dbms/src/Interpreters/QueryLog.cpp
Expand Up @@ -49,6 +49,7 @@ Block QueryLogElement::createBlock()
{std::make_shared<DataTypeUInt64>(), "memory_usage"},

{std::make_shared<DataTypeString>(), "query"},
{std::make_shared<DataTypeInt32>(), "exception_code"},
{std::make_shared<DataTypeString>(), "exception"},
{std::make_shared<DataTypeString>(), "stack_trace"},

Expand Down Expand Up @@ -107,6 +108,7 @@ void QueryLogElement::appendToBlock(Block & block) const
columns[i++]->insert(memory_usage);

columns[i++]->insertData(query.data(), query.size());
columns[i++]->insert(exception_code);
columns[i++]->insertData(exception.data(), exception.size());
columns[i++]->insertData(stack_trace.data(), stack_trace.size());

Expand Down
1 change: 1 addition & 0 deletions dbms/src/Interpreters/QueryLog.h
Expand Up @@ -54,6 +54,7 @@ struct QueryLogElement

String query;

Int32 exception_code{}; // because ErrorCodes are int
String exception;
String stack_trace;

Expand Down
2 changes: 2 additions & 0 deletions dbms/src/Interpreters/executeQuery.cpp
Expand Up @@ -163,6 +163,7 @@ static void onExceptionBeforeStart(const String & query_for_logging, Context & c
elem.query_start_time = current_time;

elem.query = query_for_logging;
elem.exception_code = getCurrentExceptionCode();
elem.exception = getCurrentExceptionMessage(false);

elem.client_info = context.getClientInfo();
Expand Down Expand Up @@ -496,6 +497,7 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(

elem.event_time = time(nullptr);
elem.query_duration_ms = 1000 * (elem.event_time - elem.query_start_time);
elem.exception_code = getCurrentExceptionCode();
elem.exception = getCurrentExceptionMessage(false);

QueryStatus * process_list_elem = context.getProcessListElement();
Expand Down
@@ -0,0 +1,5 @@
0
0
0
0
60
@@ -0,0 +1,6 @@
DROP TABLE IF EXISTS test_table;
SYSTEM FLUSH LOGS;
TRUNCATE TABLE system.query_log;
SELECT * FROM test_table; -- { serverError 60 }
SYSTEM FLUSH LOGS;
SELECT exception_code FROM system.query_log;