Commit d14a27fd authored by unknown's avatar unknown

bug#4816. index search for NULL in blob

parent 9ca47d04
...@@ -177,6 +177,8 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, ...@@ -177,6 +177,8 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
if (!(*key++= (char) 1-*old++)) /* Copy null marker */ if (!(*key++= (char) 1-*old++)) /* Copy null marker */
{ {
k_length-=length; k_length-=length;
if (keyseg->flag & (HA_VAR_LENGTH | HA_BLOB_PART))
k_length-=2; /* Skip length */
continue; /* Found NULL */ continue; /* Found NULL */
} }
} }
......
...@@ -453,3 +453,12 @@ table type possible_keys key key_len ref rows Extra ...@@ -453,3 +453,12 @@ table type possible_keys key key_len ref rows Extra
t1 system NULL NULL NULL NULL 1 Using temporary t1 system NULL NULL NULL NULL 1 Using temporary
t2 index NULL PRIMARY 4 NULL 2 Using index; Distinct t2 index NULL PRIMARY 4 NULL 2 Using index; Distinct
drop table t1,t2; drop table t1,t2;
create table t1 ( a tinytext, b char(1), index idx (a(1),b) );
insert into t1 values (null,''), (null,'');
explain select count(*) from t1 where a is null;
table type possible_keys key key_len ref rows Extra
t1 ref idx idx 4 const 1 Using where
select count(*) from t1 where a is null;
count(*)
2
drop table t1;
...@@ -436,3 +436,13 @@ select sql_big_result distinct t1.a from t1,t2; ...@@ -436,3 +436,13 @@ select sql_big_result distinct t1.a from t1,t2;
explain select sql_big_result distinct t1.a from t1,t2 order by t2.a; explain select sql_big_result distinct t1.a from t1,t2 order by t2.a;
explain select distinct t1.a from t1,t2 order by t2.a; explain select distinct t1.a from t1,t2 order by t2.a;
drop table t1,t2; drop table t1,t2;
#
# index search for NULL in blob. Bug #4816
#
create table t1 ( a tinytext, b char(1), index idx (a(1),b) );
insert into t1 values (null,''), (null,'');
explain select count(*) from t1 where a is null;
select count(*) from t1 where a is null;
drop table t1;
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