Commit 95409456 authored by unknown's avatar unknown

select.result, select.test:

  Added a test case for bug #7520.
table.cc:
  Fixed bug #7520.
  The bug was caused by a wrong calculation of the field max_key_length for
  a TABLE structure when there was an index on a blob field.


sql/table.cc:
  Fixed bug #7520.
  The bug was caused by a wrong calculation of the field max_key_length for
  a TABLE structure when there was an index on a blob field.
mysql-test/t/select.test:
  Added a test case for bug #7520.
mysql-test/r/select.result:
  Added a test case for bug #7520.
parent 82de648b
...@@ -2364,3 +2364,16 @@ EXPLAIN SELECT i FROM t1 WHERE i=1; ...@@ -2364,3 +2364,16 @@ EXPLAIN SELECT i FROM t1 WHERE i=1;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 const PRIMARY PRIMARY 4 const 1 Using index t1 const PRIMARY PRIMARY 4 const 1 Using index
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );
CREATE TABLE t2 ( a BLOB, INDEX (a(20)) );
INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');
INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five');
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a;
table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 5
t2 ref a a 23 t1.a 5
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;
table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 5
t2 ref a a 23 t1.a 5
DROP TABLE t1, t2;
...@@ -1909,3 +1909,18 @@ EXPLAIN SELECT i FROM t1 WHERE i=1; ...@@ -1909,3 +1909,18 @@ EXPLAIN SELECT i FROM t1 WHERE i=1;
EXPLAIN SELECT i FROM t1 WHERE i=1; EXPLAIN SELECT i FROM t1 WHERE i=1;
DROP TABLE t1; DROP TABLE t1;
#
# Test case for bug 7520: a wrong cost of the index for a BLOB field
#
CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );
CREATE TABLE t2 ( a BLOB, INDEX (a(20)) );
INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five');
INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five');
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a;
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;
DROP TABLE t1, t2;
...@@ -486,6 +486,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, ...@@ -486,6 +486,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
if (!(field->flags & BINARY_FLAG)) if (!(field->flags & BINARY_FLAG))
keyinfo->flags|= HA_END_SPACE_KEY; keyinfo->flags|= HA_END_SPACE_KEY;
} }
set_if_bigger(outparam->max_key_length, keyinfo->key_length);
if (i == 0 && key != primary_key) if (i == 0 && key != primary_key)
field->flags |= field->flags |=
((keyinfo->flags & HA_NOSAME) && ((keyinfo->flags & HA_NOSAME) &&
......
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