From c664a9b5784f5a9dcfb55de119aec1ab71ab3853 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Mar 2007 10:49:48 +0200 Subject: Bug#24985 - UTF8 ENUM primary key on MEMORY using BTREE causes incorrect duplicate entries Keys for BTREE indexes on ENUM and SET columns of MEMORY tables with character set UTF8 were computed incorrectly. Many different column values got the same key value. Apart of possible performance problems, it made unique indexes of this type unusable because it rejected many different values as duplicates. The problem was that multibyte character detection was tried on the internal numeric column value. Many values were not identified as characters. Their key value became blank filled. Thanks to Alexander Barkov and Ramil Kalimullin for the patch, which sets the character set of ENUM and SET key segments to the pseudo binary character set. mysql-test/r/heap_btree.result: Bug#24985 - UTF8 ENUM primary key on MEMORY using BTREE causes incorrect duplicate entries Added test result. mysql-test/t/heap_btree.test: Bug#24985 - UTF8 ENUM primary key on MEMORY using BTREE causes incorrect duplicate entries Added test. sql/ha_heap.cc: Bug#24985 - UTF8 ENUM primary key on MEMORY using BTREE causes incorrect duplicate entries Set key segment charset to my_charset_bin for ENUM and SET columns. --- mysql-test/t/heap_btree.test | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'mysql-test/t/heap_btree.test') diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index 9aa820becd9..eb4672473f6 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -182,4 +182,21 @@ delete from t1 where a >= 2; select a from t1 order by a; drop table t1; +# +# Bug#24985 - UTF8 ENUM primary key on MEMORY using BTREE +# causes incorrect duplicate entries +# +CREATE TABLE t1 ( + c1 ENUM('1', '2'), + UNIQUE USING BTREE(c1) +) ENGINE= MEMORY DEFAULT CHARSET= utf8; +INSERT INTO t1 VALUES('1'), ('2'); +DROP TABLE t1; +CREATE TABLE t1 ( + c1 SET('1', '2'), + UNIQUE USING BTREE(c1) +) ENGINE= MEMORY DEFAULT CHARSET= utf8; +INSERT INTO t1 VALUES('1'), ('2'); +DROP TABLE t1; + --echo End of 4.1 tests -- cgit v1.2.1 From fe4ff304ebb7b4b248c03c867bc7501e53a31675 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Mar 2007 12:39:31 +0200 Subject: Bug#24985 - UTF8 ENUM primary key on MEMORY using BTREE causes incorrect duplicate entries After merge fix --- mysql-test/t/heap_btree.test | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'mysql-test/t/heap_btree.test') diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index 14b1779bd1a..d2891943a4e 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -182,6 +182,23 @@ delete from t1 where a >= 2; select a from t1 order by a; drop table t1; +# +# Bug#24985 - UTF8 ENUM primary key on MEMORY using BTREE +# causes incorrect duplicate entries +# +CREATE TABLE t1 ( + c1 ENUM('1', '2'), + UNIQUE USING BTREE(c1) +) ENGINE= MEMORY DEFAULT CHARSET= utf8; +INSERT INTO t1 VALUES('1'), ('2'); +DROP TABLE t1; +CREATE TABLE t1 ( + c1 SET('1', '2'), + UNIQUE USING BTREE(c1) +) ENGINE= MEMORY DEFAULT CHARSET= utf8; +INSERT INTO t1 VALUES('1'), ('2'); +DROP TABLE t1; + --echo End of 4.1 tests # @@ -204,22 +221,4 @@ CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY; INSERT INTO t1 VALUES(NULL),(NULL); DROP TABLE t1; -# -# Bug#24985 - UTF8 ENUM primary key on MEMORY using BTREE -# causes incorrect duplicate entries -# -CREATE TABLE t1 ( - c1 ENUM('1', '2'), - UNIQUE USING BTREE(c1) -) ENGINE= MEMORY DEFAULT CHARSET= utf8; -INSERT INTO t1 VALUES('1'), ('2'); -DROP TABLE t1; -CREATE TABLE t1 ( - c1 SET('1', '2'), - UNIQUE USING BTREE(c1) -) ENGINE= MEMORY DEFAULT CHARSET= utf8; -INSERT INTO t1 VALUES('1'), ('2'); -DROP TABLE t1; - ---echo End of 4.1 tests --echo End of 5.0 tests -- cgit v1.2.1