diff options
Diffstat (limited to 'sql/handler.h')
-rw-r--r-- | sql/handler.h | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/sql/handler.h b/sql/handler.h index aabb60e4252..36cb81017c6 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1358,6 +1358,15 @@ void get_sweep_read_cost(TABLE *table, ha_rows nrows, bool interrupted, */ #define HA_MRR_MATERIALIZED_KEYS 256 +#define HA_MRR_IMPLEMENTATION_FLAG1 512 +#define HA_MRR_IMPLEMENTATION_FLAG2 1024 +#define HA_MRR_IMPLEMENTATION_FLAG3 2048 +#define HA_MRR_IMPLEMENTATION_FLAG4 4096 +#define HA_MRR_IMPLEMENTATION_FLAG5 8192 +#define HA_MRR_IMPLEMENTATION_FLAG6 16384 + +#define HA_MRR_IMPLEMENTATION_FLAGS \ + (512 | 1024 | 2048 | 4096 | 8192 | 16384) /* This is a buffer area that the handler can use to store rows. @@ -1863,14 +1872,40 @@ public: virtual ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges, uint *bufsz, - uint *flags, COST_VECT *cost); + uint *mrr_mode, COST_VECT *cost); virtual ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys, uint key_parts, uint *bufsz, - uint *flags, COST_VECT *cost); + uint *mrr_mode, COST_VECT *cost); virtual int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param, - uint n_ranges, uint mode, + uint n_ranges, uint mrr_mode, HANDLER_BUFFER *buf); virtual int multi_range_read_next(range_id_t *range_info); + /* + Return string representation of the MRR plan. + + This is intended to be used for EXPLAIN, via the following scenario: + 1. SQL layer calls handler->multi_range_read_info(). + 1.1. Storage engine figures out whether it will use some non-default + MRR strategy, sets appropritate bits in *mrr_mode, and returns + control to SQL layer + 2. SQL layer remembers the returned mrr_mode + 3. SQL layer compares various options and choses the final query plan. As + a part of that, it makes a choice of whether to use the MRR strategy + picked in 1.1 + 4. EXPLAIN code converts the query plan to its text representation. If MRR + strategy is part of the plan, it calls + multi_range_read_explain_info(mrr_mode) to get a text representation of + the picked MRR strategy. + + @param mrr_mode Mode which was returned by multi_range_read_info[_const] + @param str INOUT string to be printed for EXPLAIN + @param str_end End of the string buffer. The function is free to put the + string into [str..str_end] memory range. + */ + virtual int multi_range_read_explain_info(uint mrr_mode, char *str, + size_t size) + { return 0; } + virtual int read_range_first(const key_range *start_key, const key_range *end_key, bool eq_range, bool sorted); |