275
276
uint32_t quick_range_seq_next(range_seq_t rseq, KEY_MULTI_RANGE *range);
279
Rowid-Ordered Retrieval (ROR) index intersection quick select.
280
This quick select produces intersection of row sequences returned
281
by several QuickRangeSelects it "merges".
283
All merged QuickRangeSelects must return rowids in rowid order.
284
QUICK_ROR_INTERSECT_SELECT will return rows in rowid order, too.
286
All merged quick selects retrieve {rowid, covered_fields} tuples (not full
288
QUICK_ROR_INTERSECT_SELECT retrieves full records if it is not being used
289
by QUICK_ROR_INTERSECT_SELECT and all merged quick selects together don't
290
cover needed all fields.
292
If one of the merged quick selects is a Clustered PK range scan, it is
293
used only to filter rowid sequence produced by other merged quick selects.
295
class QUICK_ROR_INTERSECT_SELECT : public QuickSelectInterface
298
QUICK_ROR_INTERSECT_SELECT(Session *session, Table *table,
299
bool retrieve_full_rows,
300
MEM_ROOT *parent_alloc);
301
~QUICK_ROR_INTERSECT_SELECT();
306
bool reverse_sorted()
310
bool unique_key_range()
316
return QS_TYPE_ROR_INTERSECT;
318
void add_keys_and_lengths(String *key_names, String *used_lengths);
319
void add_info_string(String *str);
320
bool is_keys_used(const MyBitmap *fields);
321
int init_ror_merged_scan(bool reuse_handler);
322
bool push_quick_back(QuickRangeSelect *quick_sel_range);
325
* Range quick selects this intersection consists of, not including
328
List<QuickRangeSelect> quick_selects;
331
* Merged quick select that uses Clustered PK, if there is one. This quick
332
* select is not used for row retrieval, it is used for row retrieval.
334
QuickRangeSelect *cpk_quick;
336
MEM_ROOT alloc; /**< Memory pool for this and merged quick selects data. */
337
Session *session; /**< Pointer to the current session */
338
bool need_to_fetch_row; /**< if true, do retrieve full table records. */
339
/** in top-level quick select, true if merged scans where initialized */
345
* This function object is defined in drizzled/optimizer/range.cc
346
* We need this here for the priority_queue definition in the
347
* QUICK_ROR_UNION_SELECT class.
349
class compare_functor;
352
Rowid-Ordered Retrieval index union select.
353
This quick select produces union of row sequences returned by several
354
quick select it "merges".
356
All merged quick selects must return rowids in rowid order.
357
QUICK_ROR_UNION_SELECT will return rows in rowid order, too.
359
All merged quick selects are set not to retrieve full table records.
360
ROR-union quick select always retrieves full records.
363
class QUICK_ROR_UNION_SELECT : public QuickSelectInterface
366
QUICK_ROR_UNION_SELECT(Session *session, Table *table);
367
~QUICK_ROR_UNION_SELECT();
372
bool reverse_sorted()
376
bool unique_key_range()
382
return QS_TYPE_ROR_UNION;
384
void add_keys_and_lengths(String *key_names, String *used_lengths);
385
void add_info_string(String *str);
386
bool is_keys_used(const MyBitmap *fields);
388
bool push_quick_back(QuickSelectInterface *quick_sel_range);
390
List<QuickSelectInterface> quick_selects; /**< Merged quick selects */
392
/** Priority queue for merge operation */
393
std::priority_queue<QuickSelectInterface *, std::vector<QuickSelectInterface *>, compare_functor > *queue;
394
MEM_ROOT alloc; /**< Memory pool for this and merged quick selects data. */
396
Session *session; /**< current thread */
397
unsigned char *cur_rowid; /**< buffer used in get_next() */
398
unsigned char *prev_rowid; /**< rowid of last row returned by get_next() */
399
bool have_prev_rowid; /**< true if prev_rowid has valid data */
400
uint32_t rowid_length; /**< table rowid length */
406
Index scan for GROUP-BY queries with MIN/MAX aggregate functions.
408
This class provides a specialized index access method for GROUP-BY queries
411
SELECT A_1,...,A_k, [B_1,...,B_m], [MIN(C)], [MAX(C)]
413
WHERE [RNG(A_1,...,A_p ; where p <= k)]
414
[AND EQ(B_1,...,B_m)]
416
[AND PA(A_i1,...,A_iq)]
417
GROUP BY A_1,...,A_k;
421
SELECT DISTINCT A_i1,...,A_ik
423
WHERE [RNG(A_1,...,A_p ; where p <= k)]
424
[AND PA(A_i1,...,A_iq)];
426
where all selected fields are parts of the same index.
427
The class of queries that can be processed by this quick select is fully
428
specified in the description of get_best_trp_group_min_max() in optimizer/range.cc.
430
The get_next() method directly produces result tuples, thus obviating the
431
need to call end_send_group() because all grouping is already done inside
434
Since one of the requirements is that all select fields are part of the same
435
index, this class produces only index keys, and not complete records.
437
class QUICK_GROUP_MIN_MAX_SELECT : public QuickSelectInterface
440
Cursor *cursor; /**< The Cursor used to get data. */
441
JOIN *join; /**< Descriptor of the current query */
442
KEY *index_info; /**< The index chosen for data access */
443
unsigned char *record; /**< Buffer where the next record is returned. */
444
unsigned char *tmp_record; /**< Temporary storage for next_min(), next_max(). */
445
unsigned char *group_prefix; /**< Key prefix consisting of the GROUP fields. */
446
uint32_t group_prefix_len; /**< Length of the group prefix. */
447
uint32_t group_key_parts; /**< A number of keyparts in the group prefix */
448
unsigned char *last_prefix; /**< Prefix of the last group for detecting EOF. */
449
bool have_min; /**< Specify whether we are computing */
450
bool have_max; /**< a MIN, a MAX, or both. */
451
bool seen_first_key; /**< Denotes whether the first key was retrieved.*/
452
KEY_PART_INFO *min_max_arg_part; /** The keypart of the only argument field of all MIN/MAX functions. */
453
uint32_t min_max_arg_len; /**< The length of the MIN/MAX argument field */
454
unsigned char *key_infix; /**< Infix of constants from equality predicates. */
455
uint32_t key_infix_len;
456
DYNAMIC_ARRAY min_max_ranges; /**< Array of range ptrs for the MIN/MAX field. */
457
uint32_t real_prefix_len; /**< Length of key prefix extended with key_infix. */
458
uint32_t real_key_parts; /**< A number of keyparts in the above value. */
459
List<Item_sum> *min_functions;
460
List<Item_sum> *max_functions;
461
List_iterator<Item_sum> *min_functions_it;
462
List_iterator<Item_sum> *max_functions_it;
465
The following two members are public to allow easy access from
466
TRP_GROUP_MIN_MAX::make_quick()
468
MEM_ROOT alloc; /**< Memory pool for this and quick_prefix_select data. */
469
QuickRangeSelect *quick_prefix_select; /**< For retrieval of group prefixes. */
472
int next_min_in_range();
473
int next_max_in_range();
476
void update_min_result();
477
void update_max_result();
479
QUICK_GROUP_MIN_MAX_SELECT(Table *table, JOIN *join, bool have_min,
480
bool have_max, KEY_PART_INFO *min_max_arg_part,
481
uint32_t group_prefix_len, uint32_t group_key_parts,
482
uint32_t used_key_parts, KEY *index_info, uint
483
use_index, double read_cost, ha_rows records, uint
484
key_infix_len, unsigned char *key_infix, MEM_ROOT
486
~QUICK_GROUP_MIN_MAX_SELECT();
487
bool add_range(SEL_ARG *sel_range);
488
void update_key_stat();
489
void adjust_prefix_ranges();
490
bool alloc_buffers();
494
bool reverse_sorted()
498
bool unique_key_range()
504
return QS_TYPE_GROUP_MIN_MAX;
506
void add_keys_and_lengths(String *key_names, String *used_lengths);
510
279
* Executor class for SELECT statements.