Omit EXPLAIN FORMAT for old TCP clients.

This commit is contained in:
Nikolai Kochetov 2021-04-14 18:59:08 +03:00
parent 3f7cee1149
commit 4c37d461de

View File

@ -383,6 +383,15 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
ast = parseQuery(parser, begin, end, "", max_query_size, settings.max_parser_depth); ast = parseQuery(parser, begin, end, "", max_query_size, settings.max_parser_depth);
#endif #endif
if (auto * ast_explain = typeid_cast<ASTExplainQuery *>(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), /// Interpret SETTINGS clauses as early as possible (before invoking the corresponding interpreter),
/// to allow settings to take effect. /// to allow settings to take effect.
if (const auto * select_query = ast->as<ASTSelectQuery>()) if (const auto * select_query = ast->as<ASTSelectQuery>())