mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / extra / rpl_tests / rpl_ndb_2multi_basic.test
blob16f8116d92e8f30414ef7af7ff062f0561a94fa3
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 #######################################
11 --echo --- Doing pre test cleanup --- 
13 connection master;
14 --disable_warnings
15 DROP TABLE IF EXISTS t1;
16 --enable_query_log
18 #################################################
19 --echo --- Create Table Section ---
21 CREATE TABLE t1 (id MEDIUMINT NOT NULL, 
22                  b1 INT, 
23                  vc VARCHAR(255), 
24                  bc CHAR(255), 
25                  d DECIMAL(10,4) DEFAULT 0, 
26                  f FLOAT DEFAULT 0, 
27                  total BIGINT UNSIGNED, 
28                  y YEAR, 
29                  t DATE, 
30                  PRIMARY KEY(id));
32 --echo --- Show table on master ---
34 SHOW CREATE TABLE t1;
36 --echo --- Show table on slave ---
38 sync_slave_with_master;
39 SHOW CREATE TABLE t1;
41 --source include/rpl_multi_engine2.inc
43 #################################################
44 # Okay lets see how it holds up to table changes
45 --echo --- Check that simple Alter statements are replicated correctly --
47 ALTER TABLE t1 DROP PRIMARY KEY;
48 # note: table with no PK can't contain blobs if it is to be replicated.
49 ALTER TABLE t1 MODIFY vc char(32);  
51 --echo --- Show the new improved table on the master ---
53 SHOW CREATE TABLE t1;
55 --echo --- Make sure that our tables on slave are still same engine ---
56 --echo --- and that the alter statements replicated correctly ---
58 sync_slave_with_master;
59 SHOW CREATE TABLE t1;
61 --source include/rpl_multi_engine2.inc
63 #################################################
64 --echo --- Check that replication works when slave has more columns than master
65 connection master;
66 ALTER TABLE t1 ADD PRIMARY KEY(id,total);
67 ALTER TABLE t1 MODIFY vc TEXT;
69 INSERT INTO t1 VALUES(3,1,'Testing MySQL databases is a cool ',
70                       'Must make it bug free for the customer',
71                        654321.4321,15.21,0,1965,"1905-11-14");
72 INSERT INTO t1 VALUES(20,1,'Testing MySQL databases is a cool ',
73                       'Must make it bug free for the customer',
74                        654321.4321,15.21,0,1965,"1965-11-14");
75 INSERT INTO t1 VALUES(50,1,'Testing MySQL databases is a cool ',
76                       'Must make it bug free for the customer',
77                        654321.4321,15.21,0,1965,"1985-11-14");
79 --echo --- Add columns on slave ---
80 --sync_slave_with_master
81 ALTER TABLE t1 ADD (u int, v char(16) default 'default');
82 UPDATE t1 SET u=7 WHERE id < 50;
83 UPDATE t1 SET v='explicit' WHERE id >10;
85 --echo --- Show changed table on slave ---
87 SHOW CREATE TABLE t1;
88 SELECT * 
89 FROM t1
90 ORDER BY id;
92 --source include/rpl_multi_engine2.inc
93 TRUNCATE TABLE t1;
95 #################################################
96 --echo --- Check that replication works when master has more columns than slave
97 connection master;
99 --echo --- Remove columns on slave ---
100 --sync_slave_with_master
101 ALTER TABLE t1 DROP COLUMN v;
102 ALTER TABLE t1 DROP COLUMN u;
103 ALTER TABLE t1 DROP COLUMN t;
104 ALTER TABLE t1 DROP COLUMN y;
106 --echo --- Show changed table on slave ---
108 SHOW CREATE TABLE t1;
110 --source include/rpl_multi_engine2.inc
111 TRUNCATE TABLE t1;
113 #################################################
114 --echo --- Do Cleanup --
115 connection master;
116 DROP TABLE IF EXISTS t1;
118 sync_slave_with_master;
119 connection master;