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')
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
#
......@@ -818,6 +818,17 @@ SHOW CREATE TABLE t1;
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 #
......@@ -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);
......
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