Debian Codegraph @

mysql-test/suite/ndb_ddl/alter_copy_fail.test

raw
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 #
14 SHOW CREATE TABLE t8;
15 SELECT * 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
20 ALTER 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.
26 SHOW CREATE TABLE t8;
27 --source verify_mysql_dd.inc
28 --source count_temp_tables.inc
29
30 --echo # Bug#31546868 NDB : HA_NDBCLUSTER NOT ROLLING BACK TRANSACTION BEFORE ROLLING BACK DDL
31 # Another testcase that fails during row copy
32 USE ndb_ddl_test;
33 SHOW CREATE TABLE t1;
34 SELECT * FROM t1 ORDER BY a;
35
36 --echo # Following alter should fail with ER_CHECK_CONSTRAINT_VIOLATED
37 --echo # as a row violates the check constraint it is trying to enforce
38 --error ER_CHECK_CONSTRAINT_VIOLATED
39 ALTER TABLE t1
40 ADD CONSTRAINT t1_c1 CHECK(a < 5),
41 ALGORITHM = COPY;
42
43 --echo # Verify that the table is intact locally and across all servers.
44 --echo # Also verify that there are no tables with temp names left behind.
45 SHOW CREATE TABLE t1;
46 --source verify_mysql_dd.inc
47 --source count_temp_tables.inc
48
49 --echo #
50 --echo # Failure during the first rename
51 --echo #
52 USE ndb_ddl_test;
53 SHOW CREATE TABLE t1;
54 set debug='+d,ndb_simulate_alter_failure_rename1';
55 --error ER_INTERNAL_ERROR
56 ALTER TABLE t1
57 ADD COLUMN c INT,
58 ALGORITHM = COPY;
59
60 --echo # Verify that the table is intact locally and across all servers.
61 --echo # Also verify that there are no tables with temp names left behind.
62 SHOW CREATE TABLE t1;
63 --source verify_mysql_dd.inc
64 --source count_temp_tables.inc
65
66 --echo # ALTER should run now
67 ALTER TABLE t1
68 ADD COLUMN c INT,
69 ALGORITHM = COPY;
70 SHOW CREATE TABLE t1;
71
72 --echo #
73 --echo # Failure during the second rename
74 --echo #
75 set debug='+d,ndb_simulate_alter_failure_rename2';
76 --error ER_INTERNAL_ERROR
77 ALTER TABLE t1
78 DROP COLUMN c,
79 ALGORITHM = COPY;
80
81 --echo # Verify that the table is intact locally and across all servers.
82 --echo # Also verify that there are no tables with temp names left behind.
83 SHOW CREATE TABLE t1;
84 --source verify_mysql_dd.inc
85 --source count_temp_tables.inc
86
87 --echo # ALTER should run now
88 ALTER TABLE t1
89 DROP COLUMN c,
90 ALGORITHM = COPY;
91 SHOW CREATE TABLE t1;
92
93 --echo #
94 --echo # Failure after the table has been renamed to new name
95 --echo #
96 set debug='+d,ndb_simulate_failure_after_table_rename';
97 --error ER_INTERNAL_ERROR
98 ALTER TABLE t1
99 RENAME TO t1_new,
100 ALGORITHM = COPY;
101
102 --echo # Verify that the table is intact locally and across all servers.
103 --echo # Also verify that there are no tables with temp names left behind.
104 SHOW CREATE TABLE t1;
105 --source verify_mysql_dd.inc
106 --source count_temp_tables.inc
107
108 --echo # ALTER should run now
109 ALTER TABLE t1
110 RENAME TO t1_new,
111 ALGORITHM = COPY;
112 SHOW CREATE TABLE t1_new;
113
114 --source cleanup.inc