MySQL 8.0.40
Source Code Documentation
|
#include "sql/opt_hints.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include "m_ctype.h"
#include "my_table_map.h"
#include "mysql/udf_registration_types.h"
#include "mysqld_error.h"
#include "sql/derror.h"
#include "sql/error_handler.h"
#include "sql/item.h"
#include "sql/item_subselect.h"
#include "sql/key.h"
#include "sql/mysqld.h"
#include "sql/nested_join.h"
#include "sql/parse_tree_hints.h"
#include "sql/set_var.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "sql/sql_error.h"
#include "sql/sql_optimizer.h"
#include "sql/sql_select.h"
#include "sql/table.h"
Classes | |
class | Join_order_hint_handler |
Auxiliary class is used to save/restore table dependencies. More... | |
Functions | |
int | cmp_lex_string (const LEX_CSTRING &s, const LEX_CSTRING &t, const CHARSET_INFO *cs) |
static void | print_join_order_warn (THD *thd, opt_hints_enum type, const Hint_param_table *hint_table) |
Print warning about unresolved table for join order hints. More... | |
static bool | compare_table_name (const Hint_param_table *hint_table, const Table_ref *table) |
Function compares hint table name and Table_ref table name. More... | |
static table_map | get_other_dep (opt_hints_enum type, table_map hint_tab_map, table_map table_map) |
Function returns dependencies used for updating table dependencies depending on hint type. More... | |
static void | update_nested_join_deps (JOIN *join, const JOIN_TAB *hint_tab, table_map hint_tab_map) |
Function updates dependencies for nested joins. More... | |
static bool | set_join_hint_deps (JOIN *join, const Hint_param_table_list *hint_table_list, opt_hints_enum type) |
Function resolves hint tables, checks and sets table dependencies according to the hint. More... | |
bool | is_compound_hint (opt_hints_enum type_arg) |
static void | print_hint_from_var (const THD *thd, String *str, set_var *var) |
Function prints hint using the info from set_var variable. More... | |
static void | print_hint_specified (String *str, const std::string &sys_var_name, Item *sys_var_value) |
Function prints hint as it is specified. More... | |
static bool | get_hint_state (Opt_hints *hint, Opt_hints *parent_hint, opt_hints_enum type_arg, bool *ret_val) |
Function returns hint value depending on the specified hint level. More... | |
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. More... | |
bool | hint_table_state (const THD *thd, const Table_ref *table_list, opt_hints_enum type_arg, uint optimizer_switch) |
Returns table hint value if hint is specified, returns optimizer switch value if hint is not specified. More... | |
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. More... | |
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. More... | |
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. More... | |
Variables | |
struct st_opt_hint_info | opt_hint_info [] |
Information about hints. More... | |
const LEX_CSTRING | sys_qb_prefix = {"select#", 7} |
Prefix for system generated query block name. More... | |
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.
thd | pointer to THD object |
str | pointer to String object |
qb_name | pointer to query block name, may be null |
table_name | pointer to table name |
int cmp_lex_string | ( | const LEX_CSTRING & | s, |
const LEX_CSTRING & | t, | ||
const CHARSET_INFO * | cs | ||
) |
|
static |
Function compares hint table name and Table_ref table name.
Query block name is taken into account.
hint_table | hint table name |
table | pointer to Table_ref object |
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.
If compound hint state is on and hint is specified without indexes, function returns 'true' for any 'keyno' argument. If hint specified with indexes, function returns true only for appropriate 'keyno' index.
table | Pointer to TABLE object |
keyno | Key number |
type_arg | Hint type |
|
static |
Function returns hint value depending on the specified hint level.
If hint is specified on current level, current level hint value is returned, otherwise parent level hint is checked.
hint | Pointer to the hint object | |
parent_hint | Pointer to the parent hint object, should never be NULL | |
type_arg | hint type | |
[out] | ret_val | hint value depending on what hint level is used |
|
static |
Function returns dependencies used for updating table dependencies depending on hint type.
type | hint type |
hint_tab_map | hint table map |
table_map | table map |
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.
thd | Pointer to THD object |
table | Pointer to Table_ref object |
keyno | Key number |
type_arg | Hint type |
optimizer_switch | Optimizer switch flag |
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 specified.
thd | Pointer to THD object |
table | Pointer to Table_ref object |
type_arg | Hint type |
optimizer_switch | Optimizer switch flag |
Returns true if index merge hint state is on otherwise returns false.
thd | Thread handler |
table | Pointer to TABLE object |
use_cheapest_index_merge | IN/OUT Returns true if INDEX_MERGE hint is used without any specified key. |
bool is_compound_hint | ( | opt_hints_enum | type_arg | ) |
Function prints hint using the info from set_var variable.
thd | Thread handle |
str | Pointer to string object |
var | Pointer to set_var object |
|
static |
Function prints hint as it is specified.
str | Pointer to string object |
sys_var_name | Variable name |
sys_var_value | Variable value |
|
static |
Print warning about unresolved table for join order hints.
thd | pointer to THD object |
type | hint type |
hint_table | table name |
|
static |
Function resolves hint tables, checks and sets table dependencies according to the hint.
If the hint is ignored due to circular table dependencies, original dependencies are restored.
join | pointer to JOIN object |
hint_table_list | hint table list |
type | hint type |
|
static |
Function updates dependencies for nested joins.
If table specified in the hint belongs to nested join, we need to update dependencies of all tables of the nested join with the same dependency as for the hint table. It is also necessary to update all tables of the nested joins this table is part of.
join | pointer to JOIN object |
hint_tab | pointer to JOIN_TAB object |
hint_tab_map | map of the tables, specified in the hint |
struct st_opt_hint_info opt_hint_info[] |
Information about hints.
Should be synchronized with opt_hints_enum enum.
Note: Hint name depends on hint state. 'NO_' prefix is added if appropriate hint state bit(see Opt_hints_map::hints) is not set. Depending on 'switch_state_arg' argument in 'parse tree object' constructors(see parse_tree_hints.[h,cc]) implementor can control wishful form of the hint name.
const LEX_CSTRING sys_qb_prefix = {"select#", 7} |
Prefix for system generated query block name.
Used in information warning in EXPLAIN oputput.