| 994 | } |
| 995 | |
| 996 | static void validateAnalyzerSettings(ASTPtr ast, bool context_value) |
| 997 | { |
| 998 | if (ast->as<ASTSetQuery>()) |
| 999 | return; |
| 1000 | |
| 1001 | bool top_level = context_value; |
| 1002 | |
| 1003 | auto field_to_bool = [](const Field & f) -> bool |
| 1004 | { |
| 1005 | if (f.getType() == Field::Types::String) |
| 1006 | return stringToBool(f.safeGet<String>()); |
| 1007 | else |
| 1008 | return f.safeGet<bool>(); |
| 1009 | }; |
| 1010 | |
| 1011 | std::vector<ASTPtr> nodes_to_process{ ast }; |
| 1012 | while (!nodes_to_process.empty()) |
| 1013 | { |
| 1014 | auto node = nodes_to_process.back(); |
| 1015 | nodes_to_process.pop_back(); |
| 1016 | |
| 1017 | if (auto * set_query = node->as<ASTSetQuery>()) |
| 1018 | { |
| 1019 | if (auto * value = set_query->changes.tryGet("allow_experimental_analyzer")) |
| 1020 | { |
| 1021 | if (top_level != field_to_bool(*value)) |
| 1022 | throw Exception(ErrorCodes::INCORRECT_QUERY, "Setting 'allow_experimental_analyzer' is changed in the subquery. Top level value: {}", top_level); |
| 1023 | } |
| 1024 | |
| 1025 | if (auto * value = set_query->changes.tryGet("enable_analyzer")) |
| 1026 | { |
| 1027 | if (top_level != field_to_bool(*value)) |
| 1028 | throw Exception(ErrorCodes::INCORRECT_QUERY, "Setting 'enable_analyzer' is changed in the subquery. Top level value: {}", top_level); |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | for (auto child : node->children) |
| 1033 | { |
| 1034 | if (child) |
| 1035 | nodes_to_process.push_back(std::move(child)); |
| 1036 | } |
| 1037 | } |
| 1038 | } |
| 1039 | |
| 1040 | class ImplicitTransactionControlExecutor |
| 1041 | { |
no test coverage detected