diff options
author | Alexander Barkov <bar@mysql.com> | 2010-08-23 13:56:21 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mysql.com> | 2010-08-23 13:56:21 +0400 |
commit | 1ed02deea0986ee2aefd7b8bc61390f3675c2e94 (patch) | |
tree | b11b7fb2b2f19540079ca7bdfb3f65d6b6d219ab | |
parent | 508104d7d026bed6b9a3796f17515fec9de4b5cc (diff) | |
download | mariadb-git-1ed02deea0986ee2aefd7b8bc61390f3675c2e94.tar.gz |
Bug#52121 partition by key on utf32 enum field cause debug assertion: (length % 4) == 0
Problem: ENUM columns are sorted and distributed according to their
numeric value, but Field::hash() incorrectly passed string character set
(utf32) in combination with numeric value to the hash function,
which made assertion fail.
Fix: pass "binary" character set in combination with numeric value
to the hash function.
mysql-test/suite/parts/r/part_ctype_utf32.result
Adding tests
mysql-test/suite/parts/t/part_ctype_utf32.test
Adding test
sql/field.cc
Pass correct character set pointer to the hash function.
-rw-r--r-- | mysql-test/suite/parts/r/part_ctype_utf32.result | 14 | ||||
-rw-r--r-- | mysql-test/suite/parts/t/part_ctype_utf32.test | 28 | ||||
-rw-r--r-- | sql/field.cc | 2 |
3 files changed, 43 insertions, 1 deletions
diff --git a/mysql-test/suite/parts/r/part_ctype_utf32.result b/mysql-test/suite/parts/r/part_ctype_utf32.result new file mode 100644 index 00000000000..5d52a8eace4 --- /dev/null +++ b/mysql-test/suite/parts/r/part_ctype_utf32.result @@ -0,0 +1,14 @@ +# +# Bug#52121 partition by key on utf32 enum field cause debug assertion: (length % 4) == 0 +# +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 ( +a enum('a') CHARACTER SET utf32 COLLATE utf32_spanish2_ci +) ENGINE=MYISAM PARTITION BY KEY(a) PARTITIONS 2; +INSERT INTO t1 VALUES ('a'); +SELECT * FROM t1; +a +a +DROP TABLE t1; diff --git a/mysql-test/suite/parts/t/part_ctype_utf32.test b/mysql-test/suite/parts/t/part_ctype_utf32.test new file mode 100644 index 00000000000..12aa1fb3751 --- /dev/null +++ b/mysql-test/suite/parts/t/part_ctype_utf32.test @@ -0,0 +1,28 @@ +################################################################################ +# t/partition_ctype_utf32.test # +# # +# Purpose: # +# Tests for partitions + UTF32 # +# # +#------------------------------------------------------------------------------# +# Original Author: Alexander Barkov # +# Original Date: 2010-08-05 # +# Change Author: # +# Change Date: # +# Change: # +################################################################################ + +--source include/have_partition.inc +--source include/have_utf32.inc + +--echo # +--echo # Bug#52121 partition by key on utf32 enum field cause debug assertion: (length % 4) == 0 +--echo # + +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( + a enum('a') CHARACTER SET utf32 COLLATE utf32_spanish2_ci +) ENGINE=MYISAM PARTITION BY KEY(a) PARTITIONS 2; +INSERT INTO t1 VALUES ('a'); +SELECT * FROM t1; +DROP TABLE t1; diff --git a/sql/field.cc b/sql/field.cc index 3c93ffadac5..fc55426b177 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1329,7 +1329,7 @@ void Field::hash(ulong *nr, ulong *nr2) else { uint len= pack_length(); - CHARSET_INFO *cs= charset(); + CHARSET_INFO *cs= sort_charset(); cs->coll->hash_sort(cs, ptr, len, nr, nr2); } } |