Skip to content

Commit

Permalink
feat(StoneDB 8.0): st_select_lex::set_join is deleted in mysql8.0. (#598
Browse files Browse the repository at this point in the history
)

[summary]
1 take THD::LOCK_query_plan mutex to change the join value;
  • Loading branch information
lujiashun authored and mergify[bot] committed Sep 28, 2022
1 parent 3a8ce12 commit da4752b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
16 changes: 3 additions & 13 deletions sql/sql_lex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4398,23 +4398,13 @@ void Query_block::include_chain_in_global(Query_block **start) {
*start = this;
}

// stonedb8 start TODO: a better way.
//
// follows: from MySQL 5.7.36
//void st_select_lex::set_join(JOIN *join_arg)
//{
// master_unit()->thd->lock_query_plan();
// join= join_arg;
// master_unit()->thd->unlock_query_plan();
//}
//
void Query_block::set_join(JOIN *join_arg)
void Query_block::set_join(THD *thd, JOIN *join_arg)
{
thd->lock_query_plan();
join= join_arg;
thd->unlock_query_plan();
}

// stonedb8 end

/**
Helper function which handles the "ON conditions" part of
Query_block::get_optimizable_conditions().
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_lex.h
Original file line number Diff line number Diff line change
Expand Up @@ -1797,7 +1797,7 @@ class Query_block {
The function sets the pointer only after acquiring THD::LOCK_query_plan
mutex. This is needed to avoid races when EXPLAIN FOR CONNECTION is used.
*/
void set_join(JOIN *join_arg);
void set_join(THD *thd, JOIN *join_arg);

/**
Does permanent transformations which are local to a query block (which do
Expand Down
6 changes: 3 additions & 3 deletions storage/tianmu/core/engine_execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ int optimize_select(THD *thd, ulong select_options, Query_result *result,
}
if (!(join = new JOIN(thd, select_lex)))
return true; /* purecov: inspected */
select_lex->set_join(join); // stonedb8 TODO
select_lex->set_join(thd, join);

}
join->best_rowcount = 2;
Expand Down Expand Up @@ -564,7 +564,7 @@ int Query_expression::optimize_for_tianmu(THD *thd) {
cleanup(thd, 0); // stonedb8
return true;
}
sl->set_join(join);
sl->set_join(thd, join);
}
if (is_optimized())
sl->join->reset();
Expand Down Expand Up @@ -651,7 +651,7 @@ int Query_expression::optimize_after_tianmu(THD *thd)
cleanup(thd, 0); // stonedb8
return true;
}
sl->set_join(join);
sl->set_join(thd, join);
}
int res = sl->join->optimize(2);
if (res) {
Expand Down

0 comments on commit da4752b

Please sign in to comment.