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
dc937fb5
Commit
dc937fb5
authored
Mar 29, 2011
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MWL#90: Address review feedback part #16
parent
c5c48f1c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
21 deletions
+20
-21
sql/item_subselect.h
sql/item_subselect.h
+6
-6
sql/opt_subselect.cc
sql/opt_subselect.cc
+13
-14
sql/sql_base.cc
sql/sql_base.cc
+1
-1
No files found.
sql/item_subselect.h
View file @
dc937fb5
...
@@ -313,6 +313,8 @@ class Item_exists_subselect :public Item_subselect
...
@@ -313,6 +313,8 @@ class Item_exists_subselect :public Item_subselect
};
};
TABLE_LIST
*
const
NO_JOIN_NEST
=
(
TABLE_LIST
*
)
0x1
;
/**
/**
Representation of IN subquery predicates of the form
Representation of IN subquery predicates of the form
"left_expr IN (SELECT ...)".
"left_expr IN (SELECT ...)".
...
@@ -351,12 +353,10 @@ class Item_in_subselect :public Item_exists_subselect
...
@@ -351,12 +353,10 @@ class Item_in_subselect :public Item_exists_subselect
all JOIN in UNION
all JOIN in UNION
*/
*/
Item
*
expr
;
Item
*
expr
;
public:
Item_in_optimizer
*
optimizer
;
protected:
bool
was_null
;
bool
was_null
;
bool
abort_on_null
;
bool
abort_on_null
;
public:
public:
Item_in_optimizer
*
optimizer
;
/* Used to trigger on/off conditions that were pushed down to subselect */
/* Used to trigger on/off conditions that were pushed down to subselect */
bool
*
pushed_cond_guards
;
bool
*
pushed_cond_guards
;
...
@@ -365,7 +365,7 @@ class Item_in_subselect :public Item_exists_subselect
...
@@ -365,7 +365,7 @@ class Item_in_subselect :public Item_exists_subselect
/*
/*
Used by subquery optimizations to keep track about in which clause this
Used by subquery optimizations to keep track about in which clause this
subquery predicate is located:
subquery predicate is located:
(TABLE_LIST*) 1
- the predicate is an AND-part of the WHERE
NO_JOIN_NEST
- the predicate is an AND-part of the WHERE
join nest pointer - the predicate is an AND-part of ON expression
join nest pointer - the predicate is an AND-part of ON expression
of a join nest
of a join nest
NULL - for all other locations
NULL - for all other locations
...
@@ -377,7 +377,7 @@ class Item_in_subselect :public Item_exists_subselect
...
@@ -377,7 +377,7 @@ class Item_in_subselect :public Item_exists_subselect
- pointer to join nest if the subquery predicate is in the ON expression
- pointer to join nest if the subquery predicate is in the ON expression
- (TABLE_LIST*)1 if the predicate is in the WHERE.
- (TABLE_LIST*)1 if the predicate is in the WHERE.
*/
*/
TABLE_LIST
*
expr_join_nest
;
//
TABLE_LIST *expr_join_nest;
/*
/*
Types of left_expr and subquery's select list allow to perform subquery
Types of left_expr and subquery's select list allow to perform subquery
materialization. Currently, we set this to FALSE when it as well could
materialization. Currently, we set this to FALSE when it as well could
...
@@ -420,7 +420,7 @@ class Item_in_subselect :public Item_exists_subselect
...
@@ -420,7 +420,7 @@ class Item_in_subselect :public Item_exists_subselect
Item_in_subselect
(
Item
*
left_expr
,
st_select_lex
*
select_lex
);
Item_in_subselect
(
Item
*
left_expr
,
st_select_lex
*
select_lex
);
Item_in_subselect
()
Item_in_subselect
()
:
Item_exists_subselect
(),
left_expr_cache
(
0
),
first_execution
(
TRUE
),
:
Item_exists_subselect
(),
left_expr_cache
(
0
),
first_execution
(
TRUE
),
is_constant
(
FALSE
),
optimizer
(
0
),
abort_on_null
(
0
),
is_constant
(
FALSE
),
abort_on_null
(
0
),
optimizer
(
0
),
pushed_cond_guards
(
NULL
),
exec_method
(
NOT_TRANSFORMED
),
upper_item
(
0
)
pushed_cond_guards
(
NULL
),
exec_method
(
NOT_TRANSFORMED
),
upper_item
(
0
)
{}
{}
void
cleanup
();
void
cleanup
();
...
...
sql/opt_subselect.cc
View file @
dc937fb5
...
@@ -336,7 +336,6 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
...
@@ -336,7 +336,6 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
/* Register the subquery for further processing in flatten_subqueries() */
/* Register the subquery for further processing in flatten_subqueries() */
select_lex
->
select_lex
->
outer_select
()
->
join
->
sj_subselects
.
append
(
thd
->
mem_root
,
in_subs
);
outer_select
()
->
join
->
sj_subselects
.
append
(
thd
->
mem_root
,
in_subs
);
in_subs
->
expr_join_nest
=
thd
->
thd_marker
.
emb_on_expr_nest
;
}
}
else
else
{
{
...
@@ -396,7 +395,7 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
...
@@ -396,7 +395,7 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
with jtbm strategy
with jtbm strategy
*/
*/
if
(
in_subs
->
exec_method
==
Item_in_subselect
::
MATERIALIZATION
&&
if
(
in_subs
->
exec_method
==
Item_in_subselect
::
MATERIALIZATION
&&
thd
->
thd_marker
.
emb_on_expr_nest
==
(
TABLE_LIST
*
)
0x1
&&
thd
->
thd_marker
.
emb_on_expr_nest
==
NO_JOIN_NEST
&&
optimizer_flag
(
thd
,
OPTIMIZER_SWITCH_SEMIJOIN
))
optimizer_flag
(
thd
,
OPTIMIZER_SWITCH_SEMIJOIN
))
{
{
in_subs
->
emb_on_expr_nest
=
thd
->
thd_marker
.
emb_on_expr_nest
;
in_subs
->
emb_on_expr_nest
=
thd
->
thd_marker
.
emb_on_expr_nest
;
...
@@ -560,7 +559,7 @@ bool make_in_exists_conversion(THD *thd, JOIN *join, Item_in_subselect *item)
...
@@ -560,7 +559,7 @@ bool make_in_exists_conversion(THD *thd, JOIN *join, Item_in_subselect *item)
Item
*
replace_me
=
item
->
optimizer
;
Item
*
replace_me
=
item
->
optimizer
;
DBUG_ASSERT
(
replace_me
==
substitute
);
DBUG_ASSERT
(
replace_me
==
substitute
);
Item
**
tree
=
(
item
->
emb_on_expr_nest
==
(
TABLE_LIST
*
)
1
)
?
Item
**
tree
=
(
item
->
emb_on_expr_nest
==
NO_JOIN_NEST
)
?
&
join
->
conds
:
&
(
item
->
emb_on_expr_nest
->
on_expr
);
&
join
->
conds
:
&
(
item
->
emb_on_expr_nest
->
on_expr
);
if
(
replace_where_subcondition
(
join
,
tree
,
replace_me
,
substitute
,
if
(
replace_where_subcondition
(
join
,
tree
,
replace_me
,
substitute
,
do_fix_fields
))
do_fix_fields
))
...
@@ -569,7 +568,7 @@ bool make_in_exists_conversion(THD *thd, JOIN *join, Item_in_subselect *item)
...
@@ -569,7 +568,7 @@ bool make_in_exists_conversion(THD *thd, JOIN *join, Item_in_subselect *item)
if
(
!
thd
->
stmt_arena
->
is_conventional
())
if
(
!
thd
->
stmt_arena
->
is_conventional
())
{
{
tree
=
(
item
->
emb_on_expr_nest
==
(
TABLE_LIST
*
)
1
)
?
tree
=
(
item
->
emb_on_expr_nest
==
(
TABLE_LIST
*
)
NO_JOIN_NEST
)
?
&
join
->
select_lex
->
prep_where
:
&
join
->
select_lex
->
prep_where
:
&
(
item
->
emb_on_expr_nest
->
prep_on_expr
);
&
(
item
->
emb_on_expr_nest
->
prep_on_expr
);
...
@@ -711,7 +710,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
...
@@ -711,7 +710,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
}
}
if
(
remove_item
)
if
(
remove_item
)
{
{
Item
**
tree
=
((
*
in_subq
)
->
emb_on_expr_nest
==
(
TABLE_LIST
*
)
1
)
?
Item
**
tree
=
((
*
in_subq
)
->
emb_on_expr_nest
==
NO_JOIN_NEST
)
?
&
join
->
conds
:
&
((
*
in_subq
)
->
emb_on_expr_nest
->
on_expr
);
&
join
->
conds
:
&
((
*
in_subq
)
->
emb_on_expr_nest
->
on_expr
);
Item
*
replace_me
=
*
in_subq
;
Item
*
replace_me
=
*
in_subq
;
/*
/*
...
@@ -755,7 +754,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
...
@@ -755,7 +754,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
Item
*
substitute
=
(
*
in_subq
)
->
substitution
;
Item
*
substitute
=
(
*
in_subq
)
->
substitution
;
bool
do_fix_fields
=
!
(
*
in_subq
)
->
substitution
->
fixed
;
bool
do_fix_fields
=
!
(
*
in_subq
)
->
substitution
->
fixed
;
Item
**
tree
=
((
*
in_subq
)
->
emb_on_expr_nest
==
(
TABLE_LIST
*
)
1
)
?
Item
**
tree
=
((
*
in_subq
)
->
emb_on_expr_nest
==
NO_JOIN_NEST
)
?
&
join
->
conds
:
&
((
*
in_subq
)
->
emb_on_expr_nest
->
on_expr
);
&
join
->
conds
:
&
((
*
in_subq
)
->
emb_on_expr_nest
->
on_expr
);
Item
*
replace_me
=
*
in_subq
;
Item
*
replace_me
=
*
in_subq
;
...
@@ -776,7 +775,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
...
@@ -776,7 +775,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
if
(
!
thd
->
stmt_arena
->
is_conventional
())
if
(
!
thd
->
stmt_arena
->
is_conventional
())
{
{
tree
=
((
*
in_subq
)
->
emb_on_expr_nest
==
(
TABLE_LIST
*
)
1
)
?
tree
=
((
*
in_subq
)
->
emb_on_expr_nest
==
NO_JOIN_NEST
)
?
&
join
->
select_lex
->
prep_where
:
&
join
->
select_lex
->
prep_where
:
&
((
*
in_subq
)
->
emb_on_expr_nest
->
prep_on_expr
);
&
((
*
in_subq
)
->
emb_on_expr_nest
->
prep_on_expr
);
...
@@ -944,9 +943,9 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
...
@@ -944,9 +943,9 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
1. Find out where to put the predicate into.
1. Find out where to put the predicate into.
Note: for "t1 LEFT JOIN t2" this will be t2, a leaf.
Note: for "t1 LEFT JOIN t2" this will be t2, a leaf.
*/
*/
if
((
void
*
)
subq_pred
->
e
xpr_join_nest
!=
(
void
*
)
1
)
if
((
void
*
)
subq_pred
->
e
mb_on_expr_nest
!=
(
void
*
)
NO_JOIN_NEST
)
{
{
if
(
subq_pred
->
e
xpr_join
_nest
->
nested_join
)
if
(
subq_pred
->
e
mb_on_expr
_nest
->
nested_join
)
{
{
/*
/*
We're dealing with
We're dealing with
...
@@ -955,10 +954,10 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
...
@@ -955,10 +954,10 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
The sj-nest will be inserted into the brackets nest.
The sj-nest will be inserted into the brackets nest.
*/
*/
emb_tbl_nest
=
subq_pred
->
e
xpr_join
_nest
;
emb_tbl_nest
=
subq_pred
->
e
mb_on_expr
_nest
;
emb_join_list
=
&
emb_tbl_nest
->
nested_join
->
join_list
;
emb_join_list
=
&
emb_tbl_nest
->
nested_join
->
join_list
;
}
}
else
if
(
!
subq_pred
->
e
xpr_join
_nest
->
outer_join
)
else
if
(
!
subq_pred
->
e
mb_on_expr
_nest
->
outer_join
)
{
{
/*
/*
We're dealing with
We're dealing with
...
@@ -968,13 +967,13 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
...
@@ -968,13 +967,13 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
The sj-nest will be tblX's "sibling", i.e. another child of its
The sj-nest will be tblX's "sibling", i.e. another child of its
parent. This is ok because tblX is joined as an inner join.
parent. This is ok because tblX is joined as an inner join.
*/
*/
emb_tbl_nest
=
subq_pred
->
e
xpr_join
_nest
->
embedding
;
emb_tbl_nest
=
subq_pred
->
e
mb_on_expr
_nest
->
embedding
;
if
(
emb_tbl_nest
)
if
(
emb_tbl_nest
)
emb_join_list
=
&
emb_tbl_nest
->
nested_join
->
join_list
;
emb_join_list
=
&
emb_tbl_nest
->
nested_join
->
join_list
;
}
}
else
if
(
!
subq_pred
->
e
xpr_join
_nest
->
nested_join
)
else
if
(
!
subq_pred
->
e
mb_on_expr
_nest
->
nested_join
)
{
{
TABLE_LIST
*
outer_tbl
=
subq_pred
->
e
xpr_join_nest
;
TABLE_LIST
*
outer_tbl
=
subq_pred
->
e
mb_on_expr_nest
;
TABLE_LIST
*
wrap_nest
;
TABLE_LIST
*
wrap_nest
;
/*
/*
We're dealing with
We're dealing with
...
...
sql/sql_base.cc
View file @
dc937fb5
...
@@ -8188,7 +8188,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
...
@@ -8188,7 +8188,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
goto
err_no_arena
;
goto
err_no_arena
;
}
}
thd
->
thd_marker
.
emb_on_expr_nest
=
(
TABLE_LIST
*
)
1
;
thd
->
thd_marker
.
emb_on_expr_nest
=
NO_JOIN_NEST
;
if
(
*
conds
)
if
(
*
conds
)
{
{
thd
->
where
=
"where clause"
;
thd
->
where
=
"where clause"
;
...
...
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