mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 20:02:05 +00:00
Fix query comments in query_log and server log (w/ enable_global_with_statement)
Plus, I guess that enable_global_with_statement will be enabled by default someday, so it may become significant. The enable_global_with_statement had been introduced in #15451 Cc: @amosbird
This commit is contained in:
parent
75a02112bc
commit
e76066718d
@ -338,28 +338,26 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
|
||||
|
||||
try
|
||||
{
|
||||
bool ast_modified = false;
|
||||
/// Replace ASTQueryParameter with ASTLiteral for prepared statements.
|
||||
if (context.hasQueryParameters())
|
||||
{
|
||||
ReplaceQueryParameterVisitor visitor(context.getQueryParameters());
|
||||
visitor.visit(ast);
|
||||
ast_modified = true;
|
||||
query = serializeAST(*ast);
|
||||
}
|
||||
|
||||
/// MUST goes before any modification (except for prepared statements,
|
||||
/// since it substitute parameters and w/o them query does not contains
|
||||
/// parameters), to keep query as-is in query_log and server log.
|
||||
query_for_logging = prepareQueryForLogging(query, context);
|
||||
logQuery(query_for_logging, context, internal);
|
||||
|
||||
/// Propagate WITH statement to children ASTSelect.
|
||||
if (settings.enable_global_with_statement)
|
||||
{
|
||||
ApplyWithGlobalVisitor().visit(ast);
|
||||
ast_modified = true;
|
||||
}
|
||||
|
||||
if (ast_modified)
|
||||
query = serializeAST(*ast);
|
||||
|
||||
query_for_logging = prepareQueryForLogging(query, context);
|
||||
|
||||
logQuery(query_for_logging, context, internal);
|
||||
}
|
||||
|
||||
/// Check the limits.
|
||||
checkASTSizeLimits(*ast, settings);
|
||||
|
@ -0,0 +1,4 @@
|
||||
2
|
||||
1
|
||||
2
|
||||
1
|
12
tests/queries/0_stateless/01531_query_log_query_comment.sql
Normal file
12
tests/queries/0_stateless/01531_query_log_query_comment.sql
Normal file
@ -0,0 +1,12 @@
|
||||
set log_queries=1;
|
||||
set log_queries_min_type='QUERY_FINISH';
|
||||
|
||||
set enable_global_with_statement=1;
|
||||
select /* test=01531, enable_global_with_statement=0 */ 2;
|
||||
system flush logs;
|
||||
select count() from system.query_log where event_time >= now() - interval 5 minute and query = 'select /* test=01531, enable_global_with_statement=0 */ 2;\n';
|
||||
|
||||
set enable_global_with_statement=1;
|
||||
select /* test=01531 enable_global_with_statement=1 */ 2;
|
||||
system flush logs;
|
||||
select count() from system.query_log where event_time >= now() - interval 5 minute and query = 'select /* test=01531 enable_global_with_statement=1 */ 2;\n';
|
Loading…
Reference in New Issue
Block a user