| 1 |
--source setup.inc |
| 2 |
|
| 3 |
# Test behaviour of schema distribution when there is "shadow table" |
| 4 |
# in the dictionary, i.e a non NDB table with same name as the |
| 5 |
# table in NDB. |
| 6 |
# |
| 7 |
# This is a feature of MySQL Cluster schema distribution which should be |
| 8 |
# allowed, unfortunately it causes the DD on different MySQL Servers |
| 9 |
# connected to the same cluster to be different but that is on purpose. |
| 10 |
# |
| 11 |
# For example, one MySQL Server may have table t1 in InnoDB while all |
| 12 |
# the other MySQL Servers have table t1 in NDB. The MySQL Server having |
| 13 |
# the table in InnoDB should simply ignore all distributed DDL operations |
| 14 |
# and print a message to the MySQL Server log file |
| 15 |
# |
| 16 |
|
| 17 |
--connection mysqld1 |
| 18 |
|
| 19 |
# Create "shadow table" in other engine on first mysqld |
| 20 |
create table ndb_ddl_test.shadow1 ( |
| 21 |
in_other_engine int primary key |
| 22 |
) engine = InnoDB; |
| 23 |
insert into ndb_ddl_test.shadow1 values(100); |
| 24 |
|
| 25 |
# Supress errors provoked by the "shadow table" on first mysqld |
| 26 |
--disable_query_log |
| 27 |
call mtr.add_suppression("Local table .* shadows the NDB table"); |
| 28 |
call mtr.add_suppression("Failed to remove table definition"); |
| 29 |
call mtr.add_suppression("Failed to update table definition"); |
| 30 |
call mtr.add_suppression("Failed to rename table definition"); |
| 31 |
call mtr.add_suppression("Removing the renamed table"); |
| 32 |
call mtr.add_suppression("Distribution of CREATE TABLE"); |
| 33 |
call mtr.add_suppression("Distribution of TRUNCATE TABLE"); |
| 34 |
call mtr.add_suppression("Distribution of ALTER TABLE"); |
| 35 |
--enable_query_log |
| 36 |
|
| 37 |
--connection mysqld2 |
| 38 |
|
| 39 |
# Check that table does not exist on second mysqld(as it was not |
| 40 |
# created in NDB) |
| 41 |
--error ER_NO_SUCH_TABLE |
| 42 |
show create table ndb_ddl_test.shadow1; |
| 43 |
|
| 44 |
# Create a table in NDB with same name as on first mysqld |
| 45 |
--replace_regex /Node [0-9]+:/Node <nodeid>/ |
| 46 |
create table ndb_ddl_test.shadow1 ( |
| 47 |
in_NDB_engine int primary key |
| 48 |
) engine = NDB; |
| 49 |
|
| 50 |
--connection mysqld1 |
| 51 |
|
| 52 |
# Check that table on first mysqld is still in other engine |
| 53 |
select column_name from |
| 54 |
information_schema.columns |
| 55 |
where TABLE_SCHEMA = 'ndb_ddl_test' and TABLE_NAME = 'shadow1'; |
| 56 |
|
| 57 |
--connection mysqld2 |
| 58 |
|
| 59 |
# Truncate the NDB table, the truncate is implemented |
| 60 |
# by "drop+create" so also now the shadow table on first mysqld should |
| 61 |
# not be truncated |
| 62 |
--replace_regex /Node [0-9]+:/Node <nodeid>/ |
| 63 |
truncate table ndb_ddl_test.shadow1; |
| 64 |
|
| 65 |
--connection mysqld1 |
| 66 |
|
| 67 |
# Check that table on first mysqld is still in other engine |
| 68 |
select column_name from |
| 69 |
information_schema.columns |
| 70 |
where TABLE_SCHEMA = 'ndb_ddl_test' and TABLE_NAME = 'shadow1'; |
| 71 |
|
| 72 |
# Check that table on first mysqld still contains one row |
| 73 |
select count(*) = 1 from ndb_ddl_test.shadow1; |
| 74 |
|
| 75 |
--connection mysqld2 |
| 76 |
|
| 77 |
# Alter the NDB table with algorithm=copy, the shadow table on |
| 78 |
# first mysqld should ignore the alter |
| 79 |
--replace_regex /Node [0-9]+:/Node <nodeid>/ |
| 80 |
alter table ndb_ddl_test.shadow1 algorithm=copy, |
| 81 |
add column added_by_copying_alter int; |
| 82 |
|
| 83 |
--connection mysqld1 |
| 84 |
|
| 85 |
# Check that table on first mysqld is still in other engine |
| 86 |
# and have only one column |
| 87 |
select column_name from |
| 88 |
information_schema.columns |
| 89 |
where TABLE_SCHEMA = 'ndb_ddl_test' and TABLE_NAME = 'shadow1'; |
| 90 |
|
| 91 |
--connection mysqld2 |
| 92 |
|
| 93 |
# Alter the NDB table with algorithm=inplace, the shadow table on |
| 94 |
# first mysqld should ignore the alter |
| 95 |
--replace_regex /Node [0-9]+:/Node <nodeid>/ |
| 96 |
alter table ndb_ddl_test.shadow1 algorithm=inplace, |
| 97 |
add column added_by_inplace_alter int default NULL column_format DYNAMIC; |
| 98 |
|
| 99 |
--connection mysqld1 |
| 100 |
|
| 101 |
# Check that table on first mysqld is still in other engine |
| 102 |
# and have only one column |
| 103 |
select column_name from |
| 104 |
information_schema.columns |
| 105 |
where TABLE_SCHEMA = 'ndb_ddl_test' and TABLE_NAME = 'shadow1'; |
| 106 |
|
| 107 |
--connection mysqld2 |
| 108 |
|
| 109 |
# Drop the NDB table. Once again the first mysqld should |
| 110 |
# ignore the drop |
| 111 |
--replace_regex /Node [0-9]+:/Node <nodeid>/ |
| 112 |
drop table ndb_ddl_test.shadow1; |
| 113 |
|
| 114 |
|
| 115 |
# Test rename of table to same name as shadow table, the |
| 116 |
# renamed table should be removed on on first mysqld and thus create |
| 117 |
# a shadow table |
| 118 |
rename table ndb_ddl_test.t1 to ndb_ddl_test.shadow1; |
| 119 |
|
| 120 |
--connection mysqld1 |
| 121 |
|
| 122 |
# Check that shadow table on first mysqld is still in other engine |
| 123 |
# and have only one column |
| 124 |
select column_name from |
| 125 |
information_schema.columns |
| 126 |
where TABLE_SCHEMA = 'ndb_ddl_test' and TABLE_NAME = 'shadow1'; |
| 127 |
|
| 128 |
# Check that the NDB table on first mysqld has been removed from DD |
| 129 |
select column_name from |
| 130 |
information_schema.columns |
| 131 |
where TABLE_SCHEMA = 'ndb_ddl_test' and TABLE_NAME = 't1'; |
| 132 |
|
| 133 |
# Create another "shadow table" in other engine on first mysqld |
| 134 |
create table ndb_ddl_test.shadow2 ( |
| 135 |
in_other_engine int primary key |
| 136 |
) engine = InnoDB; |
| 137 |
insert into ndb_ddl_test.shadow2 values(100); |
| 138 |
|
| 139 |
--connection mysqld2 |
| 140 |
|
| 141 |
# Rename the shadowed NDB table to the other shadowed table name. |
| 142 |
# This should fail on the first mysqld |
| 143 |
--replace_regex /Node [0-9]+:/Node <nodeid>/ |
| 144 |
rename table ndb_ddl_test.shadow1 to ndb_ddl_test.shadow2; |
| 145 |
|
| 146 |
# Rename the NDB table back to original name |
| 147 |
rename table ndb_ddl_test.shadow2 to ndb_ddl_test.t1; |
| 148 |
|
| 149 |
--connection mysqld1 |
| 150 |
|
| 151 |
# Check that table on first mysqld is still in other engine |
| 152 |
select column_name from |
| 153 |
information_schema.columns |
| 154 |
where TABLE_SCHEMA = 'ndb_ddl_test' and TABLE_NAME = 'shadow1'; |
| 155 |
|
| 156 |
# Check that table on first mysqld still contains one row |
| 157 |
select count(*) = 1 from ndb_ddl_test.shadow1; |
| 158 |
|
| 159 |
# Drop the "shadow table" from other engine |
| 160 |
drop table ndb_ddl_test.shadow1; |
| 161 |
|
| 162 |
# Drop the second "shadow table" from other engine |
| 163 |
drop table ndb_ddl_test.shadow2; |
| 164 |
|
| 165 |
# Check that all mysqlds have identical DD |
| 166 |
--source verify_mysql_dd.inc |
| 167 |
|
| 168 |
|
| 169 |
# ####################################################### |
| 170 |
# Testing that also "drop database" is ignored if there |
| 171 |
# are shadow table(s) in a database |
| 172 |
# ####################################################### |
| 173 |
|
| 174 |
--connection mysqld1 |
| 175 |
# Create "shadow table" in other engine on first mysqld, |
| 176 |
# using the second empty test database |
| 177 |
create table ndb_ddl_test2.shadow_in_db ( |
| 178 |
in_other_engine int primary key |
| 179 |
) engine = InnoDB; |
| 180 |
|
| 181 |
--connection mysqld2 |
| 182 |
|
| 183 |
# Create a table in NDB in order to verify that it's dropped |
| 184 |
# from first mysqld although the database is still there |
| 185 |
create table ndb_ddl_test2.table_in_ndb ( |
| 186 |
in_NDB_engine int primary key |
| 187 |
) engine = NDB; |
| 188 |
|
| 189 |
# Check that table does not exist on second mysqld(as it was not |
| 190 |
# created in NDB) |
| 191 |
--error ER_NO_SUCH_TABLE |
| 192 |
show create table ndb_ddl_test2.shadow_in_db; |
| 193 |
|
| 194 |
# Drop the database on the second mysqld, the database should then be dropped |
| 195 |
# on all mysqlds except the first |
| 196 |
--replace_regex /Node [0-9]+:/Node <nodeid>/ |
| 197 |
drop database ndb_ddl_test2; |
| 198 |
|
| 199 |
# Check that the database does not exist on second mysqld |
| 200 |
--error ER_BAD_DB_ERROR |
| 201 |
use ndb_ddl_test2; |
| 202 |
|
| 203 |
--connection mysqld1 |
| 204 |
|
| 205 |
# Check that the database still exist on first mysqld |
| 206 |
use ndb_ddl_test2; |
| 207 |
|
| 208 |
# Check that the NDB table is gone although database still exist |
| 209 |
--error ER_NO_SUCH_TABLE |
| 210 |
show create table ndb_ddl_test2.table_in_ndb; |
| 211 |
|
| 212 |
# Drop the "shadow table" from other engine |
| 213 |
drop table ndb_ddl_test2.shadow_in_db; |
| 214 |
|
| 215 |
# Drop the database which now exists only on the first mysqld |
| 216 |
drop database ndb_ddl_test2; |
| 217 |
|
| 218 |
--connection mysqld2 |
| 219 |
|
| 220 |
# Create the ndb_ddl_test2 database again, thus checking it can be created |
| 221 |
# and also allowing cleanup to drop it |
| 222 |
create database ndb_ddl_test2; |
| 223 |
|
| 224 |
# ########################################################## |
| 225 |
# Test distribution involving a shadow table with a name |
| 226 |
# that stretches the NDB identifier limit. The main purpose |
| 227 |
# of this test is to check if valid warnings are returned |
| 228 |
# ########################################################## |
| 229 |
|
| 230 |
--connection mysqld1 |
| 231 |
USE ndb_ddl_test; |
| 232 |
# Create InnoDB table in mysqld1 |
| 233 |
CREATE TABLE abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz12 ( |
| 234 |
id INT PRIMARY KEY |
| 235 |
) ENGINE InnoDB; |
| 236 |
--connection mysqld2 |
| 237 |
USE ndb_ddl_test; |
| 238 |
# Create and drop NDB table with the same name. Distribution to mysqld1 shall |
| 239 |
# fail |
| 240 |
--replace_regex /Node [0-9]+:/Node <nodeid>/ |
| 241 |
CREATE TABLE abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz12 ( |
| 242 |
id INT PRIMARY KEY |
| 243 |
) ENGINE NDB; |
| 244 |
--replace_regex /Node [0-9]+:/Node <nodeid>/ |
| 245 |
DROP TABLE abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz12; |
| 246 |
--connection mysqld1 |
| 247 |
# Clean up |
| 248 |
DROP TABLE abcdefghijklmnopqrstuvwxyz1234567890bcdefghijklmnopqrstuvwxyz12; |
| 249 |
|
| 250 |
# Check that all mysqlds have identical DD |
| 251 |
--source verify_mysql_dd.inc |
| 252 |
|
| 253 |
--source cleanup.inc |