Debian Codegraph @

mysql-test/suite/ndb_ddl/drop_table_consistency.test

raw
1 #
2 # Check the behavior when a table is dropped from NDB using
3 # 'ndb_drop_table' and there's a subsequent attempt to drop
4 # the table using an SQL command i.e. DROP TABLE or DROP
5 # DATABASE. This test checks if
6 # - The table is removed on all the participants
7 # - Table events (if any) have been removed in such cases
8 #
9
10 # Connect to all MySQL Servers
11 --source connect.inc
12
13 # Create a normal user table in NDB. Such tables always have an
14 # associated event created
15 CREATE TABLE t1 (
16 a int PRIMARY KEY,
17 b varchar(255)
18 ) ENGINE NDB;
19 # Check that CREATE TABLE has been distributed
20 --let $counter = 1
21 while ($counter <= 6)
22 {
23 --let $mysqld_name = mysqld$counter
24 --connection $mysqld_name
25 SHOW TABLES;
26 --inc $counter
27 }
28
29 --echo Drop the table using ndb_drop_table
30 --exec $NDB_DROP_TABLE -d test t1 >> $NDB_TOOLS_OUTPUT
31
32 --error ER_TABLE_DEF_CHANGED
33 SHOW CREATE TABLE t1;
34 SHOW WARNINGS;
35 DROP TABLE t1;
36 # Check that DROP TABLE has been distributed
37 --let $counter = 1
38 while ($counter <= 6)
39 {
40
41 --let $mysqld_name = mysqld$counter
42 --connection $mysqld_name
43 SHOW TABLES;
44 --inc $counter
45 }
46
47 # Check that event has been dropped
48 let $check_event_dbname = test;
49 let $check_event_tabname = t1;
50 --source check_event_for_table.inc
51
52 --connection mysqld2
53 # Create a table with hidden PK. Such tables don't have events
54 CREATE TABLE t1 (
55 a int,
56 b varchar(255)
57 ) ENGINE NDB;
58 # Check that CREATE TABLE has been distributed
59 --let $counter = 1
60 while ($counter <= 6)
61 {
62 --let $mysqld_name = mysqld$counter
63 --connection $mysqld_name
64 SHOW TABLES;
65 --inc $counter
66 }
67
68 --echo Drop the table using ndb_drop_table
69 --exec $NDB_DROP_TABLE -d test t1 >> $NDB_TOOLS_OUTPUT
70
71 --disable_query_log ONCE
72 call mtr.add_suppression("Incorrect information in file");
73 --error ER_TABLE_DEF_CHANGED
74 SHOW CREATE TABLE t1;
75 SHOW WARNINGS;
76 DROP TABLE t1;
77 # Check that DROP TABLE has been distributed
78 --let $counter = 1
79 while ($counter <= 6)
80 {
81
82 --let $mysqld_name = mysqld$counter
83 --connection $mysqld_name
84 SHOW TABLES;
85 --inc $counter
86 }
87
88 --connection mysqld3
89 # Create 1 database and 2 tables
90 CREATE DATABASE ndb_ddl_test3;
91 USE ndb_ddl_test3;
92 CREATE TABLE t1 (
93 a int PRIMARY KEY,
94 b varchar(255)
95 ) ENGINE NDB;
96 CREATE TABLE t2 (
97 a int PRIMARY KEY,
98 b varchar(255)
99 ) ENGINE NDB;
100
101 # Check that CREATE TABLE has been distributed
102 --let $counter = 1
103 while ($counter <= 6)
104 {
105 --let $mysqld_name = mysqld$counter
106 --connection $mysqld_name
107 SHOW TABLES IN ndb_ddl_test3;
108 --inc $counter
109 }
110
111 --connection mysqld3
112 --echo Drop the table using ndb_drop_table
113 --exec $NDB_DROP_TABLE -d ndb_ddl_test3 t1 >> $NDB_TOOLS_OUTPUT
114
115 DROP DATABASE ndb_ddl_test3;
116
117 # Check that event has been dropped
118 let $check_event_dbname = ndb_ddl_test3;
119 let $check_event_tabname = t1;
120 --source check_event_for_table.inc
121 let $check_event_dbname = ndb_ddl_test3;
122 let $check_event_tabname = t2;
123 --source check_event_for_table.inc
124
125 --connection mysqld4
126 # Now we check if the table has been removed on a participant by creating
127 # the same table again
128 CREATE DATABASE ndb_ddl_test3;
129 USE ndb_ddl_test3;
130 CREATE TABLE t1 (
131 a int PRIMARY KEY,
132 b varchar(255)
133 ) ENGINE NDB;
134 DROP DATABASE ndb_ddl_test3;
135
136 --remove_file $NDB_TOOLS_OUTPUT