Debian Codegraph @

mysql-test/suite/ndb_ddl/alter_engine.inc

raw
1 --source include/have_debug.inc
2 #
3 # Run variations of ALTER TABLE .. ENGINE based on the
4 # $engine passed by the calling test
5 #
6
7 if (!$engine)
8 {
9 die Need the $engine variable to run the tests;
10 }
11
12 # Alter tables to $engine, they should then disappear from
13 # all but the server where they were altered
14 let $counter = 1;
15 while ($counter <= $num_tables)
16 {
17 # Default table name is t$counter, ie. t1, t2, etc
18 let $tx=t$counter;
19
20 eval ALTER TABLE $tx
21 ENGINE=$engine;
22
23 inc $counter;
24 }
25
26 # Verify that t1 on first server contains the table in $engine
27 # while it does not exist on the others(checking only two other servers)
28
29 --connection mysqld1
30 select TABLE_SCHEMA, TABLE_NAME, ENGINE
31 from information_schema.tables
32 where TABLE_SCHEMA = 'ndb_ddl_test'
33 order by TABLE_SCHEMA, TABLE_NAME;
34
35 --connection mysqld2
36 select TABLE_SCHEMA, TABLE_NAME, ENGINE
37 from information_schema.tables
38 where TABLE_SCHEMA = 'ndb_ddl_test'
39 order by TABLE_SCHEMA, TABLE_NAME;
40
41 --connection mysqld3
42 select TABLE_SCHEMA, TABLE_NAME, ENGINE
43 from information_schema.tables
44 where TABLE_SCHEMA = 'ndb_ddl_test'
45 order by TABLE_SCHEMA, TABLE_NAME;
46
47 --connection mysqld1
48
49 # Alter tables back to NDB and verify that DD on all
50 # servers are identical
51 let $counter = 1;
52 while ($counter <= $num_tables)
53 {
54 # Default table name is t$counter, ie. t1, t2, etc
55 let $tx=t$counter;
56
57 eval ALTER TABLE $tx
58 ENGINE=NDB;
59
60 inc $counter;
61 }
62
63 # All servers should be identical again
64 --source verify_mysql_dd.inc
65
66 # Simulate a failure during the ALTER to the engine from ndbcluster
67 # and check if rollback restores the original version properly
68
69 # Simulate failure during rename table
70 set debug='+d,ndb_simulate_alter_failure_rename1';
71 --error ER_INTERNAL_ERROR
72 eval ALTER TABLE ndb_ddl_test.t1 ENGINE = $engine;
73
74 # All servers should be identical
75 --source verify_mysql_dd.inc
76
77 # Simulate a failure during the ALTER to ndbcluster from the engine
78 # and check if rollback restores the original version properly
79
80 # First ALTER t1 to the target $engine
81 eval ALTER TABLE ndb_ddl_test.t1 ENGINE = $engine;
82
83 # Simulate failure during rename table
84 set debug='+d,ndb_simulate_alter_failure_rename2';
85 --error ER_INTERNAL_ERROR
86 eval ALTER TABLE ndb_ddl_test.t1 ENGINE = NDB;
87
88 # Verify that there are no tables with temp name
89 # leftover in NDB due to failure and rollback
90 --source count_temp_tables.inc
91
92 # Retry now and all should be fine.
93 eval ALTER TABLE ndb_ddl_test.t1 ENGINE = NDB;
94 --source verify_mysql_dd.inc