[Commits] Rev 3678: MDEV-4687: impossible where with < operation, but =-5 return one row in file:///home/bell/maria/bzr/work-maria-10.0-base-merge-5.5/

sanja at montyprogram.com sanja at montyprogram.com
Mon Aug 19 12:59:09 EEST 2013


At file:///home/bell/maria/bzr/work-maria-10.0-base-merge-5.5/

------------------------------------------------------------
revno: 3678
revision-id: psergey at askmonty.org-20130725184226-82igca7xm0xsogrc
parent: sanja at montyprogram.com-20130719102123-hj6ncjwg8e3s4nr2
author: Sergey Petrunya <psergey at askmonty.org>
committer: sanja at montyprogram.com
branch nick: 5.5
timestamp: Thu 2013-07-25 22:42:26 +0400
message:
  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.
-------------- next part --------------
=== modified file 'storage/maria/ma_range.c'
--- a/storage/maria/ma_range.c	2011-07-13 19:10:18 +0000
+++ b/storage/maria/ma_range.c	2013-07-25 18:42:26 +0000
@@ -144,6 +144,10 @@ static ha_rows _ma_record_pos(MARIA_HA *
 		       (HA_KEYSEG**) 0);
   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'.



More information about the commits mailing list