~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl_ndb/t/rpl_ndb_dd_partitions.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#######################################
 
2
# Author: JBM                         #
 
3
# Date: 2006-03-09                    #
 
4
# Purpose: To test the replication of #
 
5
# Cluster Disk Data using partitions  #
 
6
#######################################
 
7
 
 
8
--source include/have_ndb.inc
 
9
--source include/have_binlog_format_mixed_or_row.inc
 
10
--source include/ndb_master-slave.inc
 
11
 
 
12
--echo --- Doing pre test cleanup --- 
 
13
 
 
14
connection master;
 
15
--disable_warnings
 
16
DROP TABLE IF EXISTS t1;
 
17
--enable_query_log
 
18
 
 
19
 
 
20
# Start by creating a logfile group
 
21
##################################
 
22
 
 
23
CREATE LOGFILE GROUP lg1
 
24
ADD UNDOFILE 'undofile.dat'
 
25
INITIAL_SIZE 16M
 
26
UNDO_BUFFER_SIZE = 1M
 
27
ENGINE=NDB;
 
28
 
 
29
ALTER LOGFILE GROUP lg1
 
30
ADD UNDOFILE 'undofile02.dat'
 
31
INITIAL_SIZE = 4M
 
32
ENGINE=NDB;
 
33
 
 
34
###################################################
 
35
# Create a tablespace connected to the logfile group
 
36
###################################################
 
37
 
 
38
CREATE TABLESPACE ts1
 
39
ADD DATAFILE 'datafile.dat'
 
40
USE LOGFILE GROUP lg1
 
41
INITIAL_SIZE 12M
 
42
ENGINE NDB;
 
43
 
 
44
ALTER TABLESPACE ts1
 
45
ADD DATAFILE 'datafile02.dat'
 
46
INITIAL_SIZE = 4M
 
47
ENGINE=NDB;
 
48
 
 
49
#################################################################
 
50
 
 
51
--echo --- Start test 2 partition RANGE testing --
 
52
--echo --- Do setup --
 
53
 
 
54
 
 
55
#################################################
 
56
# Requirment: Create table that is partitioned  #
 
57
# by range on year i.e. year(t) and replicate   #
 
58
# basice operations such at insert, update      #
 
59
# delete between 2 different storage engines    #
 
60
# Alter table and ensure table is handled       #
 
61
# Correctly on the slave                        #
 
62
#################################################
 
63
 
 
64
CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(63), 
 
65
                 bc CHAR(63), d DECIMAL(10,4) DEFAULT 0, 
 
66
                 f FLOAT DEFAULT 0, total BIGINT UNSIGNED, 
 
67
                 y YEAR, t DATE)
 
68
                 TABLESPACE ts1 STORAGE DISK
 
69
                 ENGINE=NDB
 
70
                 PARTITION BY RANGE (YEAR(t)) 
 
71
                (PARTITION p0 VALUES LESS THAN (1901), 
 
72
                 PARTITION p1 VALUES LESS THAN (1946),  
 
73
                 PARTITION p2 VALUES LESS THAN (1966), 
 
74
                 PARTITION p3 VALUES LESS THAN (1986), 
 
75
                 PARTITION p4 VALUES LESS THAN (2005), 
 
76
                 PARTITION p5 VALUES LESS THAN MAXVALUE);
 
77
 
 
78
--echo --- Show table on master ---
 
79
 
 
80
SHOW CREATE TABLE t1;
 
81
 
 
82
--echo --- Show table on slave --
 
83
 
 
84
sync_slave_with_master;
 
85
SHOW CREATE TABLE t1;
 
86
 
 
87
--echo --- Perform basic operation on master ---
 
88
--echo --- and ensure replicated correctly ---
 
89
 
 
90
--source include/rpl_multi_engine3.inc
 
91
 
 
92
--echo --- Check that simple Alter statements are replicated correctly ---
 
93
 
 
94
ALTER TABLE t1 MODIFY vc VARCHAR(255);
 
95
 
 
96
--echo --- Show the new improved table on the master ---
 
97
 
 
98
SHOW CREATE TABLE t1;
 
99
 
 
100
--echo --- Make sure that our tables on slave are still same engine ---
 
101
--echo --- and that the alter statements replicated correctly ---
 
102
 
 
103
sync_slave_with_master;
 
104
SHOW CREATE TABLE t1;
 
105
 
 
106
--echo --- Perform basic operation on master ---
 
107
--echo --- and ensure replicated correctly ---
 
108
--enable_query_log
 
109
 
 
110
--source include/rpl_multi_engine3.inc
 
111
 
 
112
--echo --- End test 2 partition RANGE testing ---
 
113
--echo --- Do Cleanup ---
 
114
 
 
115
DROP TABLE IF EXISTS t1;
 
116
 
 
117
########################################################
 
118
 
 
119
--echo --- Start test 3 partition LIST testing ---
 
120
--echo --- Do setup ---
 
121
#################################################
 
122
 
 
123
 
 
124
CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(63), 
 
125
                 bc CHAR(63), d DECIMAL(10,4) DEFAULT 0, 
 
126
                 f FLOAT DEFAULT 0, total BIGINT UNSIGNED, 
 
127
                 y YEAR, t DATE)
 
128
                 TABLESPACE ts1 STORAGE DISK
 
129
                 ENGINE=NDB
 
130
                 PARTITION BY LIST(id) 
 
131
                (PARTITION p0 VALUES IN (2, 4), 
 
132
                 PARTITION p1 VALUES IN (42, 142));
 
133
 
 
134
--echo --- Test 3 Alter to add partition ---
 
135
 
 
136
ALTER TABLE t1 ADD PARTITION (PARTITION p2 VALUES IN (412));
 
137
 
 
138
--echo --- Show table on master ---
 
139
 
 
140
SHOW CREATE TABLE t1;
 
141
 
 
142
--echo --- Show table on slave ---
 
143
 
 
144
sync_slave_with_master;
 
145
SHOW CREATE TABLE t1;
 
146
 
 
147
--echo --- Perform basic operation on master ---
 
148
--echo --- and ensure replicated correctly ---
 
149
 
 
150
--source include/rpl_multi_engine3.inc
 
151
 
 
152
--echo --- Check that simple Alter statements are replicated correctly ---
 
153
 
 
154
ALTER TABLE t1 MODIFY vc VARCHAR(255);
 
155
 
 
156
--echo --- Show the new improved table on the master ---
 
157
 
 
158
SHOW CREATE TABLE t1;
 
159
 
 
160
--echo --- Make sure that our tables on slave are still same engine ---
 
161
--echo --- and that the alter statements replicated correctly ---
 
162
 
 
163
sync_slave_with_master;
 
164
SHOW CREATE TABLE t1;
 
165
 
 
166
--echo --- Perform basic operation on master ---
 
167
--echo --- and ensure replicated correctly ---
 
168
 
 
169
--source include/rpl_multi_engine3.inc
 
170
 
 
171
--echo --- End test 3 partition LIST testing ---
 
172
--echo --- Do Cleanup --
 
173
 
 
174
DROP TABLE IF EXISTS t1;
 
175
 
 
176
########################################################
 
177
 
 
178
--echo --- Start test 4 partition HASH testing ---
 
179
--echo --- Do setup ---
 
180
#################################################
 
181
 
 
182
 
 
183
CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(63), 
 
184
                 bc CHAR(63), d DECIMAL(10,4) DEFAULT 0, 
 
185
                 f FLOAT DEFAULT 0, total BIGINT UNSIGNED, 
 
186
                 y YEAR, t DATE)
 
187
                 TABLESPACE ts1 STORAGE DISK
 
188
                 ENGINE=NDB
 
189
                 PARTITION BY HASH( YEAR(t) ) 
 
190
                 PARTITIONS 4; 
 
191
 
 
192
--echo --- show that tables have been created correctly ---
 
193
 
 
194
SHOW CREATE TABLE t1;
 
195
sync_slave_with_master;
 
196
SHOW CREATE TABLE t1;
 
197
 
 
198
--echo --- Perform basic operation on master ---
 
199
--echo --- and ensure replicated correctly ---
 
200
 
 
201
--source include/rpl_multi_engine3.inc
 
202
 
 
203
--echo --- Check that simple Alter statements are replicated correctly ---
 
204
 
 
205
ALTER TABLE t1 MODIFY vc VARCHAR(255);
 
206
 
 
207
--echo --- Show the new improved table on the master ---
 
208
 
 
209
SHOW CREATE TABLE t1;
 
210
 
 
211
--echo --- Make sure that our tables on slave are still same engine ---
 
212
--echo --- and that the alter statements replicated correctly ---
 
213
 
 
214
sync_slave_with_master;
 
215
SHOW CREATE TABLE t1;
 
216
 
 
217
--echo --- Perform basic operation on master ---
 
218
--echo --- and ensure replicated correctly ---
 
219
 
 
220
--source include/rpl_multi_engine3.inc
 
221
 
 
222
--echo --- End test 4 partition HASH testing ---
 
223
--echo --- Do Cleanup --
 
224
 
 
225
DROP TABLE IF EXISTS t1;
 
226
 
 
227
########################################################
 
228
 
 
229
--echo --- Start test 5 partition by key testing ---
 
230
--echo --- Create Table Section ---
 
231
 
 
232
#################################################
 
233
 
 
234
CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(63), 
 
235
                 bc CHAR(63), d DECIMAL(10,4) DEFAULT 0, 
 
236
                 f FLOAT DEFAULT 0, total BIGINT UNSIGNED, 
 
237
                 y YEAR, t DATE,PRIMARY KEY(id))
 
238
                 TABLESPACE ts1 STORAGE DISK
 
239
                 ENGINE=NDB
 
240
                 PARTITION BY KEY() 
 
241
                 PARTITIONS 4;
 
242
 
 
243
--echo --- Show that tables on master are ndbcluster tables ---
 
244
 
 
245
SHOW CREATE TABLE t1;
 
246
 
 
247
--echo --- Show that tables on slave ---
 
248
 
 
249
sync_slave_with_master;
 
250
SHOW CREATE TABLE t1;
 
251
 
 
252
--echo --- Perform basic operation on master ---
 
253
--echo --- and ensure replicated correctly ---
 
254
 
 
255
--source include/rpl_multi_engine3.inc
 
256
 
 
257
# Okay lets see how it holds up to table changes
 
258
--echo --- Check that simple Alter statements are replicated correctly ---
 
259
 
 
260
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(id, total);
 
261
 
 
262
--echo --- Show the new improved table on the master ---
 
263
 
 
264
SHOW CREATE TABLE t1;
 
265
 
 
266
--echo --- Make sure that our tables on slave are still right type ---
 
267
--echo --- and that the alter statements replicated correctly ---
 
268
 
 
269
sync_slave_with_master;
 
270
SHOW CREATE TABLE t1;
 
271
 
 
272
--echo --- Perform basic operation on master ---
 
273
--echo --- and ensure replicated correctly ---
 
274
 
 
275
--source include/rpl_multi_engine3.inc
 
276
 
 
277
--echo --- Check that simple Alter statements are replicated correctly ---
 
278
 
 
279
ALTER TABLE t1 MODIFY vc VARCHAR(255);
 
280
 
 
281
--echo --- Show the new improved table on the master ---
 
282
 
 
283
SHOW CREATE TABLE t1;
 
284
 
 
285
--echo --- Make sure that our tables on slave are still same engine ---
 
286
--echo --- and that the alter statements replicated correctly ---
 
287
 
 
288
sync_slave_with_master;
 
289
SHOW CREATE TABLE t1;
 
290
 
 
291
--echo --- Perform basic operation on master ---
 
292
--echo --- and ensure replicated correctly ---
 
293
 
 
294
--source include/rpl_multi_engine3.inc
 
295
 
 
296
--echo --- End test 5 key partition testing ---
 
297
--echo --- Do Cleanup ---
 
298
 
 
299
DROP TABLE IF EXISTS t1;
 
300
alter tablespace ts1
 
301
drop datafile 'datafile.dat'
 
302
engine=ndb;
 
303
alter tablespace ts1
 
304
drop datafile 'datafile02.dat'
 
305
engine=ndb;
 
306
DROP TABLESPACE ts1 ENGINE=NDB;
 
307
DROP LOGFILE GROUP lg1 ENGINE=NDB;
 
308
--sync_slave_with_master
 
309
 
 
310
# End of 5.1 test case