polardbxengine/mysql-test/suite/xengine/r/online_copy_ddl_pk_blob.result

12837 lines
445 KiB
Plaintext

###################################################################
case 1 Drop primary key
###################################################################
CREATE TABLE t1(b TEXT NOT NULL, c int, PRIMARY KEY(b(10)))ENGINE=xengine;
INSERT INTO t1 VALUES('1111111', 2);
INSERT INTO t1 VALUES('2222222', 4);
ALTER TABLE t1 DROP PRIMARY KEY, ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: With INPLACE DDL, XEngine only allows that DROP PRIMARY KEY is combined with ADD PRIMARY KEY. Try ALGORITHM=COPY.
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`b` text COLLATE utf8mb4_general_ci NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
Trying COPY ALGORITHM
ALTER TABLE t1 DROP PRIMARY KEY;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`b` text COLLATE utf8mb4_general_ci NOT NULL,
`c` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 2 Modify a primary key
###################################################################
case 2.1 Change from an INT column to a TEXT column
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)ENGINE=xengine;
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE utf8mb4_general_ci NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 2.2 Change from an INT column to a TEXT column with conflict in base
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)ENGINE=xengine;
INSERT INTO t1 VALUES(1, '1111', 2);
INSERT INTO t1 VALUES(2, '1111', 4);
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '1111' for key 'PRIMARY'
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE utf8mb4_general_ci NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
# Establish another connection (user=root) for concurrent DML
# Test suite/xengine/t/online_copy_ddl_pk_blob.inc with latin1 and latin1_bin
###################################################################
case 3 Modify a primary key with concurrent DML
###################################################################
###################################################################
case 3.1 Change from an INT column to a TEXT column with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '3333333', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE latin1_bin NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
DROP TABLE t1;
###################################################################
case 3.2 Change from an INT column to a TEXT column but has duplication conflict with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '2222222', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE latin1_bin NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
DROP TABLE t1;
###################################################################
case 3.3 Change from an INT column to TEXT column but has duplication conflict with UPDATE from concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES(1, '111111');
INSERT INTO t1 VALUES(2, '222222');
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET b='222222' WHERE a=1;
UPDATE t1 SET b='111111' WHERE a=2;
SELECT * FROM t1;
a b
1 222222
2 111111
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '111111' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE latin1_bin NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
SELECT * FROM t1;
a b
1 222222
2 111111
DROP TABLE t1;
###################################################################
case 4 Add new primary key
###################################################################
case 4.1: Add new primary key with a TEXT column
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES(1, '2222');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b
1 2222
2 2222
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '1111');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
Adding a primary key successfully
SELECT * FROM t1;
a b
1 1111
2 2222
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text COLLATE latin1_bin NOT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 4.2: Add new primary key with two TEXT columns
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL, c TEXT NOT NULL)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '2222', '3333');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222-3333' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b c
1 2222 3333
2 2222 3333
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '4444', '6666');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
SELECT * FROM t1;
a b c
1 2222 3333
2 4444 6666
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text COLLATE latin1_bin NOT NULL,
`c` text COLLATE latin1_bin NOT NULL,
PRIMARY KEY (`b`(4),`c`(6))
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5 Add new primary key with concurrent DML
###################################################################
case 5.0: no conflict
###################################################################
CREATE TABLE t1(c1 INT, c2 TEXT NOT NULL, c3 INT, KEY k_c1(c1))CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES(1, 'abc', 111);
INSERT INTO t1 VALUES(2, 'def', 222);
INSERT INTO t1 VALUES(3, 'ghi', 333);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(c2(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(6, '6666', 6), (7, '777777', 7);
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 777777 7
UPDATE t1 SET c2='aaaa' WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 aaaa 7
UPDATE t1 SET c1=99 WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
DELETE FROM t1 WHERE c1=1;
SELECT * FROM t1;
c1 c2 c3
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
c1 c2 c3
6 6666 6
99 aaaa 7
2 def 222
3 ghi 333
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` text COLLATE latin1_bin NOT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c2`(4)),
KEY `k_c1` (`c1`)
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.1: key1 in d1 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.1.1: key1 in d1 duplicates with key2 in d2, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('22223333', 3);
SELECT * FROM t1;
a b
11111 1
22223333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22223333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.1.2: key1 in d1 duplicates with key2 in d2, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('22223333', 3);
DELETE FROM t1 where b>=2;
SELECT * FROM t1;
a b
11111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.1.3: key1 in d1 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.1.4: key1 in d1 duplicates with updated key2 in d2 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.1.5: key1 in d1 duplicates with updated key2 in d2 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.2: key1 in d1 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.2.1: key1 in d1 duplicates with key2 in d3, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.2.2: key1 in d1 duplicates with key2 in d3, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.2.3: key1 in d1 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.2.4: key1 in d1 duplicates with updated key2 in d3 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.2.5: key1 in d1 duplicates with updated key2 in d3 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.3: key1 in d1 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.3.1: key1 in d1 duplicates with key2 in d4, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.3.2: key1 in d1 duplicates with key2 in d4, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.3.3: key1 in d1 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.3.4: key1 in d1 duplicates with updated key2 in d4 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.3.5: key1 in d1 duplicates with updated key2 in d4 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.4: key1 in d2 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.4.1: key1 in d2 duplicates with key2 in d2 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.4.2: key1 in d2 duplicates with key2 in d2 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.4.3: key1 in d2 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=1;
select * from t1;
a b
3333222 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
3333222 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.5: key1 in d2 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.5.1: key1 in d2 duplicates with key2 in d3 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.5.2: key1 in d2 duplicates with key2 in d3 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.5.3: key1 in d2 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.6: key1 in d2 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.6.1: key1 in d2 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.6.2: key1 in d2 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.6.3: key1 in d2 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='2222333' WHERE b=3;
select * from t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.7: key1 in d3 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.7.1: key1 in d3 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.7.2: key1 in d3 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.7.3: key1 in d3 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='33331111' WHERE b=1;
select * from t1;
a b
33331111 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
33331111 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.8: key1 in d4 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.8.1: key1 in d4 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('33333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('33333444', 4);
select * from t1;
a b
11111 1
22222 2
33333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
33333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.8.2: key1 in d4 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
###################################################################
case 5.8.3: key1 in d4 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET latin1 COLLATE latin1_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE latin1_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=latin1 COLLATE=latin1_bin
DROP TABLE t1;
# Test suite/xengine/t/online_copy_ddl_pk_blob.inc with gbk and gbk_bin
###################################################################
case 3 Modify a primary key with concurrent DML
###################################################################
###################################################################
case 3.1 Change from an INT column to a TEXT column with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '3333333', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE gbk_bin NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
DROP TABLE t1;
###################################################################
case 3.2 Change from an INT column to a TEXT column but has duplication conflict with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '2222222', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE gbk_bin NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
DROP TABLE t1;
###################################################################
case 3.3 Change from an INT column to TEXT column but has duplication conflict with UPDATE from concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES(1, '111111');
INSERT INTO t1 VALUES(2, '222222');
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET b='222222' WHERE a=1;
UPDATE t1 SET b='111111' WHERE a=2;
SELECT * FROM t1;
a b
1 222222
2 111111
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '111111' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE gbk_bin NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
SELECT * FROM t1;
a b
1 222222
2 111111
DROP TABLE t1;
###################################################################
case 4 Add new primary key
###################################################################
case 4.1: Add new primary key with a TEXT column
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES(1, '2222');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b
1 2222
2 2222
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '1111');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
Adding a primary key successfully
SELECT * FROM t1;
a b
1 1111
2 2222
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text COLLATE gbk_bin NOT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 4.2: Add new primary key with two TEXT columns
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL, c TEXT NOT NULL)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '2222', '3333');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222-3333' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b c
1 2222 3333
2 2222 3333
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '4444', '6666');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
SELECT * FROM t1;
a b c
1 2222 3333
2 4444 6666
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text COLLATE gbk_bin NOT NULL,
`c` text COLLATE gbk_bin NOT NULL,
PRIMARY KEY (`b`(4),`c`(6))
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5 Add new primary key with concurrent DML
###################################################################
case 5.0: no conflict
###################################################################
CREATE TABLE t1(c1 INT, c2 TEXT NOT NULL, c3 INT, KEY k_c1(c1))CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES(1, 'abc', 111);
INSERT INTO t1 VALUES(2, 'def', 222);
INSERT INTO t1 VALUES(3, 'ghi', 333);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(c2(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(6, '6666', 6), (7, '777777', 7);
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 777777 7
UPDATE t1 SET c2='aaaa' WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 aaaa 7
UPDATE t1 SET c1=99 WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
DELETE FROM t1 WHERE c1=1;
SELECT * FROM t1;
c1 c2 c3
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
c1 c2 c3
6 6666 6
99 aaaa 7
2 def 222
3 ghi 333
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` text COLLATE gbk_bin NOT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c2`(4)),
KEY `k_c1` (`c1`)
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.1: key1 in d1 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.1.1: key1 in d1 duplicates with key2 in d2, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('22223333', 3);
SELECT * FROM t1;
a b
11111 1
22223333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22223333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.1.2: key1 in d1 duplicates with key2 in d2, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('22223333', 3);
DELETE FROM t1 where b>=2;
SELECT * FROM t1;
a b
11111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.1.3: key1 in d1 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.1.4: key1 in d1 duplicates with updated key2 in d2 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.1.5: key1 in d1 duplicates with updated key2 in d2 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.2: key1 in d1 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.2.1: key1 in d1 duplicates with key2 in d3, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.2.2: key1 in d1 duplicates with key2 in d3, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.2.3: key1 in d1 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.2.4: key1 in d1 duplicates with updated key2 in d3 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.2.5: key1 in d1 duplicates with updated key2 in d3 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.3: key1 in d1 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.3.1: key1 in d1 duplicates with key2 in d4, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.3.2: key1 in d1 duplicates with key2 in d4, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.3.3: key1 in d1 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.3.4: key1 in d1 duplicates with updated key2 in d4 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.3.5: key1 in d1 duplicates with updated key2 in d4 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.4: key1 in d2 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.4.1: key1 in d2 duplicates with key2 in d2 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.4.2: key1 in d2 duplicates with key2 in d2 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.4.3: key1 in d2 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=1;
select * from t1;
a b
3333222 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
3333222 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.5: key1 in d2 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.5.1: key1 in d2 duplicates with key2 in d3 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.5.2: key1 in d2 duplicates with key2 in d3 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.5.3: key1 in d2 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.6: key1 in d2 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.6.1: key1 in d2 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.6.2: key1 in d2 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.6.3: key1 in d2 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='2222333' WHERE b=3;
select * from t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.7: key1 in d3 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.7.1: key1 in d3 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.7.2: key1 in d3 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.7.3: key1 in d3 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='33331111' WHERE b=1;
select * from t1;
a b
33331111 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
33331111 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.8: key1 in d4 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.8.1: key1 in d4 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('33333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('33333444', 4);
select * from t1;
a b
11111 1
22222 2
33333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
33333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.8.2: key1 in d4 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
###################################################################
case 5.8.3: key1 in d4 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE gbk_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk COLLATE=gbk_bin
DROP TABLE t1;
# Test suite/xengine/t/online_copy_ddl_pk_blob.inc with gbk and gbk_chinese_ci
###################################################################
case 3 Modify a primary key with concurrent DML
###################################################################
###################################################################
case 3.1 Change from an INT column to a TEXT column with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '3333333', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=gbk
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
DROP TABLE t1;
###################################################################
case 3.2 Change from an INT column to a TEXT column but has duplication conflict with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '2222222', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=gbk
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
DROP TABLE t1;
###################################################################
case 3.3 Change from an INT column to TEXT column but has duplication conflict with UPDATE from concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES(1, '111111');
INSERT INTO t1 VALUES(2, '222222');
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET b='222222' WHERE a=1;
UPDATE t1 SET b='111111' WHERE a=2;
SELECT * FROM t1;
a b
1 222222
2 111111
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '111111' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=gbk
SELECT * FROM t1;
a b
1 222222
2 111111
DROP TABLE t1;
###################################################################
case 4 Add new primary key
###################################################################
case 4.1: Add new primary key with a TEXT column
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES(1, '2222');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b
1 2222
2 2222
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '1111');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
Adding a primary key successfully
SELECT * FROM t1;
a b
1 1111
2 2222
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text NOT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 4.2: Add new primary key with two TEXT columns
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL, c TEXT NOT NULL)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '2222', '3333');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222-3333' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b c
1 2222 3333
2 2222 3333
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '4444', '6666');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
SELECT * FROM t1;
a b c
1 2222 3333
2 4444 6666
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text NOT NULL,
`c` text NOT NULL,
PRIMARY KEY (`b`(4),`c`(6))
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5 Add new primary key with concurrent DML
###################################################################
case 5.0: no conflict
###################################################################
CREATE TABLE t1(c1 INT, c2 TEXT NOT NULL, c3 INT, KEY k_c1(c1))CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES(1, 'abc', 111);
INSERT INTO t1 VALUES(2, 'def', 222);
INSERT INTO t1 VALUES(3, 'ghi', 333);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(c2(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(6, '6666', 6), (7, '777777', 7);
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 777777 7
UPDATE t1 SET c2='aaaa' WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 aaaa 7
UPDATE t1 SET c1=99 WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
DELETE FROM t1 WHERE c1=1;
SELECT * FROM t1;
c1 c2 c3
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
c1 c2 c3
6 6666 6
99 aaaa 7
2 def 222
3 ghi 333
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` text NOT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c2`(4)),
KEY `k_c1` (`c1`)
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.1: key1 in d1 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.1.1: key1 in d1 duplicates with key2 in d2, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('22223333', 3);
SELECT * FROM t1;
a b
11111 1
22223333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22223333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.1.2: key1 in d1 duplicates with key2 in d2, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('22223333', 3);
DELETE FROM t1 where b>=2;
SELECT * FROM t1;
a b
11111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.1.3: key1 in d1 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.1.4: key1 in d1 duplicates with updated key2 in d2 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.1.5: key1 in d1 duplicates with updated key2 in d2 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.2: key1 in d1 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.2.1: key1 in d1 duplicates with key2 in d3, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.2.2: key1 in d1 duplicates with key2 in d3, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.2.3: key1 in d1 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.2.4: key1 in d1 duplicates with updated key2 in d3 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.2.5: key1 in d1 duplicates with updated key2 in d3 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.3: key1 in d1 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.3.1: key1 in d1 duplicates with key2 in d4, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.3.2: key1 in d1 duplicates with key2 in d4, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.3.3: key1 in d1 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.3.4: key1 in d1 duplicates with updated key2 in d4 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.3.5: key1 in d1 duplicates with updated key2 in d4 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.4: key1 in d2 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.4.1: key1 in d2 duplicates with key2 in d2 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.4.2: key1 in d2 duplicates with key2 in d2 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.4.3: key1 in d2 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=1;
select * from t1;
a b
3333222 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
3333222 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.5: key1 in d2 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.5.1: key1 in d2 duplicates with key2 in d3 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.5.2: key1 in d2 duplicates with key2 in d3 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.5.3: key1 in d2 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.6: key1 in d2 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.6.1: key1 in d2 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.6.2: key1 in d2 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.6.3: key1 in d2 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='2222333' WHERE b=3;
select * from t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.7: key1 in d3 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.7.1: key1 in d3 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.7.2: key1 in d3 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.7.3: key1 in d3 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='33331111' WHERE b=1;
select * from t1;
a b
33331111 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
33331111 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.8: key1 in d4 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.8.1: key1 in d4 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('33333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('33333444', 4);
select * from t1;
a b
11111 1
22222 2
33333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
33333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.8.2: key1 in d4 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
###################################################################
case 5.8.3: key1 in d4 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET gbk COLLATE gbk_chinese_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=gbk
DROP TABLE t1;
# Test suite/xengine/t/online_copy_ddl_pk_blob.inc with utf8 and utf8_bin
###################################################################
case 3 Modify a primary key with concurrent DML
###################################################################
###################################################################
case 3.1 Change from an INT column to a TEXT column with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '3333333', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE utf8_bin NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
DROP TABLE t1;
###################################################################
case 3.2 Change from an INT column to a TEXT column but has duplication conflict with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '2222222', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE utf8_bin NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
DROP TABLE t1;
###################################################################
case 3.3 Change from an INT column to TEXT column but has duplication conflict with UPDATE from concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES(1, '111111');
INSERT INTO t1 VALUES(2, '222222');
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET b='222222' WHERE a=1;
UPDATE t1 SET b='111111' WHERE a=2;
SELECT * FROM t1;
a b
1 222222
2 111111
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '111111' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
SELECT * FROM t1;
a b
1 222222
2 111111
DROP TABLE t1;
###################################################################
case 4 Add new primary key
###################################################################
case 4.1: Add new primary key with a TEXT column
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES(1, '2222');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b
1 2222
2 2222
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '1111');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
Adding a primary key successfully
SELECT * FROM t1;
a b
1 1111
2 2222
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 4.2: Add new primary key with two TEXT columns
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL, c TEXT NOT NULL)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '2222', '3333');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222-3333' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b c
1 2222 3333
2 2222 3333
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '4444', '6666');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
SELECT * FROM t1;
a b c
1 2222 3333
2 4444 6666
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text COLLATE utf8_bin NOT NULL,
`c` text COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`b`(4),`c`(6))
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5 Add new primary key with concurrent DML
###################################################################
case 5.0: no conflict
###################################################################
CREATE TABLE t1(c1 INT, c2 TEXT NOT NULL, c3 INT, KEY k_c1(c1))CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES(1, 'abc', 111);
INSERT INTO t1 VALUES(2, 'def', 222);
INSERT INTO t1 VALUES(3, 'ghi', 333);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(c2(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(6, '6666', 6), (7, '777777', 7);
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 777777 7
UPDATE t1 SET c2='aaaa' WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 aaaa 7
UPDATE t1 SET c1=99 WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
DELETE FROM t1 WHERE c1=1;
SELECT * FROM t1;
c1 c2 c3
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
c1 c2 c3
6 6666 6
99 aaaa 7
2 def 222
3 ghi 333
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` text COLLATE utf8_bin NOT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c2`(4)),
KEY `k_c1` (`c1`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.1: key1 in d1 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.1.1: key1 in d1 duplicates with key2 in d2, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('22223333', 3);
SELECT * FROM t1;
a b
11111 1
22223333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22223333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.1.2: key1 in d1 duplicates with key2 in d2, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('22223333', 3);
DELETE FROM t1 where b>=2;
SELECT * FROM t1;
a b
11111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.1.3: key1 in d1 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.1.4: key1 in d1 duplicates with updated key2 in d2 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.1.5: key1 in d1 duplicates with updated key2 in d2 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.2: key1 in d1 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.2.1: key1 in d1 duplicates with key2 in d3, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.2.2: key1 in d1 duplicates with key2 in d3, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.2.3: key1 in d1 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.2.4: key1 in d1 duplicates with updated key2 in d3 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.2.5: key1 in d1 duplicates with updated key2 in d3 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.3: key1 in d1 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.3.1: key1 in d1 duplicates with key2 in d4, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.3.2: key1 in d1 duplicates with key2 in d4, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.3.3: key1 in d1 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.3.4: key1 in d1 duplicates with updated key2 in d4 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.3.5: key1 in d1 duplicates with updated key2 in d4 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.4: key1 in d2 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.4.1: key1 in d2 duplicates with key2 in d2 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.4.2: key1 in d2 duplicates with key2 in d2 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.4.3: key1 in d2 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=1;
select * from t1;
a b
3333222 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
3333222 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.5: key1 in d2 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.5.1: key1 in d2 duplicates with key2 in d3 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.5.2: key1 in d2 duplicates with key2 in d3 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.5.3: key1 in d2 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.6: key1 in d2 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.6.1: key1 in d2 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.6.2: key1 in d2 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.6.3: key1 in d2 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='2222333' WHERE b=3;
select * from t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.7: key1 in d3 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.7.1: key1 in d3 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.7.2: key1 in d3 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.7.3: key1 in d3 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='33331111' WHERE b=1;
select * from t1;
a b
33331111 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
33331111 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.8: key1 in d4 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.8.1: key1 in d4 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('33333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('33333444', 4);
select * from t1;
a b
11111 1
22222 2
33333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
33333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.8.2: key1 in d4 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
###################################################################
case 5.8.3: key1 in d4 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_bin;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
DROP TABLE t1;
# Test suite/xengine/t/online_copy_ddl_pk_blob.inc with utf8 and utf8_general_ci
###################################################################
case 3 Modify a primary key with concurrent DML
###################################################################
###################################################################
case 3.1 Change from an INT column to a TEXT column with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '3333333', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=utf8
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
DROP TABLE t1;
###################################################################
case 3.2 Change from an INT column to a TEXT column but has duplication conflict with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '2222222', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
DROP TABLE t1;
###################################################################
case 3.3 Change from an INT column to TEXT column but has duplication conflict with UPDATE from concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES(1, '111111');
INSERT INTO t1 VALUES(2, '222222');
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET b='222222' WHERE a=1;
UPDATE t1 SET b='111111' WHERE a=2;
SELECT * FROM t1;
a b
1 222222
2 111111
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '111111' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8
SELECT * FROM t1;
a b
1 222222
2 111111
DROP TABLE t1;
###################################################################
case 4 Add new primary key
###################################################################
case 4.1: Add new primary key with a TEXT column
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES(1, '2222');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b
1 2222
2 2222
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '1111');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
Adding a primary key successfully
SELECT * FROM t1;
a b
1 1111
2 2222
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text NOT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 4.2: Add new primary key with two TEXT columns
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL, c TEXT NOT NULL)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '2222', '3333');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222-3333' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b c
1 2222 3333
2 2222 3333
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '4444', '6666');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
SELECT * FROM t1;
a b c
1 2222 3333
2 4444 6666
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text NOT NULL,
`c` text NOT NULL,
PRIMARY KEY (`b`(4),`c`(6))
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5 Add new primary key with concurrent DML
###################################################################
case 5.0: no conflict
###################################################################
CREATE TABLE t1(c1 INT, c2 TEXT NOT NULL, c3 INT, KEY k_c1(c1))CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES(1, 'abc', 111);
INSERT INTO t1 VALUES(2, 'def', 222);
INSERT INTO t1 VALUES(3, 'ghi', 333);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(c2(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(6, '6666', 6), (7, '777777', 7);
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 777777 7
UPDATE t1 SET c2='aaaa' WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 aaaa 7
UPDATE t1 SET c1=99 WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
DELETE FROM t1 WHERE c1=1;
SELECT * FROM t1;
c1 c2 c3
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
c1 c2 c3
6 6666 6
99 aaaa 7
2 def 222
3 ghi 333
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` text NOT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c2`(4)),
KEY `k_c1` (`c1`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.1: key1 in d1 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.1.1: key1 in d1 duplicates with key2 in d2, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('22223333', 3);
SELECT * FROM t1;
a b
11111 1
22223333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22223333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.1.2: key1 in d1 duplicates with key2 in d2, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('22223333', 3);
DELETE FROM t1 where b>=2;
SELECT * FROM t1;
a b
11111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.1.3: key1 in d1 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.1.4: key1 in d1 duplicates with updated key2 in d2 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.1.5: key1 in d1 duplicates with updated key2 in d2 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.2: key1 in d1 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.2.1: key1 in d1 duplicates with key2 in d3, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.2.2: key1 in d1 duplicates with key2 in d3, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.2.3: key1 in d1 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.2.4: key1 in d1 duplicates with updated key2 in d3 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.2.5: key1 in d1 duplicates with updated key2 in d3 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.3: key1 in d1 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.3.1: key1 in d1 duplicates with key2 in d4, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.3.2: key1 in d1 duplicates with key2 in d4, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.3.3: key1 in d1 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.3.4: key1 in d1 duplicates with updated key2 in d4 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.3.5: key1 in d1 duplicates with updated key2 in d4 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.4: key1 in d2 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.4.1: key1 in d2 duplicates with key2 in d2 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.4.2: key1 in d2 duplicates with key2 in d2 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.4.3: key1 in d2 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=1;
select * from t1;
a b
3333222 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
3333222 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.5: key1 in d2 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.5.1: key1 in d2 duplicates with key2 in d3 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.5.2: key1 in d2 duplicates with key2 in d3 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.5.3: key1 in d2 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.6: key1 in d2 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.6.1: key1 in d2 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.6.2: key1 in d2 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.6.3: key1 in d2 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='2222333' WHERE b=3;
select * from t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.7: key1 in d3 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.7.1: key1 in d3 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.7.2: key1 in d3 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.7.3: key1 in d3 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='33331111' WHERE b=1;
select * from t1;
a b
33331111 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
33331111 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.8: key1 in d4 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.8.1: key1 in d4 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('33333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('33333444', 4);
select * from t1;
a b
11111 1
22222 2
33333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
33333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.8.2: key1 in d4 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
###################################################################
case 5.8.3: key1 in d4 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8 COLLATE utf8_general_ci;
Warnings:
Warning 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
Warning 3778 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8
DROP TABLE t1;
# Test suite/xengine/t/online_copy_ddl_pk_blob.inc with utf8mb4 and utf8mb4_bin
###################################################################
case 3 Modify a primary key with concurrent DML
###################################################################
###################################################################
case 3.1 Change from an INT column to a TEXT column with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '3333333', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE utf8mb4_bin NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
DROP TABLE t1;
###################################################################
case 3.2 Change from an INT column to a TEXT column but has duplication conflict with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '2222222', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE utf8mb4_bin NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
DROP TABLE t1;
###################################################################
case 3.3 Change from an INT column to TEXT column but has duplication conflict with UPDATE from concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES(1, '111111');
INSERT INTO t1 VALUES(2, '222222');
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET b='222222' WHERE a=1;
UPDATE t1 SET b='111111' WHERE a=2;
SELECT * FROM t1;
a b
1 222222
2 111111
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '111111' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE utf8mb4_bin NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
SELECT * FROM t1;
a b
1 222222
2 111111
DROP TABLE t1;
###################################################################
case 4 Add new primary key
###################################################################
case 4.1: Add new primary key with a TEXT column
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES(1, '2222');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b
1 2222
2 2222
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '1111');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
Adding a primary key successfully
SELECT * FROM t1;
a b
1 1111
2 2222
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text COLLATE utf8mb4_bin NOT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 4.2: Add new primary key with two TEXT columns
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL, c TEXT NOT NULL)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '2222', '3333');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222-3333' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b c
1 2222 3333
2 2222 3333
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '4444', '6666');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
SELECT * FROM t1;
a b c
1 2222 3333
2 4444 6666
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text COLLATE utf8mb4_bin NOT NULL,
`c` text COLLATE utf8mb4_bin NOT NULL,
PRIMARY KEY (`b`(4),`c`(6))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5 Add new primary key with concurrent DML
###################################################################
case 5.0: no conflict
###################################################################
CREATE TABLE t1(c1 INT, c2 TEXT NOT NULL, c3 INT, KEY k_c1(c1))CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES(1, 'abc', 111);
INSERT INTO t1 VALUES(2, 'def', 222);
INSERT INTO t1 VALUES(3, 'ghi', 333);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(c2(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(6, '6666', 6), (7, '777777', 7);
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 777777 7
UPDATE t1 SET c2='aaaa' WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 aaaa 7
UPDATE t1 SET c1=99 WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
DELETE FROM t1 WHERE c1=1;
SELECT * FROM t1;
c1 c2 c3
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
c1 c2 c3
6 6666 6
99 aaaa 7
2 def 222
3 ghi 333
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` text COLLATE utf8mb4_bin NOT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c2`(4)),
KEY `k_c1` (`c1`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.1: key1 in d1 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.1.1: key1 in d1 duplicates with key2 in d2, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('22223333', 3);
SELECT * FROM t1;
a b
11111 1
22223333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22223333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.1.2: key1 in d1 duplicates with key2 in d2, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('22223333', 3);
DELETE FROM t1 where b>=2;
SELECT * FROM t1;
a b
11111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.1.3: key1 in d1 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.1.4: key1 in d1 duplicates with updated key2 in d2 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.1.5: key1 in d1 duplicates with updated key2 in d2 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.2: key1 in d1 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.2.1: key1 in d1 duplicates with key2 in d3, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.2.2: key1 in d1 duplicates with key2 in d3, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.2.3: key1 in d1 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.2.4: key1 in d1 duplicates with updated key2 in d3 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.2.5: key1 in d1 duplicates with updated key2 in d3 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.3: key1 in d1 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.3.1: key1 in d1 duplicates with key2 in d4, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.3.2: key1 in d1 duplicates with key2 in d4, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.3.3: key1 in d1 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.3.4: key1 in d1 duplicates with updated key2 in d4 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.3.5: key1 in d1 duplicates with updated key2 in d4 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.4: key1 in d2 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.4.1: key1 in d2 duplicates with key2 in d2 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.4.2: key1 in d2 duplicates with key2 in d2 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.4.3: key1 in d2 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=1;
select * from t1;
a b
3333222 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
3333222 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.5: key1 in d2 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.5.1: key1 in d2 duplicates with key2 in d3 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.5.2: key1 in d2 duplicates with key2 in d3 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.5.3: key1 in d2 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.6: key1 in d2 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.6.1: key1 in d2 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.6.2: key1 in d2 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.6.3: key1 in d2 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='2222333' WHERE b=3;
select * from t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.7: key1 in d3 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.7.1: key1 in d3 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.7.2: key1 in d3 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.7.3: key1 in d3 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='33331111' WHERE b=1;
select * from t1;
a b
33331111 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
33331111 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.8: key1 in d4 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.8.1: key1 in d4 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('33333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('33333444', 4);
select * from t1;
a b
11111 1
22222 2
33333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
33333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.8.2: key1 in d4 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
###################################################################
case 5.8.3: key1 in d4 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_bin NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
DROP TABLE t1;
# Test suite/xengine/t/online_copy_ddl_pk_blob.inc with utf8mb4 and utf8mb4_general_ci
###################################################################
case 3 Modify a primary key with concurrent DML
###################################################################
###################################################################
case 3.1 Change from an INT column to a TEXT column with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '3333333', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE utf8mb4_general_ci NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
DROP TABLE t1;
###################################################################
case 3.2 Change from an INT column to a TEXT column but has duplication conflict with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '2222222', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE utf8mb4_general_ci NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
DROP TABLE t1;
###################################################################
case 3.3 Change from an INT column to TEXT column but has duplication conflict with UPDATE from concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES(1, '111111');
INSERT INTO t1 VALUES(2, '222222');
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET b='222222' WHERE a=1;
UPDATE t1 SET b='111111' WHERE a=2;
SELECT * FROM t1;
a b
1 222222
2 111111
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '111111' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
SELECT * FROM t1;
a b
1 222222
2 111111
DROP TABLE t1;
###################################################################
case 4 Add new primary key
###################################################################
case 4.1: Add new primary key with a TEXT column
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES(1, '2222');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b
1 2222
2 2222
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '1111');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
Adding a primary key successfully
SELECT * FROM t1;
a b
1 1111
2 2222
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 4.2: Add new primary key with two TEXT columns
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL, c TEXT NOT NULL)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '2222', '3333');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222-3333' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b c
1 2222 3333
2 2222 3333
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '4444', '6666');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
SELECT * FROM t1;
a b c
1 2222 3333
2 4444 6666
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text COLLATE utf8mb4_general_ci NOT NULL,
`c` text COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`b`(4),`c`(6))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5 Add new primary key with concurrent DML
###################################################################
case 5.0: no conflict
###################################################################
CREATE TABLE t1(c1 INT, c2 TEXT NOT NULL, c3 INT, KEY k_c1(c1))CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES(1, 'abc', 111);
INSERT INTO t1 VALUES(2, 'def', 222);
INSERT INTO t1 VALUES(3, 'ghi', 333);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(c2(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(6, '6666', 6), (7, '777777', 7);
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 777777 7
UPDATE t1 SET c2='aaaa' WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 aaaa 7
UPDATE t1 SET c1=99 WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
DELETE FROM t1 WHERE c1=1;
SELECT * FROM t1;
c1 c2 c3
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
c1 c2 c3
6 6666 6
99 aaaa 7
2 def 222
3 ghi 333
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` text COLLATE utf8mb4_general_ci NOT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c2`(4)),
KEY `k_c1` (`c1`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.1: key1 in d1 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.1.1: key1 in d1 duplicates with key2 in d2, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('22223333', 3);
SELECT * FROM t1;
a b
11111 1
22223333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22223333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.1.2: key1 in d1 duplicates with key2 in d2, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('22223333', 3);
DELETE FROM t1 where b>=2;
SELECT * FROM t1;
a b
11111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.1.3: key1 in d1 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.1.4: key1 in d1 duplicates with updated key2 in d2 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.1.5: key1 in d1 duplicates with updated key2 in d2 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.2: key1 in d1 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.2.1: key1 in d1 duplicates with key2 in d3, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.2.2: key1 in d1 duplicates with key2 in d3, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.2.3: key1 in d1 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.2.4: key1 in d1 duplicates with updated key2 in d3 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.2.5: key1 in d1 duplicates with updated key2 in d3 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.3: key1 in d1 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.3.1: key1 in d1 duplicates with key2 in d4, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.3.2: key1 in d1 duplicates with key2 in d4, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.3.3: key1 in d1 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.3.4: key1 in d1 duplicates with updated key2 in d4 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.3.5: key1 in d1 duplicates with updated key2 in d4 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.4: key1 in d2 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.4.1: key1 in d2 duplicates with key2 in d2 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.4.2: key1 in d2 duplicates with key2 in d2 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.4.3: key1 in d2 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=1;
select * from t1;
a b
3333222 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
3333222 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.5: key1 in d2 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.5.1: key1 in d2 duplicates with key2 in d3 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.5.2: key1 in d2 duplicates with key2 in d3 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.5.3: key1 in d2 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.6: key1 in d2 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.6.1: key1 in d2 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.6.2: key1 in d2 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.6.3: key1 in d2 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='2222333' WHERE b=3;
select * from t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.7: key1 in d3 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.7.1: key1 in d3 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.7.2: key1 in d3 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.7.3: key1 in d3 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='33331111' WHERE b=1;
select * from t1;
a b
33331111 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
33331111 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.8: key1 in d4 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.8.1: key1 in d4 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('33333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('33333444', 4);
select * from t1;
a b
11111 1
22222 2
33333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
33333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.8.2: key1 in d4 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
###################################################################
case 5.8.3: key1 in d4 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text COLLATE utf8mb4_general_ci NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
DROP TABLE t1;
# Test suite/xengine/t/online_copy_ddl_pk_blob.inc with utf8mb4 and utf8mb4_0900_ai_ci
###################################################################
case 3 Modify a primary key with concurrent DML
###################################################################
###################################################################
case 3.1 Change from an INT column to a TEXT column with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '3333333', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 3333333 6
DROP TABLE t1;
###################################################################
case 3.2 Change from an INT column to a TEXT column but has duplication conflict with concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL, c int)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES(1, '1111111', 2);
INSERT INTO t1 VALUES(2, '2222222', 4);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(3, '2222222', 6);
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text NOT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
SELECT * FROM t1;
a b c
1 1111111 2
2 2222222 4
3 2222222 6
DROP TABLE t1;
###################################################################
case 3.3 Change from an INT column to TEXT column but has duplication conflict with UPDATE from concurrent DML
###################################################################
CREATE TABLE t1(a INT PRIMARY KEY, b TEXT NOT NULL)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES(1, '111111');
INSERT INTO t1 VALUES(2, '222222');
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET b='222222' WHERE a=1;
UPDATE t1 SET b='111111' WHERE a=2;
SELECT * FROM t1;
a b
1 222222
2 111111
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '111111' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` text NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
SELECT * FROM t1;
a b
1 222222
2 111111
DROP TABLE t1;
###################################################################
case 4 Add new primary key
###################################################################
case 4.1: Add new primary key with a TEXT column
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES(1, '2222');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b
1 2222
2 2222
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '1111');
INSERT INTO t1 VALUES(2, '2222');
ALTER TABLE t1 ADD PRIMARY KEY(b(10)), ALGORITHM=INPLACE, LOCK=DEFAULT;
Adding a primary key successfully
SELECT * FROM t1;
a b
1 1111
2 2222
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text NOT NULL,
PRIMARY KEY (`b`(10))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 4.2: Add new primary key with two TEXT columns
###################################################################
CREATE TABLE t1(a INT, b TEXT NOT NULL, c TEXT NOT NULL)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '2222', '3333');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
ERROR 23000: Duplicate entry '2222-3333' for key 'PRIMARY'
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
SELECT * FROM t1;
a b c
1 2222 3333
2 2222 3333
DELETE FROM t1;
INSERT INTO t1 VALUES(1, '2222', '3333');
INSERT INTO t1 VALUES(2, '4444', '6666');
ALTER TABLE t1 ADD PRIMARY KEY(b(4), c(6)), ALGORITHM=INPLACE, LOCK=DEFAULT;
SELECT * FROM t1;
a b c
1 2222 3333
2 4444 6666
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` text NOT NULL,
`c` text NOT NULL,
PRIMARY KEY (`b`(4),`c`(6))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5 Add new primary key with concurrent DML
###################################################################
case 5.0: no conflict
###################################################################
CREATE TABLE t1(c1 INT, c2 TEXT NOT NULL, c3 INT, KEY k_c1(c1))CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES(1, 'abc', 111);
INSERT INTO t1 VALUES(2, 'def', 222);
INSERT INTO t1 VALUES(3, 'ghi', 333);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(c2(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES(6, '6666', 6), (7, '777777', 7);
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 777777 7
UPDATE t1 SET c2='aaaa' WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
7 aaaa 7
UPDATE t1 SET c1=99 WHERE c1 > 6;
SELECT * FROM t1;
c1 c2 c3
1 abc 111
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
DELETE FROM t1 WHERE c1=1;
SELECT * FROM t1;
c1 c2 c3
2 def 222
3 ghi 333
6 6666 6
99 aaaa 7
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
c1 c2 c3
6 6666 6
99 aaaa 7
2 def 222
3 ghi 333
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` text NOT NULL,
`c3` int(11) DEFAULT NULL,
PRIMARY KEY (`c2`(4)),
KEY `k_c1` (`c1`)
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.1: key1 in d1 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.1.1: key1 in d1 duplicates with key2 in d2, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('22223333', 3);
SELECT * FROM t1;
a b
11111 1
22223333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22223333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.1.2: key1 in d1 duplicates with key2 in d2, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('22223333', 3);
DELETE FROM t1 where b>=2;
SELECT * FROM t1;
a b
11111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.1.3: key1 in d1 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.1.4: key1 in d1 duplicates with updated key2 in d2 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='2222111' WHERE b=1;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.1.5: key1 in d1 duplicates with updated key2 in d2 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='2222111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
2222111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
2222111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.2: key1 in d1 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.2.1: key1 in d1 duplicates with key2 in d3, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.2.2: key1 in d1 duplicates with key2 in d3, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.2.3: key1 in d1 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.2.4: key1 in d1 duplicates with updated key2 in d3 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.2.5: key1 in d1 duplicates with updated key2 in d3 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.3: key1 in d1 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222222', 3);
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222222 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.3.1: key1 in d1 duplicates with key2 in d4, but with a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 where b=2;
INSERT INTO t1 VALUES('2222333', 3);
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.3.2: key1 in d1 duplicates with key2 in d4, but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('2222333', 3);
DELETE FROM t1 where b=2;
SELECT * FROM t1;
a b
11111 1
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.3.3: key1 in d1 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.3.4: key1 in d1 duplicates with updated key2 in d4 but with pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
DELETE FROM t1 WHERE b=2;
UPDATE t1 SET a='22221111' WHERE b=1;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.3.5: key1 in d1 duplicates with updated key2 in d4 but with post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to dml connection
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
UPDATE t1 SET a='22221111' WHERE b=1;
DELETE FROM t1 WHERE b=2;
SELECT * FROM t1;
a b
22221111 1
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
22221111 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.4: key1 in d2 duplicates with key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.4.1: key1 in d2 duplicates with key2 in d2 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.4.2: key1 in d2 duplicates with key2 in d2 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.4.3: key1 in d2 duplicates with updated key2 in d2
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml WAIT_FOR dml_done';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=1;
select * from t1;
a b
3333222 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_done';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
3333222 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.5: key1 in d2 duplicates with key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.5.1: key1 in d2 duplicates with key2 in d3 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.5.2: key1 in d2 duplicates with key2 in d3 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333333', 4);
DELETE FROM t1 WHERE a='3333333';
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.5.3: key1 in d2 duplicates with updated key2 in d3
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.6: key1 in d2 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.6.1: key1 in d2 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.6.2: key1 in d2 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.6.3: key1 in d2 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='2222333' WHERE b=3;
select * from t1;
a b
11111 1
22222 2
2222333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '2222' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
2222333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.7: key1 in d3 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.7.1: key1 in d3 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.7.2: key1 in d3 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.7.3: key1 in d3 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_begin SIGNAL start_dml1 WAIT_FOR dml1_end';
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml2 WAIT_FOR dml2_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml1';
INSERT INTO t1 VALUES('3333333', 3);
SET DEBUG_SYNC= 'now SIGNAL dml1_end';
SET DEBUG_SYNC= 'now WAIT_FOR start_dml2';
UPDATE t1 SET a='33331111' WHERE b=1;
select * from t1;
a b
33331111 1
22222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml2_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
33331111 1
22222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.8: key1 in d4 duplicates with key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
select * from t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
3333333 3
3333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.8.1: key1 in d4 duplicates with key2 in d4 but has a pre deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('33333333', 3);
DELETE FROM t1 WHERE b=3;
INSERT INTO t1 VALUES('33333444', 4);
select * from t1;
a b
11111 1
22222 2
33333444 4
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
33333444 4
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`(4))
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.8.2: key1 in d4 duplicates with key2 in d4 but with a post deletion
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
INSERT INTO t1 VALUES('3333444', 4);
DELETE FROM t1 WHERE b>2;
select * from t1;
a b
11111 1
22222 2
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
22222 2
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
###################################################################
case 5.8.3: key1 in d4 duplicates with updated key2 in d4
###################################################################
CREATE TABLE t1(a TEXT NOT NULL, b INT)CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
INSERT INTO t1 VALUES('11111', 1);
INSERT INTO t1 VALUES('22222', 2);
SET DEBUG_SYNC= 'xengine.inplace_unique_check_constraint_done SIGNAL start_dml WAIT_FOR dml_end';
ALTER TABLE t1 ADD PRIMARY KEY(a(4)), ALGORITHM=INPLACE, LOCK=DEFAULT;
# Switch to connection dml
SET DEBUG_SYNC= 'now WAIT_FOR start_dml';
INSERT INTO t1 VALUES('3333333', 3);
UPDATE t1 SET a='3333222' WHERE b=2;
select * from t1;
a b
11111 1
3333222 2
3333333 3
SET DEBUG_SYNC= 'now SIGNAL dml_end';
# Switch to connection default
ERROR 23000: Duplicate entry '3333' for key 'PRIMARY'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1;
a b
11111 1
3333222 2
3333333 3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=XENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;