From 4c37d461de887f97202074c7f5003cad9a511ea8 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Wed, 14 Apr 2021 18:59:08 +0300 Subject: [PATCH] Omit EXPLAIN FORMAT for old TCP clients. --- src/Interpreters/executeQuery.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Interpreters/executeQuery.cpp b/src/Interpreters/executeQuery.cpp index e258fd2be12..d5d2ebed6b6 100644 --- a/src/Interpreters/executeQuery.cpp +++ b/src/Interpreters/executeQuery.cpp @@ -383,6 +383,15 @@ static std::tuple executeQueryImpl( ast = parseQuery(parser, begin, end, "", max_query_size, settings.max_parser_depth); #endif + if (auto * ast_explain = typeid_cast(ast.get())) + { + const auto & client_info = context.getClientInfo(); + /// Ignore format for old clients to ignore exception. Always return human-readable output. + if (client_info.interface == ClientInfo::Interface::TCP && + (client_info.client_version_major < 21 || client_info.client_version_minor < 5)) + ast_explain->format = nullptr; + } + /// Interpret SETTINGS clauses as early as possible (before invoking the corresponding interpreter), /// to allow settings to take effect. if (const auto * select_query = ast->as())