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
6d3f297f
Commit
6d3f297f
authored
Sep 25, 2019
by
Galina Shalygina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-11107 Use table check constraints in optimizer
Project code on 10.5 branch
parent
8887effe
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
2353 additions
and
0 deletions
+2353
-0
sql/CMakeLists.txt
sql/CMakeLists.txt
+1
-0
sql/item.h
sql/item.h
+10
-0
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+8
-0
sql/item_func.h
sql/item_func.h
+9
-0
sql/item_timefunc.h
sql/item_timefunc.h
+2
-0
sql/opt_cmpfunc.cc
sql/opt_cmpfunc.cc
+2314
-0
sql/sql_select.cc
sql/sql_select.cc
+9
-0
No files found.
sql/CMakeLists.txt
View file @
6d3f297f
...
@@ -147,6 +147,7 @@ SET (SQL_SOURCE
...
@@ -147,6 +147,7 @@ SET (SQL_SOURCE
opt_trace.cc
opt_trace.cc
table_cache.cc encryption.cc temporary_tables.cc
table_cache.cc encryption.cc temporary_tables.cc
proxy_protocol.cc backup.cc xa.cc
proxy_protocol.cc backup.cc xa.cc
opt_cmpfunc.cc
${
CMAKE_CURRENT_BINARY_DIR
}
/sql_yacc.cc
${
CMAKE_CURRENT_BINARY_DIR
}
/sql_yacc.cc
${
CMAKE_CURRENT_BINARY_DIR
}
/sql_yacc_ora.cc
${
CMAKE_CURRENT_BINARY_DIR
}
/sql_yacc_ora.cc
${
CMAKE_CURRENT_BINARY_DIR
}
/lex_hash.h
${
CMAKE_CURRENT_BINARY_DIR
}
/lex_hash.h
...
...
sql/item.h
View file @
6d3f297f
...
@@ -2035,6 +2035,10 @@ class Item: public Value_source,
...
@@ -2035,6 +2035,10 @@ class Item: public Value_source,
If there is some, sets a bit for this key in the proper key map.
If there is some, sets a bit for this key in the proper key map.
*/
*/
virtual
bool
check_index_dependence
(
void
*
arg
)
{
return
0
;
}
virtual
bool
check_index_dependence
(
void
*
arg
)
{
return
0
;
}
virtual
bool
linear_checker_processor
(
void
*
arg
)
{
return
true
;
}
virtual
bool
ineq_normalization_processor
(
void
*
arg
)
{
return
true
;
}
/*============== End of Item processor list ======================*/
/*============== End of Item processor list ======================*/
/*
/*
...
@@ -2762,6 +2766,8 @@ class Item_basic_constant :public Item_basic_value
...
@@ -2762,6 +2766,8 @@ class Item_basic_constant :public Item_basic_value
DBUG_ASSERT
(
0
);
DBUG_ASSERT
(
0
);
return
this
;
return
this
;
}
}
bool
linear_checker_processor
(
void
*
arg
)
{
return
false
;
}
bool
ineq_normalization_processor
(
void
*
arg
);
};
};
...
@@ -3492,6 +3498,8 @@ class Item_field :public Item_ident,
...
@@ -3492,6 +3498,8 @@ class Item_field :public Item_ident,
return
field
->
table
->
pos_in_table_list
->
outer_join
;
return
field
->
table
->
pos_in_table_list
->
outer_join
;
}
}
bool
check_index_dependence
(
void
*
arg
);
bool
check_index_dependence
(
void
*
arg
);
bool
linear_checker_processor
(
void
*
arg
);
bool
ineq_normalization_processor
(
void
*
arg
);
friend
class
Item_default_value
;
friend
class
Item_default_value
;
friend
class
Item_insert_value
;
friend
class
Item_insert_value
;
friend
class
st_select_lex_unit
;
friend
class
st_select_lex_unit
;
...
@@ -5760,6 +5768,8 @@ class Item_direct_view_ref :public Item_direct_ref
...
@@ -5760,6 +5768,8 @@ class Item_direct_view_ref :public Item_direct_ref
Item
*
field_transformer_for_having_pushdown
(
THD
*
thd
,
uchar
*
arg
)
Item
*
field_transformer_for_having_pushdown
(
THD
*
thd
,
uchar
*
arg
)
{
return
this
;
}
{
return
this
;
}
Item
*
remove_item_direct_ref
()
{
return
this
;
}
Item
*
remove_item_direct_ref
()
{
return
this
;
}
bool
linear_checker_processor
(
void
*
arg
);
bool
ineq_normalization_processor
(
void
*
arg
);
};
};
...
...
sql/item_cmpfunc.h
View file @
6d3f297f
...
@@ -783,6 +783,8 @@ class Item_func_ge :public Item_bool_rowready_func2
...
@@ -783,6 +783,8 @@ class Item_func_ge :public Item_bool_rowready_func2
Item
*
negated_item
(
THD
*
thd
);
Item
*
negated_item
(
THD
*
thd
);
Item
*
get_copy
(
THD
*
thd
)
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_func_ge
>
(
thd
,
this
);
}
{
return
get_item_copy
<
Item_func_ge
>
(
thd
,
this
);
}
bool
linear_checker_processor
(
void
*
arg
)
{
return
false
;
}
bool
ineq_normalization_processor
(
void
*
arg
);
};
};
...
@@ -799,6 +801,8 @@ class Item_func_gt :public Item_bool_rowready_func2
...
@@ -799,6 +801,8 @@ class Item_func_gt :public Item_bool_rowready_func2
Item
*
negated_item
(
THD
*
thd
);
Item
*
negated_item
(
THD
*
thd
);
Item
*
get_copy
(
THD
*
thd
)
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_func_gt
>
(
thd
,
this
);
}
{
return
get_item_copy
<
Item_func_gt
>
(
thd
,
this
);
}
bool
linear_checker_processor
(
void
*
arg
)
{
return
false
;
}
bool
ineq_normalization_processor
(
void
*
arg
);
};
};
...
@@ -815,6 +819,8 @@ class Item_func_le :public Item_bool_rowready_func2
...
@@ -815,6 +819,8 @@ class Item_func_le :public Item_bool_rowready_func2
Item
*
negated_item
(
THD
*
thd
);
Item
*
negated_item
(
THD
*
thd
);
Item
*
get_copy
(
THD
*
thd
)
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_func_le
>
(
thd
,
this
);
}
{
return
get_item_copy
<
Item_func_le
>
(
thd
,
this
);
}
bool
linear_checker_processor
(
void
*
arg
)
{
return
false
;
}
bool
ineq_normalization_processor
(
void
*
arg
);
};
};
...
@@ -831,6 +837,8 @@ class Item_func_lt :public Item_bool_rowready_func2
...
@@ -831,6 +837,8 @@ class Item_func_lt :public Item_bool_rowready_func2
Item
*
negated_item
(
THD
*
thd
);
Item
*
negated_item
(
THD
*
thd
);
Item
*
get_copy
(
THD
*
thd
)
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_func_lt
>
(
thd
,
this
);
}
{
return
get_item_copy
<
Item_func_lt
>
(
thd
,
this
);
}
bool
linear_checker_processor
(
void
*
arg
)
{
return
false
;
}
bool
ineq_normalization_processor
(
void
*
arg
);
};
};
...
...
sql/item_func.h
View file @
6d3f297f
...
@@ -1338,6 +1338,8 @@ class Item_func_plus :public Item_func_additive_op
...
@@ -1338,6 +1338,8 @@ class Item_func_plus :public Item_func_additive_op
my_decimal
*
decimal_op
(
my_decimal
*
);
my_decimal
*
decimal_op
(
my_decimal
*
);
Item
*
get_copy
(
THD
*
thd
)
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_func_plus
>
(
thd
,
this
);
}
{
return
get_item_copy
<
Item_func_plus
>
(
thd
,
this
);
}
bool
linear_checker_processor
(
void
*
arg
)
{
return
false
;
}
bool
ineq_normalization_processor
(
void
*
arg
);
};
};
class
Item_func_minus
:
public
Item_func_additive_op
class
Item_func_minus
:
public
Item_func_additive_op
...
@@ -1373,6 +1375,8 @@ class Item_func_minus :public Item_func_additive_op
...
@@ -1373,6 +1375,8 @@ class Item_func_minus :public Item_func_additive_op
}
}
Item
*
get_copy
(
THD
*
thd
)
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_func_minus
>
(
thd
,
this
);
}
{
return
get_item_copy
<
Item_func_minus
>
(
thd
,
this
);
}
bool
linear_checker_processor
(
void
*
arg
)
{
return
false
;
}
bool
ineq_normalization_processor
(
void
*
arg
);
};
};
...
@@ -1392,6 +1396,8 @@ class Item_func_mul :public Item_num_op
...
@@ -1392,6 +1396,8 @@ class Item_func_mul :public Item_num_op
bool
check_vcol_func_processor
(
void
*
arg
)
{
return
FALSE
;}
bool
check_vcol_func_processor
(
void
*
arg
)
{
return
FALSE
;}
Item
*
get_copy
(
THD
*
thd
)
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_func_mul
>
(
thd
,
this
);
}
{
return
get_item_copy
<
Item_func_mul
>
(
thd
,
this
);
}
bool
linear_checker_processor
(
void
*
arg
);
bool
ineq_normalization_processor
(
void
*
arg
);
};
};
...
@@ -1411,6 +1417,8 @@ class Item_func_div :public Item_num_op
...
@@ -1411,6 +1417,8 @@ class Item_func_div :public Item_num_op
void
result_precision
();
void
result_precision
();
Item
*
get_copy
(
THD
*
thd
)
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_func_div
>
(
thd
,
this
);
}
{
return
get_item_copy
<
Item_func_div
>
(
thd
,
this
);
}
bool
linear_checker_processor
(
void
*
arg
);
bool
ineq_normalization_processor
(
void
*
arg
);
};
};
...
@@ -1496,6 +1504,7 @@ class Item_func_neg :public Item_func_num1
...
@@ -1496,6 +1504,7 @@ class Item_func_neg :public Item_func_num1
bool
need_parentheses_in_default
()
{
return
true
;
}
bool
need_parentheses_in_default
()
{
return
true
;
}
Item
*
get_copy
(
THD
*
thd
)
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_func_neg
>
(
thd
,
this
);
}
{
return
get_item_copy
<
Item_func_neg
>
(
thd
,
this
);
}
bool
ineq_normalization_processor
(
void
*
arg
);
};
};
...
...
sql/item_timefunc.h
View file @
6d3f297f
...
@@ -969,6 +969,7 @@ class Item_date_add_interval :public Item_handled_func
...
@@ -969,6 +969,7 @@ class Item_date_add_interval :public Item_handled_func
bool
need_parentheses_in_default
()
{
return
true
;
}
bool
need_parentheses_in_default
()
{
return
true
;
}
Item
*
get_copy
(
THD
*
thd
)
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_date_add_interval
>
(
thd
,
this
);
}
{
return
get_item_copy
<
Item_date_add_interval
>
(
thd
,
this
);
}
bool
ineq_normalization_processor
(
void
*
arg
);
};
};
...
@@ -1271,6 +1272,7 @@ class Item_func_add_time :public Item_handled_func
...
@@ -1271,6 +1272,7 @@ class Item_func_add_time :public Item_handled_func
const
char
*
func_name
()
const
{
return
sign
>
0
?
"addtime"
:
"subtime"
;
}
const
char
*
func_name
()
const
{
return
sign
>
0
?
"addtime"
:
"subtime"
;
}
Item
*
get_copy
(
THD
*
thd
)
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_func_add_time
>
(
thd
,
this
);
}
{
return
get_item_copy
<
Item_func_add_time
>
(
thd
,
this
);
}
bool
ineq_normalization_processor
(
void
*
arg
);
};
};
...
...
sql/opt_cmpfunc.cc
0 → 100644
View file @
6d3f297f
This diff is collapsed.
Click to expand it.
sql/sql_select.cc
View file @
6d3f297f
...
@@ -68,6 +68,7 @@
...
@@ -68,6 +68,7 @@
#include "select_handler.h"
#include "select_handler.h"
#include "my_json_writer.h"
#include "my_json_writer.h"
#include "opt_trace.h"
#include "opt_trace.h"
#include "opt_cmpfunc.cc"
/*
/*
A key part number that means we're using a fulltext scan.
A key part number that means we're using a fulltext scan.
...
@@ -1945,6 +1946,9 @@ JOIN::optimize_inner()
...
@@ -1945,6 +1946,9 @@ JOIN::optimize_inner()
}
}
}
}
if (add_constraints(this, &conds))
DBUG_RETURN(1);
conds= optimize_cond(this, conds, join_list, FALSE,
conds= optimize_cond(this, conds, join_list, FALSE,
&cond_value, &cond_equal, OPT_LINK_EQUAL_FIELDS);
&cond_value, &cond_equal, OPT_LINK_EQUAL_FIELDS);
...
@@ -5246,6 +5250,11 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
...
@@ -5246,6 +5250,11 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
conds->update_used_tables();
conds->update_used_tables();
conds= conds->remove_eq_conds(join->thd, &join->cond_value, true);
conds= conds->remove_eq_conds(join->thd, &join->cond_value, true);
if (conds)
{
int prec_increment= thd->variables.div_precincrement;
conds= infer_inequalities(join, &conds, &join->cond_value, prec_increment);
}
if (conds && conds->type() == Item::COND_ITEM &&
if (conds && conds->type() == Item::COND_ITEM &&
((Item_cond*) conds)->functype() == Item_func::COND_AND_FUNC)
((Item_cond*) conds)->functype() == Item_func::COND_AND_FUNC)
join->cond_equal= &((Item_cond_and*) conds)->m_cond_equal;
join->cond_equal= &((Item_cond_and*) conds)->m_cond_equal;
...
...
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