Commit 6d3f297f authored by Galina Shalygina's avatar Galina Shalygina

MDEV-11107 Use table check constraints in optimizer

Project code on 10.5 branch
parent 8887effe
......@@ -147,6 +147,7 @@ SET (SQL_SOURCE
opt_trace.cc
table_cache.cc encryption.cc temporary_tables.cc
proxy_protocol.cc backup.cc xa.cc
opt_cmpfunc.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.cc
${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
......
......@@ -2035,6 +2035,10 @@ class Item: public Value_source,
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 linear_checker_processor(void *arg)
{ return true; }
virtual bool ineq_normalization_processor(void *arg)
{ return true; }
/*============== End of Item processor list ======================*/
/*
......@@ -2762,6 +2766,8 @@ class Item_basic_constant :public Item_basic_value
DBUG_ASSERT(0);
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,
return field->table->pos_in_table_list->outer_join;
}
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_insert_value;
friend class st_select_lex_unit;
......@@ -5760,6 +5768,8 @@ class Item_direct_view_ref :public Item_direct_ref
Item *field_transformer_for_having_pushdown(THD *thd, uchar *arg)
{ return this; }
Item *remove_item_direct_ref() { return this; }
bool linear_checker_processor(void *arg);
bool ineq_normalization_processor(void *arg);
};
......
......@@ -783,6 +783,8 @@ class Item_func_ge :public Item_bool_rowready_func2
Item *negated_item(THD *thd);
Item *get_copy(THD *thd)
{ 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
Item *negated_item(THD *thd);
Item *get_copy(THD *thd)
{ 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
Item *negated_item(THD *thd);
Item *get_copy(THD *thd)
{ 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
Item *negated_item(THD *thd);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_lt>(thd, this); }
bool linear_checker_processor(void *arg) { return false; }
bool ineq_normalization_processor(void *arg);
};
......
......@@ -1338,6 +1338,8 @@ class Item_func_plus :public Item_func_additive_op
my_decimal *decimal_op(my_decimal *);
Item *get_copy(THD *thd)
{ 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
......@@ -1373,6 +1375,8 @@ class Item_func_minus :public Item_func_additive_op
}
Item *get_copy(THD *thd)
{ 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
bool check_vcol_func_processor(void *arg) { return FALSE;}
Item *get_copy(THD *thd)
{ 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
void result_precision();
Item *get_copy(THD *thd)
{ 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
bool need_parentheses_in_default() { return true; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_neg>(thd, this); }
bool ineq_normalization_processor(void *arg);
};
......
......@@ -969,6 +969,7 @@ class Item_date_add_interval :public Item_handled_func
bool need_parentheses_in_default() { return true; }
Item *get_copy(THD *thd)
{ 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
const char *func_name() const { return sign > 0 ? "addtime" : "subtime"; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_add_time>(thd, this); }
bool ineq_normalization_processor(void *arg);
};
......
This diff is collapsed.
......@@ -68,6 +68,7 @@
#include "select_handler.h"
#include "my_json_writer.h"
#include "opt_trace.h"
#include "opt_cmpfunc.cc"
/*
A key part number that means we're using a fulltext scan.
......@@ -1945,6 +1946,9 @@ JOIN::optimize_inner()
}
}
if (add_constraints(this, &conds))
DBUG_RETURN(1);
conds= optimize_cond(this, conds, join_list, FALSE,
&cond_value, &cond_equal, OPT_LINK_EQUAL_FIELDS);
......@@ -5246,6 +5250,11 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
conds->update_used_tables();
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 &&
((Item_cond*) conds)->functype() == Item_func::COND_AND_FUNC)
join->cond_equal= &((Item_cond_and*) conds)->m_cond_equal;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment