diff --git a/src/Core/Settings.h b/src/Core/Settings.h index af32c15a867..c14c411bd49 100644 --- a/src/Core/Settings.h +++ b/src/Core/Settings.h @@ -347,6 +347,7 @@ static constexpr UInt64 operator""_GiB(unsigned long long value) \ M(UInt64, max_subquery_depth, 100, "If a query has more than specified number of nested subqueries, throw an exception. This allows you to have a sanity check to protect the users of your cluster from going insane with their queries.", 0) \ M(UInt64, max_pipeline_depth, 1000, "If a query has more than specified stages in the query pipeline, throw an exception. Pipeline has stages for every relational operator. This allows to limit the complexity of the queries.", 0) \ + M(UInt64, max_analyze_depth, 10000, "", 0) \ M(UInt64, max_ast_depth, 1000, "Maximum depth of query syntax tree. Checked after parsing.", 0) \ M(UInt64, max_ast_elements, 50000, "Maximum size of query syntax tree in number of nodes. Checked after parsing.", 0) \ M(UInt64, max_expanded_ast_elements, 500000, "Maximum size of query syntax tree in number of nodes after expansion of aliases and the asterisk.", 0) \ @@ -672,6 +673,8 @@ static constexpr UInt64 operator""_GiB(unsigned long long value) MAKE_OBSOLETE(M, UInt64, background_message_broker_schedule_pool_size, 16) \ MAKE_OBSOLETE(M, UInt64, background_distributed_schedule_pool_size, 16) \ MAKE_OBSOLETE(M, DefaultDatabaseEngine, default_database_engine, DefaultDatabaseEngine::Atomic) \ + MAKE_OBSOLETE(M, UInt64, max_pipeline_depth, 0) \ + /** The section above is for obsolete settings. Do not add anything there. */ diff --git a/src/Interpreters/InterpreterSelectQuery.cpp b/src/Interpreters/InterpreterSelectQuery.cpp index ac7cc4c1b4e..c596c5233ce 100644 --- a/src/Interpreters/InterpreterSelectQuery.cpp +++ b/src/Interpreters/InterpreterSelectQuery.cpp @@ -501,8 +501,8 @@ InterpreterSelectQuery::InterpreterSelectQuery( { std::atomic & current_query_analyze_count = context->getQueryContext()->kitchen_sink.analyze_counter; ++current_query_analyze_count; - if (settings.max_pipeline_depth && current_query_analyze_count >= settings.max_pipeline_depth) - throw DB::Exception(ErrorCodes::TOO_DEEP_PIPELINE, "Query analyze overflow. Try to increase `max_pipeline_depth` or simplify the query"); + if (settings.max_analyze_depth && current_query_analyze_count >= settings.max_analyze_depth) + throw DB::Exception(ErrorCodes::TOO_DEEP_RECURSION, "Query analyze overflow. Try to increase `max_analyze_depth` or simplify the query"); } /// Allow push down and other optimizations for VIEW: replace with subquery and rewrite it. diff --git a/tests/queries/0_stateless/02337_join_analyze_stuck.sql b/tests/queries/0_stateless/02337_join_analyze_stuck.sql index 9bdc418f028..4e3d0bc44c5 100644 --- a/tests/queries/0_stateless/02337_join_analyze_stuck.sql +++ b/tests/queries/0_stateless/02337_join_analyze_stuck.sql @@ -2,7 +2,7 @@ -- https://github.com/ClickHouse/ClickHouse/issues/21557 -SET max_pipeline_depth = 1000; +SET max_analyze_depth = 1000; EXPLAIN SYNTAX WITH @@ -12,4 +12,4 @@ WITH FROM x, x AS d1, x AS d2, x AS d3, x AS d4, x AS d5, x AS d6, x AS d7, x AS d8, x AS d9 WHERE x.number = d9.number ) -SELECT xx FROM cross_sales WHERE xx = 2000; -- { serverError TOO_DEEP_PIPELINE } +SELECT xx FROM cross_sales WHERE xx = 2000; -- { serverError TOO_DEEP_RECURSION }