File tree Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -266,12 +266,28 @@ bool sel_arg_range_seq_next(range_seq_t rseq, KEY_MULTI_RANGE *range)
266
266
range->end_key .flag = (cur->max_key_flag & NEAR_MAX ? HA_READ_BEFORE_KEY :
267
267
HA_READ_AFTER_KEY);
268
268
range->end_key .keypart_map = make_prev_keypart_map (cur->max_key_parts );
269
-
269
+
270
+ KEY *key_info;
271
+ if (seq->real_keyno == MAX_KEY)
272
+ key_info= NULL ;
273
+ else
274
+ key_info= &seq->param ->table ->key_info [seq->real_keyno ];
275
+
276
+ /*
277
+ Conditions below:
278
+ (1) - range analysis is used for estimating condition selectivity
279
+ (2) - This is a unique key, and we have conditions for all its
280
+ user-defined key parts.
281
+ (3) - The table uses extended keys, and we have conditions for
282
+ all key parts.
283
+ */
270
284
if (!(cur->min_key_flag & ~NULL_RANGE) && !cur->max_key_flag &&
271
- (seq->real_keyno == MAX_KEY ||
272
- ((uint)key_tree->part +1 ==
273
- seq->param ->table ->key_info [seq->real_keyno ].user_defined_key_parts &&
274
- (seq->param ->table ->key_info [seq->real_keyno ].flags & HA_NOSAME))) &&
285
+ (!key_info || // (1)
286
+ ((uint)key_tree->part +1 == key_info->user_defined_key_parts && // (2)
287
+ key_info->flags & HA_NOSAME) || // (2)
288
+ (seq->param ->table ->s ->use_ext_keys && // (3)
289
+ (uint)key_tree->part +1 == key_info->ext_key_parts ) // (3)
290
+ ) &&
275
291
range->start_key .length == range->end_key .length &&
276
292
!memcmp (seq->param ->min_key ,seq->param ->max_key ,range->start_key .length ))
277
293
range->range_flag = UNIQUE_RANGE | (cur->min_key_flag & NULL_RANGE);
You can’t perform that action at this time.
0 commit comments