1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
/* Copyright (c) 2011, 2025, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
as published by the Free Software Foundation.
This program is designed to work with certain software (including
but not limited to OpenSSL) that is licensed under separate terms,
as designated in a particular file or component or in included license
documentation. The authors of MySQL hereby grant you an additional
permission to link the program and your derivative works with the
separately licensed software that they have either included with
the program or referenced in the documentation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License, version 2.0, for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#ifndef OPT_EXPLAIN_FORMAT_TRADITIONAL_INCLUDED
#define OPT_EXPLAIN_FORMAT_TRADITIONAL_INCLUDED
#include <assert.h>
// assert
#include <memory>
#include <string>
#include <vector>
#include "sql/opt_explain_format.h"
#include "sql/parse_tree_node_base.h"
class Item;
class Json_dom;
class Json_object;
class Query_result;
class Query_expression;
template <class T>
class mem_root_deque;
/**
Formatter for the traditional EXPLAIN output
*/
class Explain_format_traditional : public Explain_format {
class Item_null *nil;
qep_row column_buffer; ///< buffer for the current output row
public:
Explain_format_traditional() : nil(nullptr) {}
bool is_hierarchical() const override { return false; }
bool send_headers(Query_result *result) override;
bool begin_context(enum_parsing_context, Query_expression *,
const Explain_format_flags *) override {
return false;
}
bool end_context(enum_parsing_context) override { return false; }
bool flush_entry() override;
qep_row *entry() override { return &column_buffer; }
private:
bool push_select_type(mem_root_deque<Item *> *items);
};
class Explain_format_tree : public Explain_format {
public:
Explain_format_tree() = default;
bool is_hierarchical() const override { return false; }
bool send_headers(Query_result *) override {
assert(false);
return true;
}
bool begin_context(enum_parsing_context, Query_expression *,
const Explain_format_flags *) override {
assert(false);
return true;
}
bool end_context(enum_parsing_context) override {
assert(false);
return true;
}
bool flush_entry() override {
assert(false);
return true;
}
qep_row *entry() override {
assert(false);
return nullptr;
}
bool is_iterator_based() const override { return true; }
/* Convert Json object to string */
std::string ExplainJsonToString(Json_object *json) override;
void ExplainPrintTreeNode(const Json_dom *json, int level,
std::string *explain,
std::vector<std::string> *tokens_for_force_subplan);
private:
bool push_select_type(mem_root_deque<Item *> *items);
void AppendChildren(const Json_dom *children, int level, std::string *explain,
std::vector<std::string> *tokens_for_force_subplan,
std::string *child_token_digest);
void ExplainPrintCosts(const Json_object *obj, std::string *explain);
};
#endif // OPT_EXPLAIN_FORMAT_TRADITIONAL_INCLUDED
|