| 5636 | } |
| 5637 | |
| 5638 | void QueryFuzzer::fuzzMain(ASTPtr & ast) |
| 5639 | { |
| 5640 | current_ast_depth = 0; |
| 5641 | iteration_count = 0; |
| 5642 | debug_visited_nodes.clear(); |
| 5643 | debug_top_ast = * |
| 5644 | last_query_parameters.clear(); |
| 5645 | param_counter = 0; |
| 5646 | |
| 5647 | collectFuzzInfoMain(ast); |
| 5648 | fuzz(ast); |
| 5649 | |
| 5650 | /// Pick up any {name:type} params introduced during fuzzing (e.g. substituted from the |
| 5651 | /// column_like pool). Use try_emplace so values seeded above are not overwritten. |
| 5652 | std::function<void(const ASTPtr &)> seed_new_params = [&](const ASTPtr & node) |
| 5653 | { |
| 5654 | if (const auto * p = typeid_cast<const ASTQueryParameter *>(node.get())) |
| 5655 | last_query_parameters.try_emplace(p->name, generateParamValue()); |
| 5656 | for (const auto & child : node->children) |
| 5657 | seed_new_params(child); |
| 5658 | }; |
| 5659 | seed_new_params(ast); |
| 5660 | |
| 5661 | CurrentMetrics::set(CurrentMetrics::ASTFuzzerAccumulatedFragments, getAccumulatedStateSize()); |
| 5662 | |
| 5663 | if (out_stream) |
| 5664 | { |
| 5665 | *out_stream << std::endl; |
| 5666 | *out_stream << ast->formatWithSecretsOneLine() << std::endl << std::endl; |
| 5667 | } |
| 5668 | } |
| 5669 | |
| 5670 | } |
no test coverage detected