Commit 3509fecf authored by Alexander Barkov's avatar Alexander Barkov

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.
parent f0d2765c
...@@ -1114,5 +1114,18 @@ format(123,2,'no_NO') ...@@ -1114,5 +1114,18 @@ format(123,2,'no_NO')
123,00 123,00
DROP TABLE t1; 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 # End of 5.5 tests
# #
...@@ -818,6 +818,17 @@ SHOW CREATE TABLE t1; ...@@ -818,6 +818,17 @@ SHOW CREATE TABLE t1;
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE 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 #
--echo # End of 5.5 tests --echo # End of 5.5 tests
--echo # --echo #
...@@ -253,18 +253,17 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, ...@@ -253,18 +253,17 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
pos=old; pos=old;
if (keyseg->flag & HA_SPACE_PACK) if (keyseg->flag & HA_SPACE_PACK)
{ {
uchar *end=pos+length;
if (type == HA_KEYTYPE_NUM) if (type == HA_KEYTYPE_NUM)
{ {
uchar *end= pos + length;
while (pos < end && pos[0] == ' ') while (pos < end && pos[0] == ' ')
pos++; pos++;
length= (uint) (end - pos);
} }
else if (type != HA_KEYTYPE_BINARY) else if (type != HA_KEYTYPE_BINARY)
{ {
while (end > pos && end[-1] == ' ') length= cs->cset->lengthsp(cs, (char*) pos, length);
end--;
} }
length=(uint) (end-pos);
FIX_LENGTH(cs, pos, length, char_length); FIX_LENGTH(cs, pos, length, char_length);
store_key_length_inc(key,char_length); store_key_length_inc(key,char_length);
memcpy((uchar*) key,pos,(size_t) char_length); memcpy((uchar*) key,pos,(size_t) char_length);
......
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