MySQL 8.3.0
Source Code Documentation
opt_explain_format.h
Go to the documentation of this file.
1/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef OPT_EXPLAIN_FORMAT_INCLUDED
24#define OPT_EXPLAIN_FORMAT_INCLUDED
25
26/**
27 @file sql/opt_explain_format.h
28 EXPLAIN FORMAT=@<format@> @<command@>.
29*/
30
31#include <assert.h>
32#include <sys/types.h>
33
34#include <cstring>
35#include <optional>
36#include <string_view>
37
38#include "my_alloc.h" // MEM_ROOT
39#include "my_compiler.h"
40
41#include "my_inttypes.h"
42#include "my_sys.h"
44#include "sql/sql_list.h"
45#include "sql_string.h"
46
48class Query_result;
50class Window;
51class Json_object;
52
53enum class enum_explain_type;
54
55/**
56 Types of traditional "extra" column parts and property names for hierarchical
57
58 The traditional_extra_tags[] and json_extra_tags[] arrays must be in sync
59 with this enum.
60*/
97 //------------------------------------
99};
100
101/**
102 Emulate lazy computation
103*/
104class Lazy {
105 public:
106 virtual ~Lazy() = default;
107
108 /**
109 Deferred evaluation of encapsulated expression
110
111 @param [out] ret Return string value
112
113 @retval false Success
114 @retval true Failure (OOM)
115 */
116 virtual bool eval(String *ret) = 0;
117};
118
119/**
120 Base class for all EXPLAIN context descriptor classes
121
122 In structured EXPLAIN implementation Explain_context is a base class for
123 notes of an intermediate tree.
124*/
127
128 explicit Explain_context(enum_parsing_context type_arg) : type(type_arg) {}
129};
130
131namespace opt_explain_json_namespace // for forward declaration of "context"
132{
133class context;
134}
135
136// Table modification type
138
139/**
140 Helper class for table property buffering
141
142 For traditional EXPLAIN this structure contains cached data for a single
143 output row.
144
145 For hierarchical EXPLAIN this structure contains property values for a single
146 CTX_TABLE/CTX_QEP_TAB context node of the intermediate tree.
147*/
148
149class qep_row {
150 private:
151 /* Don't copy this structure */
152 explicit qep_row(const qep_row &x); // undefined
153 qep_row &operator=(const qep_row &x); // undefined
154
155 public:
156 /**
157 A wrapper for numeric table properties
158
159 For traditional EXPLAIN this structure contains a value of one cell of the
160 output row (excluding textual column values - see mem_root_str, and
161 "Extra" column - see the col_extra list).
162
163 For hierarchical EXPLAIN this structure contains a numeric property value
164 for a single CTX_TABLE/CTX_QEP_TAB context node of the intermediate tree.
165 */
166 template <typename T>
167 struct column {
168 private:
169 bool nil; ///< true if the column contains NULL
170 public:
172
173 public:
175 bool is_empty() const { return nil; }
176 void cleanup() { nil = true; }
177 void set(T value_arg) {
178 value = value_arg;
179 nil = false;
180 }
181 T get() const {
182 assert(!nil);
183 return value;
184 }
185 };
186
187 /**
188 Helper class to keep string data in MEM_ROOT before passing to Item_string
189
190 Since Item_string constructors doesn't copy input string parameter data
191 in the most cases, those input strings must have the same lifetime as
192 Item_string objects, i.e. lifetime of MEM_ROOT.
193 This class allocates input parameters for Item_string objects in MEM_ROOT.
194
195 @note Call to is_empty() is necessary before the access to "str" and
196 "length" fields, since is_empty() may trigger an evaluation of
197 an associated expression that updates these fields.
198 */
200 const char *str;
201 size_t length;
202 Lazy *
203 deferred; ///< encapsulated expression to evaluate it later (on demand)
204
206 void cleanup() {
207 str = nullptr;
208 length = 0;
209 deferred = nullptr;
210 }
211 bool is_empty();
212 bool set(const char *str_arg) { return set(str_arg, strlen(str_arg)); }
213 bool set(const String &s) { return set(s.ptr(), s.length()); }
214 /**
215 Make a copy of the string in MEM_ROOT
216
217 @param str_arg string to copy
218 @param length_arg input string length
219
220 @return false if success, true if error
221 */
222 bool set(const char *str_arg, size_t length_arg);
223
224 /**
225 Save expression for further evaluation
226
227 @param x Expression
228 */
229 void set(Lazy *x) {
230 deferred = x;
231 str = nullptr;
232 length = 0;
233 }
234 /**
235 Make a copy of string constant
236
237 Variant of set() usable when the str_arg argument lives longer
238 than the mem_root_str instance.
239 */
240 void set_const(const char *str_arg) {
241 return set_const(str_arg, strlen(str_arg));
242 }
243 void set_const(const char *str_arg, size_t length_arg) {
244 deferred = nullptr;
245 str = str_arg;
246 length = length_arg;
247 }
248
249 static char *strndup_root(MEM_ROOT *root, const char *str, size_t len) {
250 if (len == 0 || str == nullptr) return const_cast<char *>("");
251 if (str[len - 1] == 0)
252 return static_cast<char *>(memdup_root(root, str, len));
253
254 char *ret = static_cast<char *>(root->Alloc(len + 1));
255 if (ret != nullptr) {
256 memcpy(ret, str, len);
257 ret[len] = 0;
258 }
259 return ret;
260 }
261 };
262
263 /**
264 Part of traditional "extra" column or related hierarchical property
265 */
266 struct extra {
267 /**
268 A property name or a constant text head of the "extra" column part
269 */
271 /**
272 Property value or a variable tail of the "extra" column part
273
274 If data == NULL, hierarchical formatter outputs a boolean property
275 value of "true".
276 */
277 const char *const data;
278
279 explicit extra(Extra_tag tag_arg, const char *data_arg = nullptr)
280 : tag(tag_arg), data(data_arg) {}
281 };
282
283 /*
284 Next "col_*" fields are intended to be filling by "explain_*()" functions.
285
286 NOTE: NULL value or mem_root_str.is_empty()==true means that Item_null
287 object will be pushed into "items" list instead.
288 */
289 column<uint> col_id; ///< "id" column: seq. number of SELECT within the query
291 mem_root_str col_table_name; ///< "table" to which the row of output refers
292 List<const char> col_partitions; ///< "partitions" column
293 mem_root_str col_join_type; ///< "type" column, see join_type_str array
295 col_possible_keys; ///< "possible_keys": comma-separated list
297 col_key; ///< "key" column: index that is actually decided to use
298 mem_root_str col_key_len; ///< "key_length" column: length of the "key" above
300 col_ref; ///< "ref":columns/constants which are compared to "key"
301 column<float> col_filtered; ///< "filtered": % of rows filtered by condition
302 List<extra> col_extra; ///< "extra" column (traditional) or property list
303
304 // non-TRADITIONAL stuff:
305 mem_root_str col_message; ///< replaces "Extra" column if not empty
306 mem_root_str col_attached_condition; ///< former "Using where"
307
308 /// "rows": estimated number of examined table rows per single scan
310 /// "rows": estimated number of examined table rows per query
312
313 column<double> col_read_cost; ///< Time to read the table
314 /// Cost of the partial join including this table
316 /// Cost of evaluating conditions on this table per query
318
319 /// Size of data expected to be read per query
321
322 /// List of used columns
324
325 /// List of columns that can be updated using partial update.
327
328 /* For structured EXPLAIN in CTX_QEP_TAB context: */
329 uint query_block_id; ///< query block id for materialized subqueries
330
331 /**
332 List of "derived" subquery trees
333 */
335
336 List<const char> col_key_parts; ///< used parts of the key
337
343 /**
344 If a clone of a materialized derived table, this is the ID of the first
345 underlying query block of the first materialized derived table. 0
346 otherwise.
347 */
349
350 List<Window> *m_windows; ///< Windows to describe in this node
351
353 : query_block_id(0),
354 is_dependent(false),
355 is_cacheable(true),
356 using_temporary(false),
361
362 virtual ~qep_row() = default;
363
364 void cleanup() {
365 col_id.cleanup();
367 col_partitions.clear();
369 col_possible_keys.clear();
372 col_ref.clear();
373 col_filtered.cleanup();
374 col_extra.clear();
377 col_key_parts.clear();
378
379 col_rows.cleanup();
380 col_prefix_rows.cleanup();
381
382 col_read_cost.cleanup();
383 col_prefix_cost.cleanup();
384 col_cond_cost.cleanup();
385
387
388 /*
389 Not needed (we call cleanup() for structured EXPLAIN only,
390 just for the consistency).
391 */
392 query_block_id = 0;
393 derived_from.clear();
394 is_dependent = false;
395 is_cacheable = true;
396 using_temporary = false;
399 }
400
401 /**
402 Remember a subquery's unit
403
404 JOIN_TAB inside a JOIN, a table in a join-less query (single-table
405 UPDATE/DELETE) or a table that's optimized out may have a WHERE
406 condition. We create the Explain_context of such a JOIN_TAB or
407 table when the Explain_context objects of its in-WHERE subqueries
408 don't exist.
409 This function collects unit pointers of WHERE subqueries that are
410 associated with the current JOIN_TAB or table. Then we can match these
411 units with units of newly-created Explain_context objects of WHERE
412 subqueries.
413
414 @param subquery WHERE clause subquery's unit
415 */
417 [[maybe_unused]]) {}
418
420};
421
422/**
423 Enumeration of ORDER BY, GROUP BY and DISTINCT clauses for array indexing
424
425 See Explain_format_flags::sorts
426*/
434 //-----------------
435 ESC_MAX
437
438/**
439 Bit flags to explain GROUP BY, ORDER BY and DISTINCT clauses
440*/
443 ESP_EXISTS = 1 << 0, ///< Original query has this clause
444 ESP_IS_SIMPLE = 1 << 1, ///< Clause is effective for single JOIN_TAB only
445 ESP_USING_FILESORT = 1 << 2, ///< Clause causes a filesort
446 ESP_USING_TMPTABLE = 1 << 3, ///< Clause creates an intermediate table
447 ESP_DUPS_REMOVAL = 1 << 4 ///< Duplicate removal for DISTINCT
449
451 /**
452 Bitmasks of Explain_sort_property flags for Explain_sort_clause clauses
453 */
455
456 public:
457 Explain_format_flags() { memset(sorts, 0, sizeof(sorts)); }
458
459 /**
460 Set property bit flag for the clause
461 */
463 sorts[clause] |= property | ESP_EXISTS;
464 }
465
467 memcpy(sorts, flags.sorts, sizeof(sorts));
468 }
469
470 /**
471 Clear property bit flag for the clause
472 */
474 sorts[clause] &= ~property;
475 }
476
477 /**
478 Return true if property is set for the clause
479 */
480 bool get(Explain_sort_clause clause, Explain_sort_property property) const {
481 return sorts[clause] & property;
482 }
483
484 /**
485 Return true if any of clauses has this property set
486
487 @param property Check if this property is present in any of the sorts
488 except clause's sort if specified
489 @param clause Optional. Do not check for the property for this clause. The
490 default is to check all clauses.
491 */
493 Explain_sort_clause clause = ESC_none) const {
494 for (size_t i = ESC_none + 1; i <= ESC_MAX - 1; i++) {
495 if (i != clause && (sorts[i] & property)) return true;
496 }
497 return false;
498 }
499};
500
501/**
502 Base class for structured and hierarchical EXPLAIN output formatters
503*/
504
506 private:
507 /* Don't copy Explain_format values */
510
511 protected:
512 Query_result *output; ///< output resulting data there
513
514 private:
515 std::optional<std::string_view> m_explain_into_variable_name;
516
517 public:
518 /* Which schema this EXPLAIN statement should be run for. */
520
521 protected:
524 std::optional<std::string_view> explain_into_variable_name)
525 : output(nullptr),
527
528 public:
529 virtual ~Explain_format() = default;
530
531 /**
532 A hierarchical text or a plain table
533
534 @retval true Formatter produces hierarchical text
535 @retval false Traditional explain
536 */
537 virtual bool is_hierarchical() const = 0;
538
539 /**
540 Whether the format closely resembles the final plan to be executed by
541 execution iterators (See RowIterator). These formats share a common logic
542 that uses AccessPath structure to generate the information, so they all
543 display exactly the same information, even though the style of each format
544 might be different.
545
546 @note: The new json format for hypergraph and the tree format are examples
547 of iterator-based formats.
548
549 @retval true Format is Iterator-based.
550 @retval false Format is not Iterator-based.
551 */
552 virtual bool is_iterator_based() const { return false; }
553
554 /**
555 * Whether the output of an EXPLAIN statement should be stored in a user
556 * variable or sent to the client. If this function returns true,
557 * explain_into_variable_name() returns the name of the variable.
558 *
559 * @retval true EXPLAIN output should be stored in a user variable.
560 * @retval false EXPLAIN output should be sent to the client.
561 */
562 bool is_explain_into() const {
563 return m_explain_into_variable_name.has_value();
564 }
565
566 /**
567 * Whether the EXPLAIN statement should be run in another schema than the
568 * current active schema. If this returns true, m_schema_name_for_explain
569 * contains the name of the schema to use for EXPLAIN.
570 *
571 * @return true The EXPLAIN statement should be run in another schema.
572 * @return false The EXPLAIN statement should be run in the current
573 * active schema.
574 */
577 }
578
579 /**
580 * Returns the name of the user variable the output of this EXPLAIN
581 * statement is to be stored in. Should only be called if this is an
582 * EXPLAIN INTO statement.
583 *
584 * @return std::string_view The name of the variable to store the output in.
585 */
586 std::string_view explain_into_variable_name() const {
587 assert(is_explain_into());
588 return m_explain_into_variable_name.value();
589 }
590
591 /**
592 Send EXPLAIN header item(s) to output stream
593
594 @note: This function caches the output result set pointer for further use.
595
596 @param result output result set
597
598 @retval false OK
599 @retval true Error
600 */
602 output = result;
603 return false;
604 }
605
606 /**
607 Enter a specified context
608
609 @param context context type
610 @param subquery for CTX_WHERE: unit of the subquery
611 @param flags Format flags, see Explain_format_flags.
612 */
614 Query_expression *subquery = nullptr,
615 const Explain_format_flags *flags = nullptr) = 0;
616
617 /**
618 Leave the current context
619
620 @param context current context type (for validation/debugging)
621 */
622 virtual bool end_context(enum_parsing_context context) = 0;
623
624 /**
625 Flush TABLE/JOIN_TAB property set
626
627 For traditional EXPLAIN: output a single EXPLAIN row.
628 */
629 virtual bool flush_entry() = 0;
630
631 /**
632 Get a pointer to the current TABLE/JOIN_TAB property set
633 */
634 virtual qep_row *entry() = 0;
635
636 /**
637 Convert Json object to string. Should only be called for iterator-based
638 formats.
639 */
640 virtual std::string ExplainJsonToString(Json_object *json [[maybe_unused]]) {
641 assert(false);
642 return nullptr;
643 }
644};
645
646#endif // OPT_EXPLAIN_FORMAT_INCLUDED
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:250
Definition: opt_explain_format.h:450
bool get(Explain_sort_clause clause, Explain_sort_property property) const
Return true if property is set for the clause.
Definition: opt_explain_format.h:480
void set(Explain_format_flags &flags)
Definition: opt_explain_format.h:466
void reset(Explain_sort_clause clause, Explain_sort_property property)
Clear property bit flag for the clause.
Definition: opt_explain_format.h:473
bool any(Explain_sort_property property, Explain_sort_clause clause=ESC_none) const
Return true if any of clauses has this property set.
Definition: opt_explain_format.h:492
Explain_format_flags()
Definition: opt_explain_format.h:457
void set(Explain_sort_clause clause, Explain_sort_property property)
Set property bit flag for the clause.
Definition: opt_explain_format.h:462
uint8 sorts[ESC_MAX]
Bitmasks of Explain_sort_property flags for Explain_sort_clause clauses.
Definition: opt_explain_format.h:454
Base class for structured and hierarchical EXPLAIN output formatters.
Definition: opt_explain_format.h:505
Query_result * output
output resulting data there
Definition: opt_explain_format.h:512
virtual bool is_iterator_based() const
Whether the format closely resembles the final plan to be executed by execution iterators (See RowIte...
Definition: opt_explain_format.h:552
virtual std::string ExplainJsonToString(Json_object *json)
Convert Json object to string.
Definition: opt_explain_format.h:640
virtual bool flush_entry()=0
Flush TABLE/JOIN_TAB property set.
virtual bool end_context(enum_parsing_context context)=0
Leave the current context.
Explain_format & operator=(Explain_format &)
Explain_format(std::optional< std::string_view > explain_into_variable_name)
Definition: opt_explain_format.h:523
std::string_view explain_into_variable_name() const
Returns the name of the user variable the output of this EXPLAIN statement is to be stored in.
Definition: opt_explain_format.h:586
bool is_explain_into() const
Whether the output of an EXPLAIN statement should be stored in a user variable or sent to the client.
Definition: opt_explain_format.h:562
LEX_CSTRING m_schema_name_for_explain
Definition: opt_explain_format.h:519
virtual ~Explain_format()=default
virtual qep_row * entry()=0
Get a pointer to the current TABLE/JOIN_TAB property set.
bool is_explain_for_schema() const
Whether the EXPLAIN statement should be run in another schema than the current active schema.
Definition: opt_explain_format.h:575
virtual bool is_hierarchical() const =0
A hierarchical text or a plain table.
std::optional< std::string_view > m_explain_into_variable_name
Definition: opt_explain_format.h:515
virtual bool begin_context(enum_parsing_context context, Query_expression *subquery=nullptr, const Explain_format_flags *flags=nullptr)=0
Enter a specified context.
Explain_format()
Definition: opt_explain_format.h:522
virtual bool send_headers(Query_result *result)
Send EXPLAIN header item(s) to output stream.
Definition: opt_explain_format.h:601
Explain_format(Explain_format &)
Represents a JSON container value of type "object" (ECMA), type J_OBJECT here.
Definition: json_dom.h:367
Emulate lazy computation.
Definition: opt_explain_format.h:104
virtual ~Lazy()=default
virtual bool eval(String *ret)=0
Deferred evaluation of encapsulated expression.
Definition: sql_list.h:434
A JSON object (unordered set of key/value pairs).
Definition: opt_trace.h:801
This class represents a query expression (one query block or several query blocks combined with UNION...
Definition: sql_lex.h:624
Definition: query_result.h:57
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:166
const char * ptr() const
Definition: sql_string.h:248
size_t length() const
Definition: sql_string.h:240
Represents the (explicit) window of a SQL 2003 section 7.11 <window clause>, or the implicit (inlined...
Definition: window.h:104
Base class for all intermediate tree nodes.
Definition: opt_explain_json.cc:219
Helper class for table property buffering.
Definition: opt_explain_format.h:149
List< const char > col_partial_update_columns
List of columns that can be updated using partial update.
Definition: opt_explain_format.h:326
List< const char > col_partitions
"partitions" column
Definition: opt_explain_format.h:292
void format_extra(Opt_trace_object *obj)
Definition: opt_explain_json.cc:2094
mem_root_str col_message
replaces "Extra" column if not empty
Definition: opt_explain_format.h:305
List< extra > col_extra
"extra" column (traditional) or property list
Definition: opt_explain_format.h:302
void cleanup()
Definition: opt_explain_format.h:364
qep_row & operator=(const qep_row &x)
List< const char > col_possible_keys
"possible_keys": comma-separated list
Definition: opt_explain_format.h:295
mem_root_str col_attached_condition
former "Using where"
Definition: opt_explain_format.h:306
enum_mod_type mod_type
Definition: opt_explain_format.h:341
mem_root_str col_join_type
"type" column, see join_type_str array
Definition: opt_explain_format.h:293
mem_root_str col_key_len
"key_length" column: length of the "key" above
Definition: opt_explain_format.h:298
column< double > col_prefix_cost
Cost of the partial join including this table.
Definition: opt_explain_format.h:315
column< ulonglong > col_rows
"rows": estimated number of examined table rows per single scan
Definition: opt_explain_format.h:309
column< double > col_read_cost
Time to read the table.
Definition: opt_explain_format.h:313
column< float > col_filtered
"filtered": % of rows filtered by condition
Definition: opt_explain_format.h:301
List< const char > col_key_parts
used parts of the key
Definition: opt_explain_format.h:336
List< const char > col_used_columns
List of used columns.
Definition: opt_explain_format.h:323
column< uint > col_id
"id" column: seq. number of SELECT within the query
Definition: opt_explain_format.h:289
List< const char > col_ref
"ref":columns/constants which are compared to "key"
Definition: opt_explain_format.h:300
qep_row()
Definition: opt_explain_format.h:352
column< ulonglong > col_prefix_rows
"rows": estimated number of examined table rows per query
Definition: opt_explain_format.h:311
mem_root_str col_key
"key" column: index that is actually decided to use
Definition: opt_explain_format.h:297
bool using_temporary
Definition: opt_explain_format.h:340
virtual void register_where_subquery(Query_expression *subquery)
Remember a subquery's unit.
Definition: opt_explain_format.h:416
bool is_dependent
Definition: opt_explain_format.h:338
List< opt_explain_json_namespace::context > derived_from
List of "derived" subquery trees.
Definition: opt_explain_format.h:334
uint derived_clone_id
If a clone of a materialized derived table, this is the ID of the first underlying query block of the...
Definition: opt_explain_format.h:348
uint query_block_id
query block id for materialized subqueries
Definition: opt_explain_format.h:329
column< enum_explain_type > col_select_type
"select_type" column
Definition: opt_explain_format.h:290
bool is_cacheable
Definition: opt_explain_format.h:339
mem_root_str col_table_name
"table" to which the row of output refers
Definition: opt_explain_format.h:291
virtual ~qep_row()=default
column< double > col_cond_cost
Cost of evaluating conditions on this table per query.
Definition: opt_explain_format.h:317
List< Window > * m_windows
Windows to describe in this node.
Definition: opt_explain_format.h:350
qep_row(const qep_row &x)
bool is_materialized_from_subquery
Definition: opt_explain_format.h:342
mem_root_str col_data_size_query
Size of data expected to be read per query.
Definition: opt_explain_format.h:320
enum_explain_type
Query_block type enum.
Definition: sql_lex.h:1136
void * memdup_root(MEM_ROOT *root, const void *str, size_t len)
Definition: my_alloc.cc:295
static int flags[50]
Definition: hp_test1.cc:39
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
Header for compiler-dependent features.
Some integer typedefs for easier portability.
uint8_t uint8
Definition: my_inttypes.h:62
Common header for many mysys elements.
Definition: opt_explain_format.h:132
Extra_tag
Types of traditional "extra" column parts and property names for hierarchical.
Definition: opt_explain_format.h:61
@ ET_SKIP_RECORDS_IN_RANGE
Definition: opt_explain_format.h:94
@ ET_UNIQUE_ROW_NOT_FOUND
Definition: opt_explain_format.h:87
@ ET_RANGE_CHECKED_FOR_EACH_RECORD
Definition: opt_explain_format.h:67
@ ET_none
Definition: opt_explain_format.h:62
@ ET_USING_JOIN_BUFFER
Definition: opt_explain_format.h:85
@ ET_USING
Definition: opt_explain_format.h:66
@ ET_USING_INDEX_CONDITION
Definition: opt_explain_format.h:65
@ ET_total
Definition: opt_explain_format.h:98
@ ET_END_MATERIALIZE
Definition: opt_explain_format.h:83
@ ET_FIRST_MATCH
Definition: opt_explain_format.h:80
@ ET_USING_INDEX
Definition: opt_explain_format.h:72
@ ET_TABLE_FUNCTION
Definition: opt_explain_format.h:93
@ ET_USING_WHERE
Definition: opt_explain_format.h:69
@ ET_RECURSIVE
Definition: opt_explain_format.h:92
@ ET_SCAN
Definition: opt_explain_format.h:84
@ ET_BACKWARD_SCAN
Definition: opt_explain_format.h:91
@ ET_NOT_EXISTS
Definition: opt_explain_format.h:70
@ ET_MATERIALIZE
Definition: opt_explain_format.h:81
@ ET_USING_INDEX_FOR_GROUP_BY
Definition: opt_explain_format.h:74
@ ET_USING_MRR
Definition: opt_explain_format.h:71
@ ET_PUSHED_JOIN
Definition: opt_explain_format.h:89
@ ET_REMATERIALIZE
Definition: opt_explain_format.h:96
@ ET_FT_HINTS
Definition: opt_explain_format.h:90
@ ET_USING_INDEX_FOR_SKIP_SCAN
Definition: opt_explain_format.h:75
@ ET_IMPOSSIBLE_ON_CONDITION
Definition: opt_explain_format.h:88
@ ET_START_TEMPORARY
Definition: opt_explain_format.h:78
@ ET_LOOSESCAN
Definition: opt_explain_format.h:77
@ ET_USING_FILESORT
Definition: opt_explain_format.h:64
@ ET_DISTINCT
Definition: opt_explain_format.h:76
@ ET_USING_PUSHED_CONDITION
Definition: opt_explain_format.h:68
@ ET_USING_TEMPORARY
Definition: opt_explain_format.h:63
@ ET_CONST_ROW_NOT_FOUND
Definition: opt_explain_format.h:86
@ ET_FULL_SCAN_ON_NULL_KEY
Definition: opt_explain_format.h:73
@ ET_END_TEMPORARY
Definition: opt_explain_format.h:79
@ ET_USING_SECONDARY_ENGINE
Definition: opt_explain_format.h:95
@ ET_START_MATERIALIZE
Definition: opt_explain_format.h:82
enum_mod_type
Definition: opt_explain_format.h:137
@ MT_UPDATE
Definition: opt_explain_format.h:137
@ MT_REPLACE
Definition: opt_explain_format.h:137
@ MT_INSERT
Definition: opt_explain_format.h:137
@ MT_NONE
Definition: opt_explain_format.h:137
@ MT_DELETE
Definition: opt_explain_format.h:137
Explain_sort_clause
Enumeration of ORDER BY, GROUP BY and DISTINCT clauses for array indexing.
Definition: opt_explain_format.h:427
@ ESC_WINDOWING
Definition: opt_explain_format.h:433
@ ESC_ORDER_BY
Definition: opt_explain_format.h:429
@ ESC_DISTINCT
Definition: opt_explain_format.h:431
@ ESC_BUFFER_RESULT
Definition: opt_explain_format.h:432
@ ESC_MAX
Definition: opt_explain_format.h:435
@ ESC_GROUP_BY
Definition: opt_explain_format.h:430
@ ESC_none
Definition: opt_explain_format.h:428
Explain_sort_property
Bit flags to explain GROUP BY, ORDER BY and DISTINCT clauses.
Definition: opt_explain_format.h:441
@ ESP_DUPS_REMOVAL
Duplicate removal for DISTINCT.
Definition: opt_explain_format.h:447
@ ESP_EXISTS
Original query has this clause.
Definition: opt_explain_format.h:443
@ ESP_USING_FILESORT
Clause causes a filesort.
Definition: opt_explain_format.h:445
@ ESP_IS_SIMPLE
Clause is effective for single JOIN_TAB only.
Definition: opt_explain_format.h:444
@ ESP_none
Definition: opt_explain_format.h:442
@ ESP_USING_TMPTABLE
Clause creates an intermediate table.
Definition: opt_explain_format.h:446
enum_parsing_context
Names for different query parse tree parts.
Definition: parse_tree_node_base.h:60
struct result result
Definition: result.h:33
Our own string classes, used pervasively throughout the executor.
Base class for all EXPLAIN context descriptor classes.
Definition: opt_explain_format.h:125
enum_parsing_context type
type tag
Definition: opt_explain_format.h:126
Explain_context(enum_parsing_context type_arg)
Definition: opt_explain_format.h:128
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:82
void * Alloc(size_t length)
Allocate memory.
Definition: my_alloc.h:144
Definition: mysql_lex_string.h:39
size_t length
Definition: mysql_lex_string.h:41
A wrapper for numeric table properties.
Definition: opt_explain_format.h:167
column()
Definition: opt_explain_format.h:174
bool nil
true if the column contains NULL
Definition: opt_explain_format.h:169
T get() const
Definition: opt_explain_format.h:181
void set(T value_arg)
Definition: opt_explain_format.h:177
T value
Definition: opt_explain_format.h:171
bool is_empty() const
Definition: opt_explain_format.h:175
void cleanup()
Definition: opt_explain_format.h:176
Part of traditional "extra" column or related hierarchical property.
Definition: opt_explain_format.h:266
extra(Extra_tag tag_arg, const char *data_arg=nullptr)
Definition: opt_explain_format.h:279
const Extra_tag tag
A property name or a constant text head of the "extra" column part.
Definition: opt_explain_format.h:270
const char *const data
Property value or a variable tail of the "extra" column part.
Definition: opt_explain_format.h:277
Helper class to keep string data in MEM_ROOT before passing to Item_string.
Definition: opt_explain_format.h:199
size_t length
Definition: opt_explain_format.h:201
void cleanup()
Definition: opt_explain_format.h:206
void set_const(const char *str_arg, size_t length_arg)
Definition: opt_explain_format.h:243
bool set(const char *str_arg)
Definition: opt_explain_format.h:212
void set_const(const char *str_arg)
Make a copy of string constant.
Definition: opt_explain_format.h:240
void set(Lazy *x)
Save expression for further evaluation.
Definition: opt_explain_format.h:229
static char * strndup_root(MEM_ROOT *root, const char *str, size_t len)
Definition: opt_explain_format.h:249
Lazy * deferred
encapsulated expression to evaluate it later (on demand)
Definition: opt_explain_format.h:203
bool is_empty()
Definition: opt_explain_format.cc:31
mem_root_str()
Definition: opt_explain_format.h:205
const char * str
Definition: opt_explain_format.h:200
bool set(const String &s)
Definition: opt_explain_format.h:213
Definition: result.h:29