Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
0a99d033
Commit
0a99d033
authored
Aug 31, 2024
by
Sergei Petrunia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Input to: MDEV-33281 Implement optimizer hints: Comments and renames
parent
6edc0225
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
18 deletions
+32
-18
sql/opt_hints.cc
sql/opt_hints.cc
+19
-5
sql/opt_hints.h
sql/opt_hints.h
+3
-3
sql/simple_parser.h
sql/simple_parser.h
+1
-1
sql/sql_lex.cc
sql/sql_lex.cc
+2
-2
sql/sql_lex.h
sql/sql_lex.h
+1
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+6
-6
No files found.
sql/opt_hints.cc
View file @
0a99d033
...
...
@@ -52,7 +52,8 @@ const LEX_CSTRING sys_qb_prefix= {"select#", 7};
static
const
Lex_ident_sys
null_ident_sys
;
static
void
print_warn
(
THD
*
thd
,
uint
err_code
,
opt_hints_enum
hint_type
,
static
void
print_warn
(
THD
*
thd
,
uint
err_code
,
opt_hints_enum
hint_type
,
bool
hint_state
,
const
Lex_ident_sys
*
qb_name_arg
,
const
Lex_ident_sys
*
table_name_arg
,
...
...
@@ -221,7 +222,7 @@ static Opt_hints_table *get_table_hints(Parse_context *pc,
bool
Opt_hints
::
get_switch
(
opt_hints_enum
type_arg
)
const
{
if
(
is_specified
(
type_arg
))
return
hints_map
.
switch
_on
(
type_arg
);
return
hints_map
.
is_switched
_on
(
type_arg
);
if
(
opt_hint_info
[
type_arg
].
check_upper_lvl
)
return
parent
->
get_switch
(
type_arg
);
...
...
@@ -263,7 +264,7 @@ void Opt_hints::print(THD *thd, String *str)
void
Opt_hints
::
append_hint_type
(
String
*
str
,
opt_hints_enum
type
)
{
if
(
!
hints_map
.
switch
_on
(
type
))
if
(
!
hints_map
.
is_switched
_on
(
type
))
str
->
append
(
STRING_WITH_LEN
(
"NO_"
));
str
->
append
(
opt_hint_info
[
type
].
hint_name
);
}
...
...
@@ -330,6 +331,11 @@ Opt_hints_table *Opt_hints_qb::adjust_table_hints(TABLE *table,
}
/*
@brief
For each index IDX, put its hints into keyinfo_array[IDX]
*/
void
Opt_hints_table
::
adjust_key_hints
(
TABLE
*
table
)
{
set_resolved
();
...
...
@@ -339,7 +345,7 @@ void Opt_hints_table::adjust_key_hints(TABLE *table)
return
;
}
/* Make sure that adjust
e
ment is called only once. */
/* Make sure that adjustment is called only once. */
DBUG_ASSERT
(
keyinfo_array
.
size
()
==
0
);
keyinfo_array
.
resize
(
table
->
s
->
keys
,
NULL
);
...
...
@@ -414,6 +420,14 @@ static bool get_hint_state(Opt_hints *hint,
}
/*
@brief
Check whether a given optimization is enabled for table.keyno.
@detail
First check if a hint is present, then check optimizer_switch
*/
bool
hint_key_state
(
const
THD
*
thd
,
const
TABLE
*
table
,
uint
keyno
,
opt_hints_enum
type_arg
,
uint
optimizer_switch
)
...
...
@@ -690,7 +704,7 @@ bool Optimizer_hint_parser::Hint_list::resolve(Parse_context *pc)
while
(
Optimizer_hint_parser
::
Hint
*
hint
=
li
++
)
{
if
(
const
Table_level_hint
&
table_hint
=
static_cast
<
const
Table_level_hint
&>
(
*
hint
))
/*static_cast<const Table_level_hint &>*/
(
*
hint
))
{
if
(
table_hint
.
resolve
(
pc
))
return
true
;
...
...
sql/opt_hints.h
View file @
0a99d033
...
...
@@ -112,7 +112,7 @@ class Opt_hints_map : public Sql_alloc
@return switch value.
*/
bool
switch
_on
(
opt_hints_enum
type_arg
)
const
bool
is_switched
_on
(
opt_hints_enum
type_arg
)
const
{
return
hints
.
is_set
(
type_arg
);
}
...
...
@@ -128,10 +128,10 @@ class Opt_hints_key;
Opt_hints_global class is hierarchical structure.
It contains information about global hints and also
conains array of QUERY BLOCK level objects (Opt_hints_qb class).
con
t
ains array of QUERY BLOCK level objects (Opt_hints_qb class).
Each QUERY BLOCK level object contains array of TABLE level hints
(class Opt_hints_table). Each TABLE level hint contains array of
KEY le
lev
hints (Opt_hints_key class).
KEY le
vel
hints (Opt_hints_key class).
Hint information(specified, on|off state) is stored in hints_map object.
*/
...
...
sql/simple_parser.h
View file @
0a99d033
...
...
@@ -196,7 +196,7 @@ class Parser_templates
/*
A rule consisting of
three
other rules in a row:
A rule consisting of
four
other rules in a row:
rule ::= rule1 rule2 rule3 rule4
*/
template
<
class
PARSER
,
class
A
,
class
B
,
class
C
,
class
D
>
...
...
sql/sql_lex.cc
View file @
0a99d033
...
...
@@ -10684,7 +10684,7 @@ bool LEX::parsed_insert_select(SELECT_LEX *first_select)
return
true
;
// fix "main" select
resolve_optimizer_hints
();
resolve_optimizer_hints
_in_last_select
();
SELECT_LEX
*
blt
__attribute__
((
unused
))
=
pop_select
();
DBUG_ASSERT
(
blt
==
&
builtin_select
);
push_select
(
first_select
);
...
...
@@ -12453,7 +12453,7 @@ LEX::parse_optimizer_hints(const Lex_comment_st &hints_str)
}
void
LEX
::
resolve_optimizer_hints
()
void
LEX
::
resolve_optimizer_hints
_in_last_select
()
{
SELECT_LEX
*
select_lex
;
if
(
likely
(
select_stack_top
))
...
...
sql/sql_lex.h
View file @
0a99d033
...
...
@@ -3725,7 +3725,7 @@ struct LEX: public Query_tables_list
DBUG_RETURN
(
select_lex
);
}
void
resolve_optimizer_hints
();
void
resolve_optimizer_hints
_in_last_select
();
SELECT_LEX
*
current_select_or_default
()
{
...
...
sql/sql_yacc.yy
View file @
0a99d033
...
...
@@ -8765,7 +8765,7 @@ query_specification:
opt_having_clause
opt_window_clause
{
Lex->resolve_optimizer_hints();
Lex->resolve_optimizer_hints
_in_last_select
();
$$= Lex->pop_select();
}
;
...
...
@@ -8779,7 +8779,7 @@ select_into_query_specification:
opt_having_clause
opt_window_clause
{
Lex->resolve_optimizer_hints();
Lex->resolve_optimizer_hints
_in_last_select
();
$$= Lex->pop_select();
}
;
...
...
@@ -13339,7 +13339,7 @@ insert:
insert_field_spec opt_insert_update opt_returning
insert_stmt_end
{
Lex->resolve_optimizer_hints();
Lex->resolve_optimizer_hints
_in_last_select
();
Lex->mark_first_table_as_inserting();
thd->get_stmt_da()->reset_current_row_for_warning(0);
}
...
...
@@ -13361,7 +13361,7 @@ replace:
insert_field_spec opt_returning
insert_stmt_end
{
Lex->resolve_optimizer_hints();
Lex->resolve_optimizer_hints
_in_last_select
();
Lex->mark_first_table_as_inserting();
thd->get_stmt_da()->reset_current_row_for_warning(0);
}
...
...
@@ -13377,7 +13377,7 @@ insert_start: {
;
stmt_end: {
Lex->resolve_optimizer_hints();
Lex->resolve_optimizer_hints
_in_last_select
();
Lex->pop_select(); //main select
if (Lex->check_main_unit_semantics())
MYSQL_YYABORT;
...
...
@@ -13744,7 +13744,7 @@ delete:
{
if (Lex->check_cte_dependencies_and_resolve_references())
MYSQL_YYABORT;
Lex->resolve_optimizer_hints();
Lex->resolve_optimizer_hints
_in_last_select
();
}
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment