1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008-2009 Sun Microsystems
4
* Copyright (C) 2008-2009 Sun Microsystems, Inc.
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
78
77
/* Table read plans are allocated on memory::Root and are never deleted */
79
78
static void *operator new(size_t size, memory::Root *mem_root)
81
return (void*) alloc_root(mem_root, (uint32_t) size);
80
return (void*) mem_root->alloc_root((uint32_t) size);
84
83
static void operator delete(void *, size_t)
105
SEL_ARG *key; /* set of intervals to be used in "range" method retrieval */
106
uint32_t key_idx; /* key number in Parameter::key */
108
uint32_t mrr_buf_size;
106
110
RangeReadPlan(SEL_ARG *key_arg, uint32_t idx_arg, uint32_t mrr_flags_arg)
109
113
key_idx(idx_arg),
110
mrr_flags(mrr_flags_arg),
114
mrr_flags(mrr_flags_arg)
114
116
virtual ~RangeReadPlan() {} /* Remove gcc warning */
116
118
QuickSelectInterface *make_quick(Parameter *param, bool, memory::Root *parent_alloc);
118
void setMRRBufferSize(uint32_t in_mrr_buf_size)
120
mrr_buf_size= in_mrr_buf_size;
123
uint32_t getKeyIndex() const
128
uint32_t getMRRBufferSize() const
135
/** set of intervals to be used in "range" method retrieval */
137
/** key number in Parameter::key */
140
uint32_t mrr_buf_size;
150
RorIntersectReadPlan()
155
index_scan_costs(0.0)
158
virtual ~RorIntersectReadPlan()
160
std::for_each(ror_range_scans.begin(),
161
ror_range_scans.end(),
163
ror_range_scans.clear();
128
RorIntersectReadPlan() {} /* Remove gcc warning */
129
virtual ~RorIntersectReadPlan() {} /* Remove gcc warning */
166
131
QuickSelectInterface *make_quick(Parameter *param,
167
132
bool retrieve_full_rows,
168
133
memory::Root *parent_alloc);
170
void setRowRetrievalNecessary(bool in_is_covering)
172
is_covering= in_is_covering;
175
void setCostOfIndexScans(double in_index_scan_costs)
177
index_scan_costs= in_index_scan_costs;
181
* @return true if row retrival phase is necessary.
183
bool isRowRetrievalNecessary() const
185
return ! is_covering;
189
* @return the sum of the cost of each index scan
191
double getCostOfIndexScans() const
193
return index_scan_costs;
196
/** Vector of pointers to ROR range scans used in this intersection */
197
std::vector<struct st_ror_scan_info *> ror_range_scans;
198
struct st_ror_scan_info *cpk_scan; /* Clustered PK scan, if there is one */
202
/** true if no row retrieval phase is necessary */
204
/* SUM(cost(index_scan)) */
205
double index_scan_costs;
135
/* Array of pointers to ROR range scans used in this intersection */
136
RorScanInfo **first_scan;
137
RorScanInfo **last_scan; /* End of the above array */
138
RorScanInfo *cpk_scan; /* Clustered PK scan, if there is one */
140
bool is_covering; /* true if no row retrieval phase is necessary */
141
double index_scan_costs; /* SUM(cost(index_scan)) */
221
157
QuickSelectInterface *make_quick(Parameter *param,
222
158
bool retrieve_full_rows,
223
159
memory::Root *parent_alloc);
224
/** vector of plans for merged scans */
225
std::vector<TableReadPlan *> merged_scans;
160
TableReadPlan **first_ror; /* array of ptrs to plans for merged scans */
161
TableReadPlan **last_ror; /* end of the above array */
252
188
class GroupMinMaxReadPlan : public TableReadPlan
193
KeyPartInfo *min_max_arg_part;
194
uint32_t group_prefix_len;
195
uint32_t used_key_parts;
196
uint32_t group_key_parts;
199
uint32_t key_infix_len;
200
unsigned char key_infix[MAX_KEY_LENGTH];
201
SEL_TREE *range_tree; /* Represents all range predicates in the query. */
202
SEL_ARG *index_tree; /* The SEL_ARG sub-tree corresponding to index_info. */
203
uint32_t param_idx; /* Index of used key in param->key. */
204
/* Number of records selected by the ranges in index_tree. */
206
ha_rows quick_prefix_records;
257
209
GroupMinMaxReadPlan(bool have_min_arg,
258
210
bool have_max_arg,
259
KEY_PART_INFO *min_max_arg_part_arg,
211
KeyPartInfo *min_max_arg_part_arg,
260
212
uint32_t group_prefix_len_arg,
261
213
uint32_t used_key_parts_arg,
262
214
uint32_t group_key_parts_arg,
215
KeyInfo *index_info_arg,
264
216
uint32_t index_arg,
265
217
uint32_t key_infix_len_arg,
266
218
unsigned char *key_infix_arg,
281
232
key_infix_len(key_infix_len_arg),
282
233
range_tree(tree_arg),
283
234
index_tree(index_tree_arg),
284
param_idx(param_idx_arg)
235
param_idx(param_idx_arg),
236
quick_prefix_records(quick_prefix_records_arg)
286
238
if (key_infix_len)
287
239
memcpy(this->key_infix, key_infix_arg, key_infix_len);
291
243
QuickSelectInterface *make_quick(Parameter *param,
292
244
bool retrieve_full_rows,
293
245
memory::Root *parent_alloc);
295
/* Number of records selected by the ranges in index_tree. */
296
ha_rows quick_prefix_records;
302
KEY_PART_INFO *min_max_arg_part;
303
uint32_t group_prefix_len;
304
uint32_t used_key_parts;
305
uint32_t group_key_parts;
308
uint32_t key_infix_len;
309
unsigned char key_infix[MAX_KEY_LENGTH];
310
SEL_TREE *range_tree; /* Represents all range predicates in the query. */
311
SEL_ARG *index_tree; /* The SEL_ARG sub-tree corresponding to index_info. */
312
uint32_t param_idx; /* Index of used key in param->key. */