1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008-2009 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_OPTIMIZER_QUICK_ROR_INTERSECT_SELECT_H
21
#define DRIZZLED_OPTIMIZER_QUICK_ROR_INTERSECT_SELECT_H
23
#include "drizzled/optimizer/range.h"
34
Rowid-Ordered Retrieval (ROR) index intersection quick select.
35
This quick select produces intersection of row sequences returned
36
by several QuickRangeSelects it "merges".
38
All merged QuickRangeSelects must return rowids in rowid order.
39
QuickRorIntersectSelect will return rows in rowid order, too.
41
All merged quick selects retrieve {rowid, covered_fields} tuples (not full
43
QuickRorIntersectSelect retrieves full records if it is not being used
44
by QuickRorIntersectSelect and all merged quick selects together don't
45
cover needed all fields.
47
If one of the merged quick selects is a Clustered PK range scan, it is
48
used only to filter rowid sequence produced by other merged quick selects.
50
class QuickRorIntersectSelect : public QuickSelectInterface
54
QuickRorIntersectSelect(Session *session,
56
bool retrieve_full_rows,
57
MEM_ROOT *parent_alloc);
59
~QuickRorIntersectSelect();
62
* Do post-constructor initialization.
64
* QuickRorIntersectSelect::init()
68
* @retval other Error code
73
* Initialize quick select for row retrieval.
78
* @retval other Error code
83
* Retrieve next record.
85
* QuickRorIntersectSelect::get_next()
88
* Invariant on enter/exit: all intersected selects have retrieved all index
89
* records with rowid <= some_rowid_val and no intersected select has
90
* retrieved any index records with rowid > some_rowid_val.
91
* We start fresh and loop until we have retrieved the same rowid in each of
92
* the key scans or we got an error.
94
* If a Clustered PK scan is present, it is used only to check if row
95
* satisfies its condition (and never used for row retrieval).
99
* @retval other - Error code if any error occurred.
103
bool reverse_sorted() const
108
bool unique_key_range() const
115
return QS_TYPE_ROR_INTERSECT;
118
void add_keys_and_lengths(String *key_names, String *used_lengths);
119
void add_info_string(String *str);
120
bool is_keys_used(const MyBitmap *fields);
123
* Initialize this quick select to be a part of a ROR-merged scan.
125
* QuickRorIntersectSelect::init_ror_merged_scan()
126
* reuse_handler If true, use head->cursor, otherwise create separate
130
* @retval other error code
132
int init_ror_merged_scan(bool reuse_handler);
135
* Add a merged quick select to this ROR-intersection quick select.
138
* QuickRorIntersectSelect::push_quick_back()
139
* quick Quick select to be added. The quick select must return
140
* rows in rowid order.
142
* This call can only be made before init() is called.
146
* @retval true Out of memory.
148
bool push_quick_back(QuickRangeSelect *quick_sel_range);
151
* Range quick selects this intersection consists of, not including
154
std::vector<QuickRangeSelect *> quick_selects;
157
* Merged quick select that uses Clustered PK, if there is one. This quick
158
* select is not used for row retrieval, it is used for row retrieval.
160
QuickRangeSelect *cpk_quick;
162
MEM_ROOT alloc; /**< Memory pool for this and merged quick selects data. */
163
Session *session; /**< Pointer to the current session */
164
bool need_to_fetch_row; /**< if true, do retrieve full table records. */
165
/** in top-level quick select, true if merged scans where initialized */
169
} /* namespace optimizer */
171
} /* namespace drizzled */
173
#endif /* DRIZZLED_OPTIMIZER_QUICK_ROR_INTERSECT_SELECT_H */