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
};
TABLE_LIST
*
const
NO_JOIN_NEST
=
(
TABLE_LIST
*
)
0x1
;
/**
Representation of IN subquery predicates of the form
"left_expr IN (SELECT ...)".
...
...
@@ -351,12 +353,10 @@ class Item_in_subselect :public Item_exists_subselect
all JOIN in UNION
*/
Item
*
expr
;
public:
Item_in_optimizer
*
optimizer
;
protected:
bool
was_null
;
bool
abort_on_null
;
public:
Item_in_optimizer
*
optimizer
;
/* Used to trigger on/off conditions that were pushed down to subselect */
bool
*
pushed_cond_guards
;
...
...
@@ -365,7 +365,7 @@ class Item_in_subselect :public Item_exists_subselect
/*
Used by subquery optimizations to keep track about in which clause this
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
of a join nest
NULL - for all other locations
...
...
@@ -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
- (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
materialization. Currently, we set this to FALSE when it as well could
...
...
@@ -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_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
)
{}
void
cleanup
();
...
...
sql/opt_subselect.cc
View file @
dc937fb5
...
...
@@ -336,7 +336,6 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
/* Register the subquery for further processing in flatten_subqueries() */
select_lex
->
outer_select
()
->
join
->
sj_subselects
.
append
(
thd
->
mem_root
,
in_subs
);
in_subs
->
expr_join_nest
=
thd
->
thd_marker
.
emb_on_expr_nest
;
}
else
{
...
...
@@ -396,7 +395,7 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
with jtbm strategy
*/
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
))
{
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)
Item
*
replace_me
=
item
->
optimizer
;
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
);
if
(
replace_where_subcondition
(
join
,
tree
,
replace_me
,
substitute
,
do_fix_fields
))
...
...
@@ -569,7 +568,7 @@ bool make_in_exists_conversion(THD *thd, JOIN *join, Item_in_subselect *item)
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
:
&
(
item
->
emb_on_expr_nest
->
prep_on_expr
);
...
...
@@ -711,7 +710,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
}
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
);
Item
*
replace_me
=
*
in_subq
;
/*
...
...
@@ -755,7 +754,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
Item
*
substitute
=
(
*
in_subq
)
->
substitution
;
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
);
Item
*
replace_me
=
*
in_subq
;
...
...
@@ -776,7 +775,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
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
:
&
((
*
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)
1. Find out where to put the predicate into.
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
...
...
@@ -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.
*/
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
;
}
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
...
...
@@ -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
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
)
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
;
/*
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,
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
)
{
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