17 #ifndef OPT_EXPLAIN_FORMAT_INCLUDED
18 #define OPT_EXPLAIN_FORMAT_INCLUDED
24 #include "sql_class.h"
33 enum Explain_context_enum
39 CTX_UPDATE_VALUE_LIST,
43 CTX_DUPLICATES_WEEDOUT,
56 CTX_OPTIMIZED_AWAY_SUBQUERY,
74 ET_USING_INDEX_CONDITION,
76 ET_RANGE_CHECKED_FOR_EACH_RECORD,
77 ET_USING_WHERE_WITH_PUSHED_CONDITION,
82 ET_FULL_SCAN_ON_NULL_KEY,
87 ET_USING_INDEX_FOR_GROUP_BY,
98 ET_CONST_ROW_NOT_FOUND,
99 ET_UNIQUE_ROW_NOT_FOUND,
100 ET_IMPOSSIBLE_ON_CONDITION,
140 namespace opt_explain_json_namespace
183 bool is_empty()
const {
return nil; }
184 void cleanup() { nil=
true; }
185 void set(T value_arg) { value= value_arg; nil=
false; }
186 T
get()
const { DBUG_ASSERT(!nil);
return value; }
219 if (deferred->
eval(&buff) ||
set(buff))
221 DBUG_ASSERT(!
"OOM!");
228 bool set(
const char *str_arg)
230 return set(str_arg, strlen(str_arg));
234 return set(s.ptr(), s.length());
244 bool set(
const char *str_arg,
size_t length_arg)
247 if (!(str= strndup_root(current_thd->mem_root, str_arg, length_arg)))
271 return set_const(str_arg, strlen(str_arg));
273 void set_const(
const char *str_arg,
size_t length_arg)
280 static char *strndup_root(
MEM_ROOT *root,
const char *str,
size_t len)
282 if (len == 0 || str == NULL)
283 return const_cast<char *
>(
"");
284 if (str[len - 1] == 0)
285 return static_cast<char *
>(memdup_root(root, str, len));
287 char *
ret=
static_cast<char*
>(alloc_root(root, len + 1));
290 memcpy(ret, str, len);
314 explicit extra(Extra_tag tag_arg,
const char *data_arg= NULL)
354 bool using_temporary;
355 bool is_materialized_from_subquery;
363 using_temporary(false),
364 is_materialized_from_subquery(false),
396 using_temporary=
false;
397 is_materialized_from_subquery=
false;
434 Explain_context_enum type_arg)
444 enum Explain_sort_clause
450 ESC_BUFFER_RESULT = 4,
458 enum Explain_sort_property
462 ESP_IS_SIMPLE = 1 << 1,
463 ESP_USING_FILESORT = 1 << 2,
464 ESP_USING_TMPTABLE = 1 << 3,
465 ESP_DUPS_REMOVAL = 1 << 4,
475 uint8 sorts[ESC_MAX];
483 void set(Explain_sort_clause clause, Explain_sort_property
property)
485 sorts[clause]|=
property | ESP_EXISTS;
490 memcpy(sorts,
flags.sorts,
sizeof(sorts));
498 sorts[clause]&= ~property;
504 bool get(Explain_sort_clause clause, Explain_sort_property
property)
const
506 return (sorts[clause] &
property) || (sorts[clause] & ESP_CHECKED);
514 for (
size_t i= ESC_none + 1;
i <= ESC_MAX - 1;
i++)
516 if (sorts[
i] & property || sorts[
i] & ESP_CHECKED)
574 SELECT_LEX_UNIT *subquery = 0,
582 virtual bool end_context(Explain_context_enum context)= 0;
597 #endif//OPT_EXPLAIN_FORMAT_INCLUDED