~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/transaction_log/tests/t/transaction_log_alter.test

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# transaction_log_alter.test
2
 
# test of various ALTER TABLE statements
3
 
# and how they are captured by the transaction log
4
 
 
5
 
# Ignore startup/shutdown events
6
 
--disable_query_log
7
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
8
 
--enable_query_log
9
 
 
10
 
--echo Testing RENAME table - positive 
11
 
--disable_warnings
12
 
DROP TABLE IF EXISTS t1, t1_new_name;
13
 
--enable_warnings
14
 
 
15
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a), KEY b_key1 (b));
16
 
 
17
 
ALTER TABLE t1 RENAME TO t1_new_name;
18
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
19
 
--echo
20
 
 
21
 
DROP TABLE t1_new_name;
22
 
 
23
 
# Truncate the log file to reset for the next test
24
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
25
 
--echo
26
 
 
27
 
--echo Testing RENAME table - negative 
28
 
--disable_warnings
29
 
DROP TABLE IF EXISTS t1, t2;
30
 
--enable_warnings
31
 
 
32
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a), KEY b_key1 (b));
33
 
 
34
 
CREATE TABLE t2 LIKE t1;
35
 
 
36
 
--ERROR ER_TABLE_EXISTS_ERROR
37
 
ALTER TABLE t1 RENAME TO t2;
38
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
39
 
--echo
40
 
 
41
 
DROP TABLE t1, t2;
42
 
 
43
 
# Truncate the log file to reset for the next test
44
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
45
 
--echo
46
 
 
47
 
--echo Testing RENAME table - negative
48
 
--disable_warnings
49
 
DROP TABLE IF EXISTS t1, t2;
50
 
--enable_warnings
51
 
 
52
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a), KEY b_key1 (b));
53
 
 
54
 
CREATE TABLE t2 LIKE t1;
55
 
 
56
 
--ERROR ER_TABLE_EXISTS_ERROR
57
 
ALTER TABLE t1 RENAME TO t2;
58
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
59
 
--echo
60
 
 
61
 
DROP TABLE t1, t2;
62
 
 
63
 
# Truncate the log file to reset for the next test
64
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
65
 
--echo
66
 
 
67
 
--echo Testing RENAME Table with Foreign Key constraints 
68
 
--disable_warnings
69
 
DROP TABLE IF EXISTS t1, t2, t1_new_name ;
70
 
--enable_warnings
71
 
 
72
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a), KEY b_key1 (b));
73
 
 
74
 
CREATE TABLE t2(a INT NOT NULL, b INT , PRIMARY KEY(a), KEY b_key (b), 
75
 
CONSTRAINT fk_constraint_t2 FOREIGN KEY (b) REFERENCES t1(b) ON DELETE SET NULL ON UPDATE CASCADE);
76
 
 
77
 
ALTER TABLE t1 RENAME to t1_new_name;
78
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
79
 
--echo
80
 
 
81
 
SHOW CREATE TABLE t2;
82
 
 
83
 
DROP TABLE t2, t1_new_name;
84
 
 
85
 
# Truncate the log file to reset for the next test
86
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
87
 
--echo
88
 
 
89
 
--echo Testing ADD COLUMN simple 
90
 
--disable_warnings
91
 
DROP TABLE IF EXISTS t1 ;
92
 
--enable_warnings
93
 
 
94
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a));
95
 
 
96
 
ALTER TABLE t1 ADD COLUMN c CHAR(100) NOT NULL;
97
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
98
 
--echo
99
 
 
100
 
DROP TABLE t1;
101
 
 
102
 
# Truncate the log file to reset for the next test
103
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
104
 
--echo
105
 
 
106
 
--echo Testing ADD COLUMN simple negative
107
 
--disable_warnings
108
 
DROP TABLE IF EXISTS t1 ;
109
 
--enable_warnings
110
 
 
111
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a));
112
 
 
113
 
--ERROR ER_DUP_FIELDNAME
114
 
ALTER TABLE t1 ADD COLUMN b CHAR(100) NOT NULL;
115
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
116
 
--echo
117
 
 
118
 
DROP TABLE t1;
119
 
 
120
 
# Truncate the log file to reset for the next test
121
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
122
 
--echo
123
 
 
124
 
--echo Testing ADD COLUMN AFTER <col_name>
125
 
--disable_warnings
126
 
DROP TABLE IF EXISTS t1 ;
127
 
--enable_warnings
128
 
 
129
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a));
130
 
 
131
 
ALTER TABLE t1 ADD COLUMN c CHAR(100) NOT NULL AFTER a;
132
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
133
 
--echo
134
 
 
135
 
DROP TABLE t1;
136
 
 
137
 
# Truncate the log file to reset for the next test
138
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
139
 
--echo
140
 
 
141
 
--echo Testing ADD COLUMN FIRST 
142
 
--disable_warnings
143
 
DROP TABLE IF EXISTS t1 ;
144
 
--enable_warnings
145
 
 
146
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a));
147
 
 
148
 
ALTER TABLE t1 ADD COLUMN c CHAR(100) NOT NULL FIRST ;
149
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
150
 
--echo
151
 
 
152
 
DROP TABLE t1;
153
 
 
154
 
# Truncate the log file to reset for the next test
155
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
156
 
--echo
157
 
 
158
 
--echo Testing ADD COLUMN multiple columns 
159
 
--disable_warnings
160
 
DROP TABLE IF EXISTS t1 ;
161
 
--enable_warnings
162
 
 
163
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a));
164
 
 
165
 
ALTER TABLE t1 ADD COLUMN c CHAR(100) NOT NULL FIRST, ADD COLUMN d BLOB AFTER a ;
166
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
167
 
--echo
168
 
 
169
 
DROP TABLE t1;
170
 
 
171
 
# Truncate the log file to reset for the next test
172
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
173
 
--echo
174
 
 
175
 
--echo Testing DROP COLUMN simple 
176
 
--disable_warnings
177
 
DROP TABLE IF EXISTS t1 ;
178
 
--enable_warnings
179
 
 
180
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a));
181
 
 
182
 
ALTER TABLE t1 DROP COLUMN b ;
183
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
184
 
--echo
185
 
 
186
 
DROP TABLE t1;
187
 
 
188
 
# Truncate the log file to reset for the next test
189
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
190
 
--echo
191
 
 
192
 
--echo Testing DROP COLUMN multiple columns 
193
 
--disable_warnings
194
 
DROP TABLE IF EXISTS t1 ;
195
 
--enable_warnings
196
 
 
197
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, c BLOB, d DATE, PRIMARY KEY(a));
198
 
 
199
 
ALTER TABLE t1 DROP COLUMN b, DROP COLUMN d ;
200
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
201
 
--echo
202
 
 
203
 
DROP TABLE t1;
204
 
 
205
 
# Truncate the log file to reset for the next test
206
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
207
 
--echo
208
 
 
209
 
--echo Testing DROP COLUMN negative 
210
 
--disable_warnings
211
 
DROP TABLE IF EXISTS t1 ;
212
 
--enable_warnings
213
 
 
214
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a));
215
 
 
216
 
--ERROR ER_CANT_REMOVE_ALL_FIELDS
217
 
ALTER TABLE t1 DROP COLUMN a, DROP COLUMN b ;
218
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
219
 
--echo
220
 
 
221
 
DROP TABLE t1;
222
 
 
223
 
# Truncate the log file to reset for the next test
224
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
225
 
--echo
226
 
 
227
 
--echo Testing DISABLE/ENABLE KEYS 
228
 
--disable_warnings
229
 
DROP TABLE IF EXISTS t1 ;
230
 
--enable_warnings
231
 
 
232
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a), KEY b_key (b,a));
233
 
 
234
 
ALTER TABLE t1 DISABLE KEYS ;
235
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
236
 
--echo
237
 
 
238
 
ALTER TABLE t1 ENABLE KEYS ;
239
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
240
 
--echo
241
 
 
242
 
 
243
 
DROP TABLE t1;
244
 
 
245
 
# Truncate the log file to reset for the next test
246
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
247
 
--echo
248
 
 
249
 
--echo Testing ADD / DROP INDEX
250
 
--disable_warnings
251
 
DROP TABLE IF EXISTS t1 ;
252
 
--enable_warnings
253
 
 
254
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a));
255
 
 
256
 
ALTER TABLE t1 ADD INDEX b_key (b,a) ;
257
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
258
 
--echo
259
 
 
260
 
ALTER TABLE t1 DROP INDEX b_key;
261
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
262
 
--echo
263
 
 
264
 
DROP TABLE t1;
265
 
 
266
 
# Truncate the log file to reset for the next test
267
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
268
 
--echo
269
 
 
270
 
--echo Testing ADD / DROP INDEX2
271
 
--disable_warnings
272
 
DROP TABLE IF EXISTS t1 ;
273
 
--enable_warnings
274
 
 
275
 
CREATE TABLE t1(a INT NOT NULL, b CHAR(50) NOT NULL, PRIMARY KEY(a));
276
 
 
277
 
ALTER TABLE t1 ADD INDEX b_key (b(10),a) ;
278
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
279
 
--echo
280
 
 
281
 
ALTER TABLE t1 DROP INDEX b_key;
282
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
283
 
--echo
284
 
 
285
 
DROP TABLE t1;
286
 
 
287
 
# Truncate the log file to reset for the next test
288
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
289
 
--echo
290
 
 
291
 
 
292
 
--echo Testing ADD INDEX negative
293
 
--disable_warnings
294
 
DROP TABLE IF EXISTS t1 ;
295
 
--enable_warnings
296
 
 
297
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a), KEY b_key(b));
298
 
 
299
 
--ERROR ER_DUP_KEYNAME
300
 
ALTER TABLE t1 ADD INDEX b_key (b,a) ;
301
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
302
 
--echo
303
 
 
304
 
DROP TABLE t1;
305
 
 
306
 
# Truncate the log file to reset for the next test
307
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
308
 
--echo
309
 
 
310
 
--echo Testing DROP INDEX negative1 
311
 
--disable_warnings
312
 
DROP TABLE IF EXISTS t1 ;
313
 
--enable_warnings
314
 
 
315
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a));
316
 
 
317
 
--ERROR ER_CANT_DROP_FIELD_OR_KEY
318
 
ALTER TABLE t1 DROP INDEX i_dont_exist ;
319
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
320
 
--echo
321
 
 
322
 
DROP TABLE t1;
323
 
 
324
 
# Truncate the log file to reset for the next test
325
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
326
 
--echo
327
 
 
328
 
--echo Testing ALTER COLUMN 
329
 
--disable_warnings
330
 
DROP TABLE IF EXISTS t1 ;
331
 
--enable_warnings
332
 
 
333
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a));
334
 
 
335
 
ALTER TABLE t1 ALTER COLUMN b SET DEFAULT 999 ;
336
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
337
 
--echo
338
 
 
339
 
SHOW CREATE TABLE t1;
340
 
 
341
 
ALTER TABLE t1 ALTER COLUMN b DROP DEFAULT ;
342
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
343
 
--echo
344
 
 
345
 
SHOW CREATE TABLE t1;
346
 
 
347
 
DROP TABLE t1;
348
 
 
349
 
# Truncate the log file to reset for the next test
350
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
351
 
--echo
352
 
 
353
 
--echo Testing CHANGE COLUMN  
354
 
--disable_warnings
355
 
DROP TABLE IF EXISTS t1 ;
356
 
--enable_warnings
357
 
 
358
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a));
359
 
 
360
 
ALTER TABLE t1 CHANGE COLUMN b new_b_name CHAR(500) DEFAULT 'I am not an int now' FIRST ;
361
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
362
 
--echo
363
 
 
364
 
SHOW CREATE TABLE t1;
365
 
 
366
 
DROP TABLE t1;
367
 
 
368
 
# Truncate the log file to reset for the next test
369
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
370
 
--echo
371
 
 
372
 
--echo Testing MODIFY COLUMN1
373
 
--disable_warnings
374
 
DROP TABLE IF EXISTS t1 ;
375
 
--enable_warnings
376
 
 
377
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, c DATE, PRIMARY KEY(a));
378
 
 
379
 
ALTER TABLE t1 MODIFY COLUMN b CHAR(50) DEFAULT 'I am now a CHAR field' AFTER c ;
380
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
381
 
--echo
382
 
 
383
 
SHOW CREATE TABLE t1;
384
 
 
385
 
DROP TABLE t1;
386
 
 
387
 
# Truncate the log file to reset for the next test
388
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
389
 
--echo
390
 
 
391
 
--echo Testing MODIFY COLUMN2
392
 
--disable_warnings
393
 
DROP TABLE IF EXISTS t1 ;
394
 
--enable_warnings
395
 
 
396
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, c DATE, PRIMARY KEY(a));
397
 
 
398
 
--ERROR ER_BAD_FIELD_ERROR
399
 
ALTER TABLE t1 MODIFY COLUMN b CHAR(50) DEFAULT 'I am now a CHAR field' AFTER b ;
400
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
401
 
--echo
402
 
 
403
 
SHOW CREATE TABLE t1;
404
 
 
405
 
DROP TABLE t1;
406
 
 
407
 
# Truncate the log file to reset for the next test
408
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
409
 
--echo
410
 
 
411
 
--echo Testing MODIFY COLUMN3
412
 
--disable_warnings
413
 
DROP TABLE IF EXISTS t1 ;
414
 
--enable_warnings
415
 
 
416
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, c DATE, PRIMARY KEY(a));
417
 
 
418
 
ALTER TABLE t1 MODIFY COLUMN b INT NOT NULL ;
419
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
420
 
--echo
421
 
 
422
 
SHOW CREATE TABLE t1;
423
 
 
424
 
DROP TABLE t1;
425
 
 
426
 
# Truncate the log file to reset for the next test
427
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
428
 
--echo
429
 
 
430
 
--echo Testing ADD/DROP Foreign Key constraints 
431
 
--disable_warnings
432
 
DROP TABLE IF EXISTS t1, t2;
433
 
--enable_warnings
434
 
 
435
 
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a), KEY b_key1 (b));
436
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
437
 
--echo
438
 
 
439
 
CREATE TABLE t2(a INT NOT NULL, b INT , PRIMARY KEY(a), KEY b_key (b));
440
 
 
441
 
ALTER TABLE t2 ADD CONSTRAINT fk_constraint_t2 FOREIGN KEY(b) REFERENCES t1(b) ON DELETE SET NULL ON UPDATE CASCADE;
442
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
443
 
--echo
444
 
 
445
 
ALTER TABLE t2 DROP FOREIGN KEY fk_constraint_t2 ;
446
 
--source ../plugin/transaction_log/tests/t/check_transaction_log.inc
447
 
--echo
448
 
 
449
 
 
450
 
DROP TABLE t2;
451
 
 
452
 
DROP TABLE t1;
453
 
 
454
 
# Truncate the log file to reset for the next test
455
 
--source ../plugin/transaction_log/tests/t/truncate_log.inc
456
 
--echo
457