28#ifndef OPT_HINTS_INCLUDED
29#define OPT_HINTS_INCLUDED
127 if (switch_state_arg)
392 uint select_number_arg);
561 :
Opt_hints(table_name_arg, qb_hints_arg, mem_root_arg),
632 Key_map *available_keys_to_use,
645 :
Opt_hints(key_name_arg, table_hints_arg, mem_root_arg) {}
699 Item *sys_var_value);
793 bool *use_cheapest_index_merge);
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:1462
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
Definition: sql_bitmap.h:154
bool is_set(uint n) const
Definition: sql_bitmap.h:186
void set_bit(uint n)
Definition: sql_bitmap.h:165
bool is_clear_all() const
Definition: sql_bitmap.h:197
void init()
Definition: sql_bitmap.h:162
void clear_bit(uint n)
Definition: sql_bitmap.h:169
Auxiliary class for compound key objects.
Definition: opt_hints.h:495
void set_key_map(uint i)
Definition: opt_hints.h:515
PT_key_level_hint * pt_hint
Definition: opt_hints.h:496
void set_pt_hint(PT_key_level_hint *pt_hint_arg)
Definition: opt_hints.h:509
Key_map key_map
Definition: opt_hints.h:497
virtual ~Compound_key_hint()=default
void set_resolved(bool arg)
Definition: opt_hints.h:512
Compound_key_hint()
Definition: opt_hints.h:501
bool resolved
Definition: opt_hints.h:498
bool is_resolved()
Definition: opt_hints.h:513
bool is_set_key_map(uint i)
Definition: opt_hints.h:516
Key_map * get_key_map()
Definition: opt_hints.h:518
bool is_key_map_clear_all()
Definition: opt_hints.h:517
virtual bool is_hint_conflicting(Opt_hints_table *table_hint, Opt_hints_key *key_hint)
Definition: opt_hints.h:519
PT_key_level_hint * get_pt_hint()
Definition: opt_hints.h:510
Auxiliary class for INDEX hint.
Definition: opt_hints.h:537
bool is_hint_conflicting(Opt_hints_table *table_hint, Opt_hints_key *key_hint) override
Function checks if INDEX hint is conflicting with already specified JOIN_INDEX, GROUP_INDEX,...
Definition: opt_hints.cc:695
Container for set_var object and original variable value.
Definition: opt_hints.h:671
Item * save_value
Definition: opt_hints.h:675
Hint_set_var(set_var *var_arg)
Definition: opt_hints.h:673
set_var * var
Definition: opt_hints.h:674
Auxiliary class for JOIN_INDEX, GROUP_INDEX, ORDER_INDEX hints.
Definition: opt_hints.h:528
bool is_hint_conflicting(Opt_hints_table *table_hint, Opt_hints_key *key_hint) override
Function checks if JOIN_INDEX|GROUP_INDEX|ORDER_INDEX hint is conflicting with already specified INDE...
Definition: opt_hints.cc:712
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:936
Definition: sql_optimizer.h:133
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:426
Global level hints.
Definition: opt_hints.h:350
void append_name(const THD *, String *) override
Definition: opt_hints.h:361
PT_hint * get_complex_hints(opt_hints_enum type) override
Returns pointer to complex hint for a given type.
Definition: opt_hints.cc:192
Opt_hints_global(MEM_ROOT *mem_root_arg)
Definition: opt_hints.h:355
Sys_var_hint * sys_var_hint
Definition: opt_hints.h:353
void print_irregular_hints(const THD *thd, String *str) override
Function prints hints which are non-standard and don't fit into existing hint infrastructure.
Definition: opt_hints.cc:199
PT_hint_max_execution_time * max_exec_time
Definition: opt_hints.h:352
Key level hints.
Definition: opt_hints.h:641
void append_name(const THD *thd, String *str) override
Append key name.
Definition: opt_hints.h:653
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:662
Opt_hints_key(const LEX_CSTRING *key_name_arg, Opt_hints_table *table_hints_arg, MEM_ROOT *mem_root_arg)
Definition: opt_hints.h:643
Opt_hints_map contains information about hint state(specified or not, hint value).
Definition: opt_hints.h:106
bool switch_on(opt_hints_enum type_arg) const
Get switch value.
Definition: opt_hints.h:140
bool is_specified(opt_hints_enum type_arg) const
Check if hint is specified.
Definition: opt_hints.h:117
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:126
Bitmap< 64 > hints_specified
Definition: opt_hints.h:108
Bitmap< 64 > hints
Definition: opt_hints.h:107
Query block level hints.
Definition: opt_hints.h:372
void print_irregular_hints(const THD *thd, String *str) override
Function prints hints which are non-standard and don't fit into existing hint infrastructure.
Definition: opt_hints.cc:277
void register_join_order_hint(PT_qb_level_hint *hint_arg)
Definition: opt_hints.h:485
Opt_hints_table * adjust_table_hints(Table_ref *table)
Function finds Opt_hints_table object corresponding to table alias in the query block and attaches co...
Definition: opt_hints.cc:225
PT_qb_level_hint * semijoin_hint
Definition: opt_hints.h:377
uint select_number
Definition: opt_hints.h:373
Subquery_strategy subquery_strategy() const
Returns which subquery execution strategy has been specified by hints for this query block.
Definition: opt_hints.cc:270
ulonglong join_order_hints_ignored
Bit map of which hints are ignored.
Definition: opt_hints.h:382
void apply_join_order_hints(JOIN *join)
Checks if join order hints are applicable and applies table dependencies if possible.
Definition: opt_hints.cc:519
PT_qb_level_hint * subquery_hint
Definition: opt_hints.h:377
Opt_hints_qb(Opt_hints *opt_hints_arg, MEM_ROOT *mem_root_arg, uint select_number_arg)
Definition: opt_hints.cc:203
LEX_CSTRING sys_name
Definition: opt_hints.h:374
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:256
void append_name(const THD *thd, String *str) override
Append query block name.
Definition: opt_hints.h:418
PT_hint * get_complex_hints(opt_hints_enum type) override
Returns pointer to complex hint for a given type.
Definition: opt_hints.cc:216
char buff[32]
Definition: opt_hints.h:375
bool semijoin_enabled(const THD *thd) const
Returns whether semi-join is enabled for this query block.
Definition: opt_hints.cc:239
const LEX_CSTRING * get_print_name() override
Definition: opt_hints.h:394
void append_qb_hint(const THD *thd, String *str)
Append query block hint.
Definition: opt_hints.h:405
Mem_root_array< PT_qb_level_hint * > join_order_hints
Array of join order hints.
Definition: opt_hints.h:380
Table level hints.
Definition: opt_hints.h:549
Compound_key_hint skip_scan
Definition: opt_hints.h:553
Index_key_hint group_index
Definition: opt_hints.h:556
void set_resolved() override
Definition: opt_hints.h:583
Index_key_hint join_index
Definition: opt_hints.h:555
bool is_hint_conflicting(Opt_hints_key *key_hint, opt_hints_enum type)
Definition: opt_hints.cc:585
void append_name(const THD *thd, String *str) override
Append table name.
Definition: opt_hints.h:570
Glob_index_key_hint index
Definition: opt_hints.h:554
void update_index_hint_map(Key_map *keys_to_use, Key_map *available_keys_to_use, opt_hints_enum type_arg)
Function updates key_to_use key map depending on index hint state.
Definition: opt_hints.cc:599
bool is_resolved(opt_hints_enum type_arg) override
Returns 'resolved' flag value for depending on hint type.
Definition: opt_hints.h:598
void set_unresolved(opt_hints_enum type_arg) override
Set hint to unresolved state.
Definition: opt_hints.h:593
bool update_index_hint_maps(THD *thd, TABLE *tbl)
Function updates keys_in_use_for_query, keys_in_use_for_group_by, keys_in_use_for_order_by depending ...
Definition: opt_hints.cc:641
Compound_key_hint * get_compound_key_hint(opt_hints_enum type_arg)
Definition: opt_hints.h:614
void set_compound_key_hint_map(Opt_hints *hint, uint arg)
Definition: opt_hints.h:605
Mem_root_array< Opt_hints_key * > keyinfo_array
Definition: opt_hints.h:551
Opt_hints_table(const LEX_CSTRING *table_name_arg, Opt_hints_qb *qb_hints_arg, MEM_ROOT *mem_root_arg)
Definition: opt_hints.h:559
void adjust_key_hints(Table_ref *table)
Function sets correlation between key hint objects and appropriate KEY structures.
Definition: opt_hints.cc:529
PT_hint * get_complex_hints(opt_hints_enum type) override
Returns pointer to complex hint for a given type.
Definition: opt_hints.cc:580
Compound_key_hint index_merge
Definition: opt_hints.h:552
bool is_force_index_hint(opt_hints_enum type_arg)
Definition: opt_hints.h:625
Index_key_hint order_index
Definition: opt_hints.h:557
Opt_hints class is used as ancestor for Opt_hints_global, Opt_hints_qb, Opt_hints_table,...
Definition: opt_hints.h:162
bool get_switch(opt_hints_enum type_arg) const
Function returns switch hint state.
Definition: opt_hints.cc:116
virtual ~Opt_hints()=default
void append_hint_type(String *str, opt_hints_enum type)
Append hint type.
Definition: opt_hints.cc:160
Mem_root_array< Opt_hints * > * child_array_ptr()
Definition: opt_hints.h:269
Opt_hints_map hints_map
Definition: opt_hints.h:179
bool is_all_resolved() const
Definition: opt_hints.h:271
virtual void set_resolved()
Definition: opt_hints.h:237
virtual void append_name(const THD *thd, String *str)=0
virtual void set_unresolved(opt_hints_enum type_arg)
Set hint to unresolved state.
Definition: opt_hints.h:253
virtual const LEX_CSTRING * get_name() const
Definition: opt_hints.h:233
virtual bool is_resolved(opt_hints_enum type_arg)
Returns 'resolved' flag value for depending on hint type.
Definition: opt_hints.h:245
Opt_hints(const LEX_CSTRING *name_arg, Opt_hints *parent_arg, MEM_ROOT *mem_root_arg)
Definition: opt_hints.h:189
bool resolved
Definition: opt_hints.h:184
virtual const LEX_CSTRING * get_print_name()
Definition: opt_hints.h:234
virtual PT_hint * get_complex_hints(opt_hints_enum type)
Returns pointer to complex hint for a given type.
Definition: opt_hints.h:287
void print(const THD *thd, String *str, enum_query_type query_type)
Print all hints except of QB_NAME hint.
Definition: opt_hints.cc:134
void incr_resolved_children()
Definition: opt_hints.h:268
Opt_hints * parent
Definition: opt_hints.h:177
bool set_switch(bool switch_state_arg, opt_hints_enum type_arg, bool check_parent)
Function sets switch hint state.
Definition: opt_hints.h:213
void register_child(Opt_hints *hint_arg)
Definition: opt_hints.h:275
uint resolved_children
Definition: opt_hints.h:186
void print_warn_unresolved(THD *thd)
Print warning for unresolved hint name.
Definition: opt_hints.cc:166
const LEX_CSTRING * name
Definition: opt_hints.h:170
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:125
virtual void print_irregular_hints(const THD *thd, String *str)
Function prints hints which are non-standard and don't fit into existing hint infrastructure.
Definition: opt_hints.h:342
bool is_specified(opt_hints_enum type_arg) const
Definition: opt_hints.h:199
void check_unresolved(THD *thd)
Check if there are any unresolved hint objects and print warnings for them.
Definition: opt_hints.cc:183
Mem_root_array< Opt_hints * > child_array
Definition: opt_hints.h:182
void set_name(const LEX_CSTRING *name_arg)
Definition: opt_hints.h:235
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:265
Opt_hints * get_parent() const
Definition: opt_hints.h:236
Parse tree hint object for MAX_EXECUTION_TIME hint.
Definition: parse_tree_hints.h:270
The class is a base class for representation of the different types of the hints.
Definition: parse_tree_hints.h:58
Parse tree hint object for key level hints.
Definition: parse_tree_hints.h:210
Parse tree hint object for query block level hints.
Definition: parse_tree_hints.h:127
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
SET_VAR hints.
Definition: opt_hints.h:682
Mem_root_array< Hint_set_var * > var_list
Definition: opt_hints.h:684
bool add_var(THD *thd, const System_variable_tracker &var_tracker, Item *sys_var_value)
Add variable to hint list.
Definition: opt_hints.cc:756
void restore_vars(THD *thd)
Restore system variables with original values.
Definition: opt_hints.cc:812
void print(const THD *thd, String *str)
Print applicable hints.
Definition: opt_hints.cc:838
void update_vars(THD *thd)
Find variable in hint list.
Definition: opt_hints.cc:789
Sys_var_hint(MEM_ROOT *mem_root_arg)
Definition: opt_hints.h:687
Wrapper interface for all kinds of system variables.
Definition: set_var.h:575
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
set_var_base descendant for assignments to the system variables.
Definition: set_var.h:978
A class representing one system variable - that is something that can be accessed as @global....
Definition: set_var.h:106
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:31
Subquery_strategy
Classes that represent predicates over table subqueries: [NOT] EXISTS, [NOT] IN, ANY/SOME and ALL.
Definition: item_subselect.h:406
A better implementation of the UNIX ctype(3) library.
Header for compiler-dependent features.
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1081
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Definition: commit_order_queue.h:34
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:76
std::string join(Container cont, const std::string &delim)
join elements of an container into a string separated by a delimiter.
Definition: string.h:151
const char * table_name
Definition: rules_table_service.cc:56
bool is_compound_hint(opt_hints_enum type_arg)
Definition: opt_hints.cc:573
bool hint_table_state(const THD *thd, const Table_ref *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:908
bool compound_hint_key_enabled(const TABLE *table, uint keyno, opt_hints_enum type_arg)
Returns true if compound hint state is on with or without specified keys, otherwise returns false.
Definition: opt_hints.cc:932
bool idx_merge_hint_state(THD *thd, const TABLE *table, bool *use_cheapest_index_merge)
Returns true if index merge hint state is on otherwise returns false.
Definition: opt_hints.cc:950
opt_hints_enum
Hint types, MAX_HINT_ENUM should be always last.
Definition: opt_hints.h:64
@ JOIN_PREFIX_HINT_ENUM
Definition: opt_hints.h:75
@ INDEX_MERGE_HINT_ENUM
Definition: opt_hints.h:79
@ DERIVED_MERGE_HINT_ENUM
Definition: opt_hints.h:74
@ MAX_HINT_ENUM
Definition: opt_hints.h:88
@ BNL_HINT_ENUM
Definition: opt_hints.h:66
@ ORDER_INDEX_HINT_ENUM
Definition: opt_hints.h:86
@ JOIN_SUFFIX_HINT_ENUM
Definition: opt_hints.h:76
@ DERIVED_CONDITION_PUSHDOWN_HINT_ENUM
Definition: opt_hints.h:87
@ RESOURCE_GROUP_HINT_ENUM
Definition: opt_hints.h:80
@ GROUP_INDEX_HINT_ENUM
Definition: opt_hints.h:85
@ JOIN_ORDER_HINT_ENUM
Definition: opt_hints.h:77
@ SUBQUERY_HINT_ENUM
Definition: opt_hints.h:73
@ SKIP_SCAN_HINT_ENUM
Definition: opt_hints.h:81
@ QB_NAME_HINT_ENUM
Definition: opt_hints.h:71
@ ICP_HINT_ENUM
Definition: opt_hints.h:67
@ JOIN_INDEX_HINT_ENUM
Definition: opt_hints.h:84
@ MAX_EXEC_TIME_HINT_ENUM
Definition: opt_hints.h:70
@ HASH_JOIN_HINT_ENUM
Definition: opt_hints.h:82
@ MRR_HINT_ENUM
Definition: opt_hints.h:68
@ JOIN_FIXED_ORDER_HINT_ENUM
Definition: opt_hints.h:78
@ INDEX_HINT_ENUM
Definition: opt_hints.h:83
@ BKA_HINT_ENUM
Definition: opt_hints.h:65
@ NO_RANGE_HINT_ENUM
Definition: opt_hints.h:69
@ SEMIJOIN_HINT_ENUM
Definition: opt_hints.h:72
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:920
bool hint_key_state(const THD *thd, const Table_ref *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:891
int cmp_lex_string(const LEX_CSTRING &s, const LEX_CSTRING &t, const CHARSET_INFO *cs)
Definition: opt_hints.cc:110
required string type
Definition: replication_group_member_actions.proto:34
Our own string classes, used pervasively throughout the executor.
#define STRING_WITH_LEN(X)
Definition: string_with_len.h:29
Definition: m_ctype.h:423
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
Definition: mysql_lex_string.h:40
Definition: opt_hints.h:91
bool switch_hint
Definition: opt_hints.h:95
bool irregular_hint
true if hint requires some special handling.
Definition: opt_hints.h:96
bool check_upper_lvl
Definition: opt_hints.h:93
const char * hint_name
Definition: opt_hints.h:92