28#ifndef OPT_HINTS_INCLUDED
29#define OPT_HINTS_INCLUDED
128 if (switch_state_arg)
393 uint select_number_arg);
478 bool toplevel =
false);
574 :
Opt_hints(table_name_arg, qb_hints_arg, mem_root_arg),
645 Key_map *available_keys_to_use,
658 :
Opt_hints(key_name_arg, table_hints_arg, mem_root_arg) {}
712 Item *sys_var_value);
806 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:508
void set_key_map(uint i)
Definition: opt_hints.h:528
PT_key_level_hint * pt_hint
Definition: opt_hints.h:509
void set_pt_hint(PT_key_level_hint *pt_hint_arg)
Definition: opt_hints.h:522
Key_map key_map
Definition: opt_hints.h:510
virtual ~Compound_key_hint()=default
void set_resolved(bool arg)
Definition: opt_hints.h:525
Compound_key_hint()
Definition: opt_hints.h:514
bool resolved
Definition: opt_hints.h:511
bool is_resolved()
Definition: opt_hints.h:526
bool is_set_key_map(uint i)
Definition: opt_hints.h:529
Key_map * get_key_map()
Definition: opt_hints.h:531
bool is_key_map_clear_all()
Definition: opt_hints.h:530
virtual bool is_hint_conflicting(Opt_hints_table *table_hint, Opt_hints_key *key_hint)
Definition: opt_hints.h:532
PT_key_level_hint * get_pt_hint()
Definition: opt_hints.h:523
Auxiliary class for INDEX hint.
Definition: opt_hints.h:550
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:1237
Container for set_var object and original variable value.
Definition: opt_hints.h:684
Item * save_value
Definition: opt_hints.h:688
Hint_set_var(set_var *var_arg)
Definition: opt_hints.h:686
set_var * var
Definition: opt_hints.h:687
Auxiliary class for JOIN_INDEX, GROUP_INDEX, ORDER_INDEX hints.
Definition: opt_hints.h:541
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:1254
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:930
Definition: sql_optimizer.h:133
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:426
Global level hints.
Definition: opt_hints.h:351
void append_name(const THD *, String *) override
Definition: opt_hints.h:362
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:356
Sys_var_hint * sys_var_hint
Definition: opt_hints.h:354
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:353
Key level hints.
Definition: opt_hints.h:654
void append_name(const THD *thd, String *str) override
Append key name.
Definition: opt_hints.h:666
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:675
Opt_hints_key(const LEX_CSTRING *key_name_arg, Opt_hints_table *table_hints_arg, MEM_ROOT *mem_root_arg)
Definition: opt_hints.h:656
Opt_hints_map contains information about hint state(specified or not, hint value).
Definition: opt_hints.h:107
bool switch_on(opt_hints_enum type_arg) const
Get switch value.
Definition: opt_hints.h:141
bool is_specified(opt_hints_enum type_arg) const
Check if hint is specified.
Definition: opt_hints.h:118
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:127
Bitmap< 64 > hints_specified
Definition: opt_hints.h:109
Bitmap< 64 > hints
Definition: opt_hints.h:108
Query block level hints.
Definition: opt_hints.h:373
bool has_join_order_hints() const
Checks if any join order hints have been specified in query.
Definition: opt_hints.cc:524
bool check_join_order_hints(RelationalExpression *left, RelationalExpression *right, const mem_root_deque< Table_ref * > *join_list)
Checks if a combination of left and right RelationalExpressions satisfy one or more join order hints.
Definition: opt_hints.cc:894
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:498
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:378
uint select_number
Definition: opt_hints.h:374
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:383
void clear_join_order_hints()
Deletes all the join order hints.
Definition: opt_hints.cc:531
void apply_join_order_hints(JOIN *join)
Checks if join order hints are applicable and applies table dependencies if possible.
Definition: opt_hints.cc:1061
PT_qb_level_hint * subquery_hint
Definition: opt_hints.h:378
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:375
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:419
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:376
bool semijoin_enabled(const THD *thd) const
Returns whether semi-join is enabled for this query block.
Definition: opt_hints.cc:239
const mem_root_deque< Table_ref * > * sort_tables_in_join_order(THD *thd, const mem_root_deque< Table_ref * > &join_list, bool toplevel=false)
Sorts tables from the join list to create a new join list which contains the tables in an order which...
Definition: opt_hints.cc:627
const LEX_CSTRING * get_print_name() override
Definition: opt_hints.h:395
void append_qb_hint(const THD *thd, String *str)
Append query block hint.
Definition: opt_hints.h:406
bool hinted_join_order(PT_qb_level_hint *hint, RelationalExpression *left, RelationalExpression *right, const mem_root_deque< Table_ref * > *join_list)
Checks if a combination of left and right RelationalExpressions satisfy a hint.
Definition: opt_hints.cc:921
Mem_root_array< PT_qb_level_hint * > join_order_hints
Array of join order hints.
Definition: opt_hints.h:381
Table level hints.
Definition: opt_hints.h:562
Compound_key_hint skip_scan
Definition: opt_hints.h:566
Index_key_hint group_index
Definition: opt_hints.h:569
void set_resolved() override
Definition: opt_hints.h:596
Index_key_hint join_index
Definition: opt_hints.h:568
bool is_hint_conflicting(Opt_hints_key *key_hint, opt_hints_enum type)
Definition: opt_hints.cc:1127
void append_name(const THD *thd, String *str) override
Append table name.
Definition: opt_hints.h:583
Glob_index_key_hint index
Definition: opt_hints.h:567
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:1141
bool is_resolved(opt_hints_enum type_arg) override
Returns 'resolved' flag value for depending on hint type.
Definition: opt_hints.h:611
void set_unresolved(opt_hints_enum type_arg) override
Set hint to unresolved state.
Definition: opt_hints.h:606
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:1183
Compound_key_hint * get_compound_key_hint(opt_hints_enum type_arg)
Definition: opt_hints.h:627
void set_compound_key_hint_map(Opt_hints *hint, uint arg)
Definition: opt_hints.h:618
Mem_root_array< Opt_hints_key * > keyinfo_array
Definition: opt_hints.h:564
Opt_hints_table(const LEX_CSTRING *table_name_arg, Opt_hints_qb *qb_hints_arg, MEM_ROOT *mem_root_arg)
Definition: opt_hints.h:572
void adjust_key_hints(Table_ref *table)
Function sets correlation between key hint objects and appropriate KEY structures.
Definition: opt_hints.cc:1071
PT_hint * get_complex_hints(opt_hints_enum type) override
Returns pointer to complex hint for a given type.
Definition: opt_hints.cc:1122
Compound_key_hint index_merge
Definition: opt_hints.h:565
bool is_force_index_hint(opt_hints_enum type_arg)
Definition: opt_hints.h:638
Index_key_hint order_index
Definition: opt_hints.h:570
Opt_hints class is used as ancestor for Opt_hints_global, Opt_hints_qb, Opt_hints_table,...
Definition: opt_hints.h:163
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:270
Opt_hints_map hints_map
Definition: opt_hints.h:180
bool is_all_resolved() const
Definition: opt_hints.h:272
virtual void set_resolved()
Definition: opt_hints.h:238
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:254
virtual const LEX_CSTRING * get_name() const
Definition: opt_hints.h:234
virtual bool is_resolved(opt_hints_enum type_arg)
Returns 'resolved' flag value for depending on hint type.
Definition: opt_hints.h:246
Opt_hints(const LEX_CSTRING *name_arg, Opt_hints *parent_arg, MEM_ROOT *mem_root_arg)
Definition: opt_hints.h:190
bool resolved
Definition: opt_hints.h:185
virtual const LEX_CSTRING * get_print_name()
Definition: opt_hints.h:235
virtual PT_hint * get_complex_hints(opt_hints_enum type)
Returns pointer to complex hint for a given type.
Definition: opt_hints.h:288
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:269
Opt_hints * parent
Definition: opt_hints.h:178
bool set_switch(bool switch_state_arg, opt_hints_enum type_arg, bool check_parent)
Function sets switch hint state.
Definition: opt_hints.h:214
void register_child(Opt_hints *hint_arg)
Definition: opt_hints.h:276
uint resolved_children
Definition: opt_hints.h:187
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:171
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:343
bool is_specified(opt_hints_enum type_arg) const
Definition: opt_hints.h:200
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:183
void set_name(const LEX_CSTRING *name_arg)
Definition: opt_hints.h:236
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:266
Opt_hints * get_parent() const
Definition: opt_hints.h:237
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:695
Mem_root_array< Hint_set_var * > var_list
Definition: opt_hints.h:697
bool add_var(THD *thd, const System_variable_tracker &var_tracker, Item *sys_var_value)
Add variable to hint list.
Definition: opt_hints.cc:1298
void restore_vars(THD *thd)
Restore system variables with original values.
Definition: opt_hints.cc:1354
void print(const THD *thd, String *str)
Print applicable hints.
Definition: opt_hints.cc:1380
void update_vars(THD *thd)
Find variable in hint list.
Definition: opt_hints.cc:1331
Sys_var_hint(MEM_ROOT *mem_root_arg)
Definition: opt_hints.h:700
Wrapper interface for all kinds of system variables.
Definition: set_var.h:580
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:111
set_var_base descendant for assignments to the system variables.
Definition: set_var.h:983
A class representing one system variable - that is something that can be accessed as @global....
Definition: set_var.h:107
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:426
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:1105
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(const detail::range auto &rng, std::string_view delim)
join elements of a range into a string separated by a delimiter.
Definition: string.h:74
const char * table_name
Definition: rules_table_service.cc:56
bool is_compound_hint(opt_hints_enum type_arg)
Definition: opt_hints.cc:1115
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:1450
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:1474
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:1492
opt_hints_enum
Hint types, MAX_HINT_ENUM should be always last.
Definition: opt_hints.h:65
@ JOIN_PREFIX_HINT_ENUM
Definition: opt_hints.h:76
@ INDEX_MERGE_HINT_ENUM
Definition: opt_hints.h:80
@ DERIVED_MERGE_HINT_ENUM
Definition: opt_hints.h:75
@ MAX_HINT_ENUM
Definition: opt_hints.h:89
@ BNL_HINT_ENUM
Definition: opt_hints.h:67
@ ORDER_INDEX_HINT_ENUM
Definition: opt_hints.h:87
@ JOIN_SUFFIX_HINT_ENUM
Definition: opt_hints.h:77
@ DERIVED_CONDITION_PUSHDOWN_HINT_ENUM
Definition: opt_hints.h:88
@ RESOURCE_GROUP_HINT_ENUM
Definition: opt_hints.h:81
@ GROUP_INDEX_HINT_ENUM
Definition: opt_hints.h:86
@ JOIN_ORDER_HINT_ENUM
Definition: opt_hints.h:78
@ SUBQUERY_HINT_ENUM
Definition: opt_hints.h:74
@ SKIP_SCAN_HINT_ENUM
Definition: opt_hints.h:82
@ QB_NAME_HINT_ENUM
Definition: opt_hints.h:72
@ ICP_HINT_ENUM
Definition: opt_hints.h:68
@ JOIN_INDEX_HINT_ENUM
Definition: opt_hints.h:85
@ MAX_EXEC_TIME_HINT_ENUM
Definition: opt_hints.h:71
@ HASH_JOIN_HINT_ENUM
Definition: opt_hints.h:83
@ MRR_HINT_ENUM
Definition: opt_hints.h:69
@ JOIN_FIXED_ORDER_HINT_ENUM
Definition: opt_hints.h:79
@ INDEX_HINT_ENUM
Definition: opt_hints.h:84
@ BKA_HINT_ENUM
Definition: opt_hints.h:66
@ NO_RANGE_HINT_ENUM
Definition: opt_hints.h:70
@ SEMIJOIN_HINT_ENUM
Definition: opt_hints.h:73
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:1462
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:1433
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:421
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
Represents an expression tree in the relational algebra of joins.
Definition: relational_expression.h:147
Definition: opt_hints.h:92
bool switch_hint
Definition: opt_hints.h:96
bool irregular_hint
true if hint requires some special handling.
Definition: opt_hints.h:97
bool check_upper_lvl
Definition: opt_hints.h:94
const char * hint_name
Definition: opt_hints.h:93