Commit e4ffff29 authored by monty@mysql.com's avatar monty@mysql.com

Fix max_key_length and max_unique_length to take into account varchar and null extra lengths

This fixes a bug found by bdb.test
Fixes a portability issue with bdb tables
parent ae1b969c
...@@ -77,6 +77,7 @@ explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' ...@@ -77,6 +77,7 @@ explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a '
alter table t1 add unique(v); alter table t1 add unique(v);
alter table t1 add key(v); alter table t1 add key(v);
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a'; select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a';
--replace_column 6 #
explain select * from t1 where v='a'; explain select * from t1 where v='a';
# GROUP BY # GROUP BY
......
...@@ -1445,7 +1445,7 @@ qq ...@@ -1445,7 +1445,7 @@ qq
*a *a*a * *a *a*a *
explain select * from t1 where v='a'; explain select * from t1 where v='a';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v,v_2 v 13 const 10 Using where 1 SIMPLE t1 ref v,v_2 # 13 const 10 Using where
select v,count(*) from t1 group by v limit 10; select v,count(*) from t1 group by v limit 10;
v count(*) v count(*)
a 1 a 1
......
...@@ -716,7 +716,7 @@ qq ...@@ -716,7 +716,7 @@ qq
*a *a*a * *a *a*a *
explain select * from t1 where v='a'; explain select * from t1 where v='a';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v,v_2 v_2 13 const 7 Using where 1 SIMPLE t1 ref v,v_2 # 13 const 7 Using where
select v,count(*) from t1 group by v limit 10; select v,count(*) from t1 group by v limit 10;
v count(*) v count(*)
a 1 a 1
......
...@@ -262,11 +262,6 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, ...@@ -262,11 +262,6 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
} }
key_part->store_length=key_part->length; key_part->store_length=key_part->length;
} }
set_if_bigger(outparam->max_key_length,keyinfo->key_length+
keyinfo->key_parts);
outparam->total_key_length+= keyinfo->key_length;
if (keyinfo->flags & HA_NOSAME)
set_if_bigger(outparam->max_unique_length,keyinfo->key_length);
} }
keynames=(char*) key_part; keynames=(char*) key_part;
strpos+= (strmov(keynames, (char *) strpos) - keynames)+1; strpos+= (strmov(keynames, (char *) strpos) - keynames)+1;
...@@ -718,6 +713,12 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, ...@@ -718,6 +713,12 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
} }
} }
keyinfo->usable_key_parts=usable_parts; // Filesort keyinfo->usable_key_parts=usable_parts; // Filesort
set_if_bigger(outparam->max_key_length,keyinfo->key_length+
keyinfo->key_parts);
outparam->total_key_length+= keyinfo->key_length;
if (keyinfo->flags & HA_NOSAME)
set_if_bigger(outparam->max_unique_length,keyinfo->key_length);
} }
if (primary_key < MAX_KEY && if (primary_key < MAX_KEY &&
(outparam->keys_in_use.is_set(primary_key))) (outparam->keys_in_use.is_set(primary_key)))
......
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