Debian Codegraph @

mysql-test/suite/ndb_rpl/t/ndb_rpl_2multi_basic.inc

raw
1 #######################################
2 # Author: Rafal Somla #
3 # Date: 2006-08-20 #
4 # Purpose: Test replication of basic #
5 # table operations in various setups #
6 # #
7 # Based on rpl_ndb_2multi_eng.test by #
8 # JBM #
9 #######################################
10
11 connection master;
12
13 #################################################
14 --echo --- Create Table Section ---
15
16 CREATE TABLE t1 (id MEDIUMINT NOT NULL,
17 b1 INT,
18 vc VARCHAR(255),
19 bc CHAR(255),
20 d DECIMAL(10,4) DEFAULT 0,
21 f FLOAT DEFAULT 0,
22 total BIGINT UNSIGNED,
23 y YEAR,
24 t DATE,
25 PRIMARY KEY(id));
26
27 --echo --- Show table on master ---
28
29 SHOW CREATE TABLE t1;
30
31 --echo --- Show table on slave ---
32
33 sync_slave_with_master;
34 SHOW CREATE TABLE t1;
35
36 --source suite/ndb_rpl/t/ndb_rpl_multi_engine2.inc
37
38 #################################################
39 # Okay lets see how it holds up to table changes
40 --echo --- Check that simple Alter statements are replicated correctly --
41
42 ALTER TABLE t1 DROP PRIMARY KEY;
43 # note: table with no PK can't contain blobs if it is to be replicated.
44 ALTER TABLE t1 MODIFY vc char(32);
45
46 --echo --- Show the new improved table on the master ---
47
48 SHOW CREATE TABLE t1;
49
50 --echo --- Make sure that our tables on slave are still same engine ---
51 --echo --- and that the alter statements replicated correctly ---
52
53 sync_slave_with_master;
54 SHOW CREATE TABLE t1;
55
56 # Turn off strict mode since the sourced include file
57 # intentionally INSERT rows which exceed the length of column 'vc'
58 connection master;
59 --source suite/ndb/include/turn_off_strict_sql_mode.inc
60
61 --source suite/ndb_rpl/t/ndb_rpl_multi_engine2.inc
62
63 connection master;
64 --source suite/ndb/include/restore_sql_mode_after_turn_off_strict.inc
65
66 #################################################
67 --echo --- Check that replication works when slave has more columns than master
68 connection master;
69 ALTER TABLE t1 ADD PRIMARY KEY(id,total);
70 ALTER TABLE t1 MODIFY vc TEXT;
71
72 INSERT INTO t1 VALUES(3,1,'Testing MySQL databases is a cool ',
73 'Must make it bug free for the customer',
74 654321.4321,15.21,0,1965,"1905-11-14");
75 INSERT INTO t1 VALUES(20,1,'Testing MySQL databases is a cool ',
76 'Must make it bug free for the customer',
77 654321.4321,15.21,0,1965,"1965-11-14");
78 INSERT INTO t1 VALUES(50,1,'Testing MySQL databases is a cool ',
79 'Must make it bug free for the customer',
80 654321.4321,15.21,0,1965,"1985-11-14");
81
82 --echo --- Add columns on slave ---
83 --sync_slave_with_master
84 ALTER TABLE t1 ADD (u int, v char(16) default 'default');
85 UPDATE t1 SET u=7 WHERE id < 50;
86 UPDATE t1 SET v='explicit' WHERE id >10;
87
88 --echo --- Show changed table on slave ---
89
90 SHOW CREATE TABLE t1;
91 SELECT *
92 FROM t1
93 ORDER BY id;
94
95 --source suite/ndb_rpl/t/ndb_rpl_multi_engine2.inc
96 TRUNCATE TABLE t1;
97
98 #################################################
99 --echo --- Check that replication works when master has more columns than slave
100 connection master;
101
102 --echo --- Remove columns on slave ---
103 --sync_slave_with_master
104 ALTER TABLE t1 DROP COLUMN v;
105 ALTER TABLE t1 DROP COLUMN u;
106 ALTER TABLE t1 DROP COLUMN t;
107 ALTER TABLE t1 DROP COLUMN y;
108
109 --echo --- Show changed table on slave ---
110
111 SHOW CREATE TABLE t1;
112
113 --source suite/ndb_rpl/t/ndb_rpl_multi_engine2.inc
114 TRUNCATE TABLE t1;
115
116 #################################################
117 --echo --- Do Cleanup --
118 connection master;
119 DROP TABLE t1;
120
121 sync_slave_with_master;
122 connection master;