MySQL  8.0.19
Source Code Documentation
opt_range.h
Go to the documentation of this file.
1 /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
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 also distributed 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 included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 /* classes to use when handling where clause */
24 
25 #ifndef _opt_range_h
26 #define _opt_range_h
27 
28 #include <stddef.h>
29 #include <sys/types.h>
30 #include <algorithm>
31 #include <memory>
32 #include <vector>
33 
34 #include "m_string.h"
35 #include "my_alloc.h"
36 #include "my_base.h"
37 #include "my_bitmap.h"
38 #include "my_compiler.h"
39 #include "my_dbug.h"
40 #include "my_inttypes.h"
41 #include "my_table_map.h"
42 #include "prealloced_array.h" // Prealloced_array
43 #include "priority_queue.h" // Priority_queue
44 #include "sql/field.h" // Field
45 #include "sql/handler.h"
46 #include "sql/key.h"
47 #include "sql/key_spec.h"
48 #include "sql/malloc_allocator.h" // IWYU pragma: keep
49 #include "sql/sql_bitmap.h"
50 #include "sql/sql_const.h"
51 #include "sql/sql_list.h"
52 #include "sql/table.h"
53 #include "sql_string.h"
54 
55 class Item;
56 class Item_sum;
57 class JOIN;
58 class Opt_trace_context;
59 class RowIterator;
60 class THD;
61 class Unique;
62 
63 struct KEY_PART {
65  /* See KEY_PART_INFO for meaning of the next two: */
68  /*
69  Keypart flags (0 when this structure is used by partition pruning code
70  for fake partitioning index description)
71  */
75 };
76 
77 class QUICK_RANGE {
78  public:
81 
82  /// Stores bitwise-or'ed bits defined in enum key_range_flags.
84 
85  /**
86  Stores one of the HA_READ_MBR_XXX items in enum ha_rkey_function, only
87  effective when flag has a GEOM_FLAG bit.
88  */
90  key_part_map min_keypart_map, // bitmap of used keyparts in min_key
91  max_keypart_map; // bitmap of used keyparts in max_key
92 
93  QUICK_RANGE(); /* Full range */
94  QUICK_RANGE(const uchar *min_key_arg, uint min_length_arg,
95  key_part_map min_keypart_map_arg, const uchar *max_key_arg,
96  uint max_length_arg, key_part_map max_keypart_map_arg,
97  uint flag_arg, enum ha_rkey_function rkey_func);
98 
99  /**
100  Initalizes a key_range object for communication with storage engine.
101 
102  This function facilitates communication with the Storage Engine API by
103  translating the minimum endpoint of the interval represented by this
104  QUICK_RANGE into an index range endpoint specifier for the engine.
105 
106  @param kr Pointer to an uninitialized key_range C struct.
107 
108  @param prefix_length The length of the search key prefix to be used for
109  lookup.
110 
111  @param keypart_map A set (bitmap) of keyparts to be used.
112  */
113  void make_min_endpoint(key_range *kr, uint prefix_length,
114  key_part_map keypart_map) {
115  make_min_endpoint(kr);
116  kr->length = std::min(kr->length, prefix_length);
117  kr->keypart_map &= keypart_map;
118  }
119 
120  /**
121  Initalizes a key_range object for communication with storage engine.
122 
123  This function facilitates communication with the Storage Engine API by
124  translating the minimum endpoint of the interval represented by this
125  QUICK_RANGE into an index range endpoint specifier for the engine.
126 
127  @param kr Pointer to an uninitialized key_range C struct.
128  */
130  kr->key = (const uchar *)min_key;
131  kr->length = min_length;
133  kr->flag = ((flag & NEAR_MIN) ? HA_READ_AFTER_KEY
136  }
137 
138  /**
139  Initalizes a key_range object for communication with storage engine.
140 
141  This function facilitates communication with the Storage Engine API by
142  translating the maximum endpoint of the interval represented by this
143  QUICK_RANGE into an index range endpoint specifier for the engine.
144 
145  @param kr Pointer to an uninitialized key_range C struct.
146 
147  @param prefix_length The length of the search key prefix to be used for
148  lookup.
149 
150  @param keypart_map A set (bitmap) of keyparts to be used.
151  */
152  void make_max_endpoint(key_range *kr, uint prefix_length,
153  key_part_map keypart_map) {
154  make_max_endpoint(kr);
155  kr->length = std::min(kr->length, prefix_length);
156  kr->keypart_map &= keypart_map;
157  }
158 
159  /**
160  Initalizes a key_range object for communication with storage engine.
161 
162  This function facilitates communication with the Storage Engine API by
163  translating the maximum endpoint of the interval represented by this
164  QUICK_RANGE into an index range endpoint specifier for the engine.
165 
166  @param kr Pointer to an uninitialized key_range C struct.
167  */
169  kr->key = (const uchar *)max_key;
170  kr->length = max_length;
172  /*
173  We use READ_AFTER_KEY here because if we are reading on a key
174  prefix we want to find all keys with this prefix
175  */
177  }
178 };
179 
180 /*
181  Quick select interface.
182  This class is a parent for all QUICK_*_SELECT classes.
183 
184  The usage scenario is as follows:
185  1. Create quick select
186  quick= new QUICK_XXX_SELECT(...);
187 
188  2. Perform lightweight initialization. This can be done in 2 ways:
189  2.a: Regular initialization
190  if (quick->init())
191  {
192  //the only valid action after failed init() call is delete
193  delete quick;
194  }
195  2.b: Special initialization for quick selects merged by QUICK_ROR_*_SELECT
196  if (quick->init_ror_merged_scan())
197  delete quick;
198 
199  3. Perform zero, one, or more scans.
200  while (...)
201  {
202  // initialize quick select for scan. This may allocate
203  // buffers and/or prefetch rows.
204  if (quick->reset())
205  {
206  //the only valid action after failed reset() call is delete
207  delete quick;
208  //abort query
209  }
210 
211  // perform the scan
212  do
213  {
214  res= quick->get_next();
215  } while (res && ...)
216  }
217 
218  4. Delete the select:
219  delete quick;
220 
221  NOTE
222  quick select doesn't use MEM_ROOT allocation because "range
223  checked for each record" functionality may create/destroy
224  O(#records_in_some_table) quick selects during query execution.
225  See Bug#18684036 ELIMINATE LAST FEW HEAP USAGE FROM THE
226  RANGE OPTIMIZER.
227 */
228 
230  public:
231  ha_rows records; /* estimate of # of records to be retrieved */
232  Cost_estimate cost_est; ///> cost to perform this retrieval
234  /*
235  Index this quick select uses, or MAX_KEY for quick selects
236  that use several indexes
237  */
239 
240  /*
241  Total length of first used_key_parts parts of the key.
242  Applicable if index!= MAX_KEY.
243  */
245 
246  /*
247  Max. number of (first) key parts this quick select uses for retrieval.
248  eg. for "(key1p1=c1 AND key1p2=c2) OR key1p1=c2" used_key_parts == 2.
249  Applicable if index!= MAX_KEY.
250 
251  For QUICK_GROUP_MIN_MAX_SELECT it includes MIN/MAX argument keyparts.
252  */
254  /**
255  true if creation of the object is forced by the hint.
256  The flag is used to skip ref evaluation in find_best_ref() function.
257  It also enables using of QUICK_SELECT object in
258  Optimize_table_order::best_access_path() regardless of the evaluation cost.
259  */
261 
262  QUICK_SELECT_I();
263  QUICK_SELECT_I(const QUICK_SELECT_I &) = default;
264  virtual ~QUICK_SELECT_I() {}
265 
266  /*
267  Do post-constructor initialization.
268  SYNOPSIS
269  init()
270 
271  init() performs initializations that should have been in constructor if
272  it was possible to return errors from constructors. The join optimizer may
273  create and then delete quick selects without retrieving any rows so init()
274  must not contain any IO or CPU intensive code.
275 
276  If init() call fails the only valid action is to delete this quick select,
277  reset() and get_next() must not be called.
278 
279  RETURN
280  0 OK
281  other Error code
282  */
283  virtual int init() = 0;
284 
285  /*
286  Initialize quick select for row retrieval.
287  SYNOPSIS
288  reset()
289 
290  reset() should be called when it is certain that row retrieval will be
291  necessary. This call may do heavyweight initialization like buffering first
292  N records etc. If reset() call fails get_next() must not be called.
293  Note that reset() may be called several times if
294  * the quick select is executed in a subselect
295  * a JOIN buffer is used
296 
297  RETURN
298  0 OK
299  other Error code
300  */
301  virtual int reset(void) = 0;
302 
303  virtual int get_next() = 0; /* get next record to retrieve */
304 
305  /* Range end should be called when we have looped over the whole index */
306  virtual void range_end() {}
307 
308  /**
309  Whether the range access method returns records in reverse order.
310  */
311  virtual bool reverse_sorted() const = 0;
312  /**
313  Whether the range access method is capable of returning records
314  in reverse order.
315  */
316  virtual bool reverse_sort_possible() const = 0;
317  virtual bool unique_key_range() { return false; }
318  virtual bool clustered_pk_range() { return false; }
319 
320  /*
321  Request that this quick select produces sorted output.
322  Not all quick selects can provide sorted output, the caller is responsible
323  for calling this function only for those quick selects that can.
324  The implementation is also allowed to provide sorted output even if it
325  was not requested if benificial, or required by implementation
326  internals.
327  */
328  virtual void need_sorted_output() = 0;
329  enum {
338  };
339 
340  /* Get type of this quick select - one of the QS_TYPE_* values */
341  virtual int get_type() const = 0;
342  virtual bool is_loose_index_scan() const = 0;
343  virtual bool is_agg_loose_index_scan() const = 0;
344 
345  /*
346  Initialize this quick select as a merged scan inside a ROR-union or a ROR-
347  intersection scan. The caller must not additionally call init() if this
348  function is called.
349  SYNOPSIS
350  init_ror_merged_scan()
351  reuse_handler If true, the quick select may use table->handler,
352  otherwise it must create and use a separate handler
353  object.
354  RETURN
355  0 Ok
356  other Error
357  */
358  virtual int init_ror_merged_scan(bool reuse_handler MY_ATTRIBUTE((unused))) {
359  DBUG_ASSERT(0);
360  return 1;
361  }
362 
363  /*
364  Save ROWID of last retrieved row in file->ref. This used in ROR-merging.
365  */
366  virtual void save_last_pos() {}
367 
368  /*
369  Append comma-separated list of keys this quick select uses to key_names;
370  append comma-separated list of corresponding used lengths to used_lengths.
371  This is used by select_describe.
372  */
373  virtual void add_keys_and_lengths(String *key_names,
374  String *used_lengths) = 0;
375 
376  /*
377  Append text representation of quick select structure (what and how is
378  merged) to str. The result is added to "Extra" field in EXPLAIN output.
379  This function is implemented only by quick selects that merge other quick
380  selects output and/or can produce output suitable for merging.
381  */
382  virtual void add_info_string(String *str MY_ATTRIBUTE((unused))) {}
383  /*
384  Return 1 if any index used by this quick select
385  uses field which is marked in passed bitmap.
386  */
387  virtual bool is_keys_used(const MY_BITMAP *fields);
388 
389  /**
390  Simple sanity check that the quick select has been set up
391  correctly. Function is overridden by quick selects that merge
392  indices.
393  */
394  virtual bool is_valid() { return index != MAX_KEY; }
395 
396  /*
397  rowid of last row retrieved by this quick select. This is used only when
398  doing ROR-index_merge selects
399  */
401 
402  /*
403  Table record buffer used by this quick select.
404  */
406 #ifndef DBUG_OFF
407  /*
408  Print quick select information to DBUG_FILE. Caller is responsible
409  for locking DBUG_FILE before this call and unlocking it afterwards.
410  */
411  virtual void dbug_dump(int indent, bool verbose) = 0;
412 #endif
413 
414  /*
415  Returns a QUICK_SELECT with reverse order of to the index.
416  */
418  uint used_key_parts_arg MY_ATTRIBUTE((unused))) {
419  return NULL;
420  }
421  virtual void set_handler(handler *file_arg MY_ATTRIBUTE((unused))) {}
422 
423  /**
424  Get the fields used by the range access method.
425 
426  @param[out] used_fields Bitmap of fields that this range access
427  method uses.
428  */
429  virtual void get_fields_used(MY_BITMAP *used_fields) = 0;
431 };
432 
433 class PARAM;
434 class SEL_ARG;
435 class SEL_ROOT;
436 
439 
440 /*
441  MRR range sequence, array<QUICK_RANGE> implementation: sequence traversal
442  context.
443 */
448 };
449 
450 range_seq_t quick_range_seq_init(void *init_param, uint n_ranges, uint flags);
452 
453 /*
454  Quick select that does a range scan on a single key. The records are
455  returned in key order if ::need_sorted_output() has been called.
456 */
458  protected:
460  /* Members to deal with case when this quick select is a ROR-merged scan */
462 
463  // TODO: pre-allocate space to avoid malloc/free for small number of columns.
465 
466  friend class TRP_ROR_INTERSECT;
467  friend bool get_quick_keys(PARAM *param, QUICK_RANGE_SELECT *quick,
468  KEY_PART *key, SEL_ARG *key_tree, uchar *min_key,
469  uint min_key_flag, uchar *max_key,
470  uint max_key_flag, uint *desc_flag,
471  uint num_key_parts);
473  SEL_ROOT *key_tree,
475  MEM_ROOT *alloc,
476  uint num_key_parts);
478  friend range_seq_t quick_range_seq_init(void *init_param, uint n_ranges,
479  uint flags);
480  friend class QUICK_SELECT_DESC;
484 
485  Quick_ranges ranges; /* ordered array of range ptrs */
486  bool free_file; /* TRUE <=> this->file is "owned" by this quick select */
487 
488  /* Range pointers to be used when not using MRR interface */
489  QUICK_RANGE **cur_range; /* current element in ranges */
491 
492  /* Members needed to use the MRR interface */
494 
495  public:
496  uint mrr_flags; /* Flags to be used with MRR interface */
497  protected:
498  uint mrr_buf_size; /* copy from thd->variables.read_rnd_buff_size */
499  HANDLER_BUFFER *mrr_buf_desc; /* the handler buffer */
500 
501  /* Info about index we're scanning */
504 
505  bool dont_free; /* Used by QUICK_SELECT_DESC */
506 
507  int cmp_next(QUICK_RANGE *range);
508  int cmp_prev(QUICK_RANGE *range);
509  bool row_in_ranges();
510 
511  public:
512  std::shared_ptr<MEM_ROOT> alloc;
513 
514  QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint index_arg, bool no_alloc,
515  MEM_ROOT *parent_alloc, bool *create_error);
517 
518  void need_sorted_output();
519  int init();
520  int reset(void);
521  int get_next();
522  void range_end();
523  int get_next_prefix(uint prefix_length, uint group_key_parts,
524  uchar *cur_prefix);
525  bool reverse_sorted() const { return false; }
526  bool reverse_sort_possible() const { return true; }
527  bool unique_key_range();
528  int init_ror_merged_scan(bool reuse_handler);
530  int get_type() const { return QS_TYPE_RANGE; }
531  virtual bool is_loose_index_scan() const { return false; }
532  virtual bool is_agg_loose_index_scan() const { return false; }
533  void add_keys_and_lengths(String *key_names, String *used_lengths);
534  void add_info_string(String *str);
535 #ifndef DBUG_OFF
536  void dbug_dump(int indent, bool verbose);
537 #endif
538  QUICK_SELECT_I *make_reverse(uint used_key_parts_arg);
539  void set_handler(handler *file_arg) { file = file_arg; }
540 
541  virtual void get_fields_used(MY_BITMAP *used_fields) {
542  for (uint i = 0; i < used_key_parts; i++)
543  bitmap_set_bit(used_fields, key_parts[i].field->field_index);
544  }
545 
546  private:
547  /* Default copy ctor used by QUICK_SELECT_DESC */
548  QUICK_RANGE_SELECT(const QUICK_RANGE_SELECT &) = default;
549 };
550 
552  public:
553  QUICK_RANGE_SELECT_GEOM(THD *thd, TABLE *table, uint index_arg, bool no_alloc,
554  MEM_ROOT *parent_alloc, bool *create_error)
555  : QUICK_RANGE_SELECT(thd, table, index_arg, no_alloc, parent_alloc,
556  create_error) {}
557  virtual int get_next();
558 };
559 
560 /*
561  QUICK_INDEX_MERGE_SELECT - index_merge access method quick select.
562 
563  QUICK_INDEX_MERGE_SELECT uses
564  * QUICK_RANGE_SELECTs to get rows
565  * Unique class to remove duplicate rows
566 
567  INDEX MERGE OPTIMIZER
568  Current implementation doesn't detect all cases where index_merge could
569  be used, in particular:
570  * index_merge will never be used if range scan is possible (even if
571  range scan is more expensive)
572 
573  * index_merge+'using index' is not supported (this the consequence of
574  the above restriction)
575 
576  * If WHERE part contains complex nested AND and OR conditions, some ways
577  to retrieve rows using index_merge will not be considered. The choice
578  of read plan may depend on the order of conjuncts/disjuncts in WHERE
579  part of the query, see comments near imerge_list_or_list and
580  SEL_IMERGE::or_sel_tree_with_checks functions for details.
581 
582  * There is no "index_merge_ref" method (but index_merge on non-first
583  table in join is possible with 'range checked for each record').
584 
585  See comments around SEL_IMERGE class and test_quick_select for more
586  details.
587 
588  ROW RETRIEVAL ALGORITHM
589 
590  index_merge uses Unique class for duplicates removal. index_merge takes
591  advantage of Clustered Primary Key (CPK) if the table has one.
592  The index_merge algorithm consists of two phases:
593 
594  Phase 1 (implemented in QUICK_INDEX_MERGE_SELECT::prepare_unique):
595  prepare()
596  {
597  activate 'index only';
598  while(retrieve next row for non-CPK scan)
599  {
600  if (there is a CPK scan and row will be retrieved by it)
601  skip this row;
602  else
603  put its rowid into Unique;
604  }
605  deactivate 'index only';
606  }
607 
608  Phase 2 (implemented as sequence of QUICK_INDEX_MERGE_SELECT::get_next
609  calls):
610 
611  fetch()
612  {
613  retrieve all rows from row pointers stored in Unique;
614  free Unique;
615  retrieve all rows for CPK scan;
616  }
617 */
618 
621 
622  public:
625 
626  int init();
627  void need_sorted_output() { DBUG_ASSERT(false); /* Can't do it */ }
628  int reset(void);
629  int get_next();
630  bool reverse_sorted() const { return false; }
631  bool reverse_sort_possible() const { return false; }
632  bool unique_key_range() { return false; }
633  int get_type() const { return QS_TYPE_INDEX_MERGE; }
634  virtual bool is_loose_index_scan() const { return false; }
635  virtual bool is_agg_loose_index_scan() const { return false; }
636  void add_keys_and_lengths(String *key_names, String *used_lengths);
637  void add_info_string(String *str);
638  bool is_keys_used(const MY_BITMAP *fields);
639 #ifndef DBUG_OFF
640  void dbug_dump(int indent, bool verbose);
641 #endif
642 
643  bool push_quick_back(QUICK_RANGE_SELECT *quick_sel_range);
644 
645  /* range quick selects this index_merge read consists of */
647 
648  /* quick select that uses clustered primary key (NULL if none) */
650 
651  /* true if this select is currently doing a clustered PK scan */
653 
656  int read_keys_and_merge();
657 
659 
660  virtual bool is_valid() {
663  bool valid = true;
664  while ((quick = it++)) {
665  if (!quick->is_valid()) {
666  valid = false;
667  break;
668  }
669  }
670  return valid;
671  }
672 
673  virtual void get_fields_used(MY_BITMAP *used_fields) {
676  while ((quick = it++)) quick->get_fields_used(used_fields);
677 
679  }
680 
681  /* used to get rows collected in Unique */
683 };
684 
685 /*
686  Rowid-Ordered Retrieval (ROR) index intersection quick select.
687  This quick select produces intersection of row sequences returned
688  by several QUICK_RANGE_SELECTs it "merges".
689 
690  All merged QUICK_RANGE_SELECTs must return rowids in rowid order.
691  QUICK_ROR_INTERSECT_SELECT will return rows in rowid order, too.
692 
693  All merged quick selects retrieve {rowid, covered_fields} tuples (not full
694  table records).
695  QUICK_ROR_INTERSECT_SELECT retrieves full records if it is not being used
696  by QUICK_ROR_INTERSECT_SELECT and all merged quick selects together don't
697  cover needed all fields.
698 
699  If one of the merged quick selects is a Clustered PK range scan, it is
700  used only to filter rowid sequence produced by other merged quick selects.
701 */
702 
704  public:
705  QUICK_ROR_INTERSECT_SELECT(THD *thd, TABLE *table, bool retrieve_full_rows,
706  MEM_ROOT *parent_alloc);
708 
709  int init();
710  void need_sorted_output() { DBUG_ASSERT(false); /* Can't do it */ }
711  int reset(void);
712  int get_next();
713  bool reverse_sorted() const { return false; }
714  bool reverse_sort_possible() const { return false; }
715  bool unique_key_range() { return false; }
716  int get_type() const { return QS_TYPE_ROR_INTERSECT; }
717  virtual bool is_loose_index_scan() const { return false; }
718  virtual bool is_agg_loose_index_scan() const { return false; }
719  void add_keys_and_lengths(String *key_names, String *used_lengths);
720  void add_info_string(String *str);
721  bool is_keys_used(const MY_BITMAP *fields);
722 #ifndef DBUG_OFF
723  void dbug_dump(int indent, bool verbose);
724 #endif
725  int init_ror_merged_scan(bool reuse_handler);
726  bool push_quick_back(QUICK_RANGE_SELECT *quick_sel_range);
727 
728  /*
729  Range quick selects this intersection consists of, not including
730  cpk_quick.
731  */
733 
734  virtual bool is_valid() {
737  bool valid = true;
738  while ((quick = it++)) {
739  if (!quick->is_valid()) {
740  valid = false;
741  break;
742  }
743  }
744  return valid;
745  }
746 
747  virtual void get_fields_used(MY_BITMAP *used_fields) {
750  while ((quick = it++)) quick->get_fields_used(used_fields);
751  }
752 
753  /*
754  Merged quick select that uses Clustered PK, if there is one. This quick
755  select is not used for row retrieval, it is used for row retrieval.
756  */
758 
759  MEM_ROOT alloc; /* Memory pool for this and merged quick selects data. */
760  THD *thd; /* current thread */
761  bool need_to_fetch_row; /* if true, do retrieve full table records. */
762  /* in top-level quick select, true if merged scans where initialized */
764 };
765 
766 /*
767  Comparison function to be used QUICK_ROR_UNION_SELECT::queue priority
768  queue.
769 */
771  explicit Quick_ror_union_less(const QUICK_SELECT_I *me) : m_me(me) {}
773  return m_me->head->file->cmp_ref(a->last_rowid, b->last_rowid) > 0;
774  }
776 };
777 
778 /*
779  Rowid-Ordered Retrieval index union select.
780  This quick select produces union of row sequences returned by several
781  quick select it "merges".
782 
783  All merged quick selects must return rowids in rowid order.
784  QUICK_ROR_UNION_SELECT will return rows in rowid order, too.
785 
786  All merged quick selects are set not to retrieve full table records.
787  ROR-union quick select always retrieves full records.
788 
789 */
790 
792  public:
795 
796  int init();
797  void need_sorted_output() { DBUG_ASSERT(false); /* Can't do it */ }
798  int reset(void);
799  int get_next();
800  bool reverse_sorted() const { return false; }
801  bool reverse_sort_possible() const { return false; }
802  bool unique_key_range() { return false; }
803  int get_type() const { return QS_TYPE_ROR_UNION; }
804  virtual bool is_loose_index_scan() const { return false; }
805  virtual bool is_agg_loose_index_scan() const { return false; }
806  void add_keys_and_lengths(String *key_names, String *used_lengths);
807  void add_info_string(String *str);
808  bool is_keys_used(const MY_BITMAP *fields);
809 #ifndef DBUG_OFF
810  void dbug_dump(int indent, bool verbose);
811 #endif
812 
813  bool push_quick_back(QUICK_SELECT_I *quick_sel_range);
814 
815  List<QUICK_SELECT_I> quick_selects; /* Merged quick selects */
816 
817  virtual bool is_valid() {
820  bool valid = true;
821  while ((quick = it++)) {
822  if (!quick->is_valid()) {
823  valid = false;
824  break;
825  }
826  }
827  return valid;
828  }
829 
830  virtual void get_fields_used(MY_BITMAP *used_fields) {
833  while ((quick = it++)) quick->get_fields_used(used_fields);
834  }
835 
837  QUICK_SELECT_I *,
838  std::vector<QUICK_SELECT_I *, Malloc_allocator<QUICK_SELECT_I *>>,
840  queue; /* Priority queue for merge operation */
841  MEM_ROOT alloc; /* Memory pool for this and merged quick selects data. */
842 
843  THD *thd; /* current thread */
844  uchar *cur_rowid; /* buffer used in get_next() */
845  uchar *prev_rowid; /* rowid of last row returned by get_next() */
846  bool have_prev_rowid; /* true if prev_rowid has valid data */
847  uint rowid_length; /* table rowid length */
848 
849  private:
851 };
852 
853 /*
854  Index scan for GROUP-BY queries with MIN/MAX aggregate functions.
855 
856  This class provides a specialized index access method for GROUP-BY queries
857  of the forms:
858 
859  SELECT A_1,...,A_k, [B_1,...,B_m], [MIN(C)], [MAX(C)]
860  FROM T
861  WHERE [RNG(A_1,...,A_p ; where p <= k)]
862  [AND EQ(B_1,...,B_m)]
863  [AND PC(C)]
864  [AND PA(A_i1,...,A_iq)]
865  GROUP BY A_1,...,A_k;
866 
867  or
868 
869  SELECT DISTINCT A_i1,...,A_ik
870  FROM T
871  WHERE [RNG(A_1,...,A_p ; where p <= k)]
872  [AND PA(A_i1,...,A_iq)];
873 
874  where all selected fields are parts of the same index.
875  The class of queries that can be processed by this quick select is fully
876  specified in the description of get_best_trp_group_min_max() in opt_range.cc.
877 
878  The get_next() method directly produces result tuples, thus obviating the
879  need to call end_send_group() because all grouping is already done inside
880  get_next().
881 
882  Since one of the requirements is that all select fields are part of the same
883  index, this class produces only index keys, and not complete records.
884 */
885 
887  private:
888  JOIN *join; /* Descriptor of the current query */
889  KEY *index_info; /* The index chosen for data access */
890  uchar *tmp_record; /* Temporary storage for next_min(), next_max(). */
891  uchar *group_prefix; /* Key prefix consisting of the GROUP fields. */
892  const uint group_prefix_len; /* Length of the group prefix. */
893  uint group_key_parts; /* A number of keyparts in the group prefix */
894  uchar *last_prefix; /* Prefix of the last group for detecting EOF. */
895  bool have_min; /* Specify whether we are computing */
896  bool have_max; /* a MIN, a MAX, or both. */
897  bool have_agg_distinct; /* aggregate_function(DISTINCT ...). */
898  bool seen_first_key; /* Denotes whether the first key was retrieved.*/
899  KEY_PART_INFO *min_max_arg_part; /* The keypart of the only argument field */
900  /* of all MIN/MAX functions. */
901  uint min_max_arg_len; /* The length of the MIN/MAX argument field */
902  bool min_max_keypart_asc; /* TRUE if min_max key part is ascending. */
904  uint key_infix_parts; /* Indicates the number infix attributes */
905  // The current infix range position (in key_infix_ranges) used for row
906  // retrieval.
908  // Indicates if all infix ranges have been used to retrieve rows (all ranges
909  // in key_infix_ranges)
911  Quick_ranges min_max_ranges; /* Array of range ptrs for the MIN/MAX field. */
912  Quick_ranges_array key_infix_ranges; /* Array of key infix range arrays. */
913  uint real_prefix_len; /* Length of key prefix extended with key_infix. */
914  uint real_key_parts; /* A number of keyparts in the above value. */
919  /*
920  Use index scan to get the next different key instead of jumping into it
921  through index read
922  */
924 
925  public:
926  /*
927  The following two members are public to allow easy access from
928  TRP_GROUP_MIN_MAX::make_quick()
929  */
930  MEM_ROOT alloc; /* Memory pool for this and quick_prefix_select data. */
932  *quick_prefix_select; /* For retrieval of group prefixes. */
933  private:
934  int next_prefix();
935  bool append_next_infix();
936  void reset_group();
937  int next_min_in_range();
938  int next_max_in_range();
939  int next_min();
940  int next_max();
941  void update_min_result(bool *reset);
942  void update_max_result(bool *reset);
943 
944  public:
946  bool have_max, bool have_agg_distinct,
950  uint use_index, const Cost_estimate *cost_est,
952  MEM_ROOT *parent_alloc, bool is_index_scan);
954  bool add_range(SEL_ARG *sel_range, int idx);
955  void update_key_stat();
956  void adjust_prefix_ranges();
957  int init();
958  void need_sorted_output() { /* always do it */
959  }
960  int reset();
961  int get_next();
962  bool reverse_sorted() const { return false; }
963  bool reverse_sort_possible() const { return false; }
964  bool unique_key_range() { return false; }
965  int get_type() const { return QS_TYPE_GROUP_MIN_MAX; }
966  virtual bool is_loose_index_scan() const { return true; }
967  virtual bool is_agg_loose_index_scan() const { return is_agg_distinct(); }
968  void add_keys_and_lengths(String *key_names, String *used_lengths);
969 #ifndef DBUG_OFF
970  void dbug_dump(int indent, bool verbose);
971 #endif
972  bool is_agg_distinct() const { return have_agg_distinct; }
973  virtual void append_loose_scan_type(String *str) {
974  if (is_index_scan) str->append(STRING_WITH_LEN("scanning"));
975  }
976 
977  virtual void get_fields_used(MY_BITMAP *used_fields) {
978  for (uint i = 0; i < used_key_parts; i++)
980  }
981  void add_info_string(String *str);
982 };
983 
985  public:
987  int get_next();
988  bool reverse_sorted() const { return true; }
989  bool reverse_sort_possible() const { return true; }
990  int get_type() const { return QS_TYPE_RANGE_DESC; }
991  virtual bool is_loose_index_scan() const { return false; }
992  virtual bool is_agg_loose_index_scan() const { return false; }
994  return this; // is already reverse sorted
995  }
996 
997  private:
998  bool range_reads_after_key(QUICK_RANGE *range);
999  int reset(void) {
1000  rev_it.rewind();
1001  return QUICK_RANGE_SELECT::reset();
1002  }
1006 };
1007 
1008 /*
1009  Index scan for range queries that can use skip scans.
1010 
1011  This class provides a specialized index access method for the queries
1012  of the forms:
1013 
1014  SELECT A_1,...,A_k, B_1,...,B_m, C
1015  FROM T
1016  WHERE
1017  EQ(A_1,...,A_k)
1018  AND RNG(C);
1019 
1020  where all selected fields are parts of the same index.
1021  The class of queries that can be processed by this quick select is fully
1022  specified in the description of get_best_skip_scan() in opt_range.cc.
1023 
1024  Since one of the requirements is that all select fields are part of the same
1025  index, this class produces only index keys, and not complete records.
1026 */
1027 
1029  private:
1030  JOIN *join; /* Pointer to JOIN object */
1031  KEY *index_info; /* Index for skip scan */
1032  SEL_ROOT *index_range_tree; /* Range tree for skip scan */
1033  MY_BITMAP column_bitmap; /* Map of key parts to be read */
1034  /*
1035  This is an array of array of equality constants with length
1036  eq_prefix_key_parts. The length of array eq_key_prefixes[i] is
1037  eq_prefix_elements[i].
1038 
1039  For example, an equality predicate like "a IN (1, 2) AND b IN (2, 3, 4)",
1040  eq_key_prefixes will contain:
1041 
1042  [
1043  [ 1, 2 ],
1044  [ 2, 3, 4 ]
1045  ]
1046 
1047  eq_prefix_elements will contain:
1048  [ 2, 3 ]
1049  */
1052  const uint eq_prefix_len; /* Total length of the equality prefix. */
1053  uint eq_prefix_key_parts; /* A number of keyparts in skip scan prefix */
1054  uchar *eq_prefix; /* Storage for current equality prefix. */
1055 
1056  /*
1057  During skip scan, we will have to iterate through all possible
1058  equality prefixes. This is the product of all the elements in
1059  eq_prefix_elements. In the above example, there are 2 x 3 = 6 possible
1060  equality prefixes.
1061 
1062  To track which prefix we are on, we use the cur_eq_prefix array.
1063  For example, the array [1, 1] indicates that the current equality prefix
1064  is (2, 3).
1065  */
1067  uchar *distinct_prefix; /* Storage for prefix A_1, ... B_m. */
1070 
1071  KEY_PART_INFO *range_key_part; /* The keypart of range condition 'C'. */
1073  /*
1074  Denotes whether the first key for the current equality prefix was
1075  retrieved.
1076  */
1078 
1079  /* Storage for full lookup key for use with handler::read_range_first/next */
1085 
1088 
1090 
1091  bool next_eq_prefix();
1092 
1093  public:
1094  MEM_ROOT alloc; /* Memory pool for data in this class. */
1095  public:
1097  KEY_PART_INFO *range_part, SEL_ROOT *index_range_tree,
1098  uint eq_prefix_len, uint eq_prefix_parts,
1100  const Cost_estimate *read_cost_arg, ha_rows records,
1101  MEM_ROOT *parent_alloc, bool has_aggregate_function);
1103  bool set_range(SEL_ARG *sel_range);
1104  int init();
1106  int reset();
1107  int get_next();
1108  bool reverse_sorted() const { return false; }
1109  bool reverse_sort_possible() const { return false; }
1110  bool unique_key_range() { return false; }
1111  int get_type() const { return QS_TYPE_SKIP_SCAN; }
1112  virtual bool is_loose_index_scan() const { return true; }
1113  virtual bool is_agg_loose_index_scan() const {
1114  return has_aggregate_function;
1115  }
1116  void add_keys_and_lengths(String *key_names, String *used_lengths);
1117 #ifndef DBUG_OFF
1118  void dbug_dump(int indent, bool verbose);
1119 #endif
1120  virtual void get_fields_used(MY_BITMAP *used_fields) {
1121  for (uint i = 0; i < used_key_parts; i++)
1122  bitmap_set_bit(used_fields, index_info->key_part[i].field->field_index);
1123  }
1124  void add_info_string(String *str);
1125 };
1126 
1127 class QEP_shared_owner;
1128 
1129 int test_quick_select(THD *thd, Key_map keys, table_map prev_tables,
1130  ha_rows limit, bool force_quick_range,
1131  const enum_order interesting_order,
1132  const QEP_shared_owner *tab, Item *cond,
1133  Key_map *needed_reg, QUICK_SELECT_I **quick,
1134  bool ignore_table_scan);
1135 
1136 bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond);
1137 void store_key_image_to_rec(Field *field, uchar *ptr, uint len);
1138 
1139 extern String null_string;
1140 
1141 /// Global initialization of the null_element. Call on server start.
1142 void range_optimizer_init();
1143 
1144 /// Global destruction of the null_element. Call on server stop.
1145 void range_optimizer_free();
1146 
1147 #endif
QUICK_ROR_INTERSECT_SELECT::reverse_sorted
bool reverse_sorted() const
Whether the range access method returns records in reverse order.
Definition: opt_range.h:713
QUICK_ROR_INTERSECT_SELECT::quick_selects
List< QUICK_RANGE_SELECT > quick_selects
Definition: opt_range.h:732
QUICK_SKIP_SCAN_SELECT
Definition: opt_range.h:1028
handler::cmp_ref
virtual int cmp_ref(const uchar *ref1, const uchar *ref2) const
Compare two positions.
Definition: handler.h:5406
QUICK_ROR_INTERSECT_SELECT::scans_inited
bool scans_inited
Definition: opt_range.h:763
QUICK_SKIP_SCAN_SELECT::eq_prefix_len
const uint eq_prefix_len
Definition: opt_range.h:1052
Bitmap< 64 >
Definition: sql_bitmap.h:136
QUICK_SKIP_SCAN_SELECT::min_range_key
uchar * min_range_key
Definition: opt_range.h:1080
QUICK_RANGE_SEQ_CTX
Definition: opt_range.h:444
Item
Definition: item.h:665
THD
Definition: sql_class.h:764
QUICK_ROR_UNION_SELECT::need_sorted_output
void need_sorted_output()
Definition: opt_range.h:797
QUICK_SKIP_SCAN_SELECT::get_next
int get_next()
Get the next row for skip scan.
Definition: opt_range.cc:15046
QUICK_ROR_INTERSECT_SELECT::~QUICK_ROR_INTERSECT_SELECT
~QUICK_ROR_INTERSECT_SELECT()
Definition: opt_range.cc:2157
QUICK_ROR_INTERSECT_SELECT::need_sorted_output
void need_sorted_output()
Definition: opt_range.h:710
key_range::key
const uchar * key
Definition: my_base.h:1117
HA_READ_KEY_OR_NEXT
@ HA_READ_KEY_OR_NEXT
Definition: my_base.h:79
Priority_queue
Implements a priority queue using a vector-based max-heap.
Definition: priority_queue.h:92
QUICK_GROUP_MIN_MAX_SELECT::get_fields_used
virtual void get_fields_used(MY_BITMAP *used_fields)
Get the fields used by the range access method.
Definition: opt_range.h:977
QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX
@ QS_TYPE_GROUP_MIN_MAX
Definition: opt_range.h:336
KEY_PART::null_bit
uint8 null_bit
Definition: opt_range.h:67
QUICK_RANGE_SELECT::reset
int reset(void)
Definition: opt_range.cc:10770
QUICK_RANGE_SELECT::quick_range_seq_next
friend uint quick_range_seq_next(range_seq_t rseq, KEY_MULTI_RANGE *range)
Definition: opt_range.cc:10890
Prealloced_array< QUICK_RANGE *, 16 >::const_iterator
const typedef QUICK_RANGE * * const_iterator
Definition: prealloced_array.h:94
QUICK_INDEX_MERGE_SELECT::quick_selects
List< QUICK_RANGE_SELECT > quick_selects
Definition: opt_range.h:646
QUICK_INDEX_MERGE_SELECT::reset
int reset(void)
Definition: opt_range.cc:1881
QUICK_ROR_UNION_SELECT::queue
Priority_queue< QUICK_SELECT_I *, std::vector< QUICK_SELECT_I *, Malloc_allocator< QUICK_SELECT_I * > >, Quick_ror_union_less > queue
Definition: opt_range.h:840
QUICK_GROUP_MIN_MAX_SELECT::key_infix_ranges
Quick_ranges_array key_infix_ranges
Definition: opt_range.h:912
KEY_PART
Definition: opt_range.h:63
my_base.h
NEAR_MAX
@ NEAR_MAX
Definition: my_base.h:1077
QUICK_ROR_UNION_SELECT::add_keys_and_lengths
void add_keys_and_lengths(String *key_names, String *used_lengths)
Definition: opt_range.cc:11456
QUICK_INDEX_MERGE_SELECT::~QUICK_INDEX_MERGE_SELECT
~QUICK_INDEX_MERGE_SELECT()
Definition: opt_range.cc:1901
QUICK_RANGE_SELECT::cur_range
QUICK_RANGE ** cur_range
Definition: opt_range.h:489
QUICK_RANGE_SELECT::init
int init()
Definition: opt_range.cc:1833
QUICK_SELECT_I::head
TABLE * head
cost to perform this retrieval
Definition: opt_range.h:233
Prealloced_array< QUICK_RANGE *, 16 >
QUICK_GROUP_MIN_MAX_SELECT::is_agg_loose_index_scan
virtual bool is_agg_loose_index_scan() const
Definition: opt_range.h:967
KEY_PART_INFO::field
Field * field
Definition: key.h:57
QUICK_GROUP_MIN_MAX_SELECT::cur_infix_range_position
uint cur_infix_range_position[MAX_REF_PARTS]
Definition: opt_range.h:907
KEY_PART::length
uint16 length
Definition: opt_range.h:66
Unique
Unique – class for unique (removing of duplicates).
Definition: uniques.h:52
QUICK_SKIP_SCAN_SELECT::range_key_len
uint range_key_len
Definition: opt_range.h:1072
NULL
#define NULL
Definition: types.h:55
QUICK_ROR_UNION_SELECT::quick_selects
List< QUICK_SELECT_I > quick_selects
Definition: opt_range.h:815
QUICK_SKIP_SCAN_SELECT::column_bitmap
MY_BITMAP column_bitmap
Definition: opt_range.h:1033
QUICK_ROR_INTERSECT_SELECT::need_to_fetch_row
bool need_to_fetch_row
Definition: opt_range.h:761
QUICK_ROR_UNION_SELECT::is_valid
virtual bool is_valid()
Simple sanity check that the quick select has been set up correctly.
Definition: opt_range.h:817
QUICK_GROUP_MIN_MAX_SELECT::add_keys_and_lengths
void add_keys_and_lengths(String *key_names, String *used_lengths)
Definition: opt_range.cc:14204
handler::position
virtual void position(const uchar *record)=0
QUICK_SELECT_DESC::is_loose_index_scan
virtual bool is_loose_index_scan() const
Definition: opt_range.h:991
QUICK_GROUP_MIN_MAX_SELECT::append_loose_scan_type
virtual void append_loose_scan_type(String *str)
Definition: opt_range.h:973
my_compiler.h
record
Definition: mi_test3.cc:54
QUICK_INDEX_MERGE_SELECT::unique_key_range
bool unique_key_range()
Definition: opt_range.h:632
QUICK_SKIP_SCAN_SELECT::add_info_string
void add_info_string(String *str)
Definition: opt_range.cc:11378
QUICK_GROUP_MIN_MAX_SELECT::min_functions
List< Item_sum > * min_functions
Definition: opt_range.h:915
QUICK_RANGE_SELECT_GEOM::QUICK_RANGE_SELECT_GEOM
QUICK_RANGE_SELECT_GEOM(THD *thd, TABLE *table, uint index_arg, bool no_alloc, MEM_ROOT *parent_alloc, bool *create_error)
Definition: opt_range.h:553
QUICK_GROUP_MIN_MAX_SELECT::append_next_infix
bool append_next_infix()
Definition: opt_range.cc:13714
QUICK_ROR_INTERSECT_SELECT::push_quick_back
bool push_quick_back(QUICK_RANGE_SELECT *quick_sel_range)
Definition: opt_range.cc:2153
QUICK_RANGE_SELECT::cmp_next
int cmp_next(QUICK_RANGE *range)
Definition: opt_range.cc:11277
QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT
~QUICK_RANGE_SELECT()
Definition: opt_range.cc:1844
KEY::key_part
KEY_PART_INFO * key_part
Definition: key.h:147
QUICK_GROUP_MIN_MAX_SELECT::need_sorted_output
void need_sorted_output()
Definition: opt_range.h:958
QUICK_GROUP_MIN_MAX_SELECT::min_max_keypart_asc
bool min_max_keypart_asc
Definition: opt_range.h:902
QUICK_SELECT_I::records
ha_rows records
Definition: opt_range.h:231
QUICK_RANGE::make_min_endpoint
void make_min_endpoint(key_range *kr, uint prefix_length, key_part_map keypart_map)
Initalizes a key_range object for communication with storage engine.
Definition: opt_range.h:113
QUICK_INDEX_MERGE_SELECT::reverse_sort_possible
bool reverse_sort_possible() const
Whether the range access method is capable of returning records in reverse order.
Definition: opt_range.h:631
QUICK_SELECT_I::QS_TYPE_FULLTEXT
@ QS_TYPE_FULLTEXT
Definition: opt_range.h:333
QUICK_RANGE_SEQ_CTX::first
Quick_ranges::const_iterator first
Definition: opt_range.h:445
sql_string.h
Opt_trace_context
Definition: opt_trace_context.h:88
my_dbug.h
QUICK_RANGE::min_key
uchar * min_key
Definition: opt_range.h:79
String
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:164
QUICK_GROUP_MIN_MAX_SELECT::reverse_sort_possible
bool reverse_sort_possible() const
Whether the range access method is capable of returning records in reverse order.
Definition: opt_range.h:963
QUICK_ROR_INTERSECT_SELECT::add_info_string
void add_info_string(String *str)
Definition: opt_range.cc:11336
QUICK_RANGE_SELECT::get_fields_used
virtual void get_fields_used(MY_BITMAP *used_fields)
Get the fields used by the range access method.
Definition: opt_range.h:541
quick_range_seq_init
range_seq_t quick_range_seq_init(void *init_param, uint n_ranges, uint flags)
Definition: opt_range.cc:10861
TABLE
Definition: table.h:1305
QUICK_SELECT_DESC::make_reverse
QUICK_SELECT_I * make_reverse(uint)
Create a compatible quick select with the result ordered in an opposite way.
Definition: opt_range.h:993
KEY_MULTI_RANGE
Definition: my_base.h:1123
QUICK_RANGE_SELECT::get_next
int get_next()
Definition: opt_range.cc:10936
QUICK_ROR_UNION_SELECT
Definition: opt_range.h:791
QUICK_ROR_INTERSECT_SELECT::init_ror_merged_scan
int init_ror_merged_scan(bool reuse_handler)
Definition: opt_range.cc:2078
QUICK_GROUP_MIN_MAX_SELECT::next_min
int next_min()
Definition: opt_range.cc:13503
QUICK_GROUP_MIN_MAX_SELECT::group_prefix_len
const uint group_prefix_len
Definition: opt_range.h:892
QUICK_ROR_UNION_SELECT::is_loose_index_scan
virtual bool is_loose_index_scan() const
Definition: opt_range.h:804
malloc_allocator.h
QUICK_GROUP_MIN_MAX_SELECT::min_max_arg_len
uint min_max_arg_len
Definition: opt_range.h:901
QUICK_SKIP_SCAN_SELECT::seen_first_key
bool seen_first_key
Definition: opt_range.h:1077
QUICK_RANGE
Definition: opt_range.h:77
QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT
@ QS_TYPE_ROR_INTERSECT
Definition: opt_range.h:334
QUICK_GROUP_MIN_MAX_SELECT::next_min_in_range
int next_min_in_range()
Definition: opt_range.cc:13903
priority_queue.h
QUICK_SELECT_I::reverse_sorted
virtual bool reverse_sorted() const =0
Whether the range access method returns records in reverse order.
key_part_map
ulong key_part_map
Definition: my_base.h:1000
QUICK_INDEX_MERGE_SELECT::need_sorted_output
void need_sorted_output()
Definition: opt_range.h:627
List_iterator< Item_sum >
QUICK_RANGE::max_length
uint16 max_length
Definition: opt_range.h:80
QUICK_SKIP_SCAN_SELECT::is_agg_loose_index_scan
virtual bool is_agg_loose_index_scan() const
Definition: opt_range.h:1113
QUICK_ROR_UNION_SELECT::push_quick_back
bool push_quick_back(QUICK_SELECT_I *quick_sel_range)
Definition: opt_range.cc:2262
Field::imagetype
imagetype
Definition: field.h:833
QUICK_RANGE_SELECT::key_part_info
KEY_PART_INFO * key_part_info
Definition: opt_range.h:503
QUICK_SELECT_DESC::rev_ranges
List< QUICK_RANGE > rev_ranges
Definition: opt_range.h:1003
QUICK_SELECT_I::is_keys_used
virtual bool is_keys_used(const MY_BITMAP *fields)
Definition: opt_range.cc:10422
EQ_RANGE
@ EQ_RANGE
Definition: my_base.h:1089
QUICK_SKIP_SCAN_SELECT::start_key
key_range start_key
Definition: opt_range.h:1086
QUICK_SELECT_I::~QUICK_SELECT_I
virtual ~QUICK_SELECT_I()
Definition: opt_range.h:264
QUICK_SKIP_SCAN_SELECT::init
int init()
Do post-constructor initialization.
Definition: opt_range.cc:14779
QUICK_ROR_INTERSECT_SELECT::is_loose_index_scan
virtual bool is_loose_index_scan() const
Definition: opt_range.h:717
Quick_ror_union_less::operator()
bool operator()(QUICK_SELECT_I *a, QUICK_SELECT_I *b)
Definition: opt_range.h:772
QUICK_SELECT_I::used_key_parts
uint used_key_parts
Definition: opt_range.h:253
KEY_PART::flag
uint16 flag
Definition: opt_range.h:72
unique_ptr_destroy_only
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:408
QUICK_RANGE_SELECT::row_in_ranges
bool row_in_ranges()
Definition: opt_range.cc:11081
QUICK_SKIP_SCAN_SELECT::next_eq_prefix
bool next_eq_prefix()
Increments cur_prefix and sets what the next equality prefix should be.
Definition: opt_range.cc:14977
QUICK_GROUP_MIN_MAX_SELECT::next_max
int next_max()
Definition: opt_range.cc:13583
QUICK_RANGE::min_length
uint16 min_length
Definition: opt_range.h:80
QUICK_SKIP_SCAN_SELECT::cur_eq_prefix
uint * cur_eq_prefix
Definition: opt_range.h:1066
QUICK_RANGE_SELECT::qr_traversal_ctx
QUICK_RANGE_SEQ_CTX qr_traversal_ctx
Definition: opt_range.h:493
KEY_PART::key
uint16 key
Definition: opt_range.h:64
QUICK_ROR_INTERSECT_SELECT::is_keys_used
bool is_keys_used(const MY_BITMAP *fields)
Definition: opt_range.cc:10435
QUICK_ROR_UNION_SELECT::add_info_string
void add_info_string(String *str)
Definition: opt_range.cc:11357
HA_READ_AFTER_KEY
@ HA_READ_AFTER_KEY
Definition: my_base.h:81
QUICK_ROR_UNION_SELECT::thd
THD * thd
Definition: opt_range.h:843
QUICK_SELECT_I::last_rowid
uchar * last_rowid
Definition: opt_range.h:400
QUICK_SELECT_I::QS_TYPE_SKIP_SCAN
@ QS_TYPE_SKIP_SCAN
Definition: opt_range.h:337
QUICK_GROUP_MIN_MAX_SELECT::add_range
bool add_range(SEL_ARG *sel_range, int idx)
Definition: opt_range.cc:13189
QUICK_INDEX_MERGE_SELECT::is_valid
virtual bool is_valid()
Simple sanity check that the quick select has been set up correctly.
Definition: opt_range.h:660
QUICK_GROUP_MIN_MAX_SELECT::alloc
MEM_ROOT alloc
Definition: opt_range.h:930
key
static const char * key
Definition: suite_stubs.c:14
QUICK_GROUP_MIN_MAX_SELECT::max_functions
List< Item_sum > * max_functions
Definition: opt_range.h:916
QUICK_ROR_INTERSECT_SELECT::is_agg_loose_index_scan
virtual bool is_agg_loose_index_scan() const
Definition: opt_range.h:718
List_iterator_fast
Definition: sql_list.h:585
prealloced_array.h
QUICK_SKIP_SCAN_SELECT::distinct_prefix_len
uint distinct_prefix_len
Definition: opt_range.h:1068
QUICK_RANGE::max_keypart_map
key_part_map max_keypart_map
Definition: opt_range.h:91
QUICK_SELECT_I::add_info_string
virtual void add_info_string(String *str)
Definition: opt_range.h:382
QUICK_SKIP_SCAN_SELECT::reset
int reset()
Initialize a quick skip scan index select for key retrieval.
Definition: opt_range.cc:14932
QUICK_INDEX_MERGE_SELECT::alloc
MEM_ROOT alloc
Definition: opt_range.h:654
KEY_PART::part
uint16 part
Definition: opt_range.h:64
QUICK_RANGE_SELECT::quick_range_seq_init
friend range_seq_t quick_range_seq_init(void *init_param, uint n_ranges, uint flags)
Definition: opt_range.cc:10861
QUICK_SELECT_DESC::reverse_sorted
bool reverse_sorted() const
Whether the range access method returns records in reverse order.
Definition: opt_range.h:988
sql_bitmap.h
QUICK_GROUP_MIN_MAX_SELECT::join
JOIN * join
Definition: opt_range.h:888
QUICK_GROUP_MIN_MAX_SELECT::quick_prefix_select
QUICK_RANGE_SELECT * quick_prefix_select
Definition: opt_range.h:932
handler.h
bitmap_set_bit
static void bitmap_set_bit(MY_BITMAP *map, uint bit)
Definition: my_bitmap.h:75
QUICK_SKIP_SCAN_SELECT::eq_prefix
uchar * eq_prefix
Definition: opt_range.h:1054
HA_READ_KEY_EXACT
@ HA_READ_KEY_EXACT
Definition: my_base.h:78
QUICK_ROR_UNION_SELECT::reverse_sort_possible
bool reverse_sort_possible() const
Whether the range access method is capable of returning records in reverse order.
Definition: opt_range.h:801
my_alloc.h
QUICK_SELECT_DESC::range_reads_after_key
bool range_reads_after_key(QUICK_RANGE *range)
Definition: opt_range.cc:11304
QUICK_SELECT_I::save_last_pos
virtual void save_last_pos()
Definition: opt_range.h:366
QUICK_SELECT_I::set_handler
virtual void set_handler(handler *file_arg)
Definition: opt_range.h:421
range_optimizer_init
void range_optimizer_init()
Global initialization of the null_element. Call on server start.
Definition: opt_range.cc:1500
QUICK_GROUP_MIN_MAX_SELECT::have_min
bool have_min
Definition: opt_range.h:895
QUICK_RANGE_SELECT::cmp_prev
int cmp_prev(QUICK_RANGE *range)
Definition: opt_range.cc:11290
QUICK_RANGE_SELECT::mrr_buf_desc
HANDLER_BUFFER * mrr_buf_desc
Definition: opt_range.h:499
QUICK_SELECT_I::cost_est
Cost_estimate cost_est
Definition: opt_range.h:232
STRING_WITH_LEN
#define STRING_WITH_LEN(X)
Definition: m_string.h:306
QEP_shared_owner
Owner of a QEP_shared; parent of JOIN_TAB and QEP_TAB.
Definition: sql_opt_exec_shared.h:463
QUICK_RANGE_SEQ_CTX::cur
Quick_ranges::const_iterator cur
Definition: opt_range.h:446
key_range::flag
enum ha_rkey_function flag
Definition: my_base.h:1120
QUICK_GROUP_MIN_MAX_SELECT::update_min_result
void update_min_result(bool *reset)
Definition: opt_range.cc:14139
QUICK_GROUP_MIN_MAX_SELECT::min_functions_it
List_iterator< Item_sum > * min_functions_it
Definition: opt_range.h:917
QUICK_GROUP_MIN_MAX_SELECT::seen_first_key
bool seen_first_key
Definition: opt_range.h:898
QUICK_RANGE_SELECT::reverse_sort_possible
bool reverse_sort_possible() const
Whether the range access method is capable of returning records in reverse order.
Definition: opt_range.h:526
KEY_PART::field
Field * field
Definition: opt_range.h:73
handler
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:3991
QUICK_ROR_UNION_SELECT::reset
int reset(void)
Definition: opt_range.cc:2210
QUICK_RANGE::rkey_func_flag
enum ha_rkey_function rkey_func_flag
Stores one of the HA_READ_MBR_XXX items in enum ha_rkey_function, only effective when flag has a GEOM...
Definition: opt_range.h:89
QUICK_SELECT_DESC::rev_it
List_iterator< QUICK_RANGE > rev_it
Definition: opt_range.h:1004
QUICK_GROUP_MIN_MAX_SELECT::seen_all_infix_ranges
bool seen_all_infix_ranges
Definition: opt_range.h:910
QUICK_SELECT_DESC::reverse_sort_possible
bool reverse_sort_possible() const
Whether the range access method is capable of returning records in reverse order.
Definition: opt_range.h:989
JOIN
Definition: sql_optimizer.h:174
QUICK_SELECT_I::dbug_dump
virtual void dbug_dump(int indent, bool verbose)=0
QUICK_SKIP_SCAN_SELECT::QUICK_SKIP_SCAN_SELECT
QUICK_SKIP_SCAN_SELECT(TABLE *table, JOIN *join, KEY *index_info, uint index, KEY_PART_INFO *range_part, SEL_ROOT *index_range_tree, uint eq_prefix_len, uint eq_prefix_parts, uint used_key_parts, const Cost_estimate *read_cost_arg, ha_rows records, MEM_ROOT *parent_alloc, bool has_aggregate_function)
Construct new quick select for queries that can do skip scans.
Definition: opt_range.cc:14695
QUICK_SELECT_DESC::get_next
int get_next()
Definition: opt_range.cc:11142
my_inttypes.h
KEY_PART_INFO
Definition: key.h:55
QUICK_ROR_INTERSECT_SELECT::dbug_dump
void dbug_dump(int indent, bool verbose)
Definition: opt_range.cc:15778
field.h
quick_range_seq_next
uint quick_range_seq_next(range_seq_t rseq, KEY_MULTI_RANGE *range)
Definition: opt_range.cc:10890
QUICK_SELECT_DESC::reset
int reset(void)
Definition: opt_range.h:999
QUICK_ROR_UNION_SELECT::reverse_sorted
bool reverse_sorted() const
Whether the range access method returns records in reverse order.
Definition: opt_range.h:800
QUICK_SKIP_SCAN_SELECT::has_aggregate_function
bool has_aggregate_function
Definition: opt_range.h:1089
QUICK_INDEX_MERGE_SELECT::unique
Unique * unique
Definition: opt_range.h:620
QUICK_INDEX_MERGE_SELECT::is_loose_index_scan
virtual bool is_loose_index_scan() const
Definition: opt_range.h:634
QUICK_SELECT_I::range_end
virtual void range_end()
Definition: opt_range.h:306
MEM_ROOT
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:77
QUICK_RANGE_SELECT::QUICK_RANGE_SELECT
QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint index_arg, bool no_alloc, MEM_ROOT *parent_alloc, bool *create_error)
Definition: opt_range.cc:1788
QUICK_ROR_UNION_SELECT::rowid_length
uint rowid_length
Definition: opt_range.h:847
QUICK_RANGE::max_key
uchar * max_key
Definition: opt_range.h:79
test_quick_select
int test_quick_select(THD *thd, Key_map keys, table_map prev_tables, ha_rows limit, bool force_quick_range, const enum_order interesting_order, const QEP_shared_owner *tab, Item *cond, Key_map *needed_reg, QUICK_SELECT_I **quick, bool ignore_table_scan)
Definition: opt_range.cc:3113
QUICK_GROUP_MIN_MAX_SELECT::add_info_string
void add_info_string(String *str)
Definition: opt_range.cc:11372
QUICK_GROUP_MIN_MAX_SELECT::update_key_stat
void update_key_stat()
Definition: opt_range.cc:13282
MAX_KEY
#define MAX_KEY
Definition: sql_const.h:51
QUICK_SKIP_SCAN_SELECT::distinct_prefix
uchar * distinct_prefix
Definition: opt_range.h:1067
QUICK_ROR_UNION_SELECT::get_next
int get_next()
Definition: opt_range.cc:10730
RowIterator
A context for reading through a single table using a chosen access method: index read,...
Definition: row_iterator.h:61
QUICK_SKIP_SCAN_SELECT::range_key_part
KEY_PART_INFO * range_key_part
Definition: opt_range.h:1071
QUICK_RANGE_SELECT::add_keys_and_lengths
void add_keys_and_lengths(String *key_names, String *used_lengths)
Definition: opt_range.cc:11384
null_string
String null_string
KEY_PART::store_length
uint16 store_length
Definition: opt_range.h:66
uint
unsigned int uint
Definition: uca-dump.cc:29
QUICK_INDEX_MERGE_SELECT::pk_quick_select
QUICK_RANGE_SELECT * pk_quick_select
Definition: opt_range.h:649
QUICK_GROUP_MIN_MAX_SELECT::QUICK_GROUP_MIN_MAX_SELECT
QUICK_GROUP_MIN_MAX_SELECT(TABLE *table, JOIN *join, bool have_min, bool have_max, bool have_agg_distinct, KEY_PART_INFO *min_max_arg_part, uint group_prefix_len, uint group_key_parts, uint used_key_parts, KEY *index_info, uint use_index, const Cost_estimate *cost_est, ha_rows records, uint key_infix_len, MEM_ROOT *parent_alloc, bool is_index_scan)
Definition: opt_range.cc:13027
QUICK_RANGE_SELECT::set_handler
void set_handler(handler *file_arg)
Definition: opt_range.h:539
QUICK_SELECT_I::QS_TYPE_RANGE
@ QS_TYPE_RANGE
Definition: opt_range.h:330
Quick_ranges
Prealloced_array< QUICK_RANGE *, 16 > Quick_ranges
Definition: opt_range.h:435
HANDLER_BUFFER
Definition: handler.h:3209
QUICK_INDEX_MERGE_SELECT::add_info_string
void add_info_string(String *str)
Definition: opt_range.cc:11317
QUICK_ROR_UNION_SELECT::init
int init()
Definition: opt_range.cc:2189
QUICK_INDEX_MERGE_SELECT::is_agg_loose_index_scan
virtual bool is_agg_loose_index_scan() const
Definition: opt_range.h:635
Quick_ror_union_less::m_me
const QUICK_SELECT_I * m_me
Definition: opt_range.h:775
QEP_shared_owner::table
TABLE * table() const
Definition: sql_opt_exec_shared.h:486
QUICK_ROR_UNION_SELECT::scans_inited
bool scans_inited
Definition: opt_range.h:850
QUICK_SKIP_SCAN_SELECT::get_type
int get_type() const
Definition: opt_range.h:1111
QUICK_GROUP_MIN_MAX_SELECT::is_agg_distinct
bool is_agg_distinct() const
Definition: opt_range.h:972
QUICK_ROR_INTERSECT_SELECT::cpk_quick
QUICK_RANGE_SELECT * cpk_quick
Definition: opt_range.h:757
QUICK_ROR_UNION_SELECT::have_prev_rowid
bool have_prev_rowid
Definition: opt_range.h:846
QUICK_RANGE_SELECT::unique_key_range
bool unique_key_range()
Definition: opt_range.cc:10388
QUICK_SELECT_I::reverse_sort_possible
virtual bool reverse_sort_possible() const =0
Whether the range access method is capable of returning records in reverse order.
QUICK_RANGE_SELECT::in_ror_merged_scan
bool in_ror_merged_scan
Definition: opt_range.h:461
QUICK_INDEX_MERGE_SELECT::doing_pk_scan
bool doing_pk_scan
Definition: opt_range.h:652
uchar
unsigned char uchar
Definition: my_inttypes.h:51
QUICK_RANGE_SELECT::free_file
bool free_file
Definition: opt_range.h:486
sql_const.h
QUICK_ROR_INTERSECT_SELECT::get_fields_used
virtual void get_fields_used(MY_BITMAP *used_fields)
Get the fields used by the range access method.
Definition: opt_range.h:747
QUICK_SKIP_SCAN_SELECT::set_range
bool set_range(SEL_ARG *sel_range)
Setup fileds that hold the range condition on key part C.
Definition: opt_range.cc:14869
QUICK_ROR_UNION_SELECT::get_fields_used
virtual void get_fields_used(MY_BITMAP *used_fields)
Get the fields used by the range access method.
Definition: opt_range.h:830
QUICK_SKIP_SCAN_SELECT::is_loose_index_scan
virtual bool is_loose_index_scan() const
Definition: opt_range.h:1112
Cost_estimate
Used to store optimizer cost estimates.
Definition: handler.h:3283
QUICK_SELECT_DESC
Definition: opt_range.h:984
QUICK_SKIP_SCAN_SELECT::unique_key_range
bool unique_key_range()
Definition: opt_range.h:1110
table_map
uint64_t table_map
Definition: my_table_map.h:30
HA_READ_BEFORE_KEY
@ HA_READ_BEFORE_KEY
Definition: my_base.h:82
QUICK_ROR_UNION_SELECT::unique_key_range
bool unique_key_range()
Definition: opt_range.h:802
QUICK_RANGE::make_min_endpoint
void make_min_endpoint(key_range *kr)
Initalizes a key_range object for communication with storage engine.
Definition: opt_range.h:129
QUICK_RANGE_SELECT::get_next_prefix
int get_next_prefix(uint prefix_length, uint group_key_parts, uchar *cur_prefix)
Definition: opt_range.cc:10985
QUICK_ROR_INTERSECT_SELECT::get_type
int get_type() const
Definition: opt_range.h:716
QUICK_ROR_INTERSECT_SELECT::init
int init()
Definition: opt_range.cc:1955
QUICK_SKIP_SCAN_SELECT::distinct_prefix_key_parts
uint distinct_prefix_key_parts
Definition: opt_range.h:1069
QUICK_SELECT_I::record
uchar * record
Definition: opt_range.h:405
my_table_map.h
QUICK_RANGE_SELECT::get_quick_select
friend QUICK_RANGE_SELECT * get_quick_select(PARAM *, uint idx, SEL_ROOT *key_tree, uint mrr_flags, uint mrr_buf_size, MEM_ROOT *alloc, uint num_key_parts)
Definition: opt_range.cc:10193
QUICK_SELECT_I::make_reverse
virtual QUICK_SELECT_I * make_reverse(uint used_key_parts_arg)
Definition: opt_range.h:417
QUICK_SELECT_I::get_fields_used
virtual void get_fields_used(MY_BITMAP *used_fields)=0
Get the fields used by the range access method.
QUICK_GROUP_MIN_MAX_SELECT::dbug_dump
void dbug_dump(int indent, bool verbose)
Definition: opt_range.cc:15821
QUICK_SKIP_SCAN_SELECT::eq_prefix_elements
uint * eq_prefix_elements
Definition: opt_range.h:1051
QUICK_GROUP_MIN_MAX_SELECT::group_prefix
uchar * group_prefix
Definition: opt_range.h:891
QUICK_GROUP_MIN_MAX_SELECT::get_next
int get_next()
Definition: opt_range.cc:13388
QUICK_ROR_INTERSECT_SELECT::thd
THD * thd
Definition: opt_range.h:760
QUICK_ROR_INTERSECT_SELECT::QUICK_ROR_INTERSECT_SELECT
QUICK_ROR_INTERSECT_SELECT(THD *thd, TABLE *table, bool retrieve_full_rows, MEM_ROOT *parent_alloc)
Definition: opt_range.cc:1925
QUICK_INDEX_MERGE_SELECT::QUICK_INDEX_MERGE_SELECT
QUICK_INDEX_MERGE_SELECT(THD *thd, TABLE *table)
Definition: opt_range.cc:1867
QUICK_SELECT_DESC::m_used_key_parts
uint m_used_key_parts
Definition: opt_range.h:1005
QUICK_GROUP_MIN_MAX_SELECT::min_max_arg_part
KEY_PART_INFO * min_max_arg_part
Definition: opt_range.h:899
QUICK_GROUP_MIN_MAX_SELECT::tmp_record
uchar * tmp_record
Definition: opt_range.h:890
String::append
bool append(const String &s)
Definition: sql_string.cc:443
QUICK_ROR_UNION_SELECT::is_keys_used
bool is_keys_used(const MY_BITMAP *fields)
Definition: opt_range.cc:10444
QUICK_ROR_UNION_SELECT::QUICK_ROR_UNION_SELECT
QUICK_ROR_UNION_SELECT(THD *thd, TABLE *table)
Definition: opt_range.cc:2165
QUICK_SELECT_I::QS_TYPE_INDEX_MERGE
@ QS_TYPE_INDEX_MERGE
Definition: opt_range.h:331
QUICK_SKIP_SCAN_SELECT::dbug_dump
void dbug_dump(int indent, bool verbose)
Definition: opt_range.cc:15839
QUICK_GROUP_MIN_MAX_SELECT::reset
int reset()
Definition: opt_range.cc:13331
QUICK_SELECT_I::QS_TYPE_ROR_UNION
@ QS_TYPE_ROR_UNION
Definition: opt_range.h:335
QUICK_GROUP_MIN_MAX_SELECT::real_key_parts
uint real_key_parts
Definition: opt_range.h:914
QUICK_RANGE_SELECT::QUICK_SELECT_DESC
friend class QUICK_SELECT_DESC
Definition: opt_range.h:480
QUICK_RANGE_SELECT::dont_free
bool dont_free
Definition: opt_range.h:505
QUICK_RANGE_SELECT::need_sorted_output
void need_sorted_output()
Definition: opt_range.cc:1831
QUICK_SKIP_SCAN_SELECT::index_range_tree
SEL_ROOT * index_range_tree
Definition: opt_range.h:1032
QUICK_GROUP_MIN_MAX_SELECT::reset_group
void reset_group()
Definition: opt_range.cc:13762
range_seq_t
void * range_seq_t
Definition: handler.h:3215
QUICK_GROUP_MIN_MAX_SELECT::is_loose_index_scan
virtual bool is_loose_index_scan() const
Definition: opt_range.h:966
QUICK_RANGE::QUICK_RANGE
QUICK_RANGE()
Definition: opt_range.cc:2273
q
synode_no q[FIFO_SIZE]
Definition: xcom_base.c:2940
key.h
QUICK_SKIP_SCAN_SELECT::need_sorted_output
void need_sorted_output()
Definition: opt_range.h:1105
QUICK_ROR_INTERSECT_SELECT::reverse_sort_possible
bool reverse_sort_possible() const
Whether the range access method is capable of returning records in reverse order.
Definition: opt_range.h:714
QUICK_SELECT_I
Definition: opt_range.h:229
key_spec.h
QUICK_RANGE_SELECT::is_loose_index_scan
virtual bool is_loose_index_scan() const
Definition: opt_range.h:531
QUICK_GROUP_MIN_MAX_SELECT::have_agg_distinct
bool have_agg_distinct
Definition: opt_range.h:897
QUICK_RANGE_SELECT::save_last_pos
void save_last_pos()
Definition: opt_range.h:529
key_range::keypart_map
key_part_map keypart_map
Definition: my_base.h:1119
QUICK_SELECT_I::is_agg_loose_index_scan
virtual bool is_agg_loose_index_scan() const =0
QUICK_SKIP_SCAN_SELECT::add_keys_and_lengths
void add_keys_and_lengths(String *key_names, String *used_lengths)
Append comma-separated list of keys this quick select uses to key_names; append comma-separated list ...
Definition: opt_range.cc:15195
QUICK_GROUP_MIN_MAX_SELECT::key_infix_parts
uint key_infix_parts
Definition: opt_range.h:904
QUICK_SKIP_SCAN_SELECT::alloc
MEM_ROOT alloc
Definition: opt_range.h:1094
QUICK_SKIP_SCAN_SELECT::eq_prefix_key_parts
uint eq_prefix_key_parts
Definition: opt_range.h:1053
QUICK_RANGE_SELECT::get_quick_keys
friend bool get_quick_keys(PARAM *param, QUICK_RANGE_SELECT *quick, KEY_PART *key, SEL_ARG *key_tree, uchar *min_key, uint min_key_flag, uchar *max_key, uint max_key_flag, uint *desc_flag, uint num_key_parts)
Generate key values for range select from given sel_arg tree.
Definition: opt_range.cc:10259
QUICK_ROR_INTERSECT_SELECT::unique_key_range
bool unique_key_range()
Definition: opt_range.h:715
KEY
Definition: key.h:111
QUICK_SELECT_I::get_next
virtual int get_next()=0
QUICK_SKIP_SCAN_SELECT::end_key
key_range end_key
Definition: opt_range.h:1087
sql_list.h
QUICK_SELECT_I::add_keys_and_lengths
virtual void add_keys_and_lengths(String *key_names, String *used_lengths)=0
QUICK_RANGE_SELECT::alloc
std::shared_ptr< MEM_ROOT > alloc
Definition: opt_range.h:512
TABLE::file
handler * file
Definition: table.h:1307
uint8
uint8_t uint8
Definition: my_inttypes.h:62
QUICK_ROR_UNION_SELECT::prev_rowid
uchar * prev_rowid
Definition: opt_range.h:845
DBUG_ASSERT
#define DBUG_ASSERT(A)
Definition: my_dbug.h:197
QUICK_RANGE_SELECT::is_agg_loose_index_scan
virtual bool is_agg_loose_index_scan() const
Definition: opt_range.h:532
Item_sum
Class Item_sum is the base class used for special expressions that SQL calls 'set functions'.
Definition: item_sum.h:390
QUICK_GROUP_MIN_MAX_SELECT::get_type
int get_type() const
Definition: opt_range.h:965
QUICK_ROR_INTERSECT_SELECT::add_keys_and_lengths
void add_keys_and_lengths(String *key_names, String *used_lengths)
Definition: opt_range.cc:11426
QUICK_GROUP_MIN_MAX_SELECT::next_prefix
int next_prefix()
Definition: opt_range.cc:13670
QUICK_ROR_UNION_SELECT::alloc
MEM_ROOT alloc
Definition: opt_range.h:841
my_bitmap.h
QUICK_GROUP_MIN_MAX_SELECT::key_infix_len
uint key_infix_len
Definition: opt_range.h:903
QUICK_SELECT_DESC::is_agg_loose_index_scan
virtual bool is_agg_loose_index_scan() const
Definition: opt_range.h:992
enum_order
enum_order
Definition: key_spec.h:64
QUICK_INDEX_MERGE_SELECT::init
int init()
Definition: opt_range.cc:1876
QUICK_RANGE::min_keypart_map
key_part_map min_keypart_map
Definition: opt_range.h:90
QUICK_SKIP_SCAN_SELECT::reverse_sort_possible
bool reverse_sort_possible() const
Whether the range access method is capable of returning records in reverse order.
Definition: opt_range.h:1109
QUICK_RANGE_SELECT::mrr_buf_size
uint mrr_buf_size
Definition: opt_range.h:498
QUICK_RANGE_SELECT
Definition: opt_range.h:457
QUICK_SKIP_SCAN_SELECT::range_cond_flag
uint range_cond_flag
Definition: opt_range.h:1084
QUICK_RANGE_SELECT::key_parts
KEY_PART * key_parts
Definition: opt_range.h:502
Field::field_index
uint16 field_index
Definition: field.h:841
QUICK_SKIP_SCAN_SELECT::reverse_sorted
bool reverse_sorted() const
Whether the range access method returns records in reverse order.
Definition: opt_range.h:1108
verbose
static uint verbose
Definition: mysqlcheck.cc:64
QUICK_SKIP_SCAN_SELECT::get_fields_used
virtual void get_fields_used(MY_BITMAP *used_fields)
Get the fields used by the range access method.
Definition: opt_range.h:1120
ha_rkey_function
ha_rkey_function
Definition: my_base.h:77
QUICK_RANGE_SELECT::range_end
void range_end()
Definition: opt_range.cc:1840
QUICK_SELECT_I::is_loose_index_scan
virtual bool is_loose_index_scan() const =0
QUICK_GROUP_MIN_MAX_SELECT::reverse_sorted
bool reverse_sorted() const
Whether the range access method returns records in reverse order.
Definition: opt_range.h:962
QUICK_RANGE_SEQ_CTX::last
Quick_ranges::const_iterator last
Definition: opt_range.h:447
QUICK_ROR_UNION_SELECT::get_type
int get_type() const
Definition: opt_range.h:803
QUICK_SELECT_I::is_valid
virtual bool is_valid()
Simple sanity check that the quick select has been set up correctly.
Definition: opt_range.h:394
QUICK_GROUP_MIN_MAX_SELECT::update_max_result
void update_max_result(bool *reset)
Definition: opt_range.cc:14176
QUICK_RANGE_SELECT::file
handler * file
Definition: opt_range.h:459
QUICK_RANGE_SELECT::dbug_dump
void dbug_dump(int indent, bool verbose)
Definition: opt_range.cc:15734
QUICK_RANGE_SELECT::column_bitmap
MY_BITMAP column_bitmap
Definition: opt_range.h:464
QUICK_INDEX_MERGE_SELECT
Definition: opt_range.h:619
QUICK_GROUP_MIN_MAX_SELECT
Definition: opt_range.h:886
QUICK_SELECT_I::get_type
virtual int get_type() const =0
QUICK_GROUP_MIN_MAX_SELECT::init
int init()
Definition: opt_range.cc:13096
QUICK_SELECT_I::unique_key_range
virtual bool unique_key_range()
Definition: opt_range.h:317
QUICK_ROR_UNION_SELECT::is_agg_loose_index_scan
virtual bool is_agg_loose_index_scan() const
Definition: opt_range.h:805
QUICK_GROUP_MIN_MAX_SELECT::real_prefix_len
uint real_prefix_len
Definition: opt_range.h:913
QUICK_INDEX_MERGE_SELECT::add_keys_and_lengths
void add_keys_and_lengths(String *key_names, String *used_lengths)
Definition: opt_range.cc:11394
QUICK_INDEX_MERGE_SELECT::get_fields_used
virtual void get_fields_used(MY_BITMAP *used_fields)
Get the fields used by the range access method.
Definition: opt_range.h:673
MAX_REF_PARTS
#define MAX_REF_PARTS
Definition: sql_const.h:52
m_string.h
QUICK_RANGE_SELECT::last_range
QUICK_RANGE * last_range
Definition: opt_range.h:490
KEY_PART::image_type
Field::imagetype image_type
Definition: opt_range.h:74
QUICK_RANGE_SELECT::init_ror_merged_scan
int init_ror_merged_scan(bool reuse_handler)
Definition: opt_range.cc:1983
table.h
QUICK_RANGE_SELECT::make_reverse
QUICK_SELECT_I * make_reverse(uint used_key_parts_arg)
Create a compatible quick select with the result ordered in an opposite way.
Definition: opt_range.cc:11266
QUICK_INDEX_MERGE_SELECT::read_record
unique_ptr_destroy_only< RowIterator > read_record
Definition: opt_range.h:682
QUICK_GROUP_MIN_MAX_SELECT::group_key_parts
uint group_key_parts
Definition: opt_range.h:893
QUICK_INDEX_MERGE_SELECT::thd
THD * thd
Definition: opt_range.h:655
QUICK_INDEX_MERGE_SELECT::clustered_pk_range
bool clustered_pk_range()
Definition: opt_range.h:658
uint16
uint16_t uint16
Definition: my_inttypes.h:64
QUICK_SKIP_SCAN_SELECT::~QUICK_SKIP_SCAN_SELECT
~QUICK_SKIP_SCAN_SELECT()
Definition: opt_range.cc:14846
SEL_ARG
Definition: opt_range.cc:664
range_optimizer_free
void range_optimizer_free()
Global destruction of the null_element. Call on server stop.
Definition: opt_range.cc:1506
QUICK_SELECT_I::clustered_pk_range
virtual bool clustered_pk_range()
Definition: opt_range.h:318
store_key_image_to_rec
void store_key_image_to_rec(Field *field, uchar *ptr, uint len)
Definition: opt_range.cc:3910
QUICK_GROUP_MIN_MAX_SELECT::~QUICK_GROUP_MIN_MAX_SELECT
~QUICK_GROUP_MIN_MAX_SELECT()
Definition: opt_range.cc:13152
List< QUICK_RANGE_SELECT >
ha_rows
my_off_t ha_rows
Definition: my_base.h:1132
Quick_ror_union_less::Quick_ror_union_less
Quick_ror_union_less(const QUICK_SELECT_I *me)
Definition: opt_range.h:771
quick
static bool quick
Definition: mysql.cc:153
QUICK_RANGE::make_max_endpoint
void make_max_endpoint(key_range *kr, uint prefix_length, key_part_map keypart_map)
Initalizes a key_range object for communication with storage engine.
Definition: opt_range.h:152
QUICK_RANGE_SELECT_GEOM::get_next
virtual int get_next()
Definition: opt_range.cc:11034
QUICK_RANGE_SELECT::mrr_flags
uint mrr_flags
Definition: opt_range.h:496
QUICK_RANGE_SELECT::get_type
int get_type() const
Definition: opt_range.h:530
QUICK_GROUP_MIN_MAX_SELECT::index_info
KEY * index_info
Definition: opt_range.h:889
PARAM
Definition: opt_range.cc:1354
QUICK_SELECT_DESC::get_type
int get_type() const
Definition: opt_range.h:990
Field
Definition: field.h:695
TRP_ROR_INTERSECT
Definition: opt_range.cc:2678
QUICK_INDEX_MERGE_SELECT::push_quick_back
bool push_quick_back(QUICK_RANGE_SELECT *quick_sel_range)
Definition: opt_range.cc:1887
QUICK_RANGE::make_max_endpoint
void make_max_endpoint(key_range *kr)
Initalizes a key_range object for communication with storage engine.
Definition: opt_range.h:168
QUICK_INDEX_MERGE_SELECT::is_keys_used
bool is_keys_used(const MY_BITMAP *fields)
Definition: opt_range.cc:10426
QUICK_GROUP_MIN_MAX_SELECT::min_max_ranges
Quick_ranges min_max_ranges
Definition: opt_range.h:911
QUICK_INDEX_MERGE_SELECT::dbug_dump
void dbug_dump(int indent, bool verbose)
Definition: opt_range.cc:15765
keys
static uint keys
Definition: hp_test2.cc:43
SEL_ROOT
A graph of (possible multiple) key ranges, represented as a red-black binary tree.
Definition: opt_range.cc:291
key_range
Definition: my_base.h:1116
QUICK_SKIP_SCAN_SELECT::index_info
KEY * index_info
Definition: opt_range.h:1031
QUICK_ROR_UNION_SELECT::cur_rowid
uchar * cur_rowid
Definition: opt_range.h:844
Quick_ranges_array
Prealloced_array< Quick_ranges *, 16 > Quick_ranges_array
Definition: opt_range.h:438
QUICK_SELECT_I::reset
virtual int reset(void)=0
QUICK_ROR_UNION_SELECT::dbug_dump
void dbug_dump(int indent, bool verbose)
Definition: opt_range.cc:15792
QUICK_ROR_INTERSECT_SELECT
Definition: opt_range.h:703
QUICK_GROUP_MIN_MAX_SELECT::is_index_scan
bool is_index_scan
Definition: opt_range.h:923
List_iterator::rewind
void rewind(void)
Definition: sql_list.h:575
QUICK_ROR_INTERSECT_SELECT::alloc
MEM_ROOT alloc
Definition: opt_range.h:759
QUICK_GROUP_MIN_MAX_SELECT::last_prefix
uchar * last_prefix
Definition: opt_range.h:894
MY_BITMAP
Definition: my_bitmap.h:41
QUICK_GROUP_MIN_MAX_SELECT::adjust_prefix_ranges
void adjust_prefix_ranges()
Definition: opt_range.cc:13251
QUICK_SELECT_I::index
uint index
Definition: opt_range.h:238
Quick_ror_union_less
Definition: opt_range.h:770
QUICK_ROR_INTERSECT_SELECT::reset
int reset(void)
Definition: opt_range.cc:2128
QUICK_GROUP_MIN_MAX_SELECT::max_functions_it
List_iterator< Item_sum > * max_functions_it
Definition: opt_range.h:918
QUICK_SKIP_SCAN_SELECT::min_search_key
uchar * min_search_key
Definition: opt_range.h:1082
QUICK_INDEX_MERGE_SELECT::get_next
int get_next()
Definition: opt_range.cc:10576
QUICK_ROR_INTERSECT_SELECT::get_next
int get_next()
Definition: opt_range.cc:10630
QUICK_SELECT_I::trace_quick_description
void trace_quick_description(Opt_trace_context *trace)
Definition: opt_range.cc:1779
QUICK_SELECT_I::init_ror_merged_scan
virtual int init_ror_merged_scan(bool reuse_handler)
Definition: opt_range.h:358
QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range
int next_max_in_range()
Definition: opt_range.cc:14030
QUICK_GROUP_MIN_MAX_SELECT::have_max
bool have_max
Definition: opt_range.h:896
QUICK_INDEX_MERGE_SELECT::read_keys_and_merge
int read_keys_and_merge()
Definition: opt_range.cc:10470
QUICK_SELECT_I::forced_by_hint
bool forced_by_hint
true if creation of the object is forced by the hint.
Definition: opt_range.h:260
QUICK_SELECT_I::max_used_key_length
uint max_used_key_length
Definition: opt_range.h:244
QUICK_SKIP_SCAN_SELECT::max_range_key
uchar * max_range_key
Definition: opt_range.h:1081
QUICK_RANGE_SELECT::add_info_string
void add_info_string(String *str)
Definition: opt_range.cc:11312
QUICK_INDEX_MERGE_SELECT::get_type
int get_type() const
Definition: opt_range.h:633
key_range::length
uint length
Definition: my_base.h:1118
QUICK_ROR_INTERSECT_SELECT::is_valid
virtual bool is_valid()
Simple sanity check that the quick select has been set up correctly.
Definition: opt_range.h:734
QUICK_RANGE_SELECT::reverse_sorted
bool reverse_sorted() const
Whether the range access method returns records in reverse order.
Definition: opt_range.h:525
QUICK_SELECT_I::QS_TYPE_RANGE_DESC
@ QS_TYPE_RANGE_DESC
Definition: opt_range.h:332
prune_partitions
bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond)
Perform partition pruning for a given table and condition.
Definition: opt_range.cc:3710
QUICK_SKIP_SCAN_SELECT::eq_key_prefixes
uchar *** eq_key_prefixes
Definition: opt_range.h:1050
QUICK_ROR_UNION_SELECT::~QUICK_ROR_UNION_SELECT
~QUICK_ROR_UNION_SELECT()
Definition: opt_range.cc:2266
QUICK_GROUP_MIN_MAX_SELECT::unique_key_range
bool unique_key_range()
Definition: opt_range.h:964
QUICK_INDEX_MERGE_SELECT::reverse_sorted
bool reverse_sorted() const
Whether the range access method returns records in reverse order.
Definition: opt_range.h:630
QUICK_SELECT_I::init
virtual int init()=0
QUICK_SELECT_I::need_sorted_output
virtual void need_sorted_output()=0
QUICK_SKIP_SCAN_SELECT::join
JOIN * join
Definition: opt_range.h:1030
QUICK_SELECT_I::QUICK_SELECT_I
QUICK_SELECT_I()
Definition: opt_range.cc:1776
QUICK_RANGE_SELECT_GEOM
Definition: opt_range.h:551
flags
static int flags[50]
Definition: hp_test1.cc:39
QUICK_RANGE_SELECT::ranges
Quick_ranges ranges
Definition: opt_range.h:485
NEAR_MIN
@ NEAR_MIN
Definition: my_base.h:1075
QUICK_RANGE::flag
uint16 flag
Stores bitwise-or'ed bits defined in enum key_range_flags.
Definition: opt_range.h:83
QUICK_SKIP_SCAN_SELECT::max_search_key
uchar * max_search_key
Definition: opt_range.h:1083