16 #ifndef OPT_TRACE_CONTEXT_INCLUDED
17 #define OPT_TRACE_CONTEXT_INCLUDED
19 #include "my_config.h"
20 #include "sql_array.h"
29 #ifdef OPTIMIZER_TRACE
121 bool start(
bool support_I_S,
122 bool support_dbug_or_missing_priv,
123 bool end_marker,
bool one_line,
138 bool is_started()
const
139 {
return unlikely(pimpl != NULL) && pimpl->current_stmt_in_gen != NULL; }
146 bool support_I_S()
const;
155 void set_query(
const char*
query,
size_t length,
166 bool get_end_marker()
const {
return pimpl->end_marker; }
168 bool get_one_line()
const {
return pimpl->one_line; }
176 static const char *flag_names[];
181 FLAG_ENABLED= 1 << 0,
182 FLAG_ONE_LINE= 1 << 1
196 static const char *feature_names[];
200 GREEDY_SEARCH= 1 << 0,
201 RANGE_OPTIMIZER= 1 << 1,
202 DYNAMIC_RANGE= 1 << 2,
203 REPEATED_SUBSELECT= 1 << 3,
224 void missing_privilege();
234 {
return unlikely(pimpl != NULL) && (pimpl->features & f); }
241 Opt_trace_stmt *get_current_stmt_in_gen()
242 {
return pimpl->current_stmt_in_gen; }
250 const Opt_trace_stmt *get_next_stmt_for_I_S(
long *got_so_far)
const;
253 void disable_I_S_for_this_and_children()
256 if (unlikely(pimpl != NULL))
257 pimpl->disable_I_S_for_this_and_children();
267 DBUG_ASSERT(I_S_disabled >= 0);
268 if (unlikely(pimpl != NULL))
269 pimpl->restore_I_S();
283 class Opt_trace_context_impl
286 Opt_trace_context_impl() : current_stmt_in_gen(NULL),
290 void disable_I_S_for_this_and_children();
321 Opt_trace_stmt *current_stmt_in_gen;
364 Opt_trace_context_impl *pimpl;
380 void purge_stmts(
bool purge_all);
392 size_t allowed_mem_size_for_current_stmt()
const;
408 GREEDY_SEARCH= 1 << 0,
409 RANGE_OPTIMIZER= 1 << 1,
410 DYNAMIC_RANGE= 1 << 2,
411 REPEATED_SUBSELECT= 1 << 3,
416 FLAG_ENABLED= 1 << 0,
417 FLAG_ONE_LINE= 1 << 1
419 static bool is_started() {
return false; }