From 5e36f5dd00d706baea7af623f09711d66ba0109c Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Tue, 28 May 2019 15:43:12 +0530 Subject: MDEV-18741: Optimizer trace: multi-part key ranges are printed incorrectly Changed the function append_range_all_keyparts to use sel_arg_range_seq_init / sel_arg_range_seq_next to produce ranges. Also adjusted to print format for the ranges, now the ranges are printed as: (keypart1_min, keypart2_min,..) OP (keypart1_name,keypart2_name, ..) OP (keypart1_max,keypart2_max, ..) Also added more tests for range and index merge access for optimizer trace --- sql/opt_range_mrr.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'sql/opt_range_mrr.cc') diff --git a/sql/opt_range_mrr.cc b/sql/opt_range_mrr.cc index 3a25da3edb2..d3a1e155fb7 100644 --- a/sql/opt_range_mrr.cc +++ b/sql/opt_range_mrr.cc @@ -53,6 +53,11 @@ typedef struct st_sel_arg_range_seq int i; /* Index of last used element in the above array */ bool at_start; /* TRUE <=> The traversal has just started */ + /* + Iteration functions will set this to FALSE + if ranges being traversed do not allow to construct a ROR-scan" + */ + bool is_ror_scan; } SEL_ARG_RANGE_SEQ; @@ -165,7 +170,7 @@ bool sel_arg_range_seq_next(range_seq_t rseq, KEY_MULTI_RANGE *range) seq->i--; step_down_to(seq, key_tree->next); key_tree= key_tree->next; - seq->param->is_ror_scan= FALSE; + seq->is_ror_scan= FALSE; goto walk_right_n_up; } @@ -207,7 +212,7 @@ walk_right_n_up: !memcmp(cur[-1].min_key, cur[-1].max_key, len) && !key_tree->min_flag && !key_tree->max_flag)) { - seq->param->is_ror_scan= FALSE; + seq->is_ror_scan= FALSE; if (!key_tree->min_flag) cur->min_key_parts += key_tree->next_key_part->store_min_key(seq->param->key[seq->keyno], @@ -312,7 +317,7 @@ walk_up_n_right: range->range_flag |= UNIQUE_RANGE | (cur->min_key_flag & NULL_RANGE); } - if (seq->param->is_ror_scan) + if (seq->is_ror_scan) { /* If we get here, the condition on the key was converted to form @@ -327,7 +332,7 @@ walk_up_n_right: (range->start_key.length == range->end_key.length) && !memcmp(range->start_key.key, range->end_key.key, range->start_key.length) && is_key_scan_ror(seq->param, seq->real_keyno, key_tree->part + 1))) - seq->param->is_ror_scan= FALSE; + seq->is_ror_scan= FALSE; } } seq->param->range_count++; -- cgit v1.2.1