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
8e92d5e5
Commit
8e92d5e5
authored
Sep 22, 2019
by
Varun Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-20468: Allocating more space than required for JOIN_TAB array for a query with SJM table
parent
f5c3ad19
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
7 deletions
+42
-7
sql/opt_subselect.cc
sql/opt_subselect.cc
+33
-0
sql/opt_subselect.h
sql/opt_subselect.h
+1
-0
sql/sql_select.cc
sql/sql_select.cc
+8
-7
No files found.
sql/opt_subselect.cc
View file @
8e92d5e5
...
...
@@ -3934,6 +3934,39 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
}
/*
Return the number of tables at the top-level of the JOIN
SYNOPSIS
get_number_of_tables_at_top_level()
join The join with the picked join order
DESCRIPTION
The number of tables in the JOIN currently include all the inner tables of the
mergeable semi-joins. The function would make sure that we only count the semi-join
nest and not the inner tables of teh semi-join nest.
*/
uint
get_number_of_tables_at_top_level
(
JOIN
*
join
)
{
uint
j
=
0
,
tables
=
0
;
while
(
j
<
join
->
table_count
)
{
POSITION
*
cur_pos
=
&
join
->
best_positions
[
j
];
tables
++
;
if
(
cur_pos
->
sj_strategy
==
SJ_OPT_MATERIALIZE
||
cur_pos
->
sj_strategy
==
SJ_OPT_MATERIALIZE_SCAN
)
{
SJ_MATERIALIZATION_INFO
*
sjm
=
cur_pos
->
table
->
emb_sj_nest
->
sj_mat_info
;
j
=
j
+
sjm
->
tables
;
}
else
j
++
;
}
return
tables
;
}
/*
Setup semi-join materialization strategy for one semi-join nest
...
...
sql/opt_subselect.h
View file @
8e92d5e5
...
...
@@ -323,6 +323,7 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join);
bool
setup_sj_materialization_part1
(
JOIN_TAB
*
sjm_tab
);
bool
setup_sj_materialization_part2
(
JOIN_TAB
*
sjm_tab
);
uint
get_number_of_tables_at_top_level
(
JOIN
*
join
);
/*
...
...
sql/sql_select.cc
View file @
8e92d5e5
...
...
@@ -3600,7 +3600,7 @@ bool JOIN::make_aggr_tables_info()
unit->select_limit_cnt == 1 (we only need one row in the result set)
*/
sort_tab
->
filesort
->
limit
=
(
has_group_by
||
(
join_tab
+
t
able
_count
>
curr_tab
+
1
))
?
(
has_group_by
||
(
join_tab
+
t
op_join_tab
_count
>
curr_tab
+
1
))
?
select_limit
:
unit
->
select_limit_cnt
;
}
if
(
!
only_const_tables
()
&&
...
...
@@ -10204,14 +10204,16 @@ bool JOIN::get_best_combination()
if
(
aggr_tables
>
2
)
aggr_tables
=
2
;
if
(
!
(
join_tab
=
(
JOIN_TAB
*
)
thd
->
alloc
(
sizeof
(
JOIN_TAB
)
*
(
top_join_tab_count
+
aggr_tables
))))
DBUG_RETURN
(
TRUE
);
full_join
=
0
;
hash_join
=
FALSE
;
fix_semijoin_strategies_for_picked_join_order
(
this
);
top_join_tab_count
=
get_number_of_tables_at_top_level
(
this
);
if
(
!
(
join_tab
=
(
JOIN_TAB
*
)
thd
->
alloc
(
sizeof
(
JOIN_TAB
)
*
(
top_join_tab_count
+
aggr_tables
))))
DBUG_RETURN
(
TRUE
);
JOIN_TAB_RANGE
*
root_range
;
if
(
!
(
root_range
=
new
(
thd
->
mem_root
)
JOIN_TAB_RANGE
))
...
...
@@ -13923,7 +13925,7 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
ORDER BY and GROUP BY
*/
for
(
JOIN_TAB
*
tab
=
join
->
join_tab
+
join
->
const_tables
;
tab
<
join
->
join_tab
+
join
->
t
able
_count
;
tab
<
join
->
join_tab
+
join
->
t
op_join_tab
_count
;
tab
++
)
tab
->
cached_eq_ref_table
=
FALSE
;
...
...
@@ -19772,8 +19774,7 @@ do_select(JOIN *join, Procedure *procedure)
if
(
join
->
pushdown_query
->
store_data_in_temp_table
)
{
JOIN_TAB
*
last_tab
=
join
->
join_tab
+
join
->
table_count
-
join
->
exec_join_tab_cnt
();
JOIN_TAB
*
last_tab
=
join
->
join_tab
+
join
->
exec_join_tab_cnt
();
last_tab
->
next_select
=
end_send
;
enum_nested_loop_state
state
=
last_tab
->
aggr
->
end_send
();
...
...
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