Skip to content

Commit 0241d96

Browse files
kahatlendahlerlend
authored andcommitted
Bug#36076513: Refactor LEX to use getter/setter instead of public member
Add a getter and a setter to better encapsulate LEX::using_hypergraph_optimizer. Change-Id: I56467ccedbe929fa18961cc37d7990febd77bdc9
1 parent 386adb9 commit 0241d96

35 files changed

+122
-69
lines changed

sql/item.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5815,7 +5815,7 @@ bool is_null_on_empty_table(THD *thd, Item_field *i) {
58155815
qsl->group_list.elements == 0;
58165816
else
58175817
return (sl->resolve_place == Query_block::RESOLVE_SELECT_LIST ||
5818-
(thd->lex->using_hypergraph_optimizer && sl->is_ordered())) &&
5818+
(thd->lex->using_hypergraph_optimizer() && sl->is_ordered())) &&
58195819
sl->with_sum_func && sl->group_list.elements == 0 &&
58205820
thd->lex->in_sum_func == nullptr;
58215821
}

sql/item_cmpfunc.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2610,7 +2610,7 @@ float Item_func_ne::get_filtering_effect(THD *thd, table_map filter_for_table,
26102610
}
26112611
};
26122612

2613-
if (!thd->lex->using_hypergraph_optimizer) {
2613+
if (!thd->lex->using_hypergraph_optimizer()) {
26142614
return get_histogram_selectivity(
26152615
thd, *fld->field, histograms::enum_operator::NOT_EQUALS_TO, *this);
26162616

@@ -2672,7 +2672,7 @@ static double GetEqualSelectivity(THD *thd, Item_eq_base *equal,
26722672
// The index calculation might be useful for the original optimizer too,
26732673
// but we are loth to change existing plans and therefore restrict
26742674
// it to Hypergraph.
2675-
if (!thd->lex->using_hypergraph_optimizer) {
2675+
if (!thd->lex->using_hypergraph_optimizer()) {
26762676
return get_histogram_selectivity(
26772677
thd, *field.field, histograms::enum_operator::EQUALS_TO, *equal);
26782678

sql/item_func.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ const Item_field *Item_func::contributes_to_filter(
909909
// We are loth to change existing plans. Therefore we keep the existing
910910
// behavior for the original optimizer, which is to return nullptr if
911911
// any of PSEUDO_TABLE_BITS are set in used_tables().
912-
const table_map remaining_tables = thd->lex->using_hypergraph_optimizer
912+
const table_map remaining_tables = thd->lex->using_hypergraph_optimizer()
913913
? (~read_tables & ~PSEUDO_TABLE_BITS)
914914
: ~read_tables;
915915

sql/item_subselect.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ AccessPath *Item_in_subselect::root_access_path() const {
583583
// the query to the log for debugging, it isn't fully optimized
584584
// yet and might not yet have an iterator. Thus, return nullptr instead of
585585
// assert-failing.
586-
assert(current_thd->lex->using_hypergraph_optimizer);
586+
assert(current_thd->lex->using_hypergraph_optimizer());
587587
return nullptr;
588588
}
589589
}
@@ -1571,7 +1571,7 @@ bool Item_exists_subselect::is_semijoin_candidate(THD *thd) {
15711571
!inner->has_windows() && // 5
15721572
(outer->resolve_place == Query_block::RESOLVE_CONDITION || // 6a
15731573
(outer->resolve_place == Query_block::RESOLVE_JOIN_NEST && // 6a
1574-
(!thd->lex->using_hypergraph_optimizer ||
1574+
(!thd->lex->using_hypergraph_optimizer() ||
15751575
(thd->secondary_engine_optimization() ==
15761576
Secondary_engine_optimization::SECONDARY &&
15771577
!Overlaps(

sql/item_sum.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4809,7 +4809,7 @@ void Item_rank::update_after_wf_arguments_changed(THD *thd) {
48094809
// on them. This is called only during resolving with ROLLUP in case
48104810
// of old optimizer.
48114811
Item **item_to_be_changed;
4812-
if (!thd->lex->using_hypergraph_optimizer) {
4812+
if (!thd->lex->using_hypergraph_optimizer()) {
48134813
Item_ref *item_ref = down_cast<Item_ref *>(m_previous[i]->get_item());
48144814
item_to_be_changed = item_ref->ref_pointer();
48154815
} else {

sql/iterators/composite_iterators.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ bool AggregateIterator::Init() {
231231
// This is a hack. It would be good to get rid of the slice system altogether
232232
// (the hypergraph join optimizer does not use it).
233233
if (!(m_join->implicit_grouping || m_join->group_optimized_away) &&
234-
!thd()->lex->using_hypergraph_optimizer) {
234+
!thd()->lex->using_hypergraph_optimizer()) {
235235
m_output_slice = m_join->get_ref_item_slice();
236236
}
237237

sql/iterators/ref_row_iterators.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ FullTextSearchIterator::FullTextSearchIterator(THD *thd, TABLE *table,
609609
// hand, maintains alternative plans with and without index scans throughout
610610
// the planning, and doesn't determine whether it should use the indexed or
611611
// non-indexed plan until the full query plan has been constructed.
612-
if (thd->lex->using_hypergraph_optimizer) {
612+
if (thd->lex->using_hypergraph_optimizer()) {
613613
// Should not already be enabled.
614614
assert(!ft_func->score_from_index_scan);
615615
// Should operate on the main object.

sql/join_optimizer/access_path.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ unique_ptr_destroy_only<RowIterator> CreateIteratorFromAccessPath(
877877
}
878878
const Mem_root_array<Item *> *extra_conditions =
879879
GetExtraHashJoinConditions(
880-
mem_root, thd->lex->using_hypergraph_optimizer, conditions,
880+
mem_root, thd->lex->using_hypergraph_optimizer(), conditions,
881881
join_predicate->expr->join_conditions);
882882
if (extra_conditions == nullptr) return nullptr;
883883
const bool probe_input_batch_mode =
@@ -931,7 +931,7 @@ unique_ptr_destroy_only<RowIterator> CreateIteratorFromAccessPath(
931931
// path instead of being computed here? We do make the same checks in
932932
// the cost model, so perhaps it should set the flag as well.
933933
uint64_t *hash_table_generation =
934-
(thd->lex->using_hypergraph_optimizer &&
934+
(thd->lex->using_hypergraph_optimizer() &&
935935
path->parameter_tables == 0)
936936
? &join->hash_table_generation
937937
: nullptr;
@@ -949,7 +949,7 @@ unique_ptr_destroy_only<RowIterator> CreateIteratorFromAccessPath(
949949
// change existing behavior.) Note that we always try the probe input
950950
// first for left join and antijoin.
951951
const HashJoinInput first_input =
952-
(thd->lex->using_hypergraph_optimizer &&
952+
(thd->lex->using_hypergraph_optimizer() &&
953953
first_row_cost(*param.inner) > first_row_cost(*param.outer))
954954
? HashJoinInput::kProbe
955955
: HashJoinInput::kBuild;

sql/join_optimizer/explain_access_path.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ static unique_ptr<Json_object> SetObjectMembers(
13921392

13931393
const Mem_root_array<Item *> *extra_join_conditions =
13941394
GetExtraHashJoinConditions(
1395-
thd->mem_root, thd->lex->using_hypergraph_optimizer,
1395+
thd->mem_root, thd->lex->using_hypergraph_optimizer(),
13961396
equijoin_conditions, predicate->expr->join_conditions);
13971397
if (extra_join_conditions == nullptr) return nullptr;
13981398

sql/mysqld.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6768,6 +6768,7 @@ int init_common_variables() {
67686768
}
67696769
}
67706770
update_parser_max_mem_size();
6771+
update_optimizer_switch();
67716772

67726773
if (set_default_auth_plugin(default_auth_plugin,
67736774
strlen(default_auth_plugin))) {

0 commit comments

Comments
 (0)