Debian Codegraph @

mysql-test/suite/ndb_ddl/alter_copy_fail.result

raw
1 #
2 # Test COPY ALTER failures at various stages
3 # - on failure, they should rollback restoring the
4 # original table definitions and cleanup the
5 # temporary tables.
6 #
7 # Failure when attempting to copy rows
8 #
9 SHOW CREATE TABLE t8;
10 Table Create Table
11 t8 CREATE TABLE `t8` (
12 `a` int DEFAULT NULL,
13 `b` varchar(255) DEFAULT NULL,
14 `c` datetime NOT NULL,
15 `d` int unsigned DEFAULT NULL,
16 `e` int NOT NULL
17 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
18 SELECT * FROM t8 ORDER BY a;
19 a b c d e
20 1 1-t8 2017-10-20 09:13:01 NULL 1
21 2 2-t8 2017-10-20 09:13:02 NULL 2
22 3 3-t8 2017-10-20 09:13:03 NULL 3
23 4 4-t8 2017-10-20 09:13:04 NULL 4
24 5 5-t8 2017-10-20 09:13:05 NULL 5
25 # Following alter should fail with error WARN_DATA_TRUNCATED
26 # as it tries to copy NULL value to non NULL column
27 ALTER TABLE t8
28 CHANGE COLUMN d d INT NOT NULL,
29 ALGORITHM = COPY;
30 ERROR 01000: Data truncated for column 'd' at row 1
31 # Verify that the table is intact locally and across all servers.
32 # Also verify that there are no tables with temp names left behind.
33 SHOW CREATE TABLE t8;
34 Table Create Table
35 t8 CREATE TABLE `t8` (
36 `a` int DEFAULT NULL,
37 `b` varchar(255) DEFAULT NULL,
38 `c` datetime NOT NULL,
39 `d` int unsigned DEFAULT NULL,
40 `e` int NOT NULL
41 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
42 == verify_mysql_dd.inc ==
43 Number of tables with temp name in NDB
44 0
45 # Bug#31546868 NDB : HA_NDBCLUSTER NOT ROLLING BACK TRANSACTION BEFORE ROLLING BACK DDL
46 USE ndb_ddl_test;
47 SHOW CREATE TABLE t1;
48 Table Create Table
49 t1 CREATE TABLE `t1` (
50 `a` int NOT NULL,
51 `b` int NOT NULL,
52 PRIMARY KEY (`a`,`b`),
53 KEY `b` (`b`)
54 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
55 SELECT * FROM t1 ORDER BY a;
56 a b
57 1 1
58 2 2
59 3 3
60 4 4
61 5 5
62 # Following alter should fail with ER_CHECK_CONSTRAINT_VIOLATED
63 # as a row violates the check constraint it is trying to enforce
64 ALTER TABLE t1
65 ADD CONSTRAINT t1_c1 CHECK(a < 5),
66 ALGORITHM = COPY;
67 ERROR HY000: Check constraint 't1_c1' is violated.
68 # Verify that the table is intact locally and across all servers.
69 # Also verify that there are no tables with temp names left behind.
70 SHOW CREATE TABLE t1;
71 Table Create Table
72 t1 CREATE TABLE `t1` (
73 `a` int NOT NULL,
74 `b` int NOT NULL,
75 PRIMARY KEY (`a`,`b`),
76 KEY `b` (`b`)
77 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
78 == verify_mysql_dd.inc ==
79 Number of tables with temp name in NDB
80 0
81 #
82 # Failure during the first rename
83 #
84 USE ndb_ddl_test;
85 SHOW CREATE TABLE t1;
86 Table Create Table
87 t1 CREATE TABLE `t1` (
88 `a` int NOT NULL,
89 `b` int NOT NULL,
90 PRIMARY KEY (`a`,`b`),
91 KEY `b` (`b`)
92 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
93 set debug='+d,ndb_simulate_alter_failure_rename1';
94 ALTER TABLE t1
95 ADD COLUMN c INT,
96 ALGORITHM = COPY;
97 ERROR HY000: Internal error: Simulated : Failed to rename original table to a temp name.
98 # Verify that the table is intact locally and across all servers.
99 # Also verify that there are no tables with temp names left behind.
100 SHOW CREATE TABLE t1;
101 Table Create Table
102 t1 CREATE TABLE `t1` (
103 `a` int NOT NULL,
104 `b` int NOT NULL,
105 PRIMARY KEY (`a`,`b`),
106 KEY `b` (`b`)
107 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
108 == verify_mysql_dd.inc ==
109 Number of tables with temp name in NDB
110 0
111 # ALTER should run now
112 ALTER TABLE t1
113 ADD COLUMN c INT,
114 ALGORITHM = COPY;
115 SHOW CREATE TABLE t1;
116 Table Create Table
117 t1 CREATE TABLE `t1` (
118 `a` int NOT NULL,
119 `b` int NOT NULL,
120 `c` int DEFAULT NULL,
121 PRIMARY KEY (`a`,`b`),
122 KEY `b` (`b`)
123 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
124 #
125 # Failure during the second rename
126 #
127 set debug='+d,ndb_simulate_alter_failure_rename2';
128 ALTER TABLE t1
129 DROP COLUMN c,
130 ALGORITHM = COPY;
131 ERROR HY000: Internal error: Simulated : Failed to rename new table to target name.
132 # Verify that the table is intact locally and across all servers.
133 # Also verify that there are no tables with temp names left behind.
134 SHOW CREATE TABLE t1;
135 Table Create Table
136 t1 CREATE TABLE `t1` (
137 `a` int NOT NULL,
138 `b` int NOT NULL,
139 `c` int DEFAULT NULL,
140 PRIMARY KEY (`a`,`b`),
141 KEY `b` (`b`)
142 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
143 == verify_mysql_dd.inc ==
144 Number of tables with temp name in NDB
145 0
146 # ALTER should run now
147 ALTER TABLE t1
148 DROP COLUMN c,
149 ALGORITHM = COPY;
150 SHOW CREATE TABLE t1;
151 Table Create Table
152 t1 CREATE TABLE `t1` (
153 `a` int NOT NULL,
154 `b` int NOT NULL,
155 PRIMARY KEY (`a`,`b`),
156 KEY `b` (`b`)
157 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
158 #
159 # Failure after the table has been renamed to new name
160 #
161 set debug='+d,ndb_simulate_failure_after_table_rename';
162 ALTER TABLE t1
163 RENAME TO t1_new,
164 ALGORITHM = COPY;
165 ERROR HY000: Internal error: Simulated : Failed after renaming the table.
166 # Verify that the table is intact locally and across all servers.
167 # Also verify that there are no tables with temp names left behind.
168 SHOW CREATE TABLE t1;
169 Table Create Table
170 t1 CREATE TABLE `t1` (
171 `a` int NOT NULL,
172 `b` int NOT NULL,
173 PRIMARY KEY (`a`,`b`),
174 KEY `b` (`b`)
175 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
176 == verify_mysql_dd.inc ==
177 Number of tables with temp name in NDB
178 0
179 # ALTER should run now
180 ALTER TABLE t1
181 RENAME TO t1_new,
182 ALGORITHM = COPY;
183 SHOW CREATE TABLE t1_new;
184 Table Create Table
185 t1_new CREATE TABLE `t1_new` (
186 `a` int NOT NULL,
187 `b` int NOT NULL,
188 PRIMARY KEY (`a`,`b`),
189 KEY `b` (`b`)
190 ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci