1--source setup.inc
2--source include/have_debug.inc
3
4
5--echo #
6--echo # Test COPY ALTER failures at various stages
7--echo #  - on failure, they should rollback restoring the
8--echo #    original table definitions and cleanup the
9--echo #    temporary tables.
10
11--echo #
12--echo # Failure when attempting to copy rows
13--echo #
14SHOW CREATE TABLE t8;
15SELECT * FROM t8 ORDER BY a;
16
17--echo # Following alter should fail with error WARN_DATA_TRUNCATED
18--echo # as it tries to copy NULL value to non NULL column
19--error 1265 # WARN_DATA_TRUNCATED
20ALTER TABLE t8
21  CHANGE COLUMN d d INT NOT NULL,
22  ALGORITHM = COPY;
23
24--echo # Verify that the table is intact locally and across all servers.
25--echo # Also verify that there are no tables with temp names left behind.
26SHOW CREATE TABLE t8;
27--source verify_mysql_dd.inc
28--source count_temp_tables.inc
29
30--echo #
31--echo # Failure during the first rename
32--echo #
33USE ndb_ddl_test;
34SHOW CREATE TABLE t1;
35set debug='+d,ndb_simulate_alter_failure_rename1';
36--error ER_INTERNAL_ERROR
37ALTER TABLE t1
38  ADD COLUMN c INT,
39  ALGORITHM = COPY;
40
41--echo # Verify that the table is intact locally and across all servers.
42--echo # Also verify that there are no tables with temp names left behind.
43SHOW CREATE TABLE t1;
44--source verify_mysql_dd.inc
45--source count_temp_tables.inc
46
47--echo # ALTER should run now
48ALTER TABLE t1
49  ADD COLUMN c INT,
50  ALGORITHM = COPY;
51SHOW CREATE TABLE t1;
52
53--echo #
54--echo # Failure during the second rename
55--echo #
56set debug='+d,ndb_simulate_alter_failure_rename2';
57--error ER_INTERNAL_ERROR
58ALTER TABLE t1
59  DROP COLUMN c,
60  ALGORITHM = COPY;
61
62--echo # Verify that the table is intact locally and across all servers.
63--echo # Also verify that there are no tables with temp names left behind.
64SHOW CREATE TABLE t1;
65--source verify_mysql_dd.inc
66--source count_temp_tables.inc
67
68--echo # ALTER should run now
69ALTER TABLE t1
70  DROP COLUMN c,
71  ALGORITHM = COPY;
72SHOW CREATE TABLE t1;
73
74--echo #
75--echo # Failure after the table has been renamed to new name
76--echo #
77set debug='+d,ndb_simulate_failure_after_table_rename';
78--error ER_INTERNAL_ERROR
79ALTER TABLE t1
80  RENAME TO t1_new,
81  ALGORITHM = COPY;
82
83--echo # Verify that the table is intact locally and across all servers.
84--echo # Also verify that there are no tables with temp names left behind.
85SHOW CREATE TABLE t1;
86--source verify_mysql_dd.inc
87--source count_temp_tables.inc
88
89--echo # ALTER should run now
90ALTER TABLE t1
91  RENAME TO t1_new,
92  ALGORITHM = COPY;
93SHOW CREATE TABLE t1_new;
94
95--source cleanup.inc
96