summaryrefslogtreecommitdiff
path: root/mysql-test/suite/innodb/t/alter_candidate_key.test
blob: 7429cd89a1a27bdb33fbea5495ca74c31459a728 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
--source include/have_innodb.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc

CREATE TABLE t1 (f1 INT NOT NULL, f2 INT NOT NULL,
		 UNIQUE KEY uidx2(f1,f2),
		 UNIQUE KEY uidx1(f2)) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1, 1);
SHOW CREATE TABLE t1;
SET DEBUG_SYNC = 'innodb_inplace_alter_table_enter
		  SIGNAL conc_dml WAIT_FOR go_ahead';
--send ALTER TABLE t1 CHANGE COLUMN f1 f11 INT, ALGORITHM=INPLACE
connect (con1,localhost,root,,);
SET DEBUG_SYNC = 'now WAIT_FOR conc_dml';
DELETE FROM t1;
SET DEBUG_SYNC = 'now SIGNAL go_ahead';
connection default;
reap;
SHOW CREATE TABLE t1;
CHECK TABLE t1;
DROP TABLE t1;

CREATE TABLE t1(f1 INT, f2 INT,
		PRIMARY KEY(f1, f2),
		UNIQUE INDEX uidx2 (f1, f2),
		UNIQUE INDEX uidx1 (f2))ENGINE=InnoDB;
ALTER TABLE t1 DROP PRIMARY KEY;
SHOW CREATE TABLE t1;
SET DEBUG_SYNC = 'innodb_inplace_alter_table_enter
		  SIGNAL conc_dml WAIT_FOR go_ahead';
--send ALTER TABLE t1 CHANGE COLUMN f1 f11 INT, ALGORITHM=INPLACE
connection con1;
SET DEBUG_SYNC = 'now WAIT_FOR conc_dml';
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES(1, 1), (1, 1);
SET DEBUG_SYNC = 'now SIGNAL go_ahead';
connection default;
reap;
SHOW CREATE TABLE t1;
CHECK TABLE t1;
DROP TABLE t1;

SET SQL_MODE= strict_trans_tables;
CREATE TABLE t1(a INT UNIQUE) ENGINE=InnoDB;
SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL dml WAIT_FOR dml_done';
--send ALTER TABLE t1 MODIFY COLUMN a INT NOT NULL
connection con1;
SET DEBUG_SYNC='now WAIT_FOR dml';
BEGIN;
INSERT INTO t1 SET a=NULL;
ROLLBACK;
set DEBUG_SYNC='now SIGNAL dml_done';
connection default;
--error ER_INVALID_USE_OF_NULL
reap;
DROP TABLE t1;
disconnect con1;
SET DEBUG_SYNC="RESET";
SET SQL_MODE=DEFAULT;

CREATE TABLE t1(f1 INT NOT NULL, f2 INT NOT NULL, PRIMARY KEY(f1, f2),
		UNIQUE KEY(f2))ENGINE=InnoDB;
ALTER TABLE t1 DROP PRIMARY KEY;
SHOW CREATE TABLE t1;
DROP TABLE t1;

CREATE TABLE t1(f1 INT NOT NULL, f2 INT NOT NULL,
		UNIQUE KEY(f2), UNIQUE KEY(f2))ENGINE=InnoDB;
SHOW CREATE TABLE t1;
ALTER TABLE t1 DROP INDEX f2, ALGORITHM=INPLACE;
SHOW CREATE TABLE t1;
DROP TABLE t1;