Commit 79cecfb5 authored by Alexander Barkov's avatar Alexander Barkov

Bug#51675 Server crashes on inserting 4 byte char. after ALTER TABLE to 'utf8mb4'

Bug#51676 Server crashes on SELECT, ORDER BY on 'utf8mb4' column
An additional fix. We should use 0xFFFD as a weight for supplementary
characters, not the "weight for character U+FFFD".
parent 19bda05a
...@@ -2456,16 +2456,16 @@ t1 CREATE TABLE `t1` ( ...@@ -2456,16 +2456,16 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t1 ORDER BY 1; SELECT * FROM t1 ORDER BY 1;
subject p subject p
𐐀 NULL
abc𐐀def NULL abc𐐀def NULL
𐐀 NULL
SELECT hex(subject), length(subject), char_length(subject), octet_length(subject) FROM t1 ORDER BY 1; SELECT hex(subject), length(subject), char_length(subject), octet_length(subject) FROM t1 ORDER BY 1;
hex(subject) length(subject) char_length(subject) octet_length(subject) hex(subject) length(subject) char_length(subject) octet_length(subject)
616263F0909080646566 10 7 10 616263F0909080646566 10 7 10
F0909080 4 1 4 F0909080 4 1 4
SELECT subject FROM t1 ORDER BY 1; SELECT subject FROM t1 ORDER BY 1;
subject subject
𐐀
abc𐐀def abc𐐀def
𐐀
DROP TABLE t1; DROP TABLE t1;
# #
# End of 5.5 tests # End of 5.5 tests
......
...@@ -6983,11 +6983,18 @@ static int my_uca_scanner_next_any(my_uca_scanner *scanner) ...@@ -6983,11 +6983,18 @@ static int my_uca_scanner_next_any(my_uca_scanner *scanner)
scanner->send)) <= 0)) scanner->send)) <= 0))
return -1; return -1;
scanner->sbeg+= mb_len;
if (wc > 0xFFFF) if (wc > 0xFFFF)
wc= MY_CS_REPLACEMENT_CHARACTER; {
/* Return 0xFFFD as weight for all characters outside BMP */
scanner->wbeg= nochar;
return 0xFFFD;
}
else
{
scanner->page= wc >> 8; scanner->page= wc >> 8;
scanner->code= wc & 0xFF; scanner->code= wc & 0xFF;
scanner->sbeg+= mb_len; }
if (scanner->contractions && !scanner->page && if (scanner->contractions && !scanner->page &&
(scanner->code > 0x40) && (scanner->code < 0x80)) (scanner->code > 0x40) && (scanner->code < 0x80))
......
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