1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Fix for bug #20732: Partial index and long sjis search with '>' fails sometimes

We miss some records sometimes using RANGE method if we have
partial key segments.
Example:
  Create table t1(a char(2), key(a(1)));
  insert into t1 values ('a'), ('xx');
  select a from t1 where a > 'x';
We call index_read() passing 'x' key and HA_READ_AFTER_KEY flag
in the handler::read_range_first() wich is wrong because we have
a partial key segment for the field and might miss records like 'xx'.

Fix: don't use open segments in such a case.
This commit is contained in:
ramil/ram@mysql.com/myoffice.izhnet.ru
2006-10-19 12:52:37 +05:00
parent cfd442b67f
commit 0027b6e4b7
6 changed files with 29 additions and 5 deletions

View File

@ -885,6 +885,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
key_parts->null_bit= key_part_info->null_bit;
key_parts->image_type =
(key_info->flags & HA_SPATIAL) ? Field::itMBR : Field::itRAW;
key_parts->flag= key_part_info->key_part_flag;
}
param.real_keynr[param.keys++]=idx;
}
@ -1398,7 +1399,9 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
}
break;
case Item_func::GT_FUNC:
if (field_is_equal_to_item(field,value))
/* Don't use open ranges for partial key_segments */
if (field_is_equal_to_item(field,value) &&
!(key_part->flag & HA_PART_KEY_SEG))
tree->min_flag=NEAR_MIN;
/* fall through */
case Item_func::GE_FUNC:
@ -2899,6 +2902,7 @@ QUICK_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, TABLE_REF *ref)
key_part->length= key_info->key_part[part].length;
key_part->store_length= key_info->key_part[part].store_length;
key_part->null_bit= key_info->key_part[part].null_bit;
key_part->flag= key_info->key_part[part].key_part_flag;
}
if (quick->ranges.push_back(range))
goto err;