MySQL 8.0.40
Source Code Documentation
reverse_index_range_scan.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef SQL_RANGE_OPTIMIZER_REVERSE_INDEX_RANGE_SCAN_H_
25#define SQL_RANGE_OPTIMIZER_REVERSE_INDEX_RANGE_SCAN_H_
26
27#include <sys/types.h>
28
31#include "sql/sql_list.h"
32
33/**
34 An iterator much like IndexRangeScanIterator, but it scans in the reverse
35 order. This makes it at times more complicated, but since it doesn't support
36 being a part of a ROR scan, it is also less complicated in many ways.
37
38 One could argue that this and IndexRangeScanIterator should be factored into
39 a common base class with separate _ASC and _DESC classes, but they don't
40 actually duplicate that much code.
41 */
43 public:
45 double expected_rows, uint index,
46 MEM_ROOT *return_mem_root, uint mrr_flags,
48 bool using_extended_key_parts);
50 int Read() override;
51 bool Init() override;
52
53 private:
54 static range_seq_t quick_range_rev_seq_init(void *init_param, uint, uint);
55
56 const uint m_index; /* Index this quick select uses */
57 const double m_expected_rows;
59
61 bool inited = false;
62
63 // TODO: pre-allocate space to avoid malloc/free for small number of columns.
65
66 uint m_mrr_flags; /* Flags to be used with MRR interface */
67
68 Bounds_checked_array<QUICK_RANGE *> ranges; /* ordered array of range ptrs */
69 /* Members needed to use the MRR interface */
71
72 QUICK_RANGE *last_range; // The range we are currently scanning, or nullptr.
74
75 /* Info about index we're scanning */
77
78 // Whether this reverse scan uses extended keyparts (in case of Innodb,
79 // secondary index is extended to include primary key).
81
84};
85
86#endif // SQL_RANGE_OPTIMIZER_REVERSE_INDEX_RANGE_SCAN_H_
A wrapper class which provides array bounds checking.
Definition: sql_array.h:47
Definition: key.h:57
Definition: range_optimizer.h:69
An iterator much like IndexRangeScanIterator, but it scans in the reverse order.
Definition: reverse_index_range_scan.h:42
~ReverseIndexRangeScanIterator() override
Definition: reverse_index_range_scan.cc:65
KEY_PART_INFO * key_part_info
Definition: reverse_index_range_scan.h:76
uint m_mrr_flags
Definition: reverse_index_range_scan.h:66
int cmp_prev(QUICK_RANGE *range)
Definition: reverse_index_range_scan.cc:272
bool m_using_extended_key_parts
Definition: reverse_index_range_scan.h:80
static range_seq_t quick_range_rev_seq_init(void *init_param, uint, uint)
Definition: reverse_index_range_scan.cc:282
QUICK_RANGE * last_range
Definition: reverse_index_range_scan.h:72
const double m_expected_rows
Definition: reverse_index_range_scan.h:57
MEM_ROOT * mem_root
Definition: reverse_index_range_scan.h:60
Bounds_checked_array< QUICK_RANGE * > ranges
Definition: reverse_index_range_scan.h:68
int Read() override
Read a single row.
Definition: reverse_index_range_scan.cc:123
const uint m_index
Definition: reverse_index_range_scan.h:56
bool inited
Definition: reverse_index_range_scan.h:61
int current_range_idx
Definition: reverse_index_range_scan.h:73
QUICK_RANGE_SEQ_CTX qr_traversal_ctx
Definition: reverse_index_range_scan.h:70
bool range_reads_after_key(QUICK_RANGE *range)
Definition: reverse_index_range_scan.cc:259
ReverseIndexRangeScanIterator(THD *thd, TABLE *table, ha_rows *examined_rows, double expected_rows, uint index, MEM_ROOT *return_mem_root, uint mrr_flags, Bounds_checked_array< QUICK_RANGE * > ranges, bool using_extended_key_parts)
Definition: reverse_index_range_scan.cc:35
MY_BITMAP column_bitmap
Definition: reverse_index_range_scan.h:64
ha_rows * m_examined_rows
Definition: reverse_index_range_scan.h:58
bool Init() override
Initialize or reinitialize the iterator.
Definition: reverse_index_range_scan.cc:71
THD * thd() const
Definition: row_iterator.h:228
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
Definition: row_iterator.h:234
TABLE * table() const
Definition: row_iterator.h:246
my_off_t ha_rows
Definition: my_base.h:1140
void * range_seq_t
Definition: handler.h:3651
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
Definition: my_bitmap.h:43
Definition: index_range_scan.h:51
Definition: table.h:1399
Definition: gen_lex_token.cc:149
unsigned int uint
Definition: uca9-dump.cc:75