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
a356cfbe
Commit
a356cfbe
authored
Oct 15, 2013
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-3798: EXPLAIN UPDATE/DELETE
- eliminate join_save_qpf() function.
parent
1ec399ce
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
48 deletions
+33
-48
sql/sql_select.cc
sql/sql_select.cc
+28
-46
sql/sql_select.h
sql/sql_select.h
+5
-2
No files found.
sql/sql_select.cc
View file @
a356cfbe
...
@@ -1002,8 +1002,6 @@ bool JOIN::prepare_stage2()
...
@@ -1002,8 +1002,6 @@ bool JOIN::prepare_stage2()
DBUG_RETURN
(
res
);
/* purecov: inspected */
DBUG_RETURN
(
res
);
/* purecov: inspected */
}
}
void
join_save_qpf
(
JOIN
*
join
);
int
JOIN
::
optimize
()
int
JOIN
::
optimize
()
{
{
bool
was_optimized
=
optimized
;
bool
was_optimized
=
optimized
;
...
@@ -1023,7 +1021,10 @@ int JOIN::optimize()
...
@@ -1023,7 +1021,10 @@ int JOIN::optimize()
if
(
was_optimized
!=
optimized
&&
!
res
&&
have_query_plan
!=
QEP_DELETED
)
if
(
was_optimized
!=
optimized
&&
!
res
&&
have_query_plan
!=
QEP_DELETED
)
{
{
have_query_plan
=
QEP_AVAILABLE
;
have_query_plan
=
QEP_AVAILABLE
;
join_save_qpf
(
this
);
save_explain_data
(
thd
->
lex
->
explain
,
false
/* can overwrite */
,
need_tmp
,
!
skip_sort_order
&&
!
no_order
&&
(
order
||
group_list
),
select_distinct
);
}
}
return
res
;
return
res
;
}
}
...
@@ -2295,31 +2296,27 @@ JOIN::save_join_tab()
...
@@ -2295,31 +2296,27 @@ JOIN::save_join_tab()
}
}
void
join_save_qpf
(
JOIN
*
join
)
void
JOIN
::
save_explain_data
(
Explain_query
*
output
,
bool
can_overwrite
,
bool
need_tmp_table
,
bool
need_order
,
bool
distinct
)
{
{
THD
*
thd
=
join
->
thd
;
if
(
select_lex
->
select_number
!=
UINT_MAX
&&
if
(
join
->
select_lex
->
select_number
!=
UINT_MAX
&&
select_lex
->
select_number
!=
INT_MAX
/* this is not a UNION's "fake select */
&&
join
->
select_lex
->
select_number
!=
INT_MAX
/* this is not a UNION's "fake select */
&&
have_query_plan
!=
JOIN
::
QEP_NOT_PRESENT_YET
&&
join
->
have_query_plan
!=
JOIN
::
QEP_NOT_PRESENT_YET
&&
have_query_plan
!=
JOIN
::
QEP_DELETED
&&
// this happens when there was
join
->
have_query_plan
!=
JOIN
::
QEP_DELETED
&&
// this happens when there was
no QEP ever, but then
//
no QEP ever, but then
//cleanup() is called multiple times
//cleanup() is called multiple times
thd
->
lex
->
explain
&&
// for "SET" command in SPs.
output
&&
// for "SET" command in SPs.
!
thd
->
lex
->
explain
->
get_select
(
join
->
select_lex
->
select_number
))
(
can_overwrite
?
true
:
!
output
->
get_select
(
select_lex
->
select_number
)
))
{
{
const
char
*
message
=
NULL
;
const
char
*
message
=
NULL
;
if
(
!
table_count
||
!
tables_list
||
zero_result_cause
)
if
(
!
join
->
table_count
||
!
join
->
tables_list
||
join
->
zero_result_cause
)
{
{
/* It's a degenerate join */
/* It's a degenerate join */
message
=
join
->
zero_result_cause
?
join
->
zero_result_cause
:
"No tables used"
;
message
=
zero_result_cause
?
zero_result_cause
:
"No tables used"
;
}
}
save_explain_data_intern
(
thd
->
lex
->
explain
,
need_tmp_table
,
need_order
,
join
->
save_explain_data
(
thd
->
lex
->
explain
,
distinct
,
message
);
join
->
need_tmp
,
!
join
->
skip_sort_order
&&
!
join
->
no_order
&&
(
join
->
order
||
join
->
group_list
),
join
->
select_distinct
,
message
);
}
}
}
}
...
@@ -2336,26 +2333,10 @@ void JOIN::exec()
...
@@ -2336,26 +2333,10 @@ void JOIN::exec()
if
(
!
exec_saved_explain
)
if
(
!
exec_saved_explain
)
{
{
if
(
select_lex
->
select_number
!=
UINT_MAX
&&
save_explain_data
(
thd
->
lex
->
explain
,
true
/* can overwrite */
,
select_lex
->
select_number
!=
INT_MAX
/* this is not a UNION's "fake select */
&&
have_query_plan
!=
QEP_NOT_PRESENT_YET
&&
have_query_plan
!=
QEP_DELETED
&&
// this happens when there was no QEP ever, but then
//cleanup() is called multiple times
thd
->
lex
->
explain
)
// for "SET" command in SPs.
{
const
char
*
message
=
NULL
;
if
(
!
table_count
||
!
tables_list
||
zero_result_cause
)
{
/* It's a degenerate join */
message
=
zero_result_cause
?
zero_result_cause
:
"No tables used"
;
}
save_explain_data
(
thd
->
lex
->
explain
,
need_tmp
,
need_tmp
,
order
!=
0
&&
!
skip_sort_order
,
order
!=
0
&&
!
skip_sort_order
,
select_distinct
,
select_distinct
);
message
);
}
exec_saved_explain
=
true
;
exec_saved_explain
=
true
;
}
}
...
@@ -22497,6 +22478,7 @@ void append_possible_keys(String *str, TABLE *table, key_map possible_keys)
...
@@ -22497,6 +22478,7 @@ void append_possible_keys(String *str, TABLE *table, key_map possible_keys)
}
}
}
}
/*
/*
Save Query Plan Footprint
Save Query Plan Footprint
...
@@ -22504,7 +22486,7 @@ void append_possible_keys(String *str, TABLE *table, key_map possible_keys)
...
@@ -22504,7 +22486,7 @@ void append_possible_keys(String *str, TABLE *table, key_map possible_keys)
Currently, this function may be called multiple times
Currently, this function may be called multiple times
*/
*/
int
JOIN
::
save_explain_data
(
Explain_query
*
output
,
bool
need_tmp_table
,
int
JOIN
::
save_explain_data
_intern
(
Explain_query
*
output
,
bool
need_tmp_table
,
bool
need_order
,
bool
distinct
,
bool
need_order
,
bool
distinct
,
const
char
*
message
)
const
char
*
message
)
{
{
...
@@ -22514,7 +22496,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table,
...
@@ -22514,7 +22496,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table,
const
CHARSET_INFO
*
cs
=
system_charset_info
;
const
CHARSET_INFO
*
cs
=
system_charset_info
;
int
quick_type
;
int
quick_type
;
int
error
=
0
;
int
error
=
0
;
DBUG_ENTER
(
"JOIN::save_explain_data"
);
DBUG_ENTER
(
"JOIN::save_explain_data
_intern
"
);
DBUG_PRINT
(
"info"
,
(
"Select 0x%lx, type %s, message %s"
,
DBUG_PRINT
(
"info"
,
(
"Select 0x%lx, type %s, message %s"
,
(
ulong
)
join
->
select_lex
,
join
->
select_lex
->
type
,
(
ulong
)
join
->
select_lex
,
join
->
select_lex
->
type
,
message
?
message
:
"NULL"
));
message
?
message
:
"NULL"
));
...
...
sql/sql_select.h
View file @
a356cfbe
...
@@ -1476,8 +1476,11 @@ class JOIN :public Sql_alloc
...
@@ -1476,8 +1476,11 @@ class JOIN :public Sql_alloc
{
{
return
(
unit
->
item
&&
unit
->
item
->
is_in_predicate
());
return
(
unit
->
item
&&
unit
->
item
->
is_in_predicate
());
}
}
int
save_explain_data
(
Explain_query
*
output
,
bool
need_tmp_table
,
void
save_explain_data
(
Explain_query
*
output
,
bool
can_overwrite
,
bool
need_order
,
bool
distinct
,
const
char
*
message
);
bool
need_tmp_table
,
bool
need_order
,
bool
distinct
);
int
save_explain_data_intern
(
Explain_query
*
output
,
bool
need_tmp_table
,
bool
need_order
,
bool
distinct
,
const
char
*
message
);
private:
private:
/**
/**
TRUE if the query contains an aggregate function but has no GROUP
TRUE if the query contains an aggregate function but has no GROUP
...
...
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