Skip to content

Instantly share code, notes, and snippets.

@elenst
Created July 16, 2016 13:17
Show Gist options
  • Save elenst/08d027e5cf6f1efe7e9d3b677b6cf3b7 to your computer and use it in GitHub Desktop.
Save elenst/08d027e5cf6f1efe7e9d3b677b6cf3b7 to your computer and use it in GitHub Desktop.
/*
Conditions below:
(1) - range analysis is used for estimating condition selectivity
(2) - This is a unique key, and we have conditions for all its
user-defined key parts.
(3) - The table uses extended keys, this key covers all components,
and we have conditions for all key parts.
*/
if (!(cur->min_key_flag & ~NULL_RANGE) && !cur->max_key_flag &&
(!key_info || // (1)
((uint)key_tree->part+1 == key_info->user_defined_key_parts && // (2)
key_info->flags & HA_NOSAME) || // (2)
((key_info->flags & HA_EXT_NOSAME) && // (3)
(uint)key_tree->part+1 == key_info->ext_key_parts) // (3)
) &&
range->start_key.length == range->end_key.length &&
!memcmp(seq->param->min_key,seq->param->max_key,range->start_key.length))
range->range_flag= UNIQUE_RANGE | (cur->min_key_flag & NULL_RANGE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment