Commit 9a780a59 authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-4687: impossible where with < operation, but =-5 return one row

- Let _ma_record_pos() set SEARCH_PART_KEY when doing a search on
  a prefix of a [unique] key.  Otherwise, _ma_search_pos() would 
  find the first key equal to search key, and assume it is also 
  the last one, which will make a wrong estimate of key's position.

  A wrong key position may cause min_pos > max_pos and records_in_range()
  will return 0, which will make the optimizer think it's an impossible 
  range while in fact it is not.
parent 9e13011e
......@@ -145,6 +145,10 @@ static ha_rows _ma_record_pos(MARIA_HA *info, const uchar *key_data,
DBUG_EXECUTE("key", _ma_print_key(DBUG_FILE, &key););
nextflag=maria_read_vec[search_flag];
/* Indicate if we're doing a search on a key prefix */
if (((((key_part_map)1) << key.keyinfo->keysegs) - 1) != keypart_map)
nextflag |= SEARCH_PART_KEY;
/*
my_handler.c:ha_compare_text() has a flag 'skip_end_space'.
This is set in my_handler.c:ha_key_cmp() in dependence on the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment