Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.5, 11.6
-
None
Description
This problem was found while working on MDEV-19123.
I put a fragment of mysql-test/suite/innodb/t/online_table_rebuild.test into a separate test flle and add CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci into the table definition:
--source include/have_innodb.inc
|
--source include/have_debug.inc
|
--source include/have_debug_sync.inc
|
--source include/have_sequence.inc
|
|
CREATE TABLE t1(f1 INT NOT NULL, f2 CHAR(200), f3 CHAR(200)) |
ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; |
|
INSERT INTO t1 VALUES(3, "innodb", "alter log"); |
|
# InnoDB fails with DUPLICATE KEY error in commit phase |
|
SET DEBUG_SYNC="inplace_after_index_build SIGNAL dml_start WAIT_FOR dml_commit"; |
send ALTER TABLE t1 ADD PRIMARY KEY(f3(10)), ADD UNIQUE KEY(f2(10)); |
CONNECT(con1,localhost,root,,,); |
SET DEBUG_SYNC="now WAIT_FOR dml_start"; |
BEGIN; |
INSERT INTO t1 VALUES(1, repeat('b', 100), repeat('c', 100)); |
INSERT INTO t1 VALUES(2, repeat('b', 100), repeat('a', 100)); |
COMMIT; |
SET DEBUG_SYNC="now SIGNAL dml_commit"; |
|
connection default; |
--error ER_DUP_ENTRY
|
reap;
|
|
DROP TABLE t1; |
|
SET DEBUG_SYNC=reset; |
TEST RESULT TIME (ms) or COMMENT
|
--------------------------------------------------------------------------
|
|
worker[01] Using MTR_BUILD_THREAD 300, with reserved ports 19000..19029
|
CREATE TABLE t1(f1 INT NOT NULL, f2 CHAR(200), f3 CHAR(200))
|
ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
INSERT INTO t1 VALUES(3, "innodb", "alter log");
|
SET DEBUG_SYNC="inplace_after_index_build SIGNAL dml_start WAIT_FOR dml_commit";
|
ALTER TABLE t1 ADD PRIMARY KEY(f3(10)), ADD UNIQUE KEY(f2(10));
|
CONNECT con1,localhost,root,,,;
|
SET DEBUG_SYNC="now WAIT_FOR dml_start";
|
BEGIN;
|
INSERT INTO t1 VALUES(1, repeat('b', 100), repeat('c', 100));
|
INSERT INTO t1 VALUES(2, repeat('b', 100), repeat('a', 100));
|
COMMIT;
|
SET DEBUG_SYNC="now SIGNAL dml_commit";
|
connection default;
|
ERROR 23000: Duplicate entry 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' for key 'f2'
|
DROP TABLE t1;
|
SET DEBUG_SYNC=reset;
|
Notice, the key is too long. The index size is only 10 characters. The expected output should be:
ERROR 23000: Duplicate entry 'bbbbbbbbbb' for key 'f2'
|
Tracing this test in gdb shows that in this code in key.cc key_part->key_part_flag misses the HA_PART_KEY_SEG flag, so field_unpack() is called with a wrong last parameter:
field_unpack(to, key_part->field, table->record[0], key_part->length,
|
MY_TEST(key_part->key_part_flag & HA_PART_KEY_SEG));
|
Attachments
Issue Links
- relates to
-
MDEV-19123 Change default charset from latin1 to utf8mb4
- Closed