MySQL  8.0.17
Source Code Documentation
opt_hints.h
Go to the documentation of this file.
1 /* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
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 /*
24  Parse tree node classes for optimizer hint syntax
25 */
26 
27 #ifndef OPT_HINTS_INCLUDED
28 #define OPT_HINTS_INCLUDED
29 
30 #include <stddef.h>
31 #include <sys/types.h>
32 
33 #include "lex_string.h"
34 #include "m_ctype.h"
35 #include "m_string.h"
36 #include "my_compiler.h"
37 #include "my_dbug.h"
38 #include "my_inttypes.h"
39 #include "sql/enum_query_type.h"
40 #include "sql/item_subselect.h" // Item_exists_subselect
41 #include "sql/mem_root_array.h" // Mem_root_array
42 #include "sql/sql_bitmap.h" // Bitmap
43 #include "sql/sql_show.h" // append_identifier
44 #include "sql_string.h" // String
45 
46 class Item;
47 class JOIN;
48 class Opt_hints_table;
49 class Sys_var_hint;
50 class THD;
51 class set_var;
52 class sys_var;
53 struct MEM_ROOT;
54 struct TABLE;
55 struct TABLE_LIST;
56 
57 /**
58  Hint types, MAX_HINT_ENUM should be always last.
59  This enum should be synchronized with opt_hint_info
60  array(see opt_hints.cc).
61 */
81 };
82 
84  const char *hint_name; // Hint name.
85  bool check_upper_lvl; // true if upper level hint check is needed (for hints
86  // which can be specified on more than one level).
87  bool switch_hint; // true if hint is not complex.
88  bool irregular_hint; ///< true if hint requires some special handling.
89  ///< Currently it's used only for join order hints
90  ///< since they need special printing procedure.
91 };
92 
93 /**
94  Opt_hints_map contains information
95  about hint state(specified or not, hint value).
96 */
97 
99  Bitmap<64> hints; // hint state
100  Bitmap<64> hints_specified; // true if hint is specified
101  public:
102  /**
103  Check if hint is specified.
104 
105  @param type_arg hint type
106 
107  @return true if hint is specified
108  */
109  bool is_specified(opt_hints_enum type_arg) const {
110  return hints_specified.is_set(type_arg);
111  }
112  /**
113  Set switch value and set hint into specified state.
114 
115  @param type_arg hint type
116  @param switch_state_arg switch value
117  */
118  void set_switch(opt_hints_enum type_arg, bool switch_state_arg) {
119  if (switch_state_arg)
120  hints.set_bit(type_arg);
121  else
122  hints.clear_bit(type_arg);
123  hints_specified.set_bit(type_arg);
124  }
125  /**
126  Get switch value.
127 
128  @param type_arg hint type
129 
130  @return switch value.
131  */
132  bool switch_on(opt_hints_enum type_arg) const {
133  return hints.is_set(type_arg);
134  }
135 };
136 
137 class Opt_hints_key;
138 class PT_hint;
140 
141 /**
142  Opt_hints class is used as ancestor for Opt_hints_global,
143  Opt_hints_qb, Opt_hints_table, Opt_hints_key classes.
144 
145  Opt_hints_global class is hierarchical structure.
146  It contains information about global hints and also
147  conains array of QUERY BLOCK level objects (Opt_hints_qb class).
148  Each QUERY BLOCK level object contains array of TABLE level hints
149  (class Opt_hints_table). Each TABLE level hint contains array of
150  KEY lelev hints (Opt_hints_key class).
151  Hint information(specified, on|off state) is stored in hints_map object.
152 */
153 
154 class Opt_hints {
155  /*
156  Name of object referred by the hint.
157  This name is empty for global level,
158  query block name for query block level,
159  table name for table level and key name
160  for key level.
161  */
163  /*
164  Parent object. There is no parent for global level,
165  for query block level parent is Opt_hints_global object,
166  for table level parent is Opt_hints_qb object,
167  for key level parent is Opt_hints_key object.
168  */
170 
172 
173  /* Array of child objects. i.e. array of the lower level objects */
175  /* true if hint is connected to the real object */
176  bool resolved;
177  /* Number of resolved children */
179 
180  public:
181  Opt_hints(const LEX_CSTRING *name_arg, Opt_hints *parent_arg,
182  MEM_ROOT *mem_root_arg)
183  : name(name_arg),
184  parent(parent_arg),
185  child_array(mem_root_arg),
186  resolved(false),
187  resolved_children(0) {}
188 
189  virtual ~Opt_hints() {}
190 
191  bool is_specified(opt_hints_enum type_arg) const {
192  return hints_map.is_specified(type_arg);
193  }
194 
195  /**
196  Function sets switch hint state.
197 
198  @param switch_state_arg switch hint state
199  @param type_arg hint type
200  @param check_parent true if hint can be on parent level
201 
202  @return true if hint is already specified,
203  false otherwise
204  */
205  bool set_switch(bool switch_state_arg, opt_hints_enum type_arg,
206  bool check_parent) {
207  if (is_specified(type_arg) ||
208  (check_parent && parent->is_specified(type_arg)))
209  return true;
210 
211  hints_map.set_switch(type_arg, switch_state_arg);
212  return false;
213  }
214 
215  /**
216  Function returns switch hint state.
217 
218  @param type_arg hint type
219 
220  @return hint value if hint is specified,
221  false otherwise
222  */
223  bool get_switch(opt_hints_enum type_arg) const;
224 
225  virtual const LEX_CSTRING *get_name() const { return name; }
226  void set_name(const LEX_CSTRING *name_arg) { name = name_arg; }
227  Opt_hints *get_parent() const { return parent; }
228  virtual void set_resolved() { resolved = true; }
229  /**
230  Returns 'resolved' flag value for depending on hint type.
231 
232  @param type_arg hint type
233 
234  @return true if all hint objects are resolved, false otherwise.
235  */
236  virtual bool is_resolved(opt_hints_enum type_arg MY_ATTRIBUTE((unused))) {
237  return resolved;
238  }
239  /**
240  Set hint to unresolved state.
241 
242  @param type_arg hint type
243  */
244  virtual void set_unresolved(opt_hints_enum type_arg MY_ATTRIBUTE((unused))) {}
245  /**
246  If ignore_print() returns true, hint is not printed
247  in Opt_hints::print() function. Atm used for
248  INDEX_MERGE, SKIP_SCAN hints.
249 
250  @param type_arg hint type
251 
252  @return true if the hint should not be printed
253  in Opt_hints::print() function, false otherwise.
254  */
255  virtual bool ignore_print(
256  opt_hints_enum type_arg MY_ATTRIBUTE((unused))) const {
257  return false;
258  }
261 
262  bool is_all_resolved() const {
263  return child_array.size() == resolved_children;
264  }
265 
266  void register_child(Opt_hints *hint_arg) { child_array.push_back(hint_arg); }
267 
268  /**
269  Returns pointer to complex hint for a given type.
270 
271  A complex hint is a hint that has arguments.
272  (It is not just an on/off switch.)
273 
274  @param type hint type
275 
276  @return pointer to complex hint for a given type.
277  */
279  opt_hints_enum type MY_ATTRIBUTE((unused))) {
280  DBUG_ASSERT(0);
281  return NULL; /* error C4716: must return a value */
282  }
283 
284  /**
285  Find hint among lower-level hint objects.
286 
287  @param name_arg hint name
288  @param cs Pointer to character set
289 
290  @return hint if found,
291  NULL otherwise
292  */
293  Opt_hints *find_by_name(const LEX_CSTRING *name_arg,
294  const CHARSET_INFO *cs) const;
295  /**
296  Print all hints except of QB_NAME hint.
297 
298  @param thd Pointer to THD object
299  @param str Pointer to String object
300  @param query_type If query type is QT_NORMALIZED_FORMAT,
301  un-resolved hints will also be printed
302  */
303  void print(const THD *thd, String *str, enum_query_type query_type);
304  /**
305  Check if there are any unresolved hint objects and
306  print warnings for them.
307 
308  @param thd Pointer to THD object
309  */
310  void check_unresolved(THD *thd);
311  virtual void append_name(const THD *thd, String *str) = 0;
312 
313  private:
314  /**
315  Append hint type.
316 
317  @param str Pointer to String object
318  @param type Hint type
319  */
321  /**
322  Print warning for unresolved hint name.
323 
324  @param thd Pointer to THD object
325  */
326  void print_warn_unresolved(THD *thd);
327  /**
328  Function prints hints which are non-standard and don't
329  fit into existing hint infrastructure.
330 
331  @param thd pointer to THD object
332  @param str pointer to String object
333  */
334  virtual void print_irregular_hints(const THD *thd MY_ATTRIBUTE((unused)),
335  String *str MY_ATTRIBUTE((unused))) {}
336 };
337 
338 /**
339  Global level hints.
340 */
341 
342 class Opt_hints_global : public Opt_hints {
343  public:
346 
347  Opt_hints_global(MEM_ROOT *mem_root_arg)
348  : Opt_hints(NULL, NULL, mem_root_arg) {
350  sys_var_hint = NULL;
351  }
352 
353  void append_name(const THD *, String *) override {}
355  void print_irregular_hints(const THD *thd, String *str) override;
356 };
357 
358 class PT_qb_level_hint;
359 
360 /**
361  Query block level hints.
362 */
363 
364 class Opt_hints_qb : public Opt_hints {
365  uint select_number; // SELECT_LEX number
366  LEX_CSTRING sys_name; // System QB name
367  char buff[32]; // Buffer to hold sys name
368 
370 
371  /// Array of join order hints
373  /// Bit map of which hints are ignored.
375 
376  /*
377  PT_qb_level_hint::contextualize sets subquery/semijoin_hint during parsing.
378  it also registers join order hints during parsing.
379  */
380  friend class PT_qb_level_hint;
381 
382  public:
383  Opt_hints_qb(Opt_hints *opt_hints_arg, MEM_ROOT *mem_root_arg,
384  uint select_number_arg);
385 
387  const LEX_CSTRING *str = Opt_hints::get_name();
388  return str ? str : &sys_name;
389  }
390 
391  /**
392  Append query block hint.
393 
394  @param thd pointer to THD object
395  @param str pointer to String object
396  */
397  void append_qb_hint(const THD *thd, String *str) {
398  if (get_name()) {
399  str->append(STRING_WITH_LEN("QB_NAME("));
400  append_identifier(thd, str, get_name()->str, get_name()->length);
401  str->append(STRING_WITH_LEN(") "));
402  }
403  }
404  /**
405  Append query block name.
406 
407  @param thd pointer to THD object
408  @param str pointer to String object
409  */
410  void append_name(const THD *thd, String *str) override {
411  str->append(STRING_WITH_LEN("@"));
412  append_identifier(thd, str, get_print_name()->str,
414  }
415 
417 
418  /**
419  Function finds Opt_hints_table object corresponding to
420  table alias in the query block and attaches corresponding
421  key hint objects to appropriate KEY structures.
422 
423  @param table Table reference
424 
425  @return pointer Opt_hints_table object if this object is found,
426  NULL otherwise.
427  */
429 
430  /**
431  Returns whether semi-join is enabled for this query block
432 
433  A SEMIJOIN hint will force semi-join regardless of optimizer_switch
434  settings. A NO_SEMIJOIN hint will only turn off semi-join if the variant
435  with no strategies is used. A SUBQUERY hint will turn off semi-join. If
436  there is no SEMIJOIN/SUBQUERY hint, optimizer_switch setting determines
437  whether SEMIJOIN is used.
438 
439  @param thd Pointer to THD object for session.
440  Used to access optimizer_switch
441 
442  @return true if semijoin is enabled
443  */
444  bool semijoin_enabled(THD *thd) const;
445 
446  /**
447  Returns bit mask of which semi-join strategies are enabled for this query
448  block.
449 
450  @param opt_switches Bit map of strategies enabled by optimizer_switch
451 
452  @return Bit mask of strategies that are enabled
453  */
454  uint sj_enabled_strategies(uint opt_switches) const;
455 
456  /**
457  Returns which subquery execution strategy has been specified by hints
458  for this query block.
459 
460  @retval EXEC_MATERIALIZATION Subquery Materialization should be used
461  @retval EXEC_EXISTS In-to-exists execution should be used
462  @retval EXEC_UNSPECIFIED No SUBQUERY hint for this query block
463  */
465 
466  void print_irregular_hints(const THD *thd, String *str) override;
467 
468  /**
469  Checks if join order hints are applicable and
470  applies table dependencies if possible.
471 
472  @param join JOIN object
473  */
475 
476  private:
478  join_order_hints.push_back(hint_arg);
479  }
480 };
481 
482 class PT_key_level_hint;
483 
484 /**
485  Auxiluary class for compound key objects.
486 */
488  PT_key_level_hint *pt_hint; // Pointer to PT_key_level_hint object.
489  Key_map key_map; // Indexes, specified in the hint.
490  bool resolved; // true if hint does not have unresolved index.
491 
492  public:
494  key_map.init();
495  resolved = false;
496  pt_hint = NULL;
497  }
498 
499  void set_pt_hint(PT_key_level_hint *pt_hint_arg) { pt_hint = pt_hint_arg; }
501 
502  void set_resolved(bool arg) { resolved = arg; }
503  bool is_resolved() { return resolved; }
504 
505  void set_key_map(uint i) { key_map.set_bit(i); }
506  bool is_set_key_map(uint i) { return key_map.is_set(i); }
508 };
509 
510 /**
511  Table level hints.
512 */
513 
514 class Opt_hints_table : public Opt_hints {
515  public:
519 
520  Opt_hints_table(const LEX_CSTRING *table_name_arg, Opt_hints_qb *qb_hints_arg,
521  MEM_ROOT *mem_root_arg)
522  : Opt_hints(table_name_arg, qb_hints_arg, mem_root_arg),
523  keyinfo_array(mem_root_arg) {}
524 
525  /**
526  Append table name.
527 
528  @param thd pointer to THD object
529  @param str pointer to String object
530  */
531  void append_name(const THD *thd, String *str) override {
532  append_identifier(thd, str, get_name()->str, get_name()->length);
533  get_parent()->append_name(thd, str);
534  }
535  /**
536  Function sets correlation between key hint objects and
537  appropriate KEY structures.
538 
539  @param table Pointer to TABLE_LIST object
540  */
541  void adjust_key_hints(TABLE_LIST *table);
542  virtual PT_hint *get_complex_hints(opt_hints_enum type) override;
543 
544  void set_resolved() override {
548  }
549 
550  void set_unresolved(opt_hints_enum type_arg) override {
551  if (is_specified(type_arg) && is_compound_key_hint(type_arg))
552  get_compound_key_hint(type_arg)->set_resolved(false);
553  }
554 
555  bool is_resolved(opt_hints_enum type_arg) override {
556  if (is_compound_key_hint(type_arg))
557  return Opt_hints::is_resolved(type_arg) &&
558  get_compound_key_hint(type_arg)->is_resolved();
559  return Opt_hints::is_resolved(type_arg);
560  }
561 
565  }
566 
568  if (type_arg == INDEX_MERGE_HINT_ENUM) return &index_merge;
569  if (type_arg == SKIP_SCAN_HINT_ENUM) return &skip_scan;
570  DBUG_ASSERT(0);
571  return NULL;
572  }
573 
575  return (type_arg == INDEX_MERGE_HINT_ENUM ||
576  type_arg == SKIP_SCAN_HINT_ENUM);
577  }
578 };
579 
580 /**
581  Key level hints.
582 */
583 
584 class Opt_hints_key : public Opt_hints {
585  public:
586  Opt_hints_key(const LEX_CSTRING *key_name_arg,
587  Opt_hints_table *table_hints_arg, MEM_ROOT *mem_root_arg)
588  : Opt_hints(key_name_arg, table_hints_arg, mem_root_arg) {}
589 
590  /**
591  Append key name.
592 
593  @param thd pointer to THD object
594  @param str pointer to String object
595  */
596  void append_name(const THD *thd, String *str) override {
597  get_parent()->append_name(thd, str);
598  str->append(' ');
599  append_identifier(thd, str, get_name()->str, get_name()->length);
600  }
601  /**
602  Ignore printing of the object since parent complex hint has
603  its own printing method.
604  */
605  bool ignore_print(opt_hints_enum type_arg) const override {
606  return (type_arg == INDEX_MERGE_HINT_ENUM ||
607  type_arg == SKIP_SCAN_HINT_ENUM);
608  }
609 };
610 
611 /**
612  Container for set_var object and original variable value.
613 */
614 
616  public:
617  Hint_set_var(set_var *var_arg) : var(var_arg), save_value(NULL) {}
618  set_var *var; // Pointer to set_var object
619  Item *save_value; // Original variable value
620 };
621 
622 /**
623  SET_VAR hints.
624 */
625 
627  // List of str_var variables which need to be updated.
629 
630  public:
631  Sys_var_hint(MEM_ROOT *mem_root_arg) : var_list(mem_root_arg) {}
632  /**
633  Add variable to hint list.
634 
635  @param thd pointer to THD object
636  @param sys_var pointer to sys_var object
637  @param sys_var_value variable value
638 
639  @return true if variable is added,
640  false otherwise
641  */
642  bool add_var(THD *thd, sys_var *sys_var, Item *sys_var_value);
643  /**
644  Find variable in hint list.
645 
646  @param thd Pointer to thread object
647 
648  @return true if variable is found,
649  false otherwise
650  */
651  void update_vars(THD *thd);
652  /**
653  Restore system variables with original values.
654 
655  @param thd Pointer to thread object
656  */
657  void restore_vars(THD *thd);
658  /**
659  Print applicable hints.
660 
661  @param thd Thread handle
662  @param str Pointer to string object
663  */
664  void print(const THD *thd, String *str);
665 };
666 
667 /**
668  Returns key hint value if hint is specified, returns
669  optimizer switch value if hint is not specified.
670 
671  @param thd Pointer to THD object
672  @param table Pointer to TABLE_LIST object
673  @param keyno Key number
674  @param type_arg Hint type
675  @param optimizer_switch Optimizer switch flag
676 
677  @return key hint value if hint is specified,
678  otherwise optimizer switch value.
679 */
680 bool hint_key_state(const THD *thd, const TABLE_LIST *table, uint keyno,
681  opt_hints_enum type_arg, uint optimizer_switch);
682 
683 /**
684  Returns table hint value if hint is specified, returns
685  optimizer switch value if hint is not specified.
686 
687  @param thd Pointer to THD object
688  @param table Pointer to TABLE_LIST object
689  @param type_arg Hint type
690  @param optimizer_switch Optimizer switch flag
691 
692  @return table hint value if hint is specified,
693  otherwise optimizer switch value.
694 */
695 bool hint_table_state(const THD *thd, const TABLE_LIST *table,
696  opt_hints_enum type_arg, uint optimizer_switch);
697 /**
698  Append table and query block name.
699 
700  @param thd pointer to THD object
701  @param str pointer to String object
702  @param qb_name pointer to query block name, may be null
703  @param table_name pointer to table name
704 */
705 void append_table_name(const THD *thd, String *str, const LEX_CSTRING *qb_name,
706  const LEX_CSTRING *table_name);
707 
708 /**
709  Returns true if compoubd hint state is on with or without
710  specified keys, otherwise returns false.
711  If compound hint state is on and hint is specified without indexes,
712  function returns 'true' for any 'keyno' argument. If hint specified
713  with indexes, function returns true only for appropriate 'keyno' index.
714 
715 
716  @param table Pointer to TABLE object
717  @param keyno Key number
718  @param type_arg Hint type
719 
720  @return true if compound hint state is on with or without
721  specified keys, otherwise returns false.
722 */
723 
724 bool compound_hint_key_enabled(const TABLE *table, uint keyno,
725  opt_hints_enum type_arg);
726 
727 /**
728  Returns true if index merge hint state is on otherwise returns false.
729 
730  @param table Pointer to TABLE object
731  @param use_cheapest_index_merge IN/OUT Returns true if INDEX_MERGE hint is
732  used without any specified key.
733 
734  @return true if index merge hint state is on otherwise returns false.
735 */
736 
737 bool idx_merge_hint_state(const TABLE *table, bool *use_cheapest_index_merge);
738 
739 #endif /* OPT_HINTS_INCLUDED */
Definition: opt_hints.h:63
Compound_key_hint * get_compound_key_hint(opt_hints_enum type_arg)
Definition: opt_hints.h:567
unsigned long long int ulonglong
Definition: my_inttypes.h:74
virtual bool is_resolved(opt_hints_enum type_arg)
Returns &#39;resolved&#39; flag value for depending on hint type.
Definition: opt_hints.h:236
Mem_root_array< Opt_hints_key * > keyinfo_array
Definition: opt_hints.h:516
Definition: sql_optimizer.h:177
Our own string classes, used pervasively throughout the executor.
void update_vars(THD *thd)
Find variable in hint list.
Definition: opt_hints.cc:644
void append_identifier(String *packet, const char *name, size_t length)
Convert and quote the given identifier if needed and append it to the target string.
Definition: sql_show.cc:776
bool irregular_hint
true if hint requires some special handling.
Definition: opt_hints.h:88
Opt_hints_key(const LEX_CSTRING *key_name_arg, Opt_hints_table *table_hints_arg, MEM_ROOT *mem_root_arg)
Definition: opt_hints.h:586
bool resolved
Definition: opt_hints.h:490
Definition: opt_hints.h:72
virtual void append_name(const THD *thd, String *str)=0
void check_unresolved(THD *thd)
Check if there are any unresolved hint objects and print warnings for them.
Definition: opt_hints.cc:175
void append_name(const THD *thd, String *str) override
Append key name.
Definition: opt_hints.h:596
PT_key_level_hint * pt_hint
Definition: opt_hints.h:488
void set_pt_hint(PT_key_level_hint *pt_hint_arg)
Definition: opt_hints.h:499
void set_name(const LEX_CSTRING *name_arg)
Definition: opt_hints.h:226
Opt_hints_map hints_map
Definition: opt_hints.h:171
Opt_hints_qb(Opt_hints *opt_hints_arg, MEM_ROOT *mem_root_arg, uint select_number_arg)
Definition: opt_hints.cc:195
Definition: opt_hints.h:75
bool resolved
Definition: opt_hints.h:176
Some integer typedefs for easier portability.
bool is_specified(opt_hints_enum type_arg) const
Definition: opt_hints.h:191
Bitmap< 64 > hints_specified
Definition: opt_hints.h:100
Definition: opt_hints.h:69
Parse tree hint object for MAX_EXECUTION_TIME hint.
Definition: parse_tree_hints.h:259
Key_map key_map
Definition: opt_hints.h:489
Definition: opt_hints.h:76
Definition: sql_bitmap.h:135
bool is_resolved(opt_hints_enum type_arg) override
Returns &#39;resolved&#39; flag value for depending on hint type.
Definition: opt_hints.h:555
bool is_set(uint n) const
Definition: sql_bitmap.h:167
PT_qb_level_hint * semijoin_hint
Definition: opt_hints.h:369
void append_name(const THD *thd, String *str) override
Append table name.
Definition: opt_hints.h:531
void set_resolved(bool arg)
Definition: opt_hints.h:502
Key level hints.
Definition: opt_hints.h:584
Mem_root_array< PT_qb_level_hint * > join_order_hints
Array of join order hints.
Definition: opt_hints.h:372
Definition: opt_hints.h:79
bool idx_merge_hint_state(const TABLE *table, bool *use_cheapest_index_merge)
Returns true if index merge hint state is on otherwise returns false.
Definition: opt_hints.cc:799
bool semijoin_enabled(THD *thd) const
Returns whether semi-join is enabled for this query block.
Definition: opt_hints.cc:231
PT_qb_level_hint * subquery_hint
Definition: opt_hints.h:369
uint resolved_children
Definition: opt_hints.h:178
void print_warn_unresolved(THD *thd)
Print warning for unresolved hint name.
Definition: opt_hints.cc:158
Definition: mysql_lex_string.h:39
Sergei Dialog Client Authentication NULL
Definition: dialog.cc:352
void set_compound_key_hint_map(Opt_hints *hint, uint arg)
Definition: opt_hints.h:562
Definition: opt_hints.h:74
bool is_all_resolved() const
Definition: opt_hints.h:262
enum_exec_method
The method chosen to execute the predicate, currently used for IN, =ANY and EXISTS predicates...
Definition: item_subselect.h:345
bool is_clear_all() const
Definition: sql_bitmap.h:178
std::string join(Container cont, const std::string &delim)
join elements of an container into a string seperated by a delimiter.
Definition: string.h:144
void register_child(Opt_hints *hint_arg)
Definition: opt_hints.h:266
Opt_hints(const LEX_CSTRING *name_arg, Opt_hints *parent_arg, MEM_ROOT *mem_root_arg)
Definition: opt_hints.h:181
Definition: opt_hints.h:67
Sys_var_hint * sys_var_hint
Definition: opt_hints.h:345
Definition: opt_hints.h:66
void set_bit(uint n)
Definition: sql_bitmap.h:146
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:30
virtual void set_unresolved(opt_hints_enum type_arg)
Set hint to unresolved state.
Definition: opt_hints.h:244
Using this class is fraught with peril, and you need to be very careful when doing so...
Definition: sql_string.h:159
virtual void set_resolved()
Definition: opt_hints.h:228
Definition: table.h:1294
Query block level hints.
Definition: opt_hints.h:364
virtual const LEX_CSTRING * get_name() const
Definition: opt_hints.h:225
set_var_base descendant for assignments to the system variables.
Definition: set_var.h:386
SET_VAR hints.
Definition: opt_hints.h:626
uint sj_enabled_strategies(uint opt_switches) const
Returns bit mask of which semi-join strategies are enabled for this query block.
Definition: opt_hints.cc:248
Bitmap< 64 > hints
Definition: opt_hints.h:99
Definition: opt_hints.h:83
#define DBUG_ASSERT(A)
Definition: my_dbug.h:183
opt_hints_enum
Hint types, MAX_HINT_ENUM should be always last.
Definition: opt_hints.h:62
Definition: opt_hints.h:77
A class representing one system variable - that is something that can be accessed as @global...
Definition: set_var.h:102
Auxiluary class for compound key objects.
Definition: opt_hints.h:487
Parse tree hint object for key level hints.
Definition: parse_tree_hints.h:199
void set_key_map(uint i)
Definition: opt_hints.h:505
Definition: opt_hints.h:71
virtual void print_irregular_hints(const THD *thd, String *str)
Function prints hints which are non-standard and don&#39;t fit into existing hint infrastructure.
Definition: opt_hints.h:334
void print(const THD *thd, String *str)
Print applicable hints.
Definition: opt_hints.cc:688
void print_irregular_hints(const THD *thd, String *str) override
Function prints hints which are non-standard and don&#39;t fit into existing hint infrastructure.
Definition: opt_hints.cc:271
bool append(const String &s)
Definition: sql_string.cc:449
bool switch_hint
Definition: opt_hints.h:87
PT_hint * get_complex_hints(opt_hints_enum type) override
Returns pointer to complex hint for a given type.
Definition: opt_hints.cc:208
void restore_vars(THD *thd)
Restore system variables with original values.
Definition: opt_hints.cc:662
Compound_key_hint index_merge
Definition: opt_hints.h:517
void print(const THD *thd, String *str, enum_query_type query_type)
Print all hints except of QB_NAME hint.
Definition: opt_hints.cc:126
bool switch_on(opt_hints_enum type_arg) const
Get switch value.
Definition: opt_hints.h:132
void append_name(const THD *, String *) override
Definition: opt_hints.h:353
virtual PT_hint * get_complex_hints(opt_hints_enum type)
Returns pointer to complex hint for a given type.
Definition: opt_hints.h:278
void clear_bit(uint n)
Definition: sql_bitmap.h:150
Mem_root_array< Opt_hints * > child_array
Definition: opt_hints.h:174
void set_switch(opt_hints_enum type_arg, bool switch_state_arg)
Set switch value and set hint into specified state.
Definition: opt_hints.h:118
Opt_hints_map contains information about hint state(specified or not, hint value).
Definition: opt_hints.h:98
Compound_key_hint skip_scan
Definition: opt_hints.h:518
bool hint_key_state(const THD *thd, const TABLE_LIST *table, uint keyno, opt_hints_enum type_arg, uint optimizer_switch)
Returns key hint value if hint is specified, returns optimizer switch value if hint is not specified...
Definition: opt_hints.cc:740
Parse tree hint object for query block level hints.
Definition: parse_tree_hints.h:116
void set_resolved() override
Definition: opt_hints.h:544
Hint_set_var(set_var *var_arg)
Definition: opt_hints.h:617
Header for compiler-dependent features.
bool set_switch(bool switch_state_arg, opt_hints_enum type_arg, bool check_parent)
Function sets switch hint state.
Definition: opt_hints.h:205
bool is_specified(opt_hints_enum type_arg) const
Check if hint is specified.
Definition: opt_hints.h:109
Definition: item.h:666
bool is_key_map_clear_all()
Definition: opt_hints.h:507
unsigned int uint
Definition: uca-dump.cc:29
uint select_number
Definition: opt_hints.h:365
The class is a base class for representation of the different types of the hints. ...
Definition: parse_tree_hints.h:57
size_t size() const
Definition: mem_root_array.h:378
void append_qb_hint(const THD *thd, String *str)
Append query block hint.
Definition: opt_hints.h:397
Sys_var_hint(MEM_ROOT *mem_root_arg)
Definition: opt_hints.h:631
Opt_hints class is used as ancestor for Opt_hints_global, Opt_hints_qb, Opt_hints_table, Opt_hints_key classes.
Definition: opt_hints.h:154
Definition: m_ctype.h:359
bool ignore_print(opt_hints_enum type_arg) const override
Ignore printing of the object since parent complex hint has its own printing method.
Definition: opt_hints.h:605
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:397
void append_name(const THD *thd, String *str) override
Append query block name.
Definition: opt_hints.h:410
bool add_var(THD *thd, sys_var *sys_var, Item *sys_var_value)
Add variable to hint list.
Definition: opt_hints.cc:617
Mem_root_array< Opt_hints * > * child_array_ptr()
Definition: opt_hints.h:260
void init()
Definition: sql_bitmap.h:143
Global level hints.
Definition: opt_hints.h:342
const LEX_CSTRING * get_print_name()
Definition: opt_hints.h:386
Item * save_value
Definition: opt_hints.h:619
void adjust_key_hints(TABLE_LIST *table)
Function sets correlation between key hint objects and appropriate KEY structures.
Definition: opt_hints.cc:530
bool is_set_key_map(uint i)
Definition: opt_hints.h:506
Opt_hints * parent
Definition: opt_hints.h:169
Definition: opt_hints.h:73
set_var * var
Definition: opt_hints.h:618
int type
Definition: http_common.h:411
Definition: opt_hints.h:78
Compound_key_hint()
Definition: opt_hints.h:493
Opt_hints_table(const LEX_CSTRING *table_name_arg, Opt_hints_qb *qb_hints_arg, MEM_ROOT *mem_root_arg)
Definition: opt_hints.h:520
bool push_back(const Element_type &element)
Adds a new element at the end of the array, after its current last element.
Definition: mem_root_array.h:188
bool check_upper_lvl
Definition: opt_hints.h:85
void set_unresolved(opt_hints_enum type_arg) override
Set hint to unresolved state.
Definition: opt_hints.h:550
void incr_resolved_children()
Definition: opt_hints.h:259
Opt_hints * get_parent() const
Definition: opt_hints.h:227
bool hint_table_state(const THD *thd, const TABLE_LIST *table, opt_hints_enum type_arg, uint optimizer_switch)
Returns table hint value if hint is specified, returns optimizer switch value if hint is not specifie...
Definition: opt_hints.cc:757
virtual PT_hint * get_complex_hints(opt_hints_enum type) override
Returns pointer to complex hint for a given type.
Definition: opt_hints.cc:573
Container for set_var object and original variable value.
Definition: opt_hints.h:615
Table level hints.
Definition: opt_hints.h:514
virtual bool ignore_print(opt_hints_enum type_arg) const
If ignore_print() returns true, hint is not printed in Opt_hints::print() function.
Definition: opt_hints.h:255
LEX_CSTRING sys_name
Definition: opt_hints.h:366
PT_hint_max_execution_time * max_exec_time
Definition: opt_hints.h:344
const LEX_CSTRING * name
Definition: opt_hints.h:162
bool compound_hint_key_enabled(const TABLE *table, uint keyno, opt_hints_enum type_arg)
Returns true if compoubd hint state is on with or without specified keys, otherwise returns false...
Definition: opt_hints.cc:781
A better implementation of the UNIX ctype(3) library.
void register_join_order_hint(PT_qb_level_hint *hint_arg)
Definition: opt_hints.h:477
const char * hint_name
Definition: opt_hints.h:84
char buff[32]
Definition: opt_hints.h:367
void apply_join_order_hints(JOIN *join)
Checks if join order hints are applicable and applies table dependencies if possible.
Definition: opt_hints.cc:520
void print_irregular_hints(const THD *thd, String *str) override
Function prints hints which are non-standard and don&#39;t fit into existing hint infrastructure.
Definition: opt_hints.cc:191
bool is_resolved()
Definition: opt_hints.h:503
PT_key_level_hint * get_pt_hint()
Definition: opt_hints.h:500
void append_hint_type(String *str, opt_hints_enum type)
Append hint type.
Definition: opt_hints.cc:152
Opt_hints_table * adjust_table_hints(TABLE_LIST *table)
Function finds Opt_hints_table object corresponding to table alias in the query block and attaches co...
Definition: opt_hints.cc:217
ulonglong join_order_hints_ignored
Bit map of which hints are ignored.
Definition: opt_hints.h:374
Opt_hints * find_by_name(const LEX_CSTRING *name_arg, const CHARSET_INFO *cs) const
Find hint among lower-level hint objects.
Definition: opt_hints.cc:117
Opt_hints_global(MEM_ROOT *mem_root_arg)
Definition: opt_hints.h:347
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:77
bool get_switch(opt_hints_enum type_arg) const
Function returns switch hint state.
Definition: opt_hints.cc:108
Definition: table.h:2442
Definition: opt_hints.h:65
Definition: opt_hints.h:64
Item_exists_subselect::enum_exec_method subquery_strategy() const
Returns which subquery execution strategy has been specified by hints for this query block...
Definition: opt_hints.cc:262
Definition: opt_hints.h:70
#define false
Definition: config_static.h:43
PT_hint * get_complex_hints(opt_hints_enum type) override
Returns pointer to complex hint for a given type.
Definition: opt_hints.cc:184
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
Definition: opt_hints.h:80
Definition: opt_hints.h:68
void append_table_name(const THD *thd, String *str, const LEX_CSTRING *qb_name, const LEX_CSTRING *table_name)
Append table and query block name.
Definition: opt_hints.cc:769
Mem_root_array< Hint_set_var * > var_list
Definition: opt_hints.h:628
#define STRING_WITH_LEN(X)
Definition: m_string.h:315
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:777
bool is_compound_key_hint(opt_hints_enum type_arg)
Definition: opt_hints.h:574
const char * table_name
Definition: rules_table_service.cc:55
virtual ~Opt_hints()
Definition: opt_hints.h:189