Commit 74093e9f authored by unknown's avatar unknown

MWL#89 Addressing Sergey's review comments - Part 1.

Address the 'trivial' part of Sergey's review of MWL#89.
parent 38cc265f
...@@ -536,7 +536,7 @@ class Item { ...@@ -536,7 +536,7 @@ class Item {
SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM, TYPE_HOLDER, SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM, TYPE_HOLDER,
PARAM_ITEM, TRIGGER_FIELD_ITEM, DECIMAL_ITEM, PARAM_ITEM, TRIGGER_FIELD_ITEM, DECIMAL_ITEM,
XPATH_NODESET, XPATH_NODESET_CMP, XPATH_NODESET, XPATH_NODESET_CMP,
VIEW_FIXER_ITEM, EXPR_CACHE_ITEM, UNKNOWN_ITEM}; VIEW_FIXER_ITEM, EXPR_CACHE_ITEM};
enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE }; enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };
......
...@@ -1766,7 +1766,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN * join, ...@@ -1766,7 +1766,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN * join,
*having_item= new_having; *having_item= new_having;
} }
else else
DBUG_ASSERT(FALSE); DBUG_ASSERT(false);
} }
} }
......
...@@ -3640,7 +3640,7 @@ static void remove_subq_pushed_predicates(JOIN *join, Item **where) ...@@ -3640,7 +3640,7 @@ static void remove_subq_pushed_predicates(JOIN *join, Item **where)
/** /**
Optimize all subqueries of a query that have were flattened into a semijoin. Optimize all subqueries of a query that were not flattened into a semijoin.
@details @details
Optimize all immediate children subqueries of a query. Optimize all immediate children subqueries of a query.
...@@ -3699,7 +3699,7 @@ bool JOIN::optimize_unflattened_subqueries() ...@@ -3699,7 +3699,7 @@ bool JOIN::optimize_unflattened_subqueries()
bool JOIN::choose_subquery_plan(table_map join_tables) bool JOIN::choose_subquery_plan(table_map join_tables)
{ {
Query_plan_state save_qep; /* The original QEP of the subquery. */ Join_plan_state save_qep; /* The original QEP of the subquery. */
enum_reopt_result reopt_result= REOPT_NONE; enum_reopt_result reopt_result= REOPT_NONE;
Item_in_subselect *in_subs; Item_in_subselect *in_subs;
......
...@@ -959,7 +959,8 @@ JOIN::optimize() ...@@ -959,7 +959,8 @@ JOIN::optimize()
*/ */
if ((res=opt_sum_query(thd, select_lex->leaf_tables, all_fields, conds))) if ((res=opt_sum_query(thd, select_lex->leaf_tables, all_fields, conds)))
{ {
if (res == HA_ERR_KEY_NOT_FOUND || res < 0) DBUG_ASSERT(res >= 0);
if (res == HA_ERR_KEY_NOT_FOUND)
{ {
DBUG_PRINT("info",("No matching min/max row")); DBUG_PRINT("info",("No matching min/max row"));
zero_result_cause= "No matching min/max row"; zero_result_cause= "No matching min/max row";
...@@ -20528,7 +20529,7 @@ void JOIN::set_allowed_join_cache_types() ...@@ -20528,7 +20529,7 @@ void JOIN::set_allowed_join_cache_types()
@param save_to The object into which the current query plan state is saved @param save_to The object into which the current query plan state is saved
*/ */
void JOIN::save_query_plan(Query_plan_state *save_to) void JOIN::save_query_plan(Join_plan_state *save_to)
{ {
if (keyuse.elements) if (keyuse.elements)
{ {
...@@ -20558,7 +20559,7 @@ void JOIN::save_query_plan(Query_plan_state *save_to) ...@@ -20558,7 +20559,7 @@ void JOIN::save_query_plan(Query_plan_state *save_to)
@param The object from which the current query plan state is restored. @param The object from which the current query plan state is restored.
*/ */
void JOIN::restore_query_plan(Query_plan_state *restore_from) void JOIN::restore_query_plan(Join_plan_state *restore_from)
{ {
if (restore_from->keyuse.elements) if (restore_from->keyuse.elements)
{ {
...@@ -20607,7 +20608,7 @@ void JOIN::restore_query_plan(Query_plan_state *restore_from) ...@@ -20607,7 +20608,7 @@ void JOIN::restore_query_plan(Query_plan_state *restore_from)
JOIN::enum_reopt_result JOIN::enum_reopt_result
JOIN::reoptimize(Item *added_where, table_map join_tables, JOIN::reoptimize(Item *added_where, table_map join_tables,
Query_plan_state *save_to) Join_plan_state *save_to)
{ {
DYNAMIC_ARRAY added_keyuse; DYNAMIC_ARRAY added_keyuse;
SARGABLE_PARAM *sargables= 0; /* Used only as a dummy parameter. */ SARGABLE_PARAM *sargables= 0; /* Used only as a dummy parameter. */
......
...@@ -611,9 +611,10 @@ class JOIN :public Sql_alloc ...@@ -611,9 +611,10 @@ class JOIN :public Sql_alloc
/** /**
The subset of the state of a JOIN that represents an optimized query The subset of the state of a JOIN that represents an optimized query
execution plan. Allows saving/restoring different plans for the same query. execution plan. Allows saving/restoring different JOIN plans for the same
query.
*/ */
class Query_plan_state { class Join_plan_state {
public: public:
DYNAMIC_ARRAY keyuse; /* Copy of the JOIN::keyuse array. */ DYNAMIC_ARRAY keyuse; /* Copy of the JOIN::keyuse array. */
POSITION best_positions[MAX_TABLES+1]; /* Copy of JOIN::best_positions */ POSITION best_positions[MAX_TABLES+1]; /* Copy of JOIN::best_positions */
...@@ -622,13 +623,13 @@ class JOIN :public Sql_alloc ...@@ -622,13 +623,13 @@ class JOIN :public Sql_alloc
/* Copies of JOIN_TAB::checked_keys for each JOIN_TAB. */ /* Copies of JOIN_TAB::checked_keys for each JOIN_TAB. */
key_map join_tab_checked_keys[MAX_TABLES]; key_map join_tab_checked_keys[MAX_TABLES];
public: public:
Query_plan_state() Join_plan_state()
{ {
keyuse.elements= 0; keyuse.elements= 0;
keyuse.buffer= NULL; keyuse.buffer= NULL;
} }
Query_plan_state(JOIN *join); Join_plan_state(JOIN *join);
~Query_plan_state() ~Join_plan_state()
{ {
delete_dynamic(&keyuse); delete_dynamic(&keyuse);
} }
...@@ -644,9 +645,9 @@ class JOIN :public Sql_alloc ...@@ -644,9 +645,9 @@ class JOIN :public Sql_alloc
/* Support for plan reoptimization with rewritten conditions. */ /* Support for plan reoptimization with rewritten conditions. */
enum_reopt_result reoptimize(Item *added_where, table_map join_tables, enum_reopt_result reoptimize(Item *added_where, table_map join_tables,
Query_plan_state *save_to); Join_plan_state *save_to);
void save_query_plan(Query_plan_state *save_to); void save_query_plan(Join_plan_state *save_to);
void restore_query_plan(Query_plan_state *restore_from); void restore_query_plan(Join_plan_state *restore_from);
/* Choose a subquery plan for a table-less subquery. */ /* Choose a subquery plan for a table-less subquery. */
bool choose_tableless_subquery_plan(); bool choose_tableless_subquery_plan();
...@@ -748,7 +749,7 @@ class JOIN :public Sql_alloc ...@@ -748,7 +749,7 @@ class JOIN :public Sql_alloc
*/ */
double best_read; double best_read;
/* /*
Estimated result rows (fanout) of the whole query. If this is a subquery Estimated result rows (fanout) of the join operation. If this is a subquery
that is reexecuted multiple times, this value includes the estiamted # of that is reexecuted multiple times, this value includes the estiamted # of
reexecutions. This value is equal to the multiplication of all reexecutions. This value is equal to the multiplication of all
join->positions[i].records_read of a JOIN. join->positions[i].records_read of a JOIN.
......
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