diff options
author | Alexander Barkov <bar@mysql.com> | 2010-08-26 16:36:33 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mysql.com> | 2010-08-26 16:36:33 +0400 |
commit | 3509fecfc1ff06860d026e59195f6ac84a35379a (patch) | |
tree | 22a95174748db7656dc7b0c291d4af92e8b20109 | |
parent | f0d2765cc3bbea7743f8932b4da877ac121905b1 (diff) | |
download | mariadb-git-3509fecfc1ff06860d026e59195f6ac84a35379a.tar.gz |
Bug#42511 mysqld: ctype-ucs2.c:2044: my_strnncollsp_utf32: Assertion (tlen % 4) == 0' fai
Problem: trailing spaces were stripped using 8-bit code,
so the truncation result length was incorrect, which led
to an assertion failure.
Fix: using multi-byte safe code.
-rw-r--r-- | mysql-test/r/ctype_utf32.result | 13 | ||||
-rw-r--r-- | mysql-test/t/ctype_utf32.test | 11 | ||||
-rw-r--r-- | storage/myisam/mi_key.c | 11 |
3 files changed, 29 insertions, 6 deletions
diff --git a/mysql-test/r/ctype_utf32.result b/mysql-test/r/ctype_utf32.result index 79e714eab47..eb8ef31c8e4 100644 --- a/mysql-test/r/ctype_utf32.result +++ b/mysql-test/r/ctype_utf32.result @@ -1114,5 +1114,18 @@ format(123,2,'no_NO') 123,00 DROP TABLE t1; # +# Bug#42511 mysqld: ctype-ucs2.c:2044: my_strnncollsp_utf32: Assertion (tlen % 4) == 0' faied +# +CREATE TABLE t1 ( +b char(250) CHARACTER SET utf32, +key (b) +) ENGINE=MYISAM; +INSERT INTO t1 VALUES ('d'),('f'); +SELECT * FROM t1 WHERE b BETWEEN 'a' AND 'z'; +b +d +f +DROP TABLE t1; +# # End of 5.5 tests # diff --git a/mysql-test/t/ctype_utf32.test b/mysql-test/t/ctype_utf32.test index 668b3b033bd..3ea497868ee 100644 --- a/mysql-test/t/ctype_utf32.test +++ b/mysql-test/t/ctype_utf32.test @@ -819,5 +819,16 @@ SELECT * FROM t1; DROP TABLE t1; --echo # +--echo # Bug#42511 mysqld: ctype-ucs2.c:2044: my_strnncollsp_utf32: Assertion (tlen % 4) == 0' faied +--echo # +CREATE TABLE t1 ( + b char(250) CHARACTER SET utf32, + key (b) +) ENGINE=MYISAM; +INSERT INTO t1 VALUES ('d'),('f'); +SELECT * FROM t1 WHERE b BETWEEN 'a' AND 'z'; +DROP TABLE t1; + +--echo # --echo # End of 5.5 tests --echo # diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index bce42b64e99..75038fce070 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -253,18 +253,17 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, pos=old; if (keyseg->flag & HA_SPACE_PACK) { - uchar *end=pos+length; if (type == HA_KEYTYPE_NUM) { - while (pos < end && pos[0] == ' ') - pos++; + uchar *end= pos + length; + while (pos < end && pos[0] == ' ') + pos++; + length= (uint) (end - pos); } else if (type != HA_KEYTYPE_BINARY) { - while (end > pos && end[-1] == ' ') - end--; + length= cs->cset->lengthsp(cs, (char*) pos, length); } - length=(uint) (end-pos); FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); memcpy((uchar*) key,pos,(size_t) char_length); |