|
27 | 27 | in some way). See row_iterator.h.
|
28 | 28 | */
|
29 | 29 |
|
30 |
| -#include "sql/records.h" |
31 |
| - |
32 |
| -#include <string.h> |
33 |
| -#include <algorithm> |
| 30 | +#include <assert.h> |
34 | 31 | #include <atomic>
|
35 |
| -#include <new> |
| 32 | +#include <memory> |
| 33 | +#include <string> |
| 34 | +#include <utility> |
| 35 | +#include <vector> |
36 | 36 |
|
| 37 | +#include "my_alloc.h" |
37 | 38 | #include "my_base.h"
|
38 | 39 | #include "my_dbug.h"
|
39 | 40 | #include "my_inttypes.h"
|
40 | 41 | #include "my_sys.h"
|
| 42 | +#include "mysqld_error.h" |
41 | 43 | #include "sql/debug_sync.h"
|
42 | 44 | #include "sql/handler.h"
|
43 |
| -#include "sql/item.h" |
| 45 | +#include "sql/iterators/basic_row_iterators.h" |
| 46 | +#include "sql/iterators/row_iterator.h" |
| 47 | +#include "sql/iterators/timing_iterator.h" |
44 | 48 | #include "sql/join_optimizer/access_path.h"
|
45 |
| -#include "sql/join_optimizer/bit_utils.h" |
46 |
| -#include "sql/key.h" |
47 |
| -#include "sql/opt_explain.h" |
| 49 | +#include "sql/mem_root_array.h" |
| 50 | +#include "sql/sql_bitmap.h" |
48 | 51 | #include "sql/sql_class.h" // THD
|
49 |
| -#include "sql/sql_const.h" |
50 | 52 | #include "sql/sql_executor.h"
|
51 |
| -#include "sql/sql_optimizer.h" |
52 | 53 | #include "sql/sql_sort.h"
|
53 | 54 | #include "sql/sql_tmp_table.h"
|
| 55 | +#include "sql/system_variables.h" |
54 | 56 | #include "sql/table.h"
|
55 |
| -#include "sql/timing_iterator.h" |
| 57 | + |
| 58 | +struct POSITION; |
56 | 59 |
|
57 | 60 | using std::string;
|
58 | 61 | using std::vector;
|
@@ -136,83 +139,6 @@ int IndexScanIterator<true>::Read() { // Backward read.
|
136 | 139 | template class IndexScanIterator<true>;
|
137 | 140 | template class IndexScanIterator<false>;
|
138 | 141 |
|
139 |
| -/** |
140 |
| - create_table_access_path is used to scan by using a number of different |
141 |
| - methods. Which method to use is set-up in this call so that you can |
142 |
| - create an iterator from the returned access path and fetch rows through |
143 |
| - said iterator afterwards. |
144 |
| -
|
145 |
| - @param thd Thread handle |
146 |
| - @param table Table the data [originally] comes from |
147 |
| - @param range_scan AccessPath to scan the table with, or nullptr |
148 |
| - @param table_ref |
149 |
| - Position for the table, must be non-nullptr for |
150 |
| - WITH RECURSIVE |
151 |
| - @param position Place to get cost information from, or nullptr |
152 |
| - @param count_examined_rows |
153 |
| - See AccessPath::count_examined_rows. |
154 |
| - */ |
155 |
| -AccessPath *create_table_access_path(THD *thd, TABLE *table, |
156 |
| - AccessPath *range_scan, |
157 |
| - TABLE_LIST *table_ref, POSITION *position, |
158 |
| - bool count_examined_rows) { |
159 |
| - AccessPath *path; |
160 |
| - if (range_scan != nullptr) { |
161 |
| - range_scan->count_examined_rows = count_examined_rows; |
162 |
| - path = range_scan; |
163 |
| - } else if (table_ref != nullptr && table_ref->is_recursive_reference()) { |
164 |
| - path = NewFollowTailAccessPath(thd, table, count_examined_rows); |
165 |
| - } else { |
166 |
| - path = NewTableScanAccessPath(thd, table, count_examined_rows); |
167 |
| - } |
168 |
| - if (position != nullptr) { |
169 |
| - SetCostOnTableAccessPath(*thd->cost_model(), position, |
170 |
| - /*is_after_filter=*/false, path); |
171 |
| - } |
172 |
| - return path; |
173 |
| -} |
174 |
| - |
175 |
| -unique_ptr_destroy_only<RowIterator> init_table_iterator( |
176 |
| - THD *thd, TABLE *table, AccessPath *range_scan, TABLE_LIST *table_ref, |
177 |
| - POSITION *position, bool ignore_not_found_rows, bool count_examined_rows) { |
178 |
| - unique_ptr_destroy_only<RowIterator> iterator; |
179 |
| - |
180 |
| - empty_record(table); |
181 |
| - |
182 |
| - if (table->unique_result.io_cache && |
183 |
| - my_b_inited(table->unique_result.io_cache)) { |
184 |
| - DBUG_PRINT("info", ("using SortFileIndirectIterator")); |
185 |
| - iterator = NewIterator<SortFileIndirectIterator>( |
186 |
| - thd, thd->mem_root, Mem_root_array<TABLE *>{table}, |
187 |
| - table->unique_result.io_cache, ignore_not_found_rows, |
188 |
| - /*has_null_flags=*/false, |
189 |
| - /*examined_rows=*/nullptr); |
190 |
| - table->unique_result.io_cache = |
191 |
| - nullptr; // Now owned by SortFileIndirectIterator. |
192 |
| - } else if (table->unique_result.has_result_in_memory()) { |
193 |
| - /* |
194 |
| - The Unique class never puts its results into table->sort's |
195 |
| - Filesort_buffer. |
196 |
| - */ |
197 |
| - assert(!table->unique_result.sorted_result_in_fsbuf); |
198 |
| - DBUG_PRINT("info", ("using SortBufferIndirectIterator (unique)")); |
199 |
| - iterator = NewIterator<SortBufferIndirectIterator>( |
200 |
| - thd, thd->mem_root, Mem_root_array<TABLE *>{table}, |
201 |
| - &table->unique_result, ignore_not_found_rows, /*has_null_flags=*/false, |
202 |
| - /*examined_rows=*/nullptr); |
203 |
| - } else { |
204 |
| - AccessPath *path = create_table_access_path( |
205 |
| - thd, table, range_scan, table_ref, position, count_examined_rows); |
206 |
| - iterator = CreateIteratorFromAccessPath(thd, path, |
207 |
| - /*join=*/nullptr, |
208 |
| - /*eligible_for_batch_mode=*/false); |
209 |
| - } |
210 |
| - if (iterator->Init()) { |
211 |
| - return nullptr; |
212 |
| - } |
213 |
| - return iterator; |
214 |
| -} |
215 |
| - |
216 | 142 | /**
|
217 | 143 | The default implementation of unlock-row method of RowIterator,
|
218 | 144 | used in all access methods except EQRefIterator.
|
|
0 commit comments