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