Skip to content

Commit f3396d6

Browse files
author
Catalin Besleaga
committed
bug#34623563 Refactoring TABLE_LIST [TABLE_REF, noclose]
Renamed TABLE_REF to Index_lookup Change-Id: Ibc0423d389d27df3a868eff8c6b0d461668c19f8
1 parent 45a7a9a commit f3396d6

23 files changed

+140
-126
lines changed

Diff for: sql/item_subselect.cc

+7-7
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ const TABLE *Item_subselect::get_table() const {
313313
->get_table();
314314
}
315315

316-
const TABLE_REF &Item_subselect::get_table_ref() const {
316+
const Index_lookup &Item_subselect::index_lookup() const {
317317
return down_cast<subselect_hash_sj_engine *>(indexsubquery_engine)
318-
->get_table_ref();
318+
->index_lookup();
319319
}
320320

321321
join_type Item_subselect::get_join_type() const {
@@ -3218,8 +3218,8 @@ Query_block *SubqueryWithResult::single_query_block() const {
32183218
the index allows at most one NULL row.
32193219
- Create a new result sink that sends the result stream of the subquery to
32203220
the temporary table,
3221-
- Create and initialize TABLE_REF objects to perform lookups into the
3222-
indexed temporary table.
3221+
- Create and initialize Index_lookup objects to perform lookups into
3222+
the indexed temporary table.
32233223
32243224
@param thd thread handle
32253225
@param tmp_columns columns of temporary table
@@ -3287,8 +3287,8 @@ bool subselect_hash_sj_engine::setup(
32873287
/* 2. Create/initialize execution related objects. */
32883288

32893289
/*
3290-
Create and initialize the TABLE_REF used by the index lookup
3291-
iterator into the materialized subquery result.
3290+
Create and initialize the Index_lookup used by the index lookup iterator
3291+
into the materialized subquery result.
32923292
*/
32933293

32943294
table = tmp_table;
@@ -3497,7 +3497,7 @@ void subselect_hash_sj_engine::cleanup() {
34973497
if (unit->is_executed()) unit->reset_executed();
34983498
}
34993499

3500-
static int safe_index_read(TABLE *table, const TABLE_REF &ref) {
3500+
static int safe_index_read(TABLE *table, const Index_lookup &ref) {
35013501
int error = table->file->ha_index_read_map(
35023502
table->record[0], ref.key_buff, make_prev_keypart_map(ref.key_parts),
35033503
HA_READ_KEY_EXACT);

Diff for: sql/item_subselect.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class Item_subselect : public Item_result_field {
118118

119119
// For EXPLAIN. Only valid if engine_type() == HASH_SJ_ENGINE.
120120
const TABLE *get_table() const;
121-
const TABLE_REF &get_table_ref() const;
121+
const Index_lookup &index_lookup() const;
122122
join_type get_join_type() const;
123123

124124
void create_iterators(THD *thd);
@@ -804,7 +804,7 @@ class subselect_indexsubquery_engine {
804804
/// Table which is read, using one of eq_ref, ref, ref_or_null.
805805
TABLE *table{nullptr};
806806
TABLE_LIST *table_ref{nullptr};
807-
TABLE_REF ref;
807+
Index_lookup ref;
808808
join_type type{JT_UNKNOWN};
809809
Item *cond; /* The WHERE condition of subselect */
810810
ulonglong hash; /* Hash value calculated by RefIterator, when needed. */
@@ -826,7 +826,8 @@ class subselect_indexsubquery_engine {
826826
enum enum_engine_type { INDEXSUBQUERY_ENGINE, HASH_SJ_ENGINE };
827827

828828
subselect_indexsubquery_engine(TABLE *table, TABLE_LIST *table_ref,
829-
const TABLE_REF &ref, enum join_type join_type,
829+
const Index_lookup &ref,
830+
enum join_type join_type,
830831
Item_in_subselect *subs, Item *where,
831832
Item *having_arg)
832833
: table(table),
@@ -902,7 +903,7 @@ class subselect_hash_sj_engine final : public subselect_indexsubquery_engine {
902903
enum_engine_type engine_type() const override { return HASH_SJ_ENGINE; }
903904

904905
TABLE *get_table() const { return table; }
905-
const TABLE_REF &get_table_ref() const { return ref; }
906+
const Index_lookup &index_lookup() const { return ref; }
906907
enum join_type get_join_type() const { return type; }
907908
AccessPath *root_access_path() const { return m_root_access_path; }
908909
void create_iterators(THD *thd) override;

Diff for: sql/iterators/bka_iterator.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ int BKAIterator::Read() {
318318
}
319319

320320
MultiRangeRowIterator::MultiRangeRowIterator(
321-
THD *thd, TABLE *table, TABLE_REF *ref, int mrr_flags, JoinType join_type,
322-
const Prealloced_array<TABLE *, 4> &outer_input_tables, bool store_rowids,
323-
table_map tables_to_get_rowid_for)
321+
THD *thd, TABLE *table, Index_lookup *ref, int mrr_flags,
322+
JoinType join_type, const Prealloced_array<TABLE *, 4> &outer_input_tables,
323+
bool store_rowids, table_map tables_to_get_rowid_for)
324324
: TableRowIterator(thd, table),
325325
m_file(table->file),
326326
m_ref(ref),
@@ -394,7 +394,7 @@ uint MultiRangeRowIterator::MrrNextCallback(KEY_MULTI_RANGE *range) {
394394

395395
LoadBufferRowIntoTableBuffers(m_outer_input_tables, *m_current_pos);
396396

397-
construct_lookup_ref(thd(), table(), m_ref);
397+
construct_lookup(thd(), table(), m_ref);
398398
if (!m_ref->impossible_null_ref()) {
399399
break;
400400
}

Diff for: sql/iterators/bka_iterator.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ class Item;
6969
class JOIN;
7070
class MultiRangeRowIterator;
7171
class THD;
72+
struct Index_lookup;
7273
struct KEY_MULTI_RANGE;
7374
struct TABLE;
74-
struct TABLE_REF;
7575

7676
/**
7777
The BKA join iterator, with an arbitrary iterator tree on the outer side
@@ -280,8 +280,8 @@ class MultiRangeRowIterator final : public TableRowIterator {
280280
will make sure that table has the correct row ID already present
281281
after Read().
282282
*/
283-
MultiRangeRowIterator(THD *thd, TABLE *table, TABLE_REF *ref, int mrr_flags,
284-
JoinType join_type,
283+
MultiRangeRowIterator(THD *thd, TABLE *table, Index_lookup *ref,
284+
int mrr_flags, JoinType join_type,
285285
const Prealloced_array<TABLE *, 4> &outer_input_tables,
286286
bool store_rowids, table_map tables_to_get_rowid_for);
287287

@@ -380,7 +380,7 @@ class MultiRangeRowIterator final : public TableRowIterator {
380380
handler *const m_file;
381381

382382
/// The index condition.
383-
TABLE_REF *const m_ref;
383+
Index_lookup *const m_ref;
384384

385385
/// Flags passed on to MRR.
386386
const int m_mrr_flags;

Diff for: sql/iterators/ref_row_iterators.cc

+14-14
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ using std::move;
7373
using std::pair;
7474

7575
static inline pair<uchar *, key_part_map> FindKeyBufferAndMap(
76-
const TABLE_REF *ref);
76+
const Index_lookup *ref);
7777

78-
ConstIterator::ConstIterator(THD *thd, TABLE *table, TABLE_REF *table_ref,
78+
ConstIterator::ConstIterator(THD *thd, TABLE *table, Index_lookup *table_ref,
7979
ha_rows *examined_rows)
8080
: TableRowIterator(thd, table),
8181
m_ref(table_ref),
@@ -108,7 +108,7 @@ int ConstIterator::Read() {
108108
return err;
109109
}
110110

111-
EQRefIterator::EQRefIterator(THD *thd, TABLE *table, TABLE_REF *ref,
111+
EQRefIterator::EQRefIterator(THD *thd, TABLE *table, Index_lookup *ref,
112112
ha_rows *examined_rows)
113113
: TableRowIterator(thd, table),
114114
m_ref(ref),
@@ -181,7 +181,7 @@ int EQRefIterator::Read() {
181181
memcpy(m_ref->key_buff2, m_ref->key_buff, m_ref->key_length);
182182

183183
// Create new key for lookup
184-
m_ref->key_err = construct_lookup_ref(thd(), table(), m_ref);
184+
m_ref->key_err = construct_lookup(thd(), table(), m_ref);
185185
if (m_ref->key_err) {
186186
table()->set_no_row();
187187
return -1;
@@ -240,7 +240,7 @@ int EQRefIterator::Read() {
240240
it if it was not used in this invocation of EQRefIterator::Read().
241241
Only count locks, thus remembering if the record was left unused,
242242
and unlock already when pruning the current value of
243-
TABLE_REF buffer.
243+
Index_lookup buffer.
244244
@sa EQRefIterator::Read()
245245
*/
246246

@@ -250,7 +250,7 @@ void EQRefIterator::UnlockRow() {
250250
}
251251

252252
PushedJoinRefIterator::PushedJoinRefIterator(THD *thd, TABLE *table,
253-
TABLE_REF *ref, bool use_order,
253+
Index_lookup *ref, bool use_order,
254254
bool is_unique,
255255
ha_rows *examined_rows)
256256
: TableRowIterator(thd, table),
@@ -285,7 +285,7 @@ int PushedJoinRefIterator::Read() {
285285
return -1;
286286
}
287287

288-
if (construct_lookup_ref(thd(), table(), m_ref)) {
288+
if (construct_lookup(thd(), table(), m_ref)) {
289289
table()->set_no_row();
290290
return -1;
291291
}
@@ -373,7 +373,7 @@ int RefIterator<false>::Read() { // Forward read.
373373
table()->set_no_row();
374374
return -1;
375375
}
376-
if (construct_lookup_ref(thd(), table(), m_ref)) {
376+
if (construct_lookup(thd(), table(), m_ref)) {
377377
table()->set_no_row();
378378
return -1;
379379
}
@@ -426,7 +426,7 @@ int RefIterator<true>::Read() { // Reverse read.
426426
table()->set_no_row();
427427
return -1;
428428
}
429-
if (construct_lookup_ref(thd(), table(), m_ref)) {
429+
if (construct_lookup(thd(), table(), m_ref)) {
430430
table()->set_no_row();
431431
return -1;
432432
}
@@ -612,7 +612,7 @@ int DynamicRangeIterator::Read() {
612612
}
613613

614614
FullTextSearchIterator::FullTextSearchIterator(THD *thd, TABLE *table,
615-
TABLE_REF *ref,
615+
Index_lookup *ref,
616616
Item_func_match *ft_func,
617617
bool use_order, bool use_limit,
618618
ha_rows *examined_rows)
@@ -704,7 +704,7 @@ int FullTextSearchIterator::Read() {
704704
Reading of key with key reference and one part that may be NULL.
705705
*/
706706

707-
RefOrNullIterator::RefOrNullIterator(THD *thd, TABLE *table, TABLE_REF *ref,
707+
RefOrNullIterator::RefOrNullIterator(THD *thd, TABLE *table, Index_lookup *ref,
708708
bool use_order, double expected_rows,
709709
ha_rows *examined_rows)
710710
: TableRowIterator(thd, table),
@@ -735,7 +735,7 @@ int RefOrNullIterator::Read() {
735735
/* Perform "Late NULLs Filtering" (see internals manual for explanations)
736736
*/
737737
if (m_ref->impossible_null_ref() ||
738-
construct_lookup_ref(thd(), table(), m_ref)) {
738+
construct_lookup(thd(), table(), m_ref)) {
739739
// Skip searching for non-NULL rows; go straight to NULL rows.
740740
*m_ref->null_ref_key = true;
741741
}
@@ -787,7 +787,7 @@ RefOrNullIterator::~RefOrNullIterator() {
787787

788788
AlternativeIterator::AlternativeIterator(
789789
THD *thd, TABLE *table, unique_ptr_destroy_only<RowIterator> source,
790-
unique_ptr_destroy_only<RowIterator> table_scan_iterator, TABLE_REF *ref)
790+
unique_ptr_destroy_only<RowIterator> table_scan_iterator, Index_lookup *ref)
791791
: RowIterator(thd),
792792
m_source_iterator(std::move(source)),
793793
m_table_scan_iterator(std::move(table_scan_iterator)),
@@ -970,7 +970,7 @@ int TableValueConstructorIterator::Read() {
970970
}
971971

972972
static inline pair<uchar *, key_part_map> FindKeyBufferAndMap(
973-
const TABLE_REF *ref) {
973+
const Index_lookup *ref) {
974974
if (ref->keypart_hash != nullptr) {
975975
return make_pair(pointer_cast<uchar *>(ref->keypart_hash), key_part_map{1});
976976
} else {

Diff for: sql/iterators/ref_row_iterators.h

+16-15
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
class Item_func_match;
3737
class QEP_TAB;
3838
class THD;
39+
struct Index_lookup;
3940
struct TABLE;
40-
struct TABLE_REF;
4141

4242
/**
4343
For each record on the left side of a join (given in Init()), returns one or
@@ -47,7 +47,7 @@ template <bool Reverse>
4747
class RefIterator final : public TableRowIterator {
4848
public:
4949
// "examined_rows", if not nullptr, is incremented for each successful Read().
50-
RefIterator(THD *thd, TABLE *table, TABLE_REF *ref, bool use_order,
50+
RefIterator(THD *thd, TABLE *table, Index_lookup *ref, bool use_order,
5151
double expected_rows, ha_rows *examined_rows)
5252
: TableRowIterator(thd, table),
5353
m_ref(ref),
@@ -60,7 +60,7 @@ class RefIterator final : public TableRowIterator {
6060
int Read() override;
6161

6262
private:
63-
TABLE_REF *const m_ref;
63+
Index_lookup *const m_ref;
6464
const bool m_use_order;
6565
const double m_expected_rows;
6666
ha_rows *const m_examined_rows;
@@ -75,15 +75,15 @@ class RefIterator final : public TableRowIterator {
7575
class RefOrNullIterator final : public TableRowIterator {
7676
public:
7777
// "examined_rows", if not nullptr, is incremented for each successful Read().
78-
RefOrNullIterator(THD *thd, TABLE *table, TABLE_REF *ref, bool use_order,
78+
RefOrNullIterator(THD *thd, TABLE *table, Index_lookup *ref, bool use_order,
7979
double expected_rows, ha_rows *examined_rows);
8080
~RefOrNullIterator() override;
8181

8282
bool Init() override;
8383
int Read() override;
8484

8585
private:
86-
TABLE_REF *const m_ref;
86+
Index_lookup *const m_ref;
8787
const bool m_use_order;
8888
bool m_reading_first_row;
8989
const double m_expected_rows;
@@ -100,7 +100,8 @@ class RefOrNullIterator final : public TableRowIterator {
100100
class EQRefIterator final : public TableRowIterator {
101101
public:
102102
// "examined_rows", if not nullptr, is incremented for each successful Read().
103-
EQRefIterator(THD *thd, TABLE *table, TABLE_REF *ref, ha_rows *examined_rows);
103+
EQRefIterator(THD *thd, TABLE *table, Index_lookup *ref,
104+
ha_rows *examined_rows);
104105

105106
bool Init() override;
106107
int Read() override;
@@ -115,7 +116,7 @@ class EQRefIterator final : public TableRowIterator {
115116
void StartPSIBatchMode() override {}
116117

117118
private:
118-
TABLE_REF *const m_ref;
119+
Index_lookup *const m_ref;
119120
bool m_first_record_since_init;
120121
ha_rows *const m_examined_rows;
121122
};
@@ -127,7 +128,7 @@ class EQRefIterator final : public TableRowIterator {
127128
class ConstIterator final : public TableRowIterator {
128129
public:
129130
// "examined_rows", if not nullptr, is incremented for each successful Read().
130-
ConstIterator(THD *thd, TABLE *table, TABLE_REF *table_ref,
131+
ConstIterator(THD *thd, TABLE *table, Index_lookup *table_ref,
131132
ha_rows *examined_rows);
132133

133134
bool Init() override;
@@ -141,7 +142,7 @@ class ConstIterator final : public TableRowIterator {
141142
void UnlockRow() override {}
142143

143144
private:
144-
TABLE_REF *const m_ref;
145+
Index_lookup *const m_ref;
145146
bool m_first_record_since_init;
146147
ha_rows *const m_examined_rows;
147148
};
@@ -150,7 +151,7 @@ class ConstIterator final : public TableRowIterator {
150151
class FullTextSearchIterator final : public TableRowIterator {
151152
public:
152153
// "examined_rows", if not nullptr, is incremented for each successful Read().
153-
FullTextSearchIterator(THD *thd, TABLE *table, TABLE_REF *ref,
154+
FullTextSearchIterator(THD *thd, TABLE *table, Index_lookup *ref,
154155
Item_func_match *ft_func, bool use_order,
155156
bool use_limit, ha_rows *examined_rows);
156157
~FullTextSearchIterator() override;
@@ -159,7 +160,7 @@ class FullTextSearchIterator final : public TableRowIterator {
159160
int Read() override;
160161

161162
private:
162-
TABLE_REF *const m_ref;
163+
Index_lookup *const m_ref;
163164
Item_func_match *const m_ft_func;
164165
const bool m_use_order;
165166
const bool m_use_limit;
@@ -253,14 +254,14 @@ class DynamicRangeIterator final : public TableRowIterator {
253254
class PushedJoinRefIterator final : public TableRowIterator {
254255
public:
255256
// "examined_rows", if not nullptr, is incremented for each successful Read().
256-
PushedJoinRefIterator(THD *thd, TABLE *table, TABLE_REF *ref, bool use_order,
257-
bool is_unique, ha_rows *examined_rows);
257+
PushedJoinRefIterator(THD *thd, TABLE *table, Index_lookup *ref,
258+
bool use_order, bool is_unique, ha_rows *examined_rows);
258259

259260
bool Init() override;
260261
int Read() override;
261262

262263
private:
263-
TABLE_REF *const m_ref;
264+
Index_lookup *const m_ref;
264265
const bool m_use_order;
265266
const bool m_is_unique;
266267
bool m_first_record_since_init;
@@ -283,7 +284,7 @@ class AlternativeIterator final : public RowIterator {
283284
AlternativeIterator(THD *thd, TABLE *table,
284285
unique_ptr_destroy_only<RowIterator> source,
285286
unique_ptr_destroy_only<RowIterator> table_scan_iterator,
286-
TABLE_REF *ref);
287+
Index_lookup *ref);
287288

288289
bool Init() override;
289290

Diff for: sql/iterators/row_iterator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class RowIterator {
9696
9797
You can call Init() multiple times; subsequent calls will rewind the
9898
iterator (or reposition it, depending on whether the iterator takes in
99-
e.g. a TABLE_REF) and allow you to read the records anew.
99+
e.g. a Index_lookup) and allow you to read the records anew.
100100
*/
101101
virtual bool Init() = 0;
102102

0 commit comments

Comments
 (0)