| Bug #113208 | IMPORT TABLESPACE not friendly with multi-byte characters | ||
|---|---|---|---|
| Submitted: | 24 Nov 2023 8:48 | Modified: | 13 Mar 2024 20:41 |
| Reporter: | Adria Lee | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: InnoDB storage engine | Severity: | S2 (Serious) |
| Version: | ALL, 8.0.35 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[27 Nov 2023 9:00]
MySQL Verification Team
Hello Lee Adria, Thank you for the report and test case. Verified as described. regards, Umes
[13 Mar 2024 20:41]
Philip Olson
Posted by developer: Fixed as of the upcoming MySQL Server 8.4.0 release, and here's the proposed changelog entry from the documentation team: --- Importing a tablespace had a hard limit of 128 characters for the imported column names, which did not properly account for variable-length encodings. It's now set to 64 * the maximum length of a multi-byte characters. Our thanks to Lee Adria for the contribution. --- Thank you for the bug report.

Description: When import tablespace, server will read source cfg file and check if the target table column definitions match the contents of the cfg file. When read cfg file, the function 'row_import_read_columns' reads each column name and check if the length exceeds. However, in the existing code, the maximum column name length is set to 128, which is not friendly to multi-byte characters like chinese. Actually, the length of column names is now limited to 64 characters, and in the check here, it should use 64*number of character bytes. How to repeat: 1. Use the following command to create table: CREATE TABLE `test` ( `id` int, ` 测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试` text )CHARSET=utf8mb3; 2. Create table t1 and use it for import create table t1 like test; flush table test for export; 3. In datadir, back up file cp test.cfg x.cfg cp test.idb x.ibd 4. prepare for import lock table t1 write; alter table t1 discard tablespace; 5. In datadir, cp x.ibd t1.ibd cp x.cfg t1.cfg 6. import tablespace alter table t1 import tablespace; Then error occurs. Suggested fix: Fix the check of len in function 'row_import_read_columns'. --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -3744,7 +3744,7 @@ dict_col_t structure, along with the column name. ulint len = mach_read_from_4(ptr); /* FIXME: What is the maximum column name length? */ - if (len == 0 || len > 128) { + if (len == 0 || len > NAME_CHAR_LEN * system_charset_info->mbmaxlen) { ib_senderrf(thd, IB_LOG_LEVEL_ERROR, ER_IO_READ_ERROR, errno, strerror(errno), "Column name length %lu, is invalid", (ulong)len);