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