~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
SET @max_row = 20;
2
SET @@session.storage_engine = 'InnoDB';
3
4
#------------------------------------------------------------------------
5
#  0. Setting of auxiliary variables + Creation of an auxiliary tables
6
#     needed in many testcases
7
#------------------------------------------------------------------------
8
SELECT @max_row DIV 2 INTO @max_row_div2;
9
SELECT @max_row DIV 3 INTO @max_row_div3;
10
SELECT @max_row DIV 4 INTO @max_row_div4;
11
SET @max_int_4 = 2147483647;
12
DROP TABLE IF EXISTS t0_template;
13
CREATE TABLE t0_template (
14
f_int1 INTEGER,
15
f_int2 INTEGER,
16
f_char1 CHAR(20),
17
f_char2 CHAR(20),
18
f_charbig VARCHAR(1000) ,
19
PRIMARY KEY(f_int1))
20
ENGINE = MEMORY;
21
#     Logging of <max_row> INSERTs into t0_template suppressed
22
DROP TABLE IF EXISTS t0_definition;
23
CREATE TABLE t0_definition (
24
state CHAR(3),
25
create_command VARBINARY(5000),
26
file_list      VARBINARY(10000),
27
PRIMARY KEY (state)
28
) ENGINE = MEMORY;
29
DROP TABLE IF EXISTS t0_aux;
30
CREATE TABLE t0_aux ( f_int1 INTEGER,
31
f_int2 INTEGER,
32
f_char1 CHAR(20),
33
f_char2 CHAR(20),
34
f_charbig VARCHAR(1000) )
35
ENGINE = MEMORY;
36
SET AUTOCOMMIT= 1;
37
SET @@session.sql_mode= '';
38
# End of basic preparations needed for all tests
39
#-----------------------------------------------
40
41
#========================================================================
42
#  Check partitioning methods on just created tables
43
#  The tables should be defined without/with PRIMARY KEY and
44
#  UNIQUE INDEXes.
45
#  Every test round has to check
46
#        PARTITION BY HASH/KEY/LIST/RANGE
47
#        PARTITION BY RANGE/LIST ... SUBPARTITION BY HASH/KEY ...
48
#========================================================================
49
#------------------------------------------------------------------------
50
#  1   Tables without PRIMARY KEY or UNIQUE INDEXes
51
#------------------------------------------------------------------------
52
#  1.1 The partitioning function contains one column.
53
DROP TABLE IF EXISTS t1;
54
CREATE TABLE t1 (
55
f_int1 INTEGER,
56
f_int2 INTEGER,
57
f_char1 CHAR(20),
58
f_char2 CHAR(20),
59
f_charbig VARCHAR(1000)
60
61
)
62
PARTITION BY HASH(f_int1) PARTITIONS 2;
63
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
64
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
65
# Start usability test (inc/partition_check.inc)
66
create_command
67
SHOW CREATE TABLE t1;
68
Table	Create Table
69
t1	CREATE TABLE `t1` (
70
  `f_int1` int(11) DEFAULT NULL,
71
  `f_int2` int(11) DEFAULT NULL,
72
  `f_char1` char(20) DEFAULT NULL,
73
  `f_char2` char(20) DEFAULT NULL,
74
  `f_charbig` varchar(1000) DEFAULT NULL
75
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (f_int1) PARTITIONS 2  */
76
77
unified filelist
78
$MYSQLTEST_VARDIR/master-data/test/t1.frm
79
$MYSQLTEST_VARDIR/master-data/test/t1.par
80
81
# check prerequisites-1 success:    1
82
# check COUNT(*) success:    1
83
# check MIN/MAX(f_int1) success:    1
84
# check MIN/MAX(f_int2) success:    1
85
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
86
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
87
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
88
WHERE f_int1 IN (2,3);
89
# check prerequisites-3 success:    1
90
DELETE FROM t1 WHERE f_charbig = 'delete me';
91
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
92
# check read via f_int1 success: 1
93
# check read via f_int2 success: 1
94
	
95
# check multiple-1 success: 	1
96
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
97
	
98
# check multiple-2 success: 	1
99
INSERT INTO t1 SELECT * FROM t0_template
100
WHERE MOD(f_int1,3) = 0;
101
	
102
# check multiple-3 success: 	1
103
UPDATE t1 SET f_int1 = f_int1 + @max_row
104
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
105
AND @max_row_div2 + @max_row_div4;
106
	
107
# check multiple-4 success: 	1
108
DELETE FROM t1
109
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
110
AND @max_row_div2 + @max_row_div4 + @max_row;
111
	
112
# check multiple-5 success: 	1
113
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
114
INSERT INTO t1
115
SET f_int1 = @cur_value , f_int2 = @cur_value,
116
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
117
f_charbig = '#SINGLE#';
118
	
119
# check single-1 success: 	1
120
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
121
INSERT INTO t1
122
SET f_int1 = @cur_value , f_int2 = @cur_value,
123
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
124
f_charbig = '#SINGLE#';
125
	
126
# check single-2 success: 	1
127
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
128
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
129
UPDATE t1 SET f_int1 = @cur_value2
130
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
131
	
132
# check single-3 success: 	1
133
SET @cur_value1= -1;
134
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
135
UPDATE t1 SET f_int1 = @cur_value1
136
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
137
	
138
# check single-4 success: 	1
139
SELECT MAX(f_int1) INTO @cur_value FROM t1;
140
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
141
	
142
# check single-5 success: 	1
143
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
144
	
145
# check single-6 success: 	1
146
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
147
	
148
# check single-7 success: 	1
149
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
150
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
151
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
152
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
153
f_charbig = '#NULL#';
154
INSERT INTO t1
155
SET f_int1 = NULL , f_int2 = -@max_row,
156
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
157
f_charbig = '#NULL#';
158
# check null success:    1
159
	
160
# check null-1 success: 	1
161
UPDATE t1 SET f_int1 = -@max_row
162
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
163
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
164
	
165
# check null-2 success: 	1
166
UPDATE t1 SET f_int1 = NULL
167
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
168
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
169
	
170
# check null-3 success: 	1
171
DELETE FROM t1
172
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
173
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
174
	
175
# check null-4 success: 	1
176
DELETE FROM t1
177
WHERE f_int1 = 0 AND f_int2 = 0
178
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
179
AND f_charbig = '#NULL#';
180
SET AUTOCOMMIT= 0;
181
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
182
SELECT f_int1, f_int1, '', '', 'was inserted'
183
FROM t0_template source_tab
184
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
185
	
186
# check transactions-1 success: 	1
187
COMMIT WORK;
188
	
189
# check transactions-2 success: 	1
190
ROLLBACK WORK;
191
	
192
# check transactions-3 success: 	1
193
DELETE FROM t1 WHERE f_charbig = 'was inserted';
194
COMMIT WORK;
195
ROLLBACK WORK;
196
	
197
# check transactions-4 success: 	1
198
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
199
SELECT f_int1, f_int1, '', '', 'was inserted'
200
FROM t0_template source_tab
201
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
202
	
203
# check transactions-5 success: 	1
204
ROLLBACK WORK;
205
	
206
# check transactions-6 success: 	1
207
# INFO: Storage engine used for t1 seems to be transactional.
208
COMMIT;
209
	
210
# check transactions-7 success: 	1
211
DELETE FROM t1 WHERE f_charbig = 'was inserted';
212
COMMIT WORK;
213
SET @@session.sql_mode = 'traditional';
214
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
215
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
216
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
217
'', '', 'was inserted' FROM t0_template
218
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
219
ERROR 22012: Division by 0
220
COMMIT;
221
	
222
# check transactions-8 success: 	1
223
# INFO: Storage engine used for t1 seems to be able to revert
224
#       changes made by the failing statement.
225
SET @@session.sql_mode = '';
226
SET AUTOCOMMIT= 1;
227
DELETE FROM t1 WHERE f_charbig = 'was inserted';
228
COMMIT WORK;
229
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
230
	
231
# check special-1 success: 	1
232
UPDATE t1 SET f_charbig = '';
233
	
234
# check special-2 success: 	1
235
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
236
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
237
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
238
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
239
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
240
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
241
'just inserted' FROM t0_template
242
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
243
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
244
BEGIN
245
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
246
f_charbig = 'updated by trigger'
247
      WHERE f_int1 = new.f_int1;
248
END|
249
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
250
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
251
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
252
	
253
# check trigger-1 success: 	1
254
DROP TRIGGER trg_1;
255
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
256
f_int2 = CAST(f_char1 AS SIGNED INT),
257
f_charbig = 'just inserted'
258
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
259
DELETE FROM t0_aux
260
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
261
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
262
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
263
'just inserted' FROM t0_template
264
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
265
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
266
BEGIN
267
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
268
f_charbig = 'updated by trigger'
269
      WHERE f_int1 = new.f_int1;
270
END|
271
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
272
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
273
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
274
	
275
# check trigger-2 success: 	1
276
DROP TRIGGER trg_1;
277
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
278
f_int2 = CAST(f_char1 AS SIGNED INT),
279
f_charbig = 'just inserted'
280
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
281
DELETE FROM t0_aux
282
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
283
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
284
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
285
'just inserted' FROM t0_template
286
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
287
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
288
BEGIN
289
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
290
f_charbig = 'updated by trigger'
291
      WHERE f_int1 = new.f_int1;
292
END|
293
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
294
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
295
	
296
# check trigger-3 success: 	1
297
DROP TRIGGER trg_1;
298
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
299
f_int2 = CAST(f_char1 AS SIGNED INT),
300
f_charbig = 'just inserted'
301
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
302
DELETE FROM t0_aux
303
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
304
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
305
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
306
'just inserted' FROM t0_template
307
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
308
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
309
BEGIN
310
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
311
f_charbig = 'updated by trigger'
312
      WHERE f_int1 = - old.f_int1;
313
END|
314
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
315
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
316
	
317
# check trigger-4 success: 	1
318
DROP TRIGGER trg_1;
319
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
320
f_int2 = CAST(f_char1 AS SIGNED INT),
321
f_charbig = 'just inserted'
322
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
323
DELETE FROM t0_aux
324
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
325
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
326
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
327
'just inserted' FROM t0_template
328
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
329
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
330
BEGIN
331
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
332
f_charbig = 'updated by trigger'
333
      WHERE f_int1 = new.f_int1;
334
END|
335
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
336
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
337
	
338
# check trigger-5 success: 	1
339
DROP TRIGGER trg_1;
340
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
341
f_int2 = CAST(f_char1 AS SIGNED INT),
342
f_charbig = 'just inserted'
343
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
344
DELETE FROM t0_aux
345
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
346
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
347
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
348
'just inserted' FROM t0_template
349
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
350
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
351
BEGIN
352
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
353
f_charbig = 'updated by trigger'
354
      WHERE f_int1 = - old.f_int1;
355
END|
356
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
357
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
358
	
359
# check trigger-6 success: 	1
360
DROP TRIGGER trg_1;
361
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
362
f_int2 = CAST(f_char1 AS SIGNED INT),
363
f_charbig = 'just inserted'
364
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
365
DELETE FROM t0_aux
366
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
367
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
368
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
369
'just inserted' FROM t0_template
370
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
371
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
372
BEGIN
373
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
374
f_charbig = 'updated by trigger'
375
      WHERE f_int1 = - old.f_int1;
376
END|
377
DELETE FROM t0_aux
378
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
379
	
380
# check trigger-7 success: 	1
381
DROP TRIGGER trg_1;
382
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
383
f_int2 = CAST(f_char1 AS SIGNED INT),
384
f_charbig = 'just inserted'
385
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
386
DELETE FROM t0_aux
387
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
388
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
389
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
390
'just inserted' FROM t0_template
391
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
392
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
393
BEGIN
394
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
395
f_charbig = 'updated by trigger'
396
      WHERE f_int1 = - old.f_int1;
397
END|
398
DELETE FROM t0_aux
399
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
400
	
401
# check trigger-8 success: 	1
402
DROP TRIGGER trg_1;
403
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
404
f_int2 = CAST(f_char1 AS SIGNED INT),
405
f_charbig = 'just inserted'
406
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
407
DELETE FROM t0_aux
408
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
409
DELETE FROM t1
410
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
411
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
412
BEGIN
413
SET new.f_int1 = old.f_int1 + @max_row,
414
new.f_int2 = old.f_int2 - @max_row,
415
new.f_charbig = '####updated per update trigger####';
416
END|
417
UPDATE t1
418
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
419
f_charbig = '####updated per update statement itself####';
420
	
421
# check trigger-9 success: 	1
422
DROP TRIGGER trg_2;
423
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
424
f_int2 = CAST(f_char1 AS SIGNED INT),
425
f_charbig = CONCAT('===',f_char1,'===');
426
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
427
BEGIN
428
SET new.f_int1 = new.f_int1 + @max_row,
429
new.f_int2 = new.f_int2 - @max_row,
430
new.f_charbig = '####updated per update trigger####';
431
END|
432
UPDATE t1
433
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
434
f_charbig = '####updated per update statement itself####';
435
	
436
# check trigger-10 success: 	1
437
DROP TRIGGER trg_2;
438
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
439
f_int2 = CAST(f_char1 AS SIGNED INT),
440
f_charbig = CONCAT('===',f_char1,'===');
441
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
442
BEGIN
443
SET new.f_int1 = @my_max1 + @counter,
444
new.f_int2 = @my_min2 - @counter,
445
new.f_charbig = '####updated per insert trigger####';
446
SET @counter = @counter + 1;
447
END|
448
SET @counter = 1;
449
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
450
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
451
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
452
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
453
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
454
ORDER BY f_int1;
455
DROP TRIGGER trg_3;
456
	
457
# check trigger-11 success: 	1
458
DELETE FROM t1
459
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
460
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
461
AND f_charbig = '####updated per insert trigger####';
462
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
463
BEGIN
464
SET new.f_int1 = @my_max1 + @counter,
465
new.f_int2 = @my_min2 - @counter,
466
new.f_charbig = '####updated per insert trigger####';
467
SET @counter = @counter + 1;
468
END|
469
SET @counter = 1;
470
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
471
INSERT INTO t1 (f_char1, f_char2, f_charbig)
472
SELECT CAST(f_int1 AS CHAR),
473
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
474
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
475
ORDER BY f_int1;
476
DROP TRIGGER trg_3;
477
	
478
# check trigger-12 success: 	1
479
DELETE FROM t1
480
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
481
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
482
AND f_charbig = '####updated per insert trigger####';
483
ANALYZE  TABLE t1;
484
Table	Op	Msg_type	Msg_text
485
test.t1	analyze	note	The storage engine for the table doesn't support analyze
486
CHECK    TABLE t1 EXTENDED;
487
Table	Op	Msg_type	Msg_text
488
test.t1	check	note	The storage engine for the table doesn't support check
489
CHECKSUM TABLE t1 EXTENDED;
490
Table	Checksum
491
test.t1	<some_value>
492
OPTIMIZE TABLE t1;
493
Table	Op	Msg_type	Msg_text
494
test.t1	optimize	note	The storage engine for the table doesn't support optimize
495
# check layout success:    1
496
REPAIR   TABLE t1 EXTENDED;
497
Table	Op	Msg_type	Msg_text
498
test.t1	repair	note	The storage engine for the table doesn't support repair
499
# check layout success:    1
500
TRUNCATE t1;
501
	
502
# check TRUNCATE success: 	1
503
# check layout success:    1
504
# End usability test (inc/partition_check.inc)
505
DROP TABLE t1;
506
CREATE TABLE t1 (
507
f_int1 INTEGER,
508
f_int2 INTEGER,
509
f_char1 CHAR(20),
510
f_char2 CHAR(20),
511
f_charbig VARCHAR(1000)
512
513
)
514
PARTITION BY KEY(f_int1) PARTITIONS 5;
515
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
516
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
517
# Start usability test (inc/partition_check.inc)
518
create_command
519
SHOW CREATE TABLE t1;
520
Table	Create Table
521
t1	CREATE TABLE `t1` (
522
  `f_int1` int(11) DEFAULT NULL,
523
  `f_int2` int(11) DEFAULT NULL,
524
  `f_char1` char(20) DEFAULT NULL,
525
  `f_char2` char(20) DEFAULT NULL,
526
  `f_charbig` varchar(1000) DEFAULT NULL
527
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5  */
528
529
unified filelist
530
$MYSQLTEST_VARDIR/master-data/test/t1.frm
531
$MYSQLTEST_VARDIR/master-data/test/t1.par
532
533
# check prerequisites-1 success:    1
534
# check COUNT(*) success:    1
535
# check MIN/MAX(f_int1) success:    1
536
# check MIN/MAX(f_int2) success:    1
537
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
538
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
539
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
540
WHERE f_int1 IN (2,3);
541
# check prerequisites-3 success:    1
542
DELETE FROM t1 WHERE f_charbig = 'delete me';
543
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
544
# check read via f_int1 success: 1
545
# check read via f_int2 success: 1
546
	
547
# check multiple-1 success: 	1
548
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
549
	
550
# check multiple-2 success: 	1
551
INSERT INTO t1 SELECT * FROM t0_template
552
WHERE MOD(f_int1,3) = 0;
553
	
554
# check multiple-3 success: 	1
555
UPDATE t1 SET f_int1 = f_int1 + @max_row
556
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
557
AND @max_row_div2 + @max_row_div4;
558
	
559
# check multiple-4 success: 	1
560
DELETE FROM t1
561
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
562
AND @max_row_div2 + @max_row_div4 + @max_row;
563
	
564
# check multiple-5 success: 	1
565
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
566
INSERT INTO t1
567
SET f_int1 = @cur_value , f_int2 = @cur_value,
568
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
569
f_charbig = '#SINGLE#';
570
	
571
# check single-1 success: 	1
572
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
573
INSERT INTO t1
574
SET f_int1 = @cur_value , f_int2 = @cur_value,
575
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
576
f_charbig = '#SINGLE#';
577
	
578
# check single-2 success: 	1
579
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
580
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
581
UPDATE t1 SET f_int1 = @cur_value2
582
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
583
	
584
# check single-3 success: 	1
585
SET @cur_value1= -1;
586
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
587
UPDATE t1 SET f_int1 = @cur_value1
588
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
589
	
590
# check single-4 success: 	1
591
SELECT MAX(f_int1) INTO @cur_value FROM t1;
592
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
593
	
594
# check single-5 success: 	1
595
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
596
	
597
# check single-6 success: 	1
598
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
599
	
600
# check single-7 success: 	1
601
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
602
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
603
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
604
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
605
f_charbig = '#NULL#';
606
INSERT INTO t1
607
SET f_int1 = NULL , f_int2 = -@max_row,
608
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
609
f_charbig = '#NULL#';
610
# check null success:    1
611
	
612
# check null-1 success: 	1
613
UPDATE t1 SET f_int1 = -@max_row
614
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
615
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
616
	
617
# check null-2 success: 	1
618
UPDATE t1 SET f_int1 = NULL
619
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
620
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
621
	
622
# check null-3 success: 	1
623
DELETE FROM t1
624
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
625
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
626
	
627
# check null-4 success: 	1
628
DELETE FROM t1
629
WHERE f_int1 = 0 AND f_int2 = 0
630
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
631
AND f_charbig = '#NULL#';
632
SET AUTOCOMMIT= 0;
633
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
634
SELECT f_int1, f_int1, '', '', 'was inserted'
635
FROM t0_template source_tab
636
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
637
	
638
# check transactions-1 success: 	1
639
COMMIT WORK;
640
	
641
# check transactions-2 success: 	1
642
ROLLBACK WORK;
643
	
644
# check transactions-3 success: 	1
645
DELETE FROM t1 WHERE f_charbig = 'was inserted';
646
COMMIT WORK;
647
ROLLBACK WORK;
648
	
649
# check transactions-4 success: 	1
650
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
651
SELECT f_int1, f_int1, '', '', 'was inserted'
652
FROM t0_template source_tab
653
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
654
	
655
# check transactions-5 success: 	1
656
ROLLBACK WORK;
657
	
658
# check transactions-6 success: 	1
659
# INFO: Storage engine used for t1 seems to be transactional.
660
COMMIT;
661
	
662
# check transactions-7 success: 	1
663
DELETE FROM t1 WHERE f_charbig = 'was inserted';
664
COMMIT WORK;
665
SET @@session.sql_mode = 'traditional';
666
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
667
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
668
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
669
'', '', 'was inserted' FROM t0_template
670
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
671
ERROR 22012: Division by 0
672
COMMIT;
673
	
674
# check transactions-8 success: 	1
675
# INFO: Storage engine used for t1 seems to be able to revert
676
#       changes made by the failing statement.
677
SET @@session.sql_mode = '';
678
SET AUTOCOMMIT= 1;
679
DELETE FROM t1 WHERE f_charbig = 'was inserted';
680
COMMIT WORK;
681
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
682
	
683
# check special-1 success: 	1
684
UPDATE t1 SET f_charbig = '';
685
	
686
# check special-2 success: 	1
687
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
688
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
689
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
690
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
691
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
692
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
693
'just inserted' FROM t0_template
694
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
695
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
696
BEGIN
697
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
698
f_charbig = 'updated by trigger'
699
      WHERE f_int1 = new.f_int1;
700
END|
701
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
702
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
703
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
704
	
705
# check trigger-1 success: 	1
706
DROP TRIGGER trg_1;
707
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
708
f_int2 = CAST(f_char1 AS SIGNED INT),
709
f_charbig = 'just inserted'
710
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
711
DELETE FROM t0_aux
712
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
713
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
714
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
715
'just inserted' FROM t0_template
716
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
717
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
718
BEGIN
719
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
720
f_charbig = 'updated by trigger'
721
      WHERE f_int1 = new.f_int1;
722
END|
723
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
724
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
725
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
726
	
727
# check trigger-2 success: 	1
728
DROP TRIGGER trg_1;
729
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
730
f_int2 = CAST(f_char1 AS SIGNED INT),
731
f_charbig = 'just inserted'
732
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
733
DELETE FROM t0_aux
734
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
735
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
736
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
737
'just inserted' FROM t0_template
738
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
739
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
740
BEGIN
741
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
742
f_charbig = 'updated by trigger'
743
      WHERE f_int1 = new.f_int1;
744
END|
745
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
746
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
747
	
748
# check trigger-3 success: 	1
749
DROP TRIGGER trg_1;
750
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
751
f_int2 = CAST(f_char1 AS SIGNED INT),
752
f_charbig = 'just inserted'
753
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
754
DELETE FROM t0_aux
755
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
756
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
757
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
758
'just inserted' FROM t0_template
759
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
760
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
761
BEGIN
762
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
763
f_charbig = 'updated by trigger'
764
      WHERE f_int1 = - old.f_int1;
765
END|
766
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
767
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
768
	
769
# check trigger-4 success: 	1
770
DROP TRIGGER trg_1;
771
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
772
f_int2 = CAST(f_char1 AS SIGNED INT),
773
f_charbig = 'just inserted'
774
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
775
DELETE FROM t0_aux
776
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
777
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
778
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
779
'just inserted' FROM t0_template
780
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
781
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
782
BEGIN
783
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
784
f_charbig = 'updated by trigger'
785
      WHERE f_int1 = new.f_int1;
786
END|
787
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
788
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
789
	
790
# check trigger-5 success: 	1
791
DROP TRIGGER trg_1;
792
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
793
f_int2 = CAST(f_char1 AS SIGNED INT),
794
f_charbig = 'just inserted'
795
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
796
DELETE FROM t0_aux
797
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
798
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
799
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
800
'just inserted' FROM t0_template
801
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
802
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
803
BEGIN
804
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
805
f_charbig = 'updated by trigger'
806
      WHERE f_int1 = - old.f_int1;
807
END|
808
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
809
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
810
	
811
# check trigger-6 success: 	1
812
DROP TRIGGER trg_1;
813
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
814
f_int2 = CAST(f_char1 AS SIGNED INT),
815
f_charbig = 'just inserted'
816
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
817
DELETE FROM t0_aux
818
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
819
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
820
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
821
'just inserted' FROM t0_template
822
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
823
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
824
BEGIN
825
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
826
f_charbig = 'updated by trigger'
827
      WHERE f_int1 = - old.f_int1;
828
END|
829
DELETE FROM t0_aux
830
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
831
	
832
# check trigger-7 success: 	1
833
DROP TRIGGER trg_1;
834
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
835
f_int2 = CAST(f_char1 AS SIGNED INT),
836
f_charbig = 'just inserted'
837
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
838
DELETE FROM t0_aux
839
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
840
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
841
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
842
'just inserted' FROM t0_template
843
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
844
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
845
BEGIN
846
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
847
f_charbig = 'updated by trigger'
848
      WHERE f_int1 = - old.f_int1;
849
END|
850
DELETE FROM t0_aux
851
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
852
	
853
# check trigger-8 success: 	1
854
DROP TRIGGER trg_1;
855
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
856
f_int2 = CAST(f_char1 AS SIGNED INT),
857
f_charbig = 'just inserted'
858
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
859
DELETE FROM t0_aux
860
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
861
DELETE FROM t1
862
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
863
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
864
BEGIN
865
SET new.f_int1 = old.f_int1 + @max_row,
866
new.f_int2 = old.f_int2 - @max_row,
867
new.f_charbig = '####updated per update trigger####';
868
END|
869
UPDATE t1
870
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
871
f_charbig = '####updated per update statement itself####';
872
	
873
# check trigger-9 success: 	1
874
DROP TRIGGER trg_2;
875
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
876
f_int2 = CAST(f_char1 AS SIGNED INT),
877
f_charbig = CONCAT('===',f_char1,'===');
878
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
879
BEGIN
880
SET new.f_int1 = new.f_int1 + @max_row,
881
new.f_int2 = new.f_int2 - @max_row,
882
new.f_charbig = '####updated per update trigger####';
883
END|
884
UPDATE t1
885
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
886
f_charbig = '####updated per update statement itself####';
887
	
888
# check trigger-10 success: 	1
889
DROP TRIGGER trg_2;
890
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
891
f_int2 = CAST(f_char1 AS SIGNED INT),
892
f_charbig = CONCAT('===',f_char1,'===');
893
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
894
BEGIN
895
SET new.f_int1 = @my_max1 + @counter,
896
new.f_int2 = @my_min2 - @counter,
897
new.f_charbig = '####updated per insert trigger####';
898
SET @counter = @counter + 1;
899
END|
900
SET @counter = 1;
901
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
902
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
903
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
904
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
905
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
906
ORDER BY f_int1;
907
DROP TRIGGER trg_3;
908
	
909
# check trigger-11 success: 	1
910
DELETE FROM t1
911
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
912
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
913
AND f_charbig = '####updated per insert trigger####';
914
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
915
BEGIN
916
SET new.f_int1 = @my_max1 + @counter,
917
new.f_int2 = @my_min2 - @counter,
918
new.f_charbig = '####updated per insert trigger####';
919
SET @counter = @counter + 1;
920
END|
921
SET @counter = 1;
922
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
923
INSERT INTO t1 (f_char1, f_char2, f_charbig)
924
SELECT CAST(f_int1 AS CHAR),
925
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
926
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
927
ORDER BY f_int1;
928
DROP TRIGGER trg_3;
929
	
930
# check trigger-12 success: 	1
931
DELETE FROM t1
932
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
933
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
934
AND f_charbig = '####updated per insert trigger####';
935
ANALYZE  TABLE t1;
936
Table	Op	Msg_type	Msg_text
937
test.t1	analyze	note	The storage engine for the table doesn't support analyze
938
CHECK    TABLE t1 EXTENDED;
939
Table	Op	Msg_type	Msg_text
940
test.t1	check	note	The storage engine for the table doesn't support check
941
CHECKSUM TABLE t1 EXTENDED;
942
Table	Checksum
943
test.t1	<some_value>
944
OPTIMIZE TABLE t1;
945
Table	Op	Msg_type	Msg_text
946
test.t1	optimize	note	The storage engine for the table doesn't support optimize
947
# check layout success:    1
948
REPAIR   TABLE t1 EXTENDED;
949
Table	Op	Msg_type	Msg_text
950
test.t1	repair	note	The storage engine for the table doesn't support repair
951
# check layout success:    1
952
TRUNCATE t1;
953
	
954
# check TRUNCATE success: 	1
955
# check layout success:    1
956
# End usability test (inc/partition_check.inc)
957
DROP TABLE t1;
958
CREATE TABLE t1 (
959
f_int1 INTEGER,
960
f_int2 INTEGER,
961
f_char1 CHAR(20),
962
f_char2 CHAR(20),
963
f_charbig VARCHAR(1000)
964
965
)
966
PARTITION BY LIST(MOD(f_int1,4))
967
(PARTITION part_3 VALUES IN (-3),
968
PARTITION part_2 VALUES IN (-2),
969
PARTITION part_1 VALUES IN (-1),
970
PARTITION part_N VALUES IN (NULL),
971
PARTITION part0 VALUES IN (0),
972
PARTITION part1 VALUES IN (1),
973
PARTITION part2 VALUES IN (2),
974
PARTITION part3 VALUES IN (3));
975
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
976
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
977
# Start usability test (inc/partition_check.inc)
978
create_command
979
SHOW CREATE TABLE t1;
980
Table	Create Table
981
t1	CREATE TABLE `t1` (
982
  `f_int1` int(11) DEFAULT NULL,
983
  `f_int2` int(11) DEFAULT NULL,
984
  `f_char1` char(20) DEFAULT NULL,
985
  `f_char2` char(20) DEFAULT NULL,
986
  `f_charbig` varchar(1000) DEFAULT NULL
987
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3) ENGINE = InnoDB, PARTITION part_2 VALUES IN (-2) ENGINE = InnoDB, PARTITION part_1 VALUES IN (-1) ENGINE = InnoDB, PARTITION part_N VALUES IN (NULL) ENGINE = InnoDB, PARTITION part0 VALUES IN (0) ENGINE = InnoDB, PARTITION part1 VALUES IN (1) ENGINE = InnoDB, PARTITION part2 VALUES IN (2) ENGINE = InnoDB, PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
988
989
unified filelist
990
$MYSQLTEST_VARDIR/master-data/test/t1.frm
991
$MYSQLTEST_VARDIR/master-data/test/t1.par
992
993
# check prerequisites-1 success:    1
994
# check COUNT(*) success:    1
995
# check MIN/MAX(f_int1) success:    1
996
# check MIN/MAX(f_int2) success:    1
997
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
998
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
999
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
1000
WHERE f_int1 IN (2,3);
1001
# check prerequisites-3 success:    1
1002
DELETE FROM t1 WHERE f_charbig = 'delete me';
1003
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
1004
# check read via f_int1 success: 1
1005
# check read via f_int2 success: 1
1006
	
1007
# check multiple-1 success: 	1
1008
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
1009
	
1010
# check multiple-2 success: 	1
1011
INSERT INTO t1 SELECT * FROM t0_template
1012
WHERE MOD(f_int1,3) = 0;
1013
	
1014
# check multiple-3 success: 	1
1015
UPDATE t1 SET f_int1 = f_int1 + @max_row
1016
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
1017
AND @max_row_div2 + @max_row_div4;
1018
	
1019
# check multiple-4 success: 	1
1020
DELETE FROM t1
1021
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
1022
AND @max_row_div2 + @max_row_div4 + @max_row;
1023
	
1024
# check multiple-5 success: 	1
1025
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
1026
INSERT INTO t1
1027
SET f_int1 = @cur_value , f_int2 = @cur_value,
1028
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
1029
f_charbig = '#SINGLE#';
1030
	
1031
# check single-1 success: 	1
1032
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
1033
INSERT INTO t1
1034
SET f_int1 = @cur_value , f_int2 = @cur_value,
1035
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
1036
f_charbig = '#SINGLE#';
1037
	
1038
# check single-2 success: 	1
1039
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
1040
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
1041
UPDATE t1 SET f_int1 = @cur_value2
1042
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
1043
	
1044
# check single-3 success: 	1
1045
SET @cur_value1= -1;
1046
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
1047
UPDATE t1 SET f_int1 = @cur_value1
1048
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
1049
	
1050
# check single-4 success: 	1
1051
SELECT MAX(f_int1) INTO @cur_value FROM t1;
1052
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
1053
	
1054
# check single-5 success: 	1
1055
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
1056
	
1057
# check single-6 success: 	1
1058
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
1059
	
1060
# check single-7 success: 	1
1061
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
1062
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
1063
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
1064
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
1065
f_charbig = '#NULL#';
1066
INSERT INTO t1
1067
SET f_int1 = NULL , f_int2 = -@max_row,
1068
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
1069
f_charbig = '#NULL#';
1070
# check null success:    1
1071
	
1072
# check null-1 success: 	1
1073
UPDATE t1 SET f_int1 = -@max_row
1074
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
1075
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
1076
	
1077
# check null-2 success: 	1
1078
UPDATE t1 SET f_int1 = NULL
1079
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
1080
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
1081
	
1082
# check null-3 success: 	1
1083
DELETE FROM t1
1084
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
1085
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
1086
	
1087
# check null-4 success: 	1
1088
DELETE FROM t1
1089
WHERE f_int1 = 0 AND f_int2 = 0
1090
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
1091
AND f_charbig = '#NULL#';
1092
SET AUTOCOMMIT= 0;
1093
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
1094
SELECT f_int1, f_int1, '', '', 'was inserted'
1095
FROM t0_template source_tab
1096
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
1097
	
1098
# check transactions-1 success: 	1
1099
COMMIT WORK;
1100
	
1101
# check transactions-2 success: 	1
1102
ROLLBACK WORK;
1103
	
1104
# check transactions-3 success: 	1
1105
DELETE FROM t1 WHERE f_charbig = 'was inserted';
1106
COMMIT WORK;
1107
ROLLBACK WORK;
1108
	
1109
# check transactions-4 success: 	1
1110
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
1111
SELECT f_int1, f_int1, '', '', 'was inserted'
1112
FROM t0_template source_tab
1113
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
1114
	
1115
# check transactions-5 success: 	1
1116
ROLLBACK WORK;
1117
	
1118
# check transactions-6 success: 	1
1119
# INFO: Storage engine used for t1 seems to be transactional.
1120
COMMIT;
1121
	
1122
# check transactions-7 success: 	1
1123
DELETE FROM t1 WHERE f_charbig = 'was inserted';
1124
COMMIT WORK;
1125
SET @@session.sql_mode = 'traditional';
1126
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
1127
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
1128
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
1129
'', '', 'was inserted' FROM t0_template
1130
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
1131
ERROR 22012: Division by 0
1132
COMMIT;
1133
	
1134
# check transactions-8 success: 	1
1135
# INFO: Storage engine used for t1 seems to be able to revert
1136
#       changes made by the failing statement.
1137
SET @@session.sql_mode = '';
1138
SET AUTOCOMMIT= 1;
1139
DELETE FROM t1 WHERE f_charbig = 'was inserted';
1140
COMMIT WORK;
1141
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
1142
	
1143
# check special-1 success: 	1
1144
UPDATE t1 SET f_charbig = '';
1145
	
1146
# check special-2 success: 	1
1147
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
1148
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
1149
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
1150
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1151
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1152
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1153
'just inserted' FROM t0_template
1154
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1155
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
1156
BEGIN
1157
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1158
f_charbig = 'updated by trigger'
1159
      WHERE f_int1 = new.f_int1;
1160
END|
1161
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1162
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
1163
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1164
	
1165
# check trigger-1 success: 	1
1166
DROP TRIGGER trg_1;
1167
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1168
f_int2 = CAST(f_char1 AS SIGNED INT),
1169
f_charbig = 'just inserted'
1170
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1171
DELETE FROM t0_aux
1172
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1173
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1174
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1175
'just inserted' FROM t0_template
1176
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1177
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
1178
BEGIN
1179
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1180
f_charbig = 'updated by trigger'
1181
      WHERE f_int1 = new.f_int1;
1182
END|
1183
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1184
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
1185
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1186
	
1187
# check trigger-2 success: 	1
1188
DROP TRIGGER trg_1;
1189
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1190
f_int2 = CAST(f_char1 AS SIGNED INT),
1191
f_charbig = 'just inserted'
1192
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1193
DELETE FROM t0_aux
1194
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1195
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1196
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1197
'just inserted' FROM t0_template
1198
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1199
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
1200
BEGIN
1201
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1202
f_charbig = 'updated by trigger'
1203
      WHERE f_int1 = new.f_int1;
1204
END|
1205
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
1206
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
1207
	
1208
# check trigger-3 success: 	1
1209
DROP TRIGGER trg_1;
1210
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1211
f_int2 = CAST(f_char1 AS SIGNED INT),
1212
f_charbig = 'just inserted'
1213
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1214
DELETE FROM t0_aux
1215
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1216
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1217
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1218
'just inserted' FROM t0_template
1219
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1220
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
1221
BEGIN
1222
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1223
f_charbig = 'updated by trigger'
1224
      WHERE f_int1 = - old.f_int1;
1225
END|
1226
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
1227
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
1228
	
1229
# check trigger-4 success: 	1
1230
DROP TRIGGER trg_1;
1231
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1232
f_int2 = CAST(f_char1 AS SIGNED INT),
1233
f_charbig = 'just inserted'
1234
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1235
DELETE FROM t0_aux
1236
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1237
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1238
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1239
'just inserted' FROM t0_template
1240
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1241
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
1242
BEGIN
1243
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1244
f_charbig = 'updated by trigger'
1245
      WHERE f_int1 = new.f_int1;
1246
END|
1247
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
1248
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
1249
	
1250
# check trigger-5 success: 	1
1251
DROP TRIGGER trg_1;
1252
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1253
f_int2 = CAST(f_char1 AS SIGNED INT),
1254
f_charbig = 'just inserted'
1255
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1256
DELETE FROM t0_aux
1257
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1258
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1259
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1260
'just inserted' FROM t0_template
1261
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1262
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
1263
BEGIN
1264
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1265
f_charbig = 'updated by trigger'
1266
      WHERE f_int1 = - old.f_int1;
1267
END|
1268
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
1269
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
1270
	
1271
# check trigger-6 success: 	1
1272
DROP TRIGGER trg_1;
1273
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1274
f_int2 = CAST(f_char1 AS SIGNED INT),
1275
f_charbig = 'just inserted'
1276
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1277
DELETE FROM t0_aux
1278
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1279
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1280
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1281
'just inserted' FROM t0_template
1282
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1283
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
1284
BEGIN
1285
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1286
f_charbig = 'updated by trigger'
1287
      WHERE f_int1 = - old.f_int1;
1288
END|
1289
DELETE FROM t0_aux
1290
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
1291
	
1292
# check trigger-7 success: 	1
1293
DROP TRIGGER trg_1;
1294
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1295
f_int2 = CAST(f_char1 AS SIGNED INT),
1296
f_charbig = 'just inserted'
1297
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1298
DELETE FROM t0_aux
1299
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1300
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1301
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1302
'just inserted' FROM t0_template
1303
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1304
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
1305
BEGIN
1306
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1307
f_charbig = 'updated by trigger'
1308
      WHERE f_int1 = - old.f_int1;
1309
END|
1310
DELETE FROM t0_aux
1311
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
1312
	
1313
# check trigger-8 success: 	1
1314
DROP TRIGGER trg_1;
1315
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1316
f_int2 = CAST(f_char1 AS SIGNED INT),
1317
f_charbig = 'just inserted'
1318
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1319
DELETE FROM t0_aux
1320
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1321
DELETE FROM t1
1322
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1323
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
1324
BEGIN
1325
SET new.f_int1 = old.f_int1 + @max_row,
1326
new.f_int2 = old.f_int2 - @max_row,
1327
new.f_charbig = '####updated per update trigger####';
1328
END|
1329
UPDATE t1
1330
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
1331
f_charbig = '####updated per update statement itself####';
1332
	
1333
# check trigger-9 success: 	1
1334
DROP TRIGGER trg_2;
1335
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1336
f_int2 = CAST(f_char1 AS SIGNED INT),
1337
f_charbig = CONCAT('===',f_char1,'===');
1338
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
1339
BEGIN
1340
SET new.f_int1 = new.f_int1 + @max_row,
1341
new.f_int2 = new.f_int2 - @max_row,
1342
new.f_charbig = '####updated per update trigger####';
1343
END|
1344
UPDATE t1
1345
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
1346
f_charbig = '####updated per update statement itself####';
1347
	
1348
# check trigger-10 success: 	1
1349
DROP TRIGGER trg_2;
1350
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1351
f_int2 = CAST(f_char1 AS SIGNED INT),
1352
f_charbig = CONCAT('===',f_char1,'===');
1353
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
1354
BEGIN
1355
SET new.f_int1 = @my_max1 + @counter,
1356
new.f_int2 = @my_min2 - @counter,
1357
new.f_charbig = '####updated per insert trigger####';
1358
SET @counter = @counter + 1;
1359
END|
1360
SET @counter = 1;
1361
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
1362
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
1363
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
1364
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
1365
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
1366
ORDER BY f_int1;
1367
DROP TRIGGER trg_3;
1368
	
1369
# check trigger-11 success: 	1
1370
DELETE FROM t1
1371
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
1372
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
1373
AND f_charbig = '####updated per insert trigger####';
1374
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
1375
BEGIN
1376
SET new.f_int1 = @my_max1 + @counter,
1377
new.f_int2 = @my_min2 - @counter,
1378
new.f_charbig = '####updated per insert trigger####';
1379
SET @counter = @counter + 1;
1380
END|
1381
SET @counter = 1;
1382
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
1383
INSERT INTO t1 (f_char1, f_char2, f_charbig)
1384
SELECT CAST(f_int1 AS CHAR),
1385
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
1386
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
1387
ORDER BY f_int1;
1388
DROP TRIGGER trg_3;
1389
	
1390
# check trigger-12 success: 	1
1391
DELETE FROM t1
1392
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
1393
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
1394
AND f_charbig = '####updated per insert trigger####';
1395
ANALYZE  TABLE t1;
1396
Table	Op	Msg_type	Msg_text
1397
test.t1	analyze	note	The storage engine for the table doesn't support analyze
1398
CHECK    TABLE t1 EXTENDED;
1399
Table	Op	Msg_type	Msg_text
1400
test.t1	check	note	The storage engine for the table doesn't support check
1401
CHECKSUM TABLE t1 EXTENDED;
1402
Table	Checksum
1403
test.t1	<some_value>
1404
OPTIMIZE TABLE t1;
1405
Table	Op	Msg_type	Msg_text
1406
test.t1	optimize	note	The storage engine for the table doesn't support optimize
1407
# check layout success:    1
1408
REPAIR   TABLE t1 EXTENDED;
1409
Table	Op	Msg_type	Msg_text
1410
test.t1	repair	note	The storage engine for the table doesn't support repair
1411
# check layout success:    1
1412
TRUNCATE t1;
1413
	
1414
# check TRUNCATE success: 	1
1415
# check layout success:    1
1416
# End usability test (inc/partition_check.inc)
1417
DROP TABLE t1;
1418
CREATE TABLE t1 (
1419
f_int1 INTEGER,
1420
f_int2 INTEGER,
1421
f_char1 CHAR(20),
1422
f_char2 CHAR(20),
1423
f_charbig VARCHAR(1000)
1424
1425
)
1426
PARTITION BY RANGE(f_int1)
1427
(PARTITION parta VALUES LESS THAN (0),
1428
PARTITION partb VALUES LESS THAN (5),
1429
PARTITION partc VALUES LESS THAN (10),
1430
PARTITION partd VALUES LESS THAN (10 + 5),
1431
PARTITION parte VALUES LESS THAN (20),
1432
PARTITION partf VALUES LESS THAN (2147483646));
1433
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
1434
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
1435
# Start usability test (inc/partition_check.inc)
1436
create_command
1437
SHOW CREATE TABLE t1;
1438
Table	Create Table
1439
t1	CREATE TABLE `t1` (
1440
  `f_int1` int(11) DEFAULT NULL,
1441
  `f_int2` int(11) DEFAULT NULL,
1442
  `f_char1` char(20) DEFAULT NULL,
1443
  `f_char2` char(20) DEFAULT NULL,
1444
  `f_charbig` varchar(1000) DEFAULT NULL
1445
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION parte VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
1446
1447
unified filelist
1448
$MYSQLTEST_VARDIR/master-data/test/t1.frm
1449
$MYSQLTEST_VARDIR/master-data/test/t1.par
1450
1451
# check prerequisites-1 success:    1
1452
# check COUNT(*) success:    1
1453
# check MIN/MAX(f_int1) success:    1
1454
# check MIN/MAX(f_int2) success:    1
1455
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
1456
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
1457
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
1458
WHERE f_int1 IN (2,3);
1459
# check prerequisites-3 success:    1
1460
DELETE FROM t1 WHERE f_charbig = 'delete me';
1461
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
1462
# check read via f_int1 success: 1
1463
# check read via f_int2 success: 1
1464
	
1465
# check multiple-1 success: 	1
1466
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
1467
	
1468
# check multiple-2 success: 	1
1469
INSERT INTO t1 SELECT * FROM t0_template
1470
WHERE MOD(f_int1,3) = 0;
1471
	
1472
# check multiple-3 success: 	1
1473
UPDATE t1 SET f_int1 = f_int1 + @max_row
1474
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
1475
AND @max_row_div2 + @max_row_div4;
1476
	
1477
# check multiple-4 success: 	1
1478
DELETE FROM t1
1479
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
1480
AND @max_row_div2 + @max_row_div4 + @max_row;
1481
	
1482
# check multiple-5 success: 	1
1483
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
1484
INSERT INTO t1
1485
SET f_int1 = @cur_value , f_int2 = @cur_value,
1486
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
1487
f_charbig = '#SINGLE#';
1488
	
1489
# check single-1 success: 	1
1490
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
1491
INSERT INTO t1
1492
SET f_int1 = @cur_value , f_int2 = @cur_value,
1493
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
1494
f_charbig = '#SINGLE#';
1495
	
1496
# check single-2 success: 	1
1497
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
1498
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
1499
UPDATE t1 SET f_int1 = @cur_value2
1500
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
1501
	
1502
# check single-3 success: 	1
1503
SET @cur_value1= -1;
1504
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
1505
UPDATE t1 SET f_int1 = @cur_value1
1506
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
1507
	
1508
# check single-4 success: 	1
1509
SELECT MAX(f_int1) INTO @cur_value FROM t1;
1510
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
1511
	
1512
# check single-5 success: 	1
1513
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
1514
	
1515
# check single-6 success: 	1
1516
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
1517
ERROR HY000: Table has no partition for value 2147483647
1518
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
1519
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
1520
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
1521
f_charbig = '#NULL#';
1522
INSERT INTO t1
1523
SET f_int1 = NULL , f_int2 = -@max_row,
1524
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
1525
f_charbig = '#NULL#';
1526
# check null success:    1
1527
	
1528
# check null-1 success: 	1
1529
UPDATE t1 SET f_int1 = -@max_row
1530
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
1531
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
1532
	
1533
# check null-2 success: 	1
1534
UPDATE t1 SET f_int1 = NULL
1535
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
1536
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
1537
	
1538
# check null-3 success: 	1
1539
DELETE FROM t1
1540
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
1541
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
1542
	
1543
# check null-4 success: 	1
1544
DELETE FROM t1
1545
WHERE f_int1 = 0 AND f_int2 = 0
1546
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
1547
AND f_charbig = '#NULL#';
1548
SET AUTOCOMMIT= 0;
1549
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
1550
SELECT f_int1, f_int1, '', '', 'was inserted'
1551
FROM t0_template source_tab
1552
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
1553
	
1554
# check transactions-1 success: 	1
1555
COMMIT WORK;
1556
	
1557
# check transactions-2 success: 	1
1558
ROLLBACK WORK;
1559
	
1560
# check transactions-3 success: 	1
1561
DELETE FROM t1 WHERE f_charbig = 'was inserted';
1562
COMMIT WORK;
1563
ROLLBACK WORK;
1564
	
1565
# check transactions-4 success: 	1
1566
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
1567
SELECT f_int1, f_int1, '', '', 'was inserted'
1568
FROM t0_template source_tab
1569
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
1570
	
1571
# check transactions-5 success: 	1
1572
ROLLBACK WORK;
1573
	
1574
# check transactions-6 success: 	1
1575
# INFO: Storage engine used for t1 seems to be transactional.
1576
COMMIT;
1577
	
1578
# check transactions-7 success: 	1
1579
DELETE FROM t1 WHERE f_charbig = 'was inserted';
1580
COMMIT WORK;
1581
SET @@session.sql_mode = 'traditional';
1582
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
1583
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
1584
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
1585
'', '', 'was inserted' FROM t0_template
1586
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
1587
ERROR 22012: Division by 0
1588
COMMIT;
1589
	
1590
# check transactions-8 success: 	1
1591
# INFO: Storage engine used for t1 seems to be able to revert
1592
#       changes made by the failing statement.
1593
SET @@session.sql_mode = '';
1594
SET AUTOCOMMIT= 1;
1595
DELETE FROM t1 WHERE f_charbig = 'was inserted';
1596
COMMIT WORK;
1597
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
1598
	
1599
# check special-1 success: 	1
1600
UPDATE t1 SET f_charbig = '';
1601
	
1602
# check special-2 success: 	1
1603
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
1604
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
1605
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
1606
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1607
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1608
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1609
'just inserted' FROM t0_template
1610
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1611
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
1612
BEGIN
1613
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1614
f_charbig = 'updated by trigger'
1615
      WHERE f_int1 = new.f_int1;
1616
END|
1617
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1618
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
1619
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1620
	
1621
# check trigger-1 success: 	1
1622
DROP TRIGGER trg_1;
1623
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1624
f_int2 = CAST(f_char1 AS SIGNED INT),
1625
f_charbig = 'just inserted'
1626
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1627
DELETE FROM t0_aux
1628
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1629
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1630
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1631
'just inserted' FROM t0_template
1632
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1633
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
1634
BEGIN
1635
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1636
f_charbig = 'updated by trigger'
1637
      WHERE f_int1 = new.f_int1;
1638
END|
1639
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1640
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
1641
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1642
	
1643
# check trigger-2 success: 	1
1644
DROP TRIGGER trg_1;
1645
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1646
f_int2 = CAST(f_char1 AS SIGNED INT),
1647
f_charbig = 'just inserted'
1648
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1649
DELETE FROM t0_aux
1650
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1651
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1652
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1653
'just inserted' FROM t0_template
1654
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1655
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
1656
BEGIN
1657
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1658
f_charbig = 'updated by trigger'
1659
      WHERE f_int1 = new.f_int1;
1660
END|
1661
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
1662
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
1663
	
1664
# check trigger-3 success: 	1
1665
DROP TRIGGER trg_1;
1666
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1667
f_int2 = CAST(f_char1 AS SIGNED INT),
1668
f_charbig = 'just inserted'
1669
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1670
DELETE FROM t0_aux
1671
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1672
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1673
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1674
'just inserted' FROM t0_template
1675
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1676
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
1677
BEGIN
1678
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1679
f_charbig = 'updated by trigger'
1680
      WHERE f_int1 = - old.f_int1;
1681
END|
1682
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
1683
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
1684
	
1685
# check trigger-4 success: 	1
1686
DROP TRIGGER trg_1;
1687
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1688
f_int2 = CAST(f_char1 AS SIGNED INT),
1689
f_charbig = 'just inserted'
1690
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1691
DELETE FROM t0_aux
1692
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1693
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1694
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1695
'just inserted' FROM t0_template
1696
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1697
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
1698
BEGIN
1699
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1700
f_charbig = 'updated by trigger'
1701
      WHERE f_int1 = new.f_int1;
1702
END|
1703
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
1704
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
1705
	
1706
# check trigger-5 success: 	1
1707
DROP TRIGGER trg_1;
1708
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1709
f_int2 = CAST(f_char1 AS SIGNED INT),
1710
f_charbig = 'just inserted'
1711
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1712
DELETE FROM t0_aux
1713
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1714
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1715
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1716
'just inserted' FROM t0_template
1717
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1718
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
1719
BEGIN
1720
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1721
f_charbig = 'updated by trigger'
1722
      WHERE f_int1 = - old.f_int1;
1723
END|
1724
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
1725
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
1726
	
1727
# check trigger-6 success: 	1
1728
DROP TRIGGER trg_1;
1729
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1730
f_int2 = CAST(f_char1 AS SIGNED INT),
1731
f_charbig = 'just inserted'
1732
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1733
DELETE FROM t0_aux
1734
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1735
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1736
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1737
'just inserted' FROM t0_template
1738
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1739
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
1740
BEGIN
1741
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1742
f_charbig = 'updated by trigger'
1743
      WHERE f_int1 = - old.f_int1;
1744
END|
1745
DELETE FROM t0_aux
1746
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
1747
	
1748
# check trigger-7 success: 	1
1749
DROP TRIGGER trg_1;
1750
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1751
f_int2 = CAST(f_char1 AS SIGNED INT),
1752
f_charbig = 'just inserted'
1753
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1754
DELETE FROM t0_aux
1755
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1756
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
1757
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
1758
'just inserted' FROM t0_template
1759
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1760
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
1761
BEGIN
1762
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
1763
f_charbig = 'updated by trigger'
1764
      WHERE f_int1 = - old.f_int1;
1765
END|
1766
DELETE FROM t0_aux
1767
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
1768
	
1769
# check trigger-8 success: 	1
1770
DROP TRIGGER trg_1;
1771
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1772
f_int2 = CAST(f_char1 AS SIGNED INT),
1773
f_charbig = 'just inserted'
1774
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
1775
DELETE FROM t0_aux
1776
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1777
DELETE FROM t1
1778
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
1779
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
1780
BEGIN
1781
SET new.f_int1 = old.f_int1 + @max_row,
1782
new.f_int2 = old.f_int2 - @max_row,
1783
new.f_charbig = '####updated per update trigger####';
1784
END|
1785
UPDATE t1
1786
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
1787
f_charbig = '####updated per update statement itself####';
1788
	
1789
# check trigger-9 success: 	1
1790
DROP TRIGGER trg_2;
1791
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1792
f_int2 = CAST(f_char1 AS SIGNED INT),
1793
f_charbig = CONCAT('===',f_char1,'===');
1794
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
1795
BEGIN
1796
SET new.f_int1 = new.f_int1 + @max_row,
1797
new.f_int2 = new.f_int2 - @max_row,
1798
new.f_charbig = '####updated per update trigger####';
1799
END|
1800
UPDATE t1
1801
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
1802
f_charbig = '####updated per update statement itself####';
1803
	
1804
# check trigger-10 success: 	1
1805
DROP TRIGGER trg_2;
1806
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
1807
f_int2 = CAST(f_char1 AS SIGNED INT),
1808
f_charbig = CONCAT('===',f_char1,'===');
1809
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
1810
BEGIN
1811
SET new.f_int1 = @my_max1 + @counter,
1812
new.f_int2 = @my_min2 - @counter,
1813
new.f_charbig = '####updated per insert trigger####';
1814
SET @counter = @counter + 1;
1815
END|
1816
SET @counter = 1;
1817
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
1818
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
1819
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
1820
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
1821
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
1822
ORDER BY f_int1;
1823
DROP TRIGGER trg_3;
1824
	
1825
# check trigger-11 success: 	1
1826
DELETE FROM t1
1827
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
1828
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
1829
AND f_charbig = '####updated per insert trigger####';
1830
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
1831
BEGIN
1832
SET new.f_int1 = @my_max1 + @counter,
1833
new.f_int2 = @my_min2 - @counter,
1834
new.f_charbig = '####updated per insert trigger####';
1835
SET @counter = @counter + 1;
1836
END|
1837
SET @counter = 1;
1838
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
1839
INSERT INTO t1 (f_char1, f_char2, f_charbig)
1840
SELECT CAST(f_int1 AS CHAR),
1841
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
1842
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
1843
ORDER BY f_int1;
1844
DROP TRIGGER trg_3;
1845
	
1846
# check trigger-12 success: 	1
1847
DELETE FROM t1
1848
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
1849
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
1850
AND f_charbig = '####updated per insert trigger####';
1851
ANALYZE  TABLE t1;
1852
Table	Op	Msg_type	Msg_text
1853
test.t1	analyze	note	The storage engine for the table doesn't support analyze
1854
CHECK    TABLE t1 EXTENDED;
1855
Table	Op	Msg_type	Msg_text
1856
test.t1	check	note	The storage engine for the table doesn't support check
1857
CHECKSUM TABLE t1 EXTENDED;
1858
Table	Checksum
1859
test.t1	<some_value>
1860
OPTIMIZE TABLE t1;
1861
Table	Op	Msg_type	Msg_text
1862
test.t1	optimize	note	The storage engine for the table doesn't support optimize
1863
# check layout success:    1
1864
REPAIR   TABLE t1 EXTENDED;
1865
Table	Op	Msg_type	Msg_text
1866
test.t1	repair	note	The storage engine for the table doesn't support repair
1867
# check layout success:    1
1868
TRUNCATE t1;
1869
	
1870
# check TRUNCATE success: 	1
1871
# check layout success:    1
1872
# End usability test (inc/partition_check.inc)
1873
DROP TABLE t1;
1874
CREATE TABLE t1 (
1875
f_int1 INTEGER,
1876
f_int2 INTEGER,
1877
f_char1 CHAR(20),
1878
f_char2 CHAR(20),
1879
f_charbig VARCHAR(1000)
1880
1881
)
1882
PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
1883
(PARTITION parta VALUES LESS THAN (0),
1884
PARTITION partb VALUES LESS THAN (5),
1885
PARTITION partc VALUES LESS THAN (10),
1886
PARTITION partd VALUES LESS THAN (2147483646));
1887
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
1888
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
1889
# Start usability test (inc/partition_check.inc)
1890
create_command
1891
SHOW CREATE TABLE t1;
1892
Table	Create Table
1893
t1	CREATE TABLE `t1` (
1894
  `f_int1` int(11) DEFAULT NULL,
1895
  `f_int2` int(11) DEFAULT NULL,
1896
  `f_char1` char(20) DEFAULT NULL,
1897
  `f_char2` char(20) DEFAULT NULL,
1898
  `f_charbig` varchar(1000) DEFAULT NULL
1899
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1 DIV 2) SUBPARTITION BY HASH (f_int1) SUBPARTITIONS 2 (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
1900
1901
unified filelist
1902
$MYSQLTEST_VARDIR/master-data/test/t1.frm
1903
$MYSQLTEST_VARDIR/master-data/test/t1.par
1904
1905
# check prerequisites-1 success:    1
1906
# check COUNT(*) success:    1
1907
# check MIN/MAX(f_int1) success:    1
1908
# check MIN/MAX(f_int2) success:    1
1909
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
1910
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
1911
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
1912
WHERE f_int1 IN (2,3);
1913
# check prerequisites-3 success:    1
1914
DELETE FROM t1 WHERE f_charbig = 'delete me';
1915
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
1916
# check read via f_int1 success: 1
1917
# check read via f_int2 success: 1
1918
	
1919
# check multiple-1 success: 	1
1920
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
1921
	
1922
# check multiple-2 success: 	1
1923
INSERT INTO t1 SELECT * FROM t0_template
1924
WHERE MOD(f_int1,3) = 0;
1925
	
1926
# check multiple-3 success: 	1
1927
UPDATE t1 SET f_int1 = f_int1 + @max_row
1928
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
1929
AND @max_row_div2 + @max_row_div4;
1930
	
1931
# check multiple-4 success: 	1
1932
DELETE FROM t1
1933
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
1934
AND @max_row_div2 + @max_row_div4 + @max_row;
1935
	
1936
# check multiple-5 success: 	1
1937
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
1938
INSERT INTO t1
1939
SET f_int1 = @cur_value , f_int2 = @cur_value,
1940
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
1941
f_charbig = '#SINGLE#';
1942
	
1943
# check single-1 success: 	1
1944
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
1945
INSERT INTO t1
1946
SET f_int1 = @cur_value , f_int2 = @cur_value,
1947
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
1948
f_charbig = '#SINGLE#';
1949
	
1950
# check single-2 success: 	1
1951
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
1952
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
1953
UPDATE t1 SET f_int1 = @cur_value2
1954
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
1955
	
1956
# check single-3 success: 	1
1957
SET @cur_value1= -1;
1958
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
1959
UPDATE t1 SET f_int1 = @cur_value1
1960
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
1961
	
1962
# check single-4 success: 	1
1963
SELECT MAX(f_int1) INTO @cur_value FROM t1;
1964
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
1965
	
1966
# check single-5 success: 	1
1967
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
1968
	
1969
# check single-6 success: 	1
1970
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
1971
	
1972
# check single-7 success: 	1
1973
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
1974
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
1975
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
1976
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
1977
f_charbig = '#NULL#';
1978
INSERT INTO t1
1979
SET f_int1 = NULL , f_int2 = -@max_row,
1980
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
1981
f_charbig = '#NULL#';
1982
# check null success:    1
1983
	
1984
# check null-1 success: 	1
1985
UPDATE t1 SET f_int1 = -@max_row
1986
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
1987
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
1988
	
1989
# check null-2 success: 	1
1990
UPDATE t1 SET f_int1 = NULL
1991
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
1992
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
1993
	
1994
# check null-3 success: 	1
1995
DELETE FROM t1
1996
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
1997
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
1998
	
1999
# check null-4 success: 	1
2000
DELETE FROM t1
2001
WHERE f_int1 = 0 AND f_int2 = 0
2002
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
2003
AND f_charbig = '#NULL#';
2004
SET AUTOCOMMIT= 0;
2005
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
2006
SELECT f_int1, f_int1, '', '', 'was inserted'
2007
FROM t0_template source_tab
2008
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
2009
	
2010
# check transactions-1 success: 	1
2011
COMMIT WORK;
2012
	
2013
# check transactions-2 success: 	1
2014
ROLLBACK WORK;
2015
	
2016
# check transactions-3 success: 	1
2017
DELETE FROM t1 WHERE f_charbig = 'was inserted';
2018
COMMIT WORK;
2019
ROLLBACK WORK;
2020
	
2021
# check transactions-4 success: 	1
2022
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
2023
SELECT f_int1, f_int1, '', '', 'was inserted'
2024
FROM t0_template source_tab
2025
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
2026
	
2027
# check transactions-5 success: 	1
2028
ROLLBACK WORK;
2029
	
2030
# check transactions-6 success: 	1
2031
# INFO: Storage engine used for t1 seems to be transactional.
2032
COMMIT;
2033
	
2034
# check transactions-7 success: 	1
2035
DELETE FROM t1 WHERE f_charbig = 'was inserted';
2036
COMMIT WORK;
2037
SET @@session.sql_mode = 'traditional';
2038
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
2039
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
2040
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
2041
'', '', 'was inserted' FROM t0_template
2042
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
2043
ERROR 22012: Division by 0
2044
COMMIT;
2045
	
2046
# check transactions-8 success: 	1
2047
# INFO: Storage engine used for t1 seems to be able to revert
2048
#       changes made by the failing statement.
2049
SET @@session.sql_mode = '';
2050
SET AUTOCOMMIT= 1;
2051
DELETE FROM t1 WHERE f_charbig = 'was inserted';
2052
COMMIT WORK;
2053
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
2054
	
2055
# check special-1 success: 	1
2056
UPDATE t1 SET f_charbig = '';
2057
	
2058
# check special-2 success: 	1
2059
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
2060
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
2061
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
2062
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2063
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2064
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2065
'just inserted' FROM t0_template
2066
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2067
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
2068
BEGIN
2069
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2070
f_charbig = 'updated by trigger'
2071
      WHERE f_int1 = new.f_int1;
2072
END|
2073
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2074
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
2075
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2076
	
2077
# check trigger-1 success: 	1
2078
DROP TRIGGER trg_1;
2079
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2080
f_int2 = CAST(f_char1 AS SIGNED INT),
2081
f_charbig = 'just inserted'
2082
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2083
DELETE FROM t0_aux
2084
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2085
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2086
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2087
'just inserted' FROM t0_template
2088
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2089
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
2090
BEGIN
2091
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2092
f_charbig = 'updated by trigger'
2093
      WHERE f_int1 = new.f_int1;
2094
END|
2095
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2096
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
2097
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2098
	
2099
# check trigger-2 success: 	1
2100
DROP TRIGGER trg_1;
2101
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2102
f_int2 = CAST(f_char1 AS SIGNED INT),
2103
f_charbig = 'just inserted'
2104
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2105
DELETE FROM t0_aux
2106
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2107
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2108
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2109
'just inserted' FROM t0_template
2110
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2111
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
2112
BEGIN
2113
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2114
f_charbig = 'updated by trigger'
2115
      WHERE f_int1 = new.f_int1;
2116
END|
2117
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
2118
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
2119
	
2120
# check trigger-3 success: 	1
2121
DROP TRIGGER trg_1;
2122
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2123
f_int2 = CAST(f_char1 AS SIGNED INT),
2124
f_charbig = 'just inserted'
2125
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2126
DELETE FROM t0_aux
2127
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2128
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2129
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2130
'just inserted' FROM t0_template
2131
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2132
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
2133
BEGIN
2134
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2135
f_charbig = 'updated by trigger'
2136
      WHERE f_int1 = - old.f_int1;
2137
END|
2138
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
2139
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
2140
	
2141
# check trigger-4 success: 	1
2142
DROP TRIGGER trg_1;
2143
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2144
f_int2 = CAST(f_char1 AS SIGNED INT),
2145
f_charbig = 'just inserted'
2146
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2147
DELETE FROM t0_aux
2148
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2149
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2150
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2151
'just inserted' FROM t0_template
2152
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2153
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
2154
BEGIN
2155
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2156
f_charbig = 'updated by trigger'
2157
      WHERE f_int1 = new.f_int1;
2158
END|
2159
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
2160
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
2161
	
2162
# check trigger-5 success: 	1
2163
DROP TRIGGER trg_1;
2164
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2165
f_int2 = CAST(f_char1 AS SIGNED INT),
2166
f_charbig = 'just inserted'
2167
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2168
DELETE FROM t0_aux
2169
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2170
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2171
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2172
'just inserted' FROM t0_template
2173
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2174
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
2175
BEGIN
2176
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2177
f_charbig = 'updated by trigger'
2178
      WHERE f_int1 = - old.f_int1;
2179
END|
2180
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
2181
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
2182
	
2183
# check trigger-6 success: 	1
2184
DROP TRIGGER trg_1;
2185
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2186
f_int2 = CAST(f_char1 AS SIGNED INT),
2187
f_charbig = 'just inserted'
2188
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2189
DELETE FROM t0_aux
2190
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2191
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2192
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2193
'just inserted' FROM t0_template
2194
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2195
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
2196
BEGIN
2197
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2198
f_charbig = 'updated by trigger'
2199
      WHERE f_int1 = - old.f_int1;
2200
END|
2201
DELETE FROM t0_aux
2202
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
2203
	
2204
# check trigger-7 success: 	1
2205
DROP TRIGGER trg_1;
2206
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2207
f_int2 = CAST(f_char1 AS SIGNED INT),
2208
f_charbig = 'just inserted'
2209
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2210
DELETE FROM t0_aux
2211
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2212
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2213
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2214
'just inserted' FROM t0_template
2215
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2216
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
2217
BEGIN
2218
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2219
f_charbig = 'updated by trigger'
2220
      WHERE f_int1 = - old.f_int1;
2221
END|
2222
DELETE FROM t0_aux
2223
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
2224
	
2225
# check trigger-8 success: 	1
2226
DROP TRIGGER trg_1;
2227
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2228
f_int2 = CAST(f_char1 AS SIGNED INT),
2229
f_charbig = 'just inserted'
2230
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2231
DELETE FROM t0_aux
2232
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2233
DELETE FROM t1
2234
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2235
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
2236
BEGIN
2237
SET new.f_int1 = old.f_int1 + @max_row,
2238
new.f_int2 = old.f_int2 - @max_row,
2239
new.f_charbig = '####updated per update trigger####';
2240
END|
2241
UPDATE t1
2242
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
2243
f_charbig = '####updated per update statement itself####';
2244
	
2245
# check trigger-9 success: 	1
2246
DROP TRIGGER trg_2;
2247
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2248
f_int2 = CAST(f_char1 AS SIGNED INT),
2249
f_charbig = CONCAT('===',f_char1,'===');
2250
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
2251
BEGIN
2252
SET new.f_int1 = new.f_int1 + @max_row,
2253
new.f_int2 = new.f_int2 - @max_row,
2254
new.f_charbig = '####updated per update trigger####';
2255
END|
2256
UPDATE t1
2257
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
2258
f_charbig = '####updated per update statement itself####';
2259
	
2260
# check trigger-10 success: 	1
2261
DROP TRIGGER trg_2;
2262
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2263
f_int2 = CAST(f_char1 AS SIGNED INT),
2264
f_charbig = CONCAT('===',f_char1,'===');
2265
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
2266
BEGIN
2267
SET new.f_int1 = @my_max1 + @counter,
2268
new.f_int2 = @my_min2 - @counter,
2269
new.f_charbig = '####updated per insert trigger####';
2270
SET @counter = @counter + 1;
2271
END|
2272
SET @counter = 1;
2273
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
2274
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
2275
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
2276
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
2277
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
2278
ORDER BY f_int1;
2279
DROP TRIGGER trg_3;
2280
	
2281
# check trigger-11 success: 	1
2282
DELETE FROM t1
2283
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
2284
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
2285
AND f_charbig = '####updated per insert trigger####';
2286
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
2287
BEGIN
2288
SET new.f_int1 = @my_max1 + @counter,
2289
new.f_int2 = @my_min2 - @counter,
2290
new.f_charbig = '####updated per insert trigger####';
2291
SET @counter = @counter + 1;
2292
END|
2293
SET @counter = 1;
2294
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
2295
INSERT INTO t1 (f_char1, f_char2, f_charbig)
2296
SELECT CAST(f_int1 AS CHAR),
2297
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
2298
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
2299
ORDER BY f_int1;
2300
DROP TRIGGER trg_3;
2301
	
2302
# check trigger-12 success: 	1
2303
DELETE FROM t1
2304
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
2305
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
2306
AND f_charbig = '####updated per insert trigger####';
2307
ANALYZE  TABLE t1;
2308
Table	Op	Msg_type	Msg_text
2309
test.t1	analyze	note	The storage engine for the table doesn't support analyze
2310
CHECK    TABLE t1 EXTENDED;
2311
Table	Op	Msg_type	Msg_text
2312
test.t1	check	note	The storage engine for the table doesn't support check
2313
CHECKSUM TABLE t1 EXTENDED;
2314
Table	Checksum
2315
test.t1	<some_value>
2316
OPTIMIZE TABLE t1;
2317
Table	Op	Msg_type	Msg_text
2318
test.t1	optimize	note	The storage engine for the table doesn't support optimize
2319
# check layout success:    1
2320
REPAIR   TABLE t1 EXTENDED;
2321
Table	Op	Msg_type	Msg_text
2322
test.t1	repair	note	The storage engine for the table doesn't support repair
2323
# check layout success:    1
2324
TRUNCATE t1;
2325
	
2326
# check TRUNCATE success: 	1
2327
# check layout success:    1
2328
# End usability test (inc/partition_check.inc)
2329
DROP TABLE t1;
2330
CREATE TABLE t1 (
2331
f_int1 INTEGER,
2332
f_int2 INTEGER,
2333
f_char1 CHAR(20),
2334
f_char2 CHAR(20),
2335
f_charbig VARCHAR(1000)
2336
2337
)
2338
PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1)
2339
(PARTITION part1 VALUES LESS THAN (0)
2340
(SUBPARTITION subpart11, SUBPARTITION subpart12),
2341
PARTITION part2 VALUES LESS THAN (5)
2342
(SUBPARTITION subpart21, SUBPARTITION subpart22),
2343
PARTITION part3 VALUES LESS THAN (10)
2344
(SUBPARTITION subpart31, SUBPARTITION subpart32),
2345
PARTITION part4 VALUES LESS THAN (2147483646)
2346
(SUBPARTITION subpart41, SUBPARTITION subpart42));
2347
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
2348
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
2349
# Start usability test (inc/partition_check.inc)
2350
create_command
2351
SHOW CREATE TABLE t1;
2352
Table	Create Table
2353
t1	CREATE TABLE `t1` (
2354
  `f_int1` int(11) DEFAULT NULL,
2355
  `f_int2` int(11) DEFAULT NULL,
2356
  `f_char1` char(20) DEFAULT NULL,
2357
  `f_char2` char(20) DEFAULT NULL,
2358
  `f_charbig` varchar(1000) DEFAULT NULL
2359
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), PARTITION part2 VALUES LESS THAN (5) (SUBPARTITION subpart21 ENGINE = InnoDB, SUBPARTITION subpart22 ENGINE = InnoDB), PARTITION part3 VALUES LESS THAN (10) (SUBPARTITION subpart31 ENGINE = InnoDB, SUBPARTITION subpart32 ENGINE = InnoDB), PARTITION part4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41 ENGINE = InnoDB, SUBPARTITION subpart42 ENGINE = InnoDB)) */
2360
2361
unified filelist
2362
$MYSQLTEST_VARDIR/master-data/test/t1.frm
2363
$MYSQLTEST_VARDIR/master-data/test/t1.par
2364
2365
# check prerequisites-1 success:    1
2366
# check COUNT(*) success:    1
2367
# check MIN/MAX(f_int1) success:    1
2368
# check MIN/MAX(f_int2) success:    1
2369
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
2370
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
2371
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
2372
WHERE f_int1 IN (2,3);
2373
# check prerequisites-3 success:    1
2374
DELETE FROM t1 WHERE f_charbig = 'delete me';
2375
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
2376
# check read via f_int1 success: 1
2377
# check read via f_int2 success: 1
2378
	
2379
# check multiple-1 success: 	1
2380
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
2381
	
2382
# check multiple-2 success: 	1
2383
INSERT INTO t1 SELECT * FROM t0_template
2384
WHERE MOD(f_int1,3) = 0;
2385
	
2386
# check multiple-3 success: 	1
2387
UPDATE t1 SET f_int1 = f_int1 + @max_row
2388
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
2389
AND @max_row_div2 + @max_row_div4;
2390
	
2391
# check multiple-4 success: 	1
2392
DELETE FROM t1
2393
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
2394
AND @max_row_div2 + @max_row_div4 + @max_row;
2395
	
2396
# check multiple-5 success: 	1
2397
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
2398
INSERT INTO t1
2399
SET f_int1 = @cur_value , f_int2 = @cur_value,
2400
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
2401
f_charbig = '#SINGLE#';
2402
	
2403
# check single-1 success: 	1
2404
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
2405
INSERT INTO t1
2406
SET f_int1 = @cur_value , f_int2 = @cur_value,
2407
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
2408
f_charbig = '#SINGLE#';
2409
	
2410
# check single-2 success: 	1
2411
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
2412
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
2413
UPDATE t1 SET f_int1 = @cur_value2
2414
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
2415
	
2416
# check single-3 success: 	1
2417
SET @cur_value1= -1;
2418
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
2419
UPDATE t1 SET f_int1 = @cur_value1
2420
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
2421
	
2422
# check single-4 success: 	1
2423
SELECT MAX(f_int1) INTO @cur_value FROM t1;
2424
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
2425
	
2426
# check single-5 success: 	1
2427
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
2428
	
2429
# check single-6 success: 	1
2430
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
2431
ERROR HY000: Table has no partition for value 2147483647
2432
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
2433
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
2434
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
2435
f_charbig = '#NULL#';
2436
INSERT INTO t1
2437
SET f_int1 = NULL , f_int2 = -@max_row,
2438
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
2439
f_charbig = '#NULL#';
2440
# check null success:    1
2441
	
2442
# check null-1 success: 	1
2443
UPDATE t1 SET f_int1 = -@max_row
2444
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
2445
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
2446
	
2447
# check null-2 success: 	1
2448
UPDATE t1 SET f_int1 = NULL
2449
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
2450
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
2451
	
2452
# check null-3 success: 	1
2453
DELETE FROM t1
2454
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
2455
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
2456
	
2457
# check null-4 success: 	1
2458
DELETE FROM t1
2459
WHERE f_int1 = 0 AND f_int2 = 0
2460
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
2461
AND f_charbig = '#NULL#';
2462
SET AUTOCOMMIT= 0;
2463
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
2464
SELECT f_int1, f_int1, '', '', 'was inserted'
2465
FROM t0_template source_tab
2466
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
2467
	
2468
# check transactions-1 success: 	1
2469
COMMIT WORK;
2470
	
2471
# check transactions-2 success: 	1
2472
ROLLBACK WORK;
2473
	
2474
# check transactions-3 success: 	1
2475
DELETE FROM t1 WHERE f_charbig = 'was inserted';
2476
COMMIT WORK;
2477
ROLLBACK WORK;
2478
	
2479
# check transactions-4 success: 	1
2480
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
2481
SELECT f_int1, f_int1, '', '', 'was inserted'
2482
FROM t0_template source_tab
2483
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
2484
	
2485
# check transactions-5 success: 	1
2486
ROLLBACK WORK;
2487
	
2488
# check transactions-6 success: 	1
2489
# INFO: Storage engine used for t1 seems to be transactional.
2490
COMMIT;
2491
	
2492
# check transactions-7 success: 	1
2493
DELETE FROM t1 WHERE f_charbig = 'was inserted';
2494
COMMIT WORK;
2495
SET @@session.sql_mode = 'traditional';
2496
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
2497
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
2498
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
2499
'', '', 'was inserted' FROM t0_template
2500
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
2501
ERROR 22012: Division by 0
2502
COMMIT;
2503
	
2504
# check transactions-8 success: 	1
2505
# INFO: Storage engine used for t1 seems to be able to revert
2506
#       changes made by the failing statement.
2507
SET @@session.sql_mode = '';
2508
SET AUTOCOMMIT= 1;
2509
DELETE FROM t1 WHERE f_charbig = 'was inserted';
2510
COMMIT WORK;
2511
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
2512
	
2513
# check special-1 success: 	1
2514
UPDATE t1 SET f_charbig = '';
2515
	
2516
# check special-2 success: 	1
2517
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
2518
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
2519
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
2520
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2521
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2522
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2523
'just inserted' FROM t0_template
2524
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2525
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
2526
BEGIN
2527
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2528
f_charbig = 'updated by trigger'
2529
      WHERE f_int1 = new.f_int1;
2530
END|
2531
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2532
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
2533
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2534
	
2535
# check trigger-1 success: 	1
2536
DROP TRIGGER trg_1;
2537
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2538
f_int2 = CAST(f_char1 AS SIGNED INT),
2539
f_charbig = 'just inserted'
2540
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2541
DELETE FROM t0_aux
2542
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2543
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2544
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2545
'just inserted' FROM t0_template
2546
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2547
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
2548
BEGIN
2549
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2550
f_charbig = 'updated by trigger'
2551
      WHERE f_int1 = new.f_int1;
2552
END|
2553
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2554
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
2555
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2556
	
2557
# check trigger-2 success: 	1
2558
DROP TRIGGER trg_1;
2559
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2560
f_int2 = CAST(f_char1 AS SIGNED INT),
2561
f_charbig = 'just inserted'
2562
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2563
DELETE FROM t0_aux
2564
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2565
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2566
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2567
'just inserted' FROM t0_template
2568
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2569
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
2570
BEGIN
2571
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2572
f_charbig = 'updated by trigger'
2573
      WHERE f_int1 = new.f_int1;
2574
END|
2575
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
2576
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
2577
	
2578
# check trigger-3 success: 	1
2579
DROP TRIGGER trg_1;
2580
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2581
f_int2 = CAST(f_char1 AS SIGNED INT),
2582
f_charbig = 'just inserted'
2583
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2584
DELETE FROM t0_aux
2585
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2586
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2587
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2588
'just inserted' FROM t0_template
2589
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2590
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
2591
BEGIN
2592
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2593
f_charbig = 'updated by trigger'
2594
      WHERE f_int1 = - old.f_int1;
2595
END|
2596
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
2597
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
2598
	
2599
# check trigger-4 success: 	1
2600
DROP TRIGGER trg_1;
2601
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2602
f_int2 = CAST(f_char1 AS SIGNED INT),
2603
f_charbig = 'just inserted'
2604
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2605
DELETE FROM t0_aux
2606
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2607
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2608
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2609
'just inserted' FROM t0_template
2610
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2611
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
2612
BEGIN
2613
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2614
f_charbig = 'updated by trigger'
2615
      WHERE f_int1 = new.f_int1;
2616
END|
2617
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
2618
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
2619
	
2620
# check trigger-5 success: 	1
2621
DROP TRIGGER trg_1;
2622
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2623
f_int2 = CAST(f_char1 AS SIGNED INT),
2624
f_charbig = 'just inserted'
2625
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2626
DELETE FROM t0_aux
2627
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2628
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2629
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2630
'just inserted' FROM t0_template
2631
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2632
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
2633
BEGIN
2634
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2635
f_charbig = 'updated by trigger'
2636
      WHERE f_int1 = - old.f_int1;
2637
END|
2638
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
2639
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
2640
	
2641
# check trigger-6 success: 	1
2642
DROP TRIGGER trg_1;
2643
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2644
f_int2 = CAST(f_char1 AS SIGNED INT),
2645
f_charbig = 'just inserted'
2646
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2647
DELETE FROM t0_aux
2648
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2649
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2650
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2651
'just inserted' FROM t0_template
2652
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2653
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
2654
BEGIN
2655
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2656
f_charbig = 'updated by trigger'
2657
      WHERE f_int1 = - old.f_int1;
2658
END|
2659
DELETE FROM t0_aux
2660
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
2661
	
2662
# check trigger-7 success: 	1
2663
DROP TRIGGER trg_1;
2664
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2665
f_int2 = CAST(f_char1 AS SIGNED INT),
2666
f_charbig = 'just inserted'
2667
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2668
DELETE FROM t0_aux
2669
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2670
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2671
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2672
'just inserted' FROM t0_template
2673
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2674
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
2675
BEGIN
2676
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2677
f_charbig = 'updated by trigger'
2678
      WHERE f_int1 = - old.f_int1;
2679
END|
2680
DELETE FROM t0_aux
2681
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
2682
	
2683
# check trigger-8 success: 	1
2684
DROP TRIGGER trg_1;
2685
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2686
f_int2 = CAST(f_char1 AS SIGNED INT),
2687
f_charbig = 'just inserted'
2688
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
2689
DELETE FROM t0_aux
2690
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2691
DELETE FROM t1
2692
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2693
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
2694
BEGIN
2695
SET new.f_int1 = old.f_int1 + @max_row,
2696
new.f_int2 = old.f_int2 - @max_row,
2697
new.f_charbig = '####updated per update trigger####';
2698
END|
2699
UPDATE t1
2700
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
2701
f_charbig = '####updated per update statement itself####';
2702
	
2703
# check trigger-9 success: 	1
2704
DROP TRIGGER trg_2;
2705
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2706
f_int2 = CAST(f_char1 AS SIGNED INT),
2707
f_charbig = CONCAT('===',f_char1,'===');
2708
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
2709
BEGIN
2710
SET new.f_int1 = new.f_int1 + @max_row,
2711
new.f_int2 = new.f_int2 - @max_row,
2712
new.f_charbig = '####updated per update trigger####';
2713
END|
2714
UPDATE t1
2715
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
2716
f_charbig = '####updated per update statement itself####';
2717
	
2718
# check trigger-10 success: 	1
2719
DROP TRIGGER trg_2;
2720
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
2721
f_int2 = CAST(f_char1 AS SIGNED INT),
2722
f_charbig = CONCAT('===',f_char1,'===');
2723
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
2724
BEGIN
2725
SET new.f_int1 = @my_max1 + @counter,
2726
new.f_int2 = @my_min2 - @counter,
2727
new.f_charbig = '####updated per insert trigger####';
2728
SET @counter = @counter + 1;
2729
END|
2730
SET @counter = 1;
2731
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
2732
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
2733
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
2734
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
2735
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
2736
ORDER BY f_int1;
2737
DROP TRIGGER trg_3;
2738
	
2739
# check trigger-11 success: 	1
2740
DELETE FROM t1
2741
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
2742
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
2743
AND f_charbig = '####updated per insert trigger####';
2744
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
2745
BEGIN
2746
SET new.f_int1 = @my_max1 + @counter,
2747
new.f_int2 = @my_min2 - @counter,
2748
new.f_charbig = '####updated per insert trigger####';
2749
SET @counter = @counter + 1;
2750
END|
2751
SET @counter = 1;
2752
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
2753
INSERT INTO t1 (f_char1, f_char2, f_charbig)
2754
SELECT CAST(f_int1 AS CHAR),
2755
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
2756
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
2757
ORDER BY f_int1;
2758
DROP TRIGGER trg_3;
2759
	
2760
# check trigger-12 success: 	1
2761
DELETE FROM t1
2762
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
2763
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
2764
AND f_charbig = '####updated per insert trigger####';
2765
ANALYZE  TABLE t1;
2766
Table	Op	Msg_type	Msg_text
2767
test.t1	analyze	note	The storage engine for the table doesn't support analyze
2768
CHECK    TABLE t1 EXTENDED;
2769
Table	Op	Msg_type	Msg_text
2770
test.t1	check	note	The storage engine for the table doesn't support check
2771
CHECKSUM TABLE t1 EXTENDED;
2772
Table	Checksum
2773
test.t1	<some_value>
2774
OPTIMIZE TABLE t1;
2775
Table	Op	Msg_type	Msg_text
2776
test.t1	optimize	note	The storage engine for the table doesn't support optimize
2777
# check layout success:    1
2778
REPAIR   TABLE t1 EXTENDED;
2779
Table	Op	Msg_type	Msg_text
2780
test.t1	repair	note	The storage engine for the table doesn't support repair
2781
# check layout success:    1
2782
TRUNCATE t1;
2783
	
2784
# check TRUNCATE success: 	1
2785
# check layout success:    1
2786
# End usability test (inc/partition_check.inc)
2787
DROP TABLE t1;
2788
CREATE TABLE t1 (
2789
f_int1 INTEGER,
2790
f_int2 INTEGER,
2791
f_char1 CHAR(20),
2792
f_char2 CHAR(20),
2793
f_charbig VARCHAR(1000)
2794
2795
)
2796
PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1)
2797
(PARTITION part1 VALUES IN (0)
2798
(SUBPARTITION sp11,
2799
SUBPARTITION sp12),
2800
PARTITION part2 VALUES IN (1)
2801
(SUBPARTITION sp21,
2802
SUBPARTITION sp22),
2803
PARTITION part3 VALUES IN (2)
2804
(SUBPARTITION sp31, 
2805
SUBPARTITION sp32),
2806
PARTITION part4 VALUES IN (NULL)
2807
(SUBPARTITION sp41,
2808
SUBPARTITION sp42));
2809
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
2810
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
2811
# Start usability test (inc/partition_check.inc)
2812
create_command
2813
SHOW CREATE TABLE t1;
2814
Table	Create Table
2815
t1	CREATE TABLE `t1` (
2816
  `f_int1` int(11) DEFAULT NULL,
2817
  `f_int2` int(11) DEFAULT NULL,
2818
  `f_char1` char(20) DEFAULT NULL,
2819
  `f_char2` char(20) DEFAULT NULL,
2820
  `f_charbig` varchar(1000) DEFAULT NULL
2821
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,3))) SUBPARTITION BY HASH (f_int1 + 1) (PARTITION part1 VALUES IN (0) (SUBPARTITION sp11 ENGINE = InnoDB, SUBPARTITION sp12 ENGINE = InnoDB), PARTITION part2 VALUES IN (1) (SUBPARTITION sp21 ENGINE = InnoDB, SUBPARTITION sp22 ENGINE = InnoDB), PARTITION part3 VALUES IN (2) (SUBPARTITION sp31 ENGINE = InnoDB, SUBPARTITION sp32 ENGINE = InnoDB), PARTITION part4 VALUES IN (NULL) (SUBPARTITION sp41 ENGINE = InnoDB, SUBPARTITION sp42 ENGINE = InnoDB)) */
2822
2823
unified filelist
2824
$MYSQLTEST_VARDIR/master-data/test/t1.frm
2825
$MYSQLTEST_VARDIR/master-data/test/t1.par
2826
2827
# check prerequisites-1 success:    1
2828
# check COUNT(*) success:    1
2829
# check MIN/MAX(f_int1) success:    1
2830
# check MIN/MAX(f_int2) success:    1
2831
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
2832
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
2833
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
2834
WHERE f_int1 IN (2,3);
2835
# check prerequisites-3 success:    1
2836
DELETE FROM t1 WHERE f_charbig = 'delete me';
2837
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
2838
# check read via f_int1 success: 1
2839
# check read via f_int2 success: 1
2840
	
2841
# check multiple-1 success: 	1
2842
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
2843
	
2844
# check multiple-2 success: 	1
2845
INSERT INTO t1 SELECT * FROM t0_template
2846
WHERE MOD(f_int1,3) = 0;
2847
	
2848
# check multiple-3 success: 	1
2849
UPDATE t1 SET f_int1 = f_int1 + @max_row
2850
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
2851
AND @max_row_div2 + @max_row_div4;
2852
	
2853
# check multiple-4 success: 	1
2854
DELETE FROM t1
2855
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
2856
AND @max_row_div2 + @max_row_div4 + @max_row;
2857
	
2858
# check multiple-5 success: 	1
2859
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
2860
INSERT INTO t1
2861
SET f_int1 = @cur_value , f_int2 = @cur_value,
2862
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
2863
f_charbig = '#SINGLE#';
2864
	
2865
# check single-1 success: 	1
2866
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
2867
INSERT INTO t1
2868
SET f_int1 = @cur_value , f_int2 = @cur_value,
2869
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
2870
f_charbig = '#SINGLE#';
2871
	
2872
# check single-2 success: 	1
2873
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
2874
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
2875
UPDATE t1 SET f_int1 = @cur_value2
2876
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
2877
	
2878
# check single-3 success: 	1
2879
SET @cur_value1= -1;
2880
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
2881
UPDATE t1 SET f_int1 = @cur_value1
2882
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
2883
	
2884
# check single-4 success: 	1
2885
SELECT MAX(f_int1) INTO @cur_value FROM t1;
2886
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
2887
	
2888
# check single-5 success: 	1
2889
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
2890
	
2891
# check single-6 success: 	1
2892
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
2893
	
2894
# check single-7 success: 	1
2895
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
2896
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
2897
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
2898
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
2899
f_charbig = '#NULL#';
2900
INSERT INTO t1
2901
SET f_int1 = NULL , f_int2 = -@max_row,
2902
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
2903
f_charbig = '#NULL#';
2904
# check null success:    1
2905
	
2906
# check null-1 success: 	1
2907
UPDATE t1 SET f_int1 = -@max_row
2908
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
2909
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
2910
	
2911
# check null-2 success: 	1
2912
UPDATE t1 SET f_int1 = NULL
2913
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
2914
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
2915
	
2916
# check null-3 success: 	1
2917
DELETE FROM t1
2918
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
2919
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
2920
	
2921
# check null-4 success: 	1
2922
DELETE FROM t1
2923
WHERE f_int1 = 0 AND f_int2 = 0
2924
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
2925
AND f_charbig = '#NULL#';
2926
SET AUTOCOMMIT= 0;
2927
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
2928
SELECT f_int1, f_int1, '', '', 'was inserted'
2929
FROM t0_template source_tab
2930
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
2931
	
2932
# check transactions-1 success: 	1
2933
COMMIT WORK;
2934
	
2935
# check transactions-2 success: 	1
2936
ROLLBACK WORK;
2937
	
2938
# check transactions-3 success: 	1
2939
DELETE FROM t1 WHERE f_charbig = 'was inserted';
2940
COMMIT WORK;
2941
ROLLBACK WORK;
2942
	
2943
# check transactions-4 success: 	1
2944
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
2945
SELECT f_int1, f_int1, '', '', 'was inserted'
2946
FROM t0_template source_tab
2947
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
2948
	
2949
# check transactions-5 success: 	1
2950
ROLLBACK WORK;
2951
	
2952
# check transactions-6 success: 	1
2953
# INFO: Storage engine used for t1 seems to be transactional.
2954
COMMIT;
2955
	
2956
# check transactions-7 success: 	1
2957
DELETE FROM t1 WHERE f_charbig = 'was inserted';
2958
COMMIT WORK;
2959
SET @@session.sql_mode = 'traditional';
2960
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
2961
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
2962
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
2963
'', '', 'was inserted' FROM t0_template
2964
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
2965
ERROR 22012: Division by 0
2966
COMMIT;
2967
	
2968
# check transactions-8 success: 	1
2969
# INFO: Storage engine used for t1 seems to be able to revert
2970
#       changes made by the failing statement.
2971
SET @@session.sql_mode = '';
2972
SET AUTOCOMMIT= 1;
2973
DELETE FROM t1 WHERE f_charbig = 'was inserted';
2974
COMMIT WORK;
2975
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
2976
	
2977
# check special-1 success: 	1
2978
UPDATE t1 SET f_charbig = '';
2979
	
2980
# check special-2 success: 	1
2981
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
2982
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
2983
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
2984
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2985
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2986
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
2987
'just inserted' FROM t0_template
2988
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2989
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
2990
BEGIN
2991
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
2992
f_charbig = 'updated by trigger'
2993
      WHERE f_int1 = new.f_int1;
2994
END|
2995
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
2996
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
2997
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
2998
	
2999
# check trigger-1 success: 	1
3000
DROP TRIGGER trg_1;
3001
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3002
f_int2 = CAST(f_char1 AS SIGNED INT),
3003
f_charbig = 'just inserted'
3004
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3005
DELETE FROM t0_aux
3006
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3007
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3008
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3009
'just inserted' FROM t0_template
3010
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3011
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
3012
BEGIN
3013
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3014
f_charbig = 'updated by trigger'
3015
      WHERE f_int1 = new.f_int1;
3016
END|
3017
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3018
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
3019
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3020
	
3021
# check trigger-2 success: 	1
3022
DROP TRIGGER trg_1;
3023
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3024
f_int2 = CAST(f_char1 AS SIGNED INT),
3025
f_charbig = 'just inserted'
3026
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3027
DELETE FROM t0_aux
3028
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3029
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3030
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3031
'just inserted' FROM t0_template
3032
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3033
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
3034
BEGIN
3035
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3036
f_charbig = 'updated by trigger'
3037
      WHERE f_int1 = new.f_int1;
3038
END|
3039
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
3040
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
3041
	
3042
# check trigger-3 success: 	1
3043
DROP TRIGGER trg_1;
3044
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3045
f_int2 = CAST(f_char1 AS SIGNED INT),
3046
f_charbig = 'just inserted'
3047
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3048
DELETE FROM t0_aux
3049
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3050
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3051
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3052
'just inserted' FROM t0_template
3053
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3054
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
3055
BEGIN
3056
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3057
f_charbig = 'updated by trigger'
3058
      WHERE f_int1 = - old.f_int1;
3059
END|
3060
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
3061
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
3062
	
3063
# check trigger-4 success: 	1
3064
DROP TRIGGER trg_1;
3065
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3066
f_int2 = CAST(f_char1 AS SIGNED INT),
3067
f_charbig = 'just inserted'
3068
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3069
DELETE FROM t0_aux
3070
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3071
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3072
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3073
'just inserted' FROM t0_template
3074
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3075
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
3076
BEGIN
3077
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3078
f_charbig = 'updated by trigger'
3079
      WHERE f_int1 = new.f_int1;
3080
END|
3081
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
3082
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
3083
	
3084
# check trigger-5 success: 	1
3085
DROP TRIGGER trg_1;
3086
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3087
f_int2 = CAST(f_char1 AS SIGNED INT),
3088
f_charbig = 'just inserted'
3089
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3090
DELETE FROM t0_aux
3091
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3092
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3093
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3094
'just inserted' FROM t0_template
3095
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3096
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
3097
BEGIN
3098
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3099
f_charbig = 'updated by trigger'
3100
      WHERE f_int1 = - old.f_int1;
3101
END|
3102
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
3103
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
3104
	
3105
# check trigger-6 success: 	1
3106
DROP TRIGGER trg_1;
3107
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3108
f_int2 = CAST(f_char1 AS SIGNED INT),
3109
f_charbig = 'just inserted'
3110
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3111
DELETE FROM t0_aux
3112
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3113
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3114
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3115
'just inserted' FROM t0_template
3116
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3117
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
3118
BEGIN
3119
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3120
f_charbig = 'updated by trigger'
3121
      WHERE f_int1 = - old.f_int1;
3122
END|
3123
DELETE FROM t0_aux
3124
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
3125
	
3126
# check trigger-7 success: 	1
3127
DROP TRIGGER trg_1;
3128
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3129
f_int2 = CAST(f_char1 AS SIGNED INT),
3130
f_charbig = 'just inserted'
3131
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3132
DELETE FROM t0_aux
3133
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3134
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3135
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3136
'just inserted' FROM t0_template
3137
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3138
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
3139
BEGIN
3140
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3141
f_charbig = 'updated by trigger'
3142
      WHERE f_int1 = - old.f_int1;
3143
END|
3144
DELETE FROM t0_aux
3145
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
3146
	
3147
# check trigger-8 success: 	1
3148
DROP TRIGGER trg_1;
3149
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3150
f_int2 = CAST(f_char1 AS SIGNED INT),
3151
f_charbig = 'just inserted'
3152
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3153
DELETE FROM t0_aux
3154
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3155
DELETE FROM t1
3156
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3157
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
3158
BEGIN
3159
SET new.f_int1 = old.f_int1 + @max_row,
3160
new.f_int2 = old.f_int2 - @max_row,
3161
new.f_charbig = '####updated per update trigger####';
3162
END|
3163
UPDATE t1
3164
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
3165
f_charbig = '####updated per update statement itself####';
3166
	
3167
# check trigger-9 success: 	1
3168
DROP TRIGGER trg_2;
3169
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3170
f_int2 = CAST(f_char1 AS SIGNED INT),
3171
f_charbig = CONCAT('===',f_char1,'===');
3172
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
3173
BEGIN
3174
SET new.f_int1 = new.f_int1 + @max_row,
3175
new.f_int2 = new.f_int2 - @max_row,
3176
new.f_charbig = '####updated per update trigger####';
3177
END|
3178
UPDATE t1
3179
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
3180
f_charbig = '####updated per update statement itself####';
3181
	
3182
# check trigger-10 success: 	1
3183
DROP TRIGGER trg_2;
3184
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3185
f_int2 = CAST(f_char1 AS SIGNED INT),
3186
f_charbig = CONCAT('===',f_char1,'===');
3187
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
3188
BEGIN
3189
SET new.f_int1 = @my_max1 + @counter,
3190
new.f_int2 = @my_min2 - @counter,
3191
new.f_charbig = '####updated per insert trigger####';
3192
SET @counter = @counter + 1;
3193
END|
3194
SET @counter = 1;
3195
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
3196
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
3197
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
3198
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
3199
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
3200
ORDER BY f_int1;
3201
DROP TRIGGER trg_3;
3202
	
3203
# check trigger-11 success: 	1
3204
DELETE FROM t1
3205
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
3206
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
3207
AND f_charbig = '####updated per insert trigger####';
3208
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
3209
BEGIN
3210
SET new.f_int1 = @my_max1 + @counter,
3211
new.f_int2 = @my_min2 - @counter,
3212
new.f_charbig = '####updated per insert trigger####';
3213
SET @counter = @counter + 1;
3214
END|
3215
SET @counter = 1;
3216
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
3217
INSERT INTO t1 (f_char1, f_char2, f_charbig)
3218
SELECT CAST(f_int1 AS CHAR),
3219
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
3220
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
3221
ORDER BY f_int1;
3222
DROP TRIGGER trg_3;
3223
	
3224
# check trigger-12 success: 	1
3225
DELETE FROM t1
3226
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
3227
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
3228
AND f_charbig = '####updated per insert trigger####';
3229
ANALYZE  TABLE t1;
3230
Table	Op	Msg_type	Msg_text
3231
test.t1	analyze	note	The storage engine for the table doesn't support analyze
3232
CHECK    TABLE t1 EXTENDED;
3233
Table	Op	Msg_type	Msg_text
3234
test.t1	check	note	The storage engine for the table doesn't support check
3235
CHECKSUM TABLE t1 EXTENDED;
3236
Table	Checksum
3237
test.t1	<some_value>
3238
OPTIMIZE TABLE t1;
3239
Table	Op	Msg_type	Msg_text
3240
test.t1	optimize	note	The storage engine for the table doesn't support optimize
3241
# check layout success:    1
3242
REPAIR   TABLE t1 EXTENDED;
3243
Table	Op	Msg_type	Msg_text
3244
test.t1	repair	note	The storage engine for the table doesn't support repair
3245
# check layout success:    1
3246
TRUNCATE t1;
3247
	
3248
# check TRUNCATE success: 	1
3249
# check layout success:    1
3250
# End usability test (inc/partition_check.inc)
3251
DROP TABLE t1;
3252
CREATE TABLE t1 (
3253
f_int1 INTEGER,
3254
f_int2 INTEGER,
3255
f_char1 CHAR(20),
3256
f_char2 CHAR(20),
3257
f_charbig VARCHAR(1000)
3258
3259
)
3260
PARTITION BY LIST(ABS(MOD(f_int1,2)))
3261
SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3
3262
(PARTITION part1 VALUES IN (0),
3263
PARTITION part2 VALUES IN (1),
3264
PARTITION part3 VALUES IN (NULL));
3265
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
3266
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
3267
# Start usability test (inc/partition_check.inc)
3268
create_command
3269
SHOW CREATE TABLE t1;
3270
Table	Create Table
3271
t1	CREATE TABLE `t1` (
3272
  `f_int1` int(11) DEFAULT NULL,
3273
  `f_int2` int(11) DEFAULT NULL,
3274
  `f_char1` char(20) DEFAULT NULL,
3275
  `f_char2` char(20) DEFAULT NULL,
3276
  `f_charbig` varchar(1000) DEFAULT NULL
3277
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
3278
3279
unified filelist
3280
$MYSQLTEST_VARDIR/master-data/test/t1.frm
3281
$MYSQLTEST_VARDIR/master-data/test/t1.par
3282
3283
# check prerequisites-1 success:    1
3284
# check COUNT(*) success:    1
3285
# check MIN/MAX(f_int1) success:    1
3286
# check MIN/MAX(f_int2) success:    1
3287
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
3288
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
3289
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
3290
WHERE f_int1 IN (2,3);
3291
# check prerequisites-3 success:    1
3292
DELETE FROM t1 WHERE f_charbig = 'delete me';
3293
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
3294
# check read via f_int1 success: 1
3295
# check read via f_int2 success: 1
3296
	
3297
# check multiple-1 success: 	1
3298
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
3299
	
3300
# check multiple-2 success: 	1
3301
INSERT INTO t1 SELECT * FROM t0_template
3302
WHERE MOD(f_int1,3) = 0;
3303
	
3304
# check multiple-3 success: 	1
3305
UPDATE t1 SET f_int1 = f_int1 + @max_row
3306
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
3307
AND @max_row_div2 + @max_row_div4;
3308
	
3309
# check multiple-4 success: 	1
3310
DELETE FROM t1
3311
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
3312
AND @max_row_div2 + @max_row_div4 + @max_row;
3313
	
3314
# check multiple-5 success: 	1
3315
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
3316
INSERT INTO t1
3317
SET f_int1 = @cur_value , f_int2 = @cur_value,
3318
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
3319
f_charbig = '#SINGLE#';
3320
	
3321
# check single-1 success: 	1
3322
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
3323
INSERT INTO t1
3324
SET f_int1 = @cur_value , f_int2 = @cur_value,
3325
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
3326
f_charbig = '#SINGLE#';
3327
	
3328
# check single-2 success: 	1
3329
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
3330
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
3331
UPDATE t1 SET f_int1 = @cur_value2
3332
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
3333
	
3334
# check single-3 success: 	1
3335
SET @cur_value1= -1;
3336
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
3337
UPDATE t1 SET f_int1 = @cur_value1
3338
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
3339
	
3340
# check single-4 success: 	1
3341
SELECT MAX(f_int1) INTO @cur_value FROM t1;
3342
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
3343
	
3344
# check single-5 success: 	1
3345
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
3346
	
3347
# check single-6 success: 	1
3348
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
3349
	
3350
# check single-7 success: 	1
3351
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
3352
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
3353
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
3354
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
3355
f_charbig = '#NULL#';
3356
INSERT INTO t1
3357
SET f_int1 = NULL , f_int2 = -@max_row,
3358
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
3359
f_charbig = '#NULL#';
3360
# check null success:    1
3361
	
3362
# check null-1 success: 	1
3363
UPDATE t1 SET f_int1 = -@max_row
3364
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
3365
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
3366
	
3367
# check null-2 success: 	1
3368
UPDATE t1 SET f_int1 = NULL
3369
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
3370
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
3371
	
3372
# check null-3 success: 	1
3373
DELETE FROM t1
3374
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
3375
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
3376
	
3377
# check null-4 success: 	1
3378
DELETE FROM t1
3379
WHERE f_int1 = 0 AND f_int2 = 0
3380
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
3381
AND f_charbig = '#NULL#';
3382
SET AUTOCOMMIT= 0;
3383
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
3384
SELECT f_int1, f_int1, '', '', 'was inserted'
3385
FROM t0_template source_tab
3386
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
3387
	
3388
# check transactions-1 success: 	1
3389
COMMIT WORK;
3390
	
3391
# check transactions-2 success: 	1
3392
ROLLBACK WORK;
3393
	
3394
# check transactions-3 success: 	1
3395
DELETE FROM t1 WHERE f_charbig = 'was inserted';
3396
COMMIT WORK;
3397
ROLLBACK WORK;
3398
	
3399
# check transactions-4 success: 	1
3400
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
3401
SELECT f_int1, f_int1, '', '', 'was inserted'
3402
FROM t0_template source_tab
3403
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
3404
	
3405
# check transactions-5 success: 	1
3406
ROLLBACK WORK;
3407
	
3408
# check transactions-6 success: 	1
3409
# INFO: Storage engine used for t1 seems to be transactional.
3410
COMMIT;
3411
	
3412
# check transactions-7 success: 	1
3413
DELETE FROM t1 WHERE f_charbig = 'was inserted';
3414
COMMIT WORK;
3415
SET @@session.sql_mode = 'traditional';
3416
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
3417
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
3418
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
3419
'', '', 'was inserted' FROM t0_template
3420
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
3421
ERROR 22012: Division by 0
3422
COMMIT;
3423
	
3424
# check transactions-8 success: 	1
3425
# INFO: Storage engine used for t1 seems to be able to revert
3426
#       changes made by the failing statement.
3427
SET @@session.sql_mode = '';
3428
SET AUTOCOMMIT= 1;
3429
DELETE FROM t1 WHERE f_charbig = 'was inserted';
3430
COMMIT WORK;
3431
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
3432
	
3433
# check special-1 success: 	1
3434
UPDATE t1 SET f_charbig = '';
3435
	
3436
# check special-2 success: 	1
3437
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
3438
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
3439
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
3440
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3441
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3442
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3443
'just inserted' FROM t0_template
3444
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3445
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
3446
BEGIN
3447
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3448
f_charbig = 'updated by trigger'
3449
      WHERE f_int1 = new.f_int1;
3450
END|
3451
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3452
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
3453
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3454
	
3455
# check trigger-1 success: 	1
3456
DROP TRIGGER trg_1;
3457
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3458
f_int2 = CAST(f_char1 AS SIGNED INT),
3459
f_charbig = 'just inserted'
3460
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3461
DELETE FROM t0_aux
3462
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3463
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3464
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3465
'just inserted' FROM t0_template
3466
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3467
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
3468
BEGIN
3469
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3470
f_charbig = 'updated by trigger'
3471
      WHERE f_int1 = new.f_int1;
3472
END|
3473
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3474
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
3475
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3476
	
3477
# check trigger-2 success: 	1
3478
DROP TRIGGER trg_1;
3479
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3480
f_int2 = CAST(f_char1 AS SIGNED INT),
3481
f_charbig = 'just inserted'
3482
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3483
DELETE FROM t0_aux
3484
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3485
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3486
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3487
'just inserted' FROM t0_template
3488
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3489
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
3490
BEGIN
3491
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3492
f_charbig = 'updated by trigger'
3493
      WHERE f_int1 = new.f_int1;
3494
END|
3495
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
3496
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
3497
	
3498
# check trigger-3 success: 	1
3499
DROP TRIGGER trg_1;
3500
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3501
f_int2 = CAST(f_char1 AS SIGNED INT),
3502
f_charbig = 'just inserted'
3503
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3504
DELETE FROM t0_aux
3505
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3506
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3507
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3508
'just inserted' FROM t0_template
3509
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3510
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
3511
BEGIN
3512
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3513
f_charbig = 'updated by trigger'
3514
      WHERE f_int1 = - old.f_int1;
3515
END|
3516
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
3517
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
3518
	
3519
# check trigger-4 success: 	1
3520
DROP TRIGGER trg_1;
3521
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3522
f_int2 = CAST(f_char1 AS SIGNED INT),
3523
f_charbig = 'just inserted'
3524
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3525
DELETE FROM t0_aux
3526
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3527
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3528
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3529
'just inserted' FROM t0_template
3530
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3531
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
3532
BEGIN
3533
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3534
f_charbig = 'updated by trigger'
3535
      WHERE f_int1 = new.f_int1;
3536
END|
3537
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
3538
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
3539
	
3540
# check trigger-5 success: 	1
3541
DROP TRIGGER trg_1;
3542
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3543
f_int2 = CAST(f_char1 AS SIGNED INT),
3544
f_charbig = 'just inserted'
3545
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3546
DELETE FROM t0_aux
3547
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3548
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3549
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3550
'just inserted' FROM t0_template
3551
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3552
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
3553
BEGIN
3554
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3555
f_charbig = 'updated by trigger'
3556
      WHERE f_int1 = - old.f_int1;
3557
END|
3558
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
3559
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
3560
	
3561
# check trigger-6 success: 	1
3562
DROP TRIGGER trg_1;
3563
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3564
f_int2 = CAST(f_char1 AS SIGNED INT),
3565
f_charbig = 'just inserted'
3566
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3567
DELETE FROM t0_aux
3568
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3569
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3570
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3571
'just inserted' FROM t0_template
3572
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3573
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
3574
BEGIN
3575
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3576
f_charbig = 'updated by trigger'
3577
      WHERE f_int1 = - old.f_int1;
3578
END|
3579
DELETE FROM t0_aux
3580
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
3581
	
3582
# check trigger-7 success: 	1
3583
DROP TRIGGER trg_1;
3584
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3585
f_int2 = CAST(f_char1 AS SIGNED INT),
3586
f_charbig = 'just inserted'
3587
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3588
DELETE FROM t0_aux
3589
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3590
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3591
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3592
'just inserted' FROM t0_template
3593
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3594
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
3595
BEGIN
3596
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3597
f_charbig = 'updated by trigger'
3598
      WHERE f_int1 = - old.f_int1;
3599
END|
3600
DELETE FROM t0_aux
3601
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
3602
	
3603
# check trigger-8 success: 	1
3604
DROP TRIGGER trg_1;
3605
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3606
f_int2 = CAST(f_char1 AS SIGNED INT),
3607
f_charbig = 'just inserted'
3608
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3609
DELETE FROM t0_aux
3610
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3611
DELETE FROM t1
3612
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3613
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
3614
BEGIN
3615
SET new.f_int1 = old.f_int1 + @max_row,
3616
new.f_int2 = old.f_int2 - @max_row,
3617
new.f_charbig = '####updated per update trigger####';
3618
END|
3619
UPDATE t1
3620
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
3621
f_charbig = '####updated per update statement itself####';
3622
	
3623
# check trigger-9 success: 	1
3624
DROP TRIGGER trg_2;
3625
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3626
f_int2 = CAST(f_char1 AS SIGNED INT),
3627
f_charbig = CONCAT('===',f_char1,'===');
3628
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
3629
BEGIN
3630
SET new.f_int1 = new.f_int1 + @max_row,
3631
new.f_int2 = new.f_int2 - @max_row,
3632
new.f_charbig = '####updated per update trigger####';
3633
END|
3634
UPDATE t1
3635
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
3636
f_charbig = '####updated per update statement itself####';
3637
	
3638
# check trigger-10 success: 	1
3639
DROP TRIGGER trg_2;
3640
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3641
f_int2 = CAST(f_char1 AS SIGNED INT),
3642
f_charbig = CONCAT('===',f_char1,'===');
3643
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
3644
BEGIN
3645
SET new.f_int1 = @my_max1 + @counter,
3646
new.f_int2 = @my_min2 - @counter,
3647
new.f_charbig = '####updated per insert trigger####';
3648
SET @counter = @counter + 1;
3649
END|
3650
SET @counter = 1;
3651
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
3652
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
3653
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
3654
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
3655
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
3656
ORDER BY f_int1;
3657
DROP TRIGGER trg_3;
3658
	
3659
# check trigger-11 success: 	1
3660
DELETE FROM t1
3661
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
3662
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
3663
AND f_charbig = '####updated per insert trigger####';
3664
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
3665
BEGIN
3666
SET new.f_int1 = @my_max1 + @counter,
3667
new.f_int2 = @my_min2 - @counter,
3668
new.f_charbig = '####updated per insert trigger####';
3669
SET @counter = @counter + 1;
3670
END|
3671
SET @counter = 1;
3672
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
3673
INSERT INTO t1 (f_char1, f_char2, f_charbig)
3674
SELECT CAST(f_int1 AS CHAR),
3675
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
3676
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
3677
ORDER BY f_int1;
3678
DROP TRIGGER trg_3;
3679
	
3680
# check trigger-12 success: 	1
3681
DELETE FROM t1
3682
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
3683
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
3684
AND f_charbig = '####updated per insert trigger####';
3685
ANALYZE  TABLE t1;
3686
Table	Op	Msg_type	Msg_text
3687
test.t1	analyze	note	The storage engine for the table doesn't support analyze
3688
CHECK    TABLE t1 EXTENDED;
3689
Table	Op	Msg_type	Msg_text
3690
test.t1	check	note	The storage engine for the table doesn't support check
3691
CHECKSUM TABLE t1 EXTENDED;
3692
Table	Checksum
3693
test.t1	<some_value>
3694
OPTIMIZE TABLE t1;
3695
Table	Op	Msg_type	Msg_text
3696
test.t1	optimize	note	The storage engine for the table doesn't support optimize
3697
# check layout success:    1
3698
REPAIR   TABLE t1 EXTENDED;
3699
Table	Op	Msg_type	Msg_text
3700
test.t1	repair	note	The storage engine for the table doesn't support repair
3701
# check layout success:    1
3702
TRUNCATE t1;
3703
	
3704
# check TRUNCATE success: 	1
3705
# check layout success:    1
3706
# End usability test (inc/partition_check.inc)
3707
DROP TABLE t1;
3708
#  1.2 The partitioning function contains two columns.
3709
DROP TABLE IF EXISTS t1;
3710
CREATE TABLE t1 (
3711
f_int1 INTEGER,
3712
f_int2 INTEGER,
3713
f_char1 CHAR(20),
3714
f_char2 CHAR(20),
3715
f_charbig VARCHAR(1000)
3716
3717
)
3718
PARTITION BY HASH(f_int1 + f_int2) PARTITIONS 2;
3719
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
3720
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
3721
# Start usability test (inc/partition_check.inc)
3722
create_command
3723
SHOW CREATE TABLE t1;
3724
Table	Create Table
3725
t1	CREATE TABLE `t1` (
3726
  `f_int1` int(11) DEFAULT NULL,
3727
  `f_int2` int(11) DEFAULT NULL,
3728
  `f_char1` char(20) DEFAULT NULL,
3729
  `f_char2` char(20) DEFAULT NULL,
3730
  `f_charbig` varchar(1000) DEFAULT NULL
3731
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (f_int1 + f_int2) PARTITIONS 2  */
3732
3733
unified filelist
3734
$MYSQLTEST_VARDIR/master-data/test/t1.frm
3735
$MYSQLTEST_VARDIR/master-data/test/t1.par
3736
3737
# check prerequisites-1 success:    1
3738
# check COUNT(*) success:    1
3739
# check MIN/MAX(f_int1) success:    1
3740
# check MIN/MAX(f_int2) success:    1
3741
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
3742
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
3743
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
3744
WHERE f_int1 IN (2,3);
3745
# check prerequisites-3 success:    1
3746
DELETE FROM t1 WHERE f_charbig = 'delete me';
3747
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
3748
# check read via f_int1 success: 1
3749
# check read via f_int2 success: 1
3750
	
3751
# check multiple-1 success: 	1
3752
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
3753
	
3754
# check multiple-2 success: 	1
3755
INSERT INTO t1 SELECT * FROM t0_template
3756
WHERE MOD(f_int1,3) = 0;
3757
	
3758
# check multiple-3 success: 	1
3759
UPDATE t1 SET f_int1 = f_int1 + @max_row
3760
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
3761
AND @max_row_div2 + @max_row_div4;
3762
	
3763
# check multiple-4 success: 	1
3764
DELETE FROM t1
3765
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
3766
AND @max_row_div2 + @max_row_div4 + @max_row;
3767
	
3768
# check multiple-5 success: 	1
3769
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
3770
INSERT INTO t1
3771
SET f_int1 = @cur_value , f_int2 = @cur_value,
3772
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
3773
f_charbig = '#SINGLE#';
3774
	
3775
# check single-1 success: 	1
3776
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
3777
INSERT INTO t1
3778
SET f_int1 = @cur_value , f_int2 = @cur_value,
3779
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
3780
f_charbig = '#SINGLE#';
3781
	
3782
# check single-2 success: 	1
3783
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
3784
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
3785
UPDATE t1 SET f_int1 = @cur_value2
3786
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
3787
	
3788
# check single-3 success: 	1
3789
SET @cur_value1= -1;
3790
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
3791
UPDATE t1 SET f_int1 = @cur_value1
3792
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
3793
	
3794
# check single-4 success: 	1
3795
SELECT MAX(f_int1) INTO @cur_value FROM t1;
3796
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
3797
	
3798
# check single-5 success: 	1
3799
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
3800
	
3801
# check single-6 success: 	1
3802
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
3803
	
3804
# check single-7 success: 	1
3805
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
3806
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
3807
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
3808
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
3809
f_charbig = '#NULL#';
3810
INSERT INTO t1
3811
SET f_int1 = NULL , f_int2 = -@max_row,
3812
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
3813
f_charbig = '#NULL#';
3814
# check null success:    1
3815
	
3816
# check null-1 success: 	1
3817
UPDATE t1 SET f_int1 = -@max_row
3818
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
3819
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
3820
	
3821
# check null-2 success: 	1
3822
UPDATE t1 SET f_int1 = NULL
3823
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
3824
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
3825
	
3826
# check null-3 success: 	1
3827
DELETE FROM t1
3828
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
3829
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
3830
	
3831
# check null-4 success: 	1
3832
DELETE FROM t1
3833
WHERE f_int1 = 0 AND f_int2 = 0
3834
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
3835
AND f_charbig = '#NULL#';
3836
SET AUTOCOMMIT= 0;
3837
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
3838
SELECT f_int1, f_int1, '', '', 'was inserted'
3839
FROM t0_template source_tab
3840
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
3841
	
3842
# check transactions-1 success: 	1
3843
COMMIT WORK;
3844
	
3845
# check transactions-2 success: 	1
3846
ROLLBACK WORK;
3847
	
3848
# check transactions-3 success: 	1
3849
DELETE FROM t1 WHERE f_charbig = 'was inserted';
3850
COMMIT WORK;
3851
ROLLBACK WORK;
3852
	
3853
# check transactions-4 success: 	1
3854
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
3855
SELECT f_int1, f_int1, '', '', 'was inserted'
3856
FROM t0_template source_tab
3857
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
3858
	
3859
# check transactions-5 success: 	1
3860
ROLLBACK WORK;
3861
	
3862
# check transactions-6 success: 	1
3863
# INFO: Storage engine used for t1 seems to be transactional.
3864
COMMIT;
3865
	
3866
# check transactions-7 success: 	1
3867
DELETE FROM t1 WHERE f_charbig = 'was inserted';
3868
COMMIT WORK;
3869
SET @@session.sql_mode = 'traditional';
3870
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
3871
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
3872
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
3873
'', '', 'was inserted' FROM t0_template
3874
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
3875
ERROR 22012: Division by 0
3876
COMMIT;
3877
	
3878
# check transactions-8 success: 	1
3879
# INFO: Storage engine used for t1 seems to be able to revert
3880
#       changes made by the failing statement.
3881
SET @@session.sql_mode = '';
3882
SET AUTOCOMMIT= 1;
3883
DELETE FROM t1 WHERE f_charbig = 'was inserted';
3884
COMMIT WORK;
3885
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
3886
	
3887
# check special-1 success: 	1
3888
UPDATE t1 SET f_charbig = '';
3889
	
3890
# check special-2 success: 	1
3891
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
3892
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
3893
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
3894
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3895
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3896
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3897
'just inserted' FROM t0_template
3898
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3899
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
3900
BEGIN
3901
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3902
f_charbig = 'updated by trigger'
3903
      WHERE f_int1 = new.f_int1;
3904
END|
3905
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3906
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
3907
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3908
	
3909
# check trigger-1 success: 	1
3910
DROP TRIGGER trg_1;
3911
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3912
f_int2 = CAST(f_char1 AS SIGNED INT),
3913
f_charbig = 'just inserted'
3914
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3915
DELETE FROM t0_aux
3916
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3917
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3918
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3919
'just inserted' FROM t0_template
3920
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3921
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
3922
BEGIN
3923
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3924
f_charbig = 'updated by trigger'
3925
      WHERE f_int1 = new.f_int1;
3926
END|
3927
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3928
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
3929
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3930
	
3931
# check trigger-2 success: 	1
3932
DROP TRIGGER trg_1;
3933
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3934
f_int2 = CAST(f_char1 AS SIGNED INT),
3935
f_charbig = 'just inserted'
3936
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3937
DELETE FROM t0_aux
3938
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3939
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3940
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3941
'just inserted' FROM t0_template
3942
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3943
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
3944
BEGIN
3945
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3946
f_charbig = 'updated by trigger'
3947
      WHERE f_int1 = new.f_int1;
3948
END|
3949
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
3950
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
3951
	
3952
# check trigger-3 success: 	1
3953
DROP TRIGGER trg_1;
3954
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3955
f_int2 = CAST(f_char1 AS SIGNED INT),
3956
f_charbig = 'just inserted'
3957
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3958
DELETE FROM t0_aux
3959
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3960
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3961
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3962
'just inserted' FROM t0_template
3963
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3964
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
3965
BEGIN
3966
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3967
f_charbig = 'updated by trigger'
3968
      WHERE f_int1 = - old.f_int1;
3969
END|
3970
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
3971
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
3972
	
3973
# check trigger-4 success: 	1
3974
DROP TRIGGER trg_1;
3975
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3976
f_int2 = CAST(f_char1 AS SIGNED INT),
3977
f_charbig = 'just inserted'
3978
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
3979
DELETE FROM t0_aux
3980
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3981
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
3982
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
3983
'just inserted' FROM t0_template
3984
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
3985
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
3986
BEGIN
3987
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
3988
f_charbig = 'updated by trigger'
3989
      WHERE f_int1 = new.f_int1;
3990
END|
3991
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
3992
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
3993
	
3994
# check trigger-5 success: 	1
3995
DROP TRIGGER trg_1;
3996
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
3997
f_int2 = CAST(f_char1 AS SIGNED INT),
3998
f_charbig = 'just inserted'
3999
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4000
DELETE FROM t0_aux
4001
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4002
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4003
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4004
'just inserted' FROM t0_template
4005
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4006
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
4007
BEGIN
4008
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4009
f_charbig = 'updated by trigger'
4010
      WHERE f_int1 = - old.f_int1;
4011
END|
4012
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
4013
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
4014
	
4015
# check trigger-6 success: 	1
4016
DROP TRIGGER trg_1;
4017
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4018
f_int2 = CAST(f_char1 AS SIGNED INT),
4019
f_charbig = 'just inserted'
4020
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4021
DELETE FROM t0_aux
4022
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4023
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4024
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4025
'just inserted' FROM t0_template
4026
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4027
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
4028
BEGIN
4029
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4030
f_charbig = 'updated by trigger'
4031
      WHERE f_int1 = - old.f_int1;
4032
END|
4033
DELETE FROM t0_aux
4034
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
4035
	
4036
# check trigger-7 success: 	1
4037
DROP TRIGGER trg_1;
4038
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4039
f_int2 = CAST(f_char1 AS SIGNED INT),
4040
f_charbig = 'just inserted'
4041
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4042
DELETE FROM t0_aux
4043
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4044
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4045
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4046
'just inserted' FROM t0_template
4047
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4048
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
4049
BEGIN
4050
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4051
f_charbig = 'updated by trigger'
4052
      WHERE f_int1 = - old.f_int1;
4053
END|
4054
DELETE FROM t0_aux
4055
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
4056
	
4057
# check trigger-8 success: 	1
4058
DROP TRIGGER trg_1;
4059
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4060
f_int2 = CAST(f_char1 AS SIGNED INT),
4061
f_charbig = 'just inserted'
4062
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4063
DELETE FROM t0_aux
4064
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4065
DELETE FROM t1
4066
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4067
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
4068
BEGIN
4069
SET new.f_int1 = old.f_int1 + @max_row,
4070
new.f_int2 = old.f_int2 - @max_row,
4071
new.f_charbig = '####updated per update trigger####';
4072
END|
4073
UPDATE t1
4074
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
4075
f_charbig = '####updated per update statement itself####';
4076
	
4077
# check trigger-9 success: 	1
4078
DROP TRIGGER trg_2;
4079
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4080
f_int2 = CAST(f_char1 AS SIGNED INT),
4081
f_charbig = CONCAT('===',f_char1,'===');
4082
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
4083
BEGIN
4084
SET new.f_int1 = new.f_int1 + @max_row,
4085
new.f_int2 = new.f_int2 - @max_row,
4086
new.f_charbig = '####updated per update trigger####';
4087
END|
4088
UPDATE t1
4089
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
4090
f_charbig = '####updated per update statement itself####';
4091
	
4092
# check trigger-10 success: 	1
4093
DROP TRIGGER trg_2;
4094
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4095
f_int2 = CAST(f_char1 AS SIGNED INT),
4096
f_charbig = CONCAT('===',f_char1,'===');
4097
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
4098
BEGIN
4099
SET new.f_int1 = @my_max1 + @counter,
4100
new.f_int2 = @my_min2 - @counter,
4101
new.f_charbig = '####updated per insert trigger####';
4102
SET @counter = @counter + 1;
4103
END|
4104
SET @counter = 1;
4105
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
4106
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
4107
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
4108
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
4109
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
4110
ORDER BY f_int1;
4111
DROP TRIGGER trg_3;
4112
	
4113
# check trigger-11 success: 	1
4114
DELETE FROM t1
4115
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
4116
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
4117
AND f_charbig = '####updated per insert trigger####';
4118
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
4119
BEGIN
4120
SET new.f_int1 = @my_max1 + @counter,
4121
new.f_int2 = @my_min2 - @counter,
4122
new.f_charbig = '####updated per insert trigger####';
4123
SET @counter = @counter + 1;
4124
END|
4125
SET @counter = 1;
4126
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
4127
INSERT INTO t1 (f_char1, f_char2, f_charbig)
4128
SELECT CAST(f_int1 AS CHAR),
4129
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
4130
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
4131
ORDER BY f_int1;
4132
DROP TRIGGER trg_3;
4133
	
4134
# check trigger-12 success: 	1
4135
DELETE FROM t1
4136
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
4137
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
4138
AND f_charbig = '####updated per insert trigger####';
4139
ANALYZE  TABLE t1;
4140
Table	Op	Msg_type	Msg_text
4141
test.t1	analyze	note	The storage engine for the table doesn't support analyze
4142
CHECK    TABLE t1 EXTENDED;
4143
Table	Op	Msg_type	Msg_text
4144
test.t1	check	note	The storage engine for the table doesn't support check
4145
CHECKSUM TABLE t1 EXTENDED;
4146
Table	Checksum
4147
test.t1	<some_value>
4148
OPTIMIZE TABLE t1;
4149
Table	Op	Msg_type	Msg_text
4150
test.t1	optimize	note	The storage engine for the table doesn't support optimize
4151
# check layout success:    1
4152
REPAIR   TABLE t1 EXTENDED;
4153
Table	Op	Msg_type	Msg_text
4154
test.t1	repair	note	The storage engine for the table doesn't support repair
4155
# check layout success:    1
4156
TRUNCATE t1;
4157
	
4158
# check TRUNCATE success: 	1
4159
# check layout success:    1
4160
# End usability test (inc/partition_check.inc)
4161
DROP TABLE t1;
4162
CREATE TABLE t1 (
4163
f_int1 INTEGER,
4164
f_int2 INTEGER,
4165
f_char1 CHAR(20),
4166
f_char2 CHAR(20),
4167
f_charbig VARCHAR(1000)
4168
4169
)
4170
PARTITION BY KEY(f_int1,f_int2) PARTITIONS 5;
4171
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
4172
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
4173
# Start usability test (inc/partition_check.inc)
4174
create_command
4175
SHOW CREATE TABLE t1;
4176
Table	Create Table
4177
t1	CREATE TABLE `t1` (
4178
  `f_int1` int(11) DEFAULT NULL,
4179
  `f_int2` int(11) DEFAULT NULL,
4180
  `f_char1` char(20) DEFAULT NULL,
4181
  `f_char2` char(20) DEFAULT NULL,
4182
  `f_charbig` varchar(1000) DEFAULT NULL
4183
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5  */
4184
4185
unified filelist
4186
$MYSQLTEST_VARDIR/master-data/test/t1.frm
4187
$MYSQLTEST_VARDIR/master-data/test/t1.par
4188
4189
# check prerequisites-1 success:    1
4190
# check COUNT(*) success:    1
4191
# check MIN/MAX(f_int1) success:    1
4192
# check MIN/MAX(f_int2) success:    1
4193
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
4194
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
4195
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
4196
WHERE f_int1 IN (2,3);
4197
# check prerequisites-3 success:    1
4198
DELETE FROM t1 WHERE f_charbig = 'delete me';
4199
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
4200
# check read via f_int1 success: 1
4201
# check read via f_int2 success: 1
4202
	
4203
# check multiple-1 success: 	1
4204
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
4205
	
4206
# check multiple-2 success: 	1
4207
INSERT INTO t1 SELECT * FROM t0_template
4208
WHERE MOD(f_int1,3) = 0;
4209
	
4210
# check multiple-3 success: 	1
4211
UPDATE t1 SET f_int1 = f_int1 + @max_row
4212
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
4213
AND @max_row_div2 + @max_row_div4;
4214
	
4215
# check multiple-4 success: 	1
4216
DELETE FROM t1
4217
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
4218
AND @max_row_div2 + @max_row_div4 + @max_row;
4219
	
4220
# check multiple-5 success: 	1
4221
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
4222
INSERT INTO t1
4223
SET f_int1 = @cur_value , f_int2 = @cur_value,
4224
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
4225
f_charbig = '#SINGLE#';
4226
	
4227
# check single-1 success: 	1
4228
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
4229
INSERT INTO t1
4230
SET f_int1 = @cur_value , f_int2 = @cur_value,
4231
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
4232
f_charbig = '#SINGLE#';
4233
	
4234
# check single-2 success: 	1
4235
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
4236
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
4237
UPDATE t1 SET f_int1 = @cur_value2
4238
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
4239
	
4240
# check single-3 success: 	1
4241
SET @cur_value1= -1;
4242
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
4243
UPDATE t1 SET f_int1 = @cur_value1
4244
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
4245
	
4246
# check single-4 success: 	1
4247
SELECT MAX(f_int1) INTO @cur_value FROM t1;
4248
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
4249
	
4250
# check single-5 success: 	1
4251
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
4252
	
4253
# check single-6 success: 	1
4254
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
4255
	
4256
# check single-7 success: 	1
4257
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
4258
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
4259
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
4260
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
4261
f_charbig = '#NULL#';
4262
INSERT INTO t1
4263
SET f_int1 = NULL , f_int2 = -@max_row,
4264
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
4265
f_charbig = '#NULL#';
4266
# check null success:    1
4267
	
4268
# check null-1 success: 	1
4269
UPDATE t1 SET f_int1 = -@max_row
4270
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
4271
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
4272
	
4273
# check null-2 success: 	1
4274
UPDATE t1 SET f_int1 = NULL
4275
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
4276
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
4277
	
4278
# check null-3 success: 	1
4279
DELETE FROM t1
4280
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
4281
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
4282
	
4283
# check null-4 success: 	1
4284
DELETE FROM t1
4285
WHERE f_int1 = 0 AND f_int2 = 0
4286
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
4287
AND f_charbig = '#NULL#';
4288
SET AUTOCOMMIT= 0;
4289
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
4290
SELECT f_int1, f_int1, '', '', 'was inserted'
4291
FROM t0_template source_tab
4292
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
4293
	
4294
# check transactions-1 success: 	1
4295
COMMIT WORK;
4296
	
4297
# check transactions-2 success: 	1
4298
ROLLBACK WORK;
4299
	
4300
# check transactions-3 success: 	1
4301
DELETE FROM t1 WHERE f_charbig = 'was inserted';
4302
COMMIT WORK;
4303
ROLLBACK WORK;
4304
	
4305
# check transactions-4 success: 	1
4306
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
4307
SELECT f_int1, f_int1, '', '', 'was inserted'
4308
FROM t0_template source_tab
4309
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
4310
	
4311
# check transactions-5 success: 	1
4312
ROLLBACK WORK;
4313
	
4314
# check transactions-6 success: 	1
4315
# INFO: Storage engine used for t1 seems to be transactional.
4316
COMMIT;
4317
	
4318
# check transactions-7 success: 	1
4319
DELETE FROM t1 WHERE f_charbig = 'was inserted';
4320
COMMIT WORK;
4321
SET @@session.sql_mode = 'traditional';
4322
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
4323
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
4324
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
4325
'', '', 'was inserted' FROM t0_template
4326
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
4327
ERROR 22012: Division by 0
4328
COMMIT;
4329
	
4330
# check transactions-8 success: 	1
4331
# INFO: Storage engine used for t1 seems to be able to revert
4332
#       changes made by the failing statement.
4333
SET @@session.sql_mode = '';
4334
SET AUTOCOMMIT= 1;
4335
DELETE FROM t1 WHERE f_charbig = 'was inserted';
4336
COMMIT WORK;
4337
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
4338
	
4339
# check special-1 success: 	1
4340
UPDATE t1 SET f_charbig = '';
4341
	
4342
# check special-2 success: 	1
4343
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
4344
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
4345
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
4346
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4347
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4348
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4349
'just inserted' FROM t0_template
4350
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4351
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
4352
BEGIN
4353
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4354
f_charbig = 'updated by trigger'
4355
      WHERE f_int1 = new.f_int1;
4356
END|
4357
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4358
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
4359
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4360
	
4361
# check trigger-1 success: 	1
4362
DROP TRIGGER trg_1;
4363
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4364
f_int2 = CAST(f_char1 AS SIGNED INT),
4365
f_charbig = 'just inserted'
4366
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4367
DELETE FROM t0_aux
4368
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4369
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4370
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4371
'just inserted' FROM t0_template
4372
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4373
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
4374
BEGIN
4375
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4376
f_charbig = 'updated by trigger'
4377
      WHERE f_int1 = new.f_int1;
4378
END|
4379
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4380
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
4381
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4382
	
4383
# check trigger-2 success: 	1
4384
DROP TRIGGER trg_1;
4385
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4386
f_int2 = CAST(f_char1 AS SIGNED INT),
4387
f_charbig = 'just inserted'
4388
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4389
DELETE FROM t0_aux
4390
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4391
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4392
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4393
'just inserted' FROM t0_template
4394
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4395
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
4396
BEGIN
4397
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4398
f_charbig = 'updated by trigger'
4399
      WHERE f_int1 = new.f_int1;
4400
END|
4401
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
4402
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
4403
	
4404
# check trigger-3 success: 	1
4405
DROP TRIGGER trg_1;
4406
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4407
f_int2 = CAST(f_char1 AS SIGNED INT),
4408
f_charbig = 'just inserted'
4409
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4410
DELETE FROM t0_aux
4411
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4412
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4413
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4414
'just inserted' FROM t0_template
4415
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4416
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
4417
BEGIN
4418
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4419
f_charbig = 'updated by trigger'
4420
      WHERE f_int1 = - old.f_int1;
4421
END|
4422
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
4423
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
4424
	
4425
# check trigger-4 success: 	1
4426
DROP TRIGGER trg_1;
4427
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4428
f_int2 = CAST(f_char1 AS SIGNED INT),
4429
f_charbig = 'just inserted'
4430
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4431
DELETE FROM t0_aux
4432
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4433
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4434
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4435
'just inserted' FROM t0_template
4436
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4437
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
4438
BEGIN
4439
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4440
f_charbig = 'updated by trigger'
4441
      WHERE f_int1 = new.f_int1;
4442
END|
4443
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
4444
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
4445
	
4446
# check trigger-5 success: 	1
4447
DROP TRIGGER trg_1;
4448
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4449
f_int2 = CAST(f_char1 AS SIGNED INT),
4450
f_charbig = 'just inserted'
4451
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4452
DELETE FROM t0_aux
4453
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4454
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4455
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4456
'just inserted' FROM t0_template
4457
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4458
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
4459
BEGIN
4460
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4461
f_charbig = 'updated by trigger'
4462
      WHERE f_int1 = - old.f_int1;
4463
END|
4464
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
4465
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
4466
	
4467
# check trigger-6 success: 	1
4468
DROP TRIGGER trg_1;
4469
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4470
f_int2 = CAST(f_char1 AS SIGNED INT),
4471
f_charbig = 'just inserted'
4472
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4473
DELETE FROM t0_aux
4474
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4475
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4476
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4477
'just inserted' FROM t0_template
4478
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4479
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
4480
BEGIN
4481
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4482
f_charbig = 'updated by trigger'
4483
      WHERE f_int1 = - old.f_int1;
4484
END|
4485
DELETE FROM t0_aux
4486
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
4487
	
4488
# check trigger-7 success: 	1
4489
DROP TRIGGER trg_1;
4490
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4491
f_int2 = CAST(f_char1 AS SIGNED INT),
4492
f_charbig = 'just inserted'
4493
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4494
DELETE FROM t0_aux
4495
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4496
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4497
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4498
'just inserted' FROM t0_template
4499
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4500
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
4501
BEGIN
4502
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4503
f_charbig = 'updated by trigger'
4504
      WHERE f_int1 = - old.f_int1;
4505
END|
4506
DELETE FROM t0_aux
4507
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
4508
	
4509
# check trigger-8 success: 	1
4510
DROP TRIGGER trg_1;
4511
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4512
f_int2 = CAST(f_char1 AS SIGNED INT),
4513
f_charbig = 'just inserted'
4514
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4515
DELETE FROM t0_aux
4516
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4517
DELETE FROM t1
4518
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4519
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
4520
BEGIN
4521
SET new.f_int1 = old.f_int1 + @max_row,
4522
new.f_int2 = old.f_int2 - @max_row,
4523
new.f_charbig = '####updated per update trigger####';
4524
END|
4525
UPDATE t1
4526
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
4527
f_charbig = '####updated per update statement itself####';
4528
	
4529
# check trigger-9 success: 	1
4530
DROP TRIGGER trg_2;
4531
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4532
f_int2 = CAST(f_char1 AS SIGNED INT),
4533
f_charbig = CONCAT('===',f_char1,'===');
4534
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
4535
BEGIN
4536
SET new.f_int1 = new.f_int1 + @max_row,
4537
new.f_int2 = new.f_int2 - @max_row,
4538
new.f_charbig = '####updated per update trigger####';
4539
END|
4540
UPDATE t1
4541
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
4542
f_charbig = '####updated per update statement itself####';
4543
	
4544
# check trigger-10 success: 	1
4545
DROP TRIGGER trg_2;
4546
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4547
f_int2 = CAST(f_char1 AS SIGNED INT),
4548
f_charbig = CONCAT('===',f_char1,'===');
4549
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
4550
BEGIN
4551
SET new.f_int1 = @my_max1 + @counter,
4552
new.f_int2 = @my_min2 - @counter,
4553
new.f_charbig = '####updated per insert trigger####';
4554
SET @counter = @counter + 1;
4555
END|
4556
SET @counter = 1;
4557
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
4558
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
4559
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
4560
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
4561
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
4562
ORDER BY f_int1;
4563
DROP TRIGGER trg_3;
4564
	
4565
# check trigger-11 success: 	1
4566
DELETE FROM t1
4567
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
4568
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
4569
AND f_charbig = '####updated per insert trigger####';
4570
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
4571
BEGIN
4572
SET new.f_int1 = @my_max1 + @counter,
4573
new.f_int2 = @my_min2 - @counter,
4574
new.f_charbig = '####updated per insert trigger####';
4575
SET @counter = @counter + 1;
4576
END|
4577
SET @counter = 1;
4578
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
4579
INSERT INTO t1 (f_char1, f_char2, f_charbig)
4580
SELECT CAST(f_int1 AS CHAR),
4581
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
4582
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
4583
ORDER BY f_int1;
4584
DROP TRIGGER trg_3;
4585
	
4586
# check trigger-12 success: 	1
4587
DELETE FROM t1
4588
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
4589
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
4590
AND f_charbig = '####updated per insert trigger####';
4591
ANALYZE  TABLE t1;
4592
Table	Op	Msg_type	Msg_text
4593
test.t1	analyze	note	The storage engine for the table doesn't support analyze
4594
CHECK    TABLE t1 EXTENDED;
4595
Table	Op	Msg_type	Msg_text
4596
test.t1	check	note	The storage engine for the table doesn't support check
4597
CHECKSUM TABLE t1 EXTENDED;
4598
Table	Checksum
4599
test.t1	<some_value>
4600
OPTIMIZE TABLE t1;
4601
Table	Op	Msg_type	Msg_text
4602
test.t1	optimize	note	The storage engine for the table doesn't support optimize
4603
# check layout success:    1
4604
REPAIR   TABLE t1 EXTENDED;
4605
Table	Op	Msg_type	Msg_text
4606
test.t1	repair	note	The storage engine for the table doesn't support repair
4607
# check layout success:    1
4608
TRUNCATE t1;
4609
	
4610
# check TRUNCATE success: 	1
4611
# check layout success:    1
4612
# End usability test (inc/partition_check.inc)
4613
DROP TABLE t1;
4614
CREATE TABLE t1 (
4615
f_int1 INTEGER,
4616
f_int2 INTEGER,
4617
f_char1 CHAR(20),
4618
f_char2 CHAR(20),
4619
f_charbig VARCHAR(1000)
4620
4621
)
4622
PARTITION BY LIST(MOD(f_int1 + f_int2,4))
4623
(PARTITION part_3 VALUES IN (-3),
4624
PARTITION part_2 VALUES IN (-2),
4625
PARTITION part_1 VALUES IN (-1),
4626
PARTITION part_N VALUES IN (NULL),
4627
PARTITION part0 VALUES IN (0),
4628
PARTITION part1 VALUES IN (1),
4629
PARTITION part2 VALUES IN (2),
4630
PARTITION part3 VALUES IN (3));
4631
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
4632
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
4633
# Start usability test (inc/partition_check.inc)
4634
create_command
4635
SHOW CREATE TABLE t1;
4636
Table	Create Table
4637
t1	CREATE TABLE `t1` (
4638
  `f_int1` int(11) DEFAULT NULL,
4639
  `f_int2` int(11) DEFAULT NULL,
4640
  `f_char1` char(20) DEFAULT NULL,
4641
  `f_char2` char(20) DEFAULT NULL,
4642
  `f_charbig` varchar(1000) DEFAULT NULL
4643
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (MOD(f_int1 + f_int2,4)) (PARTITION part_3 VALUES IN (-3) ENGINE = InnoDB, PARTITION part_2 VALUES IN (-2) ENGINE = InnoDB, PARTITION part_1 VALUES IN (-1) ENGINE = InnoDB, PARTITION part_N VALUES IN (NULL) ENGINE = InnoDB, PARTITION part0 VALUES IN (0) ENGINE = InnoDB, PARTITION part1 VALUES IN (1) ENGINE = InnoDB, PARTITION part2 VALUES IN (2) ENGINE = InnoDB, PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
4644
4645
unified filelist
4646
$MYSQLTEST_VARDIR/master-data/test/t1.frm
4647
$MYSQLTEST_VARDIR/master-data/test/t1.par
4648
4649
# check prerequisites-1 success:    1
4650
# check COUNT(*) success:    1
4651
# check MIN/MAX(f_int1) success:    1
4652
# check MIN/MAX(f_int2) success:    1
4653
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
4654
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
4655
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
4656
WHERE f_int1 IN (2,3);
4657
# check prerequisites-3 success:    1
4658
DELETE FROM t1 WHERE f_charbig = 'delete me';
4659
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
4660
# check read via f_int1 success: 1
4661
# check read via f_int2 success: 1
4662
	
4663
# check multiple-1 success: 	1
4664
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
4665
	
4666
# check multiple-2 success: 	1
4667
INSERT INTO t1 SELECT * FROM t0_template
4668
WHERE MOD(f_int1,3) = 0;
4669
	
4670
# check multiple-3 success: 	1
4671
UPDATE t1 SET f_int1 = f_int1 + @max_row
4672
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
4673
AND @max_row_div2 + @max_row_div4;
4674
	
4675
# check multiple-4 success: 	1
4676
DELETE FROM t1
4677
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
4678
AND @max_row_div2 + @max_row_div4 + @max_row;
4679
	
4680
# check multiple-5 success: 	1
4681
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
4682
INSERT INTO t1
4683
SET f_int1 = @cur_value , f_int2 = @cur_value,
4684
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
4685
f_charbig = '#SINGLE#';
4686
	
4687
# check single-1 success: 	1
4688
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
4689
INSERT INTO t1
4690
SET f_int1 = @cur_value , f_int2 = @cur_value,
4691
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
4692
f_charbig = '#SINGLE#';
4693
	
4694
# check single-2 success: 	1
4695
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
4696
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
4697
UPDATE t1 SET f_int1 = @cur_value2
4698
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
4699
	
4700
# check single-3 success: 	1
4701
SET @cur_value1= -1;
4702
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
4703
UPDATE t1 SET f_int1 = @cur_value1
4704
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
4705
	
4706
# check single-4 success: 	1
4707
SELECT MAX(f_int1) INTO @cur_value FROM t1;
4708
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
4709
	
4710
# check single-5 success: 	1
4711
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
4712
	
4713
# check single-6 success: 	1
4714
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
4715
	
4716
# check single-7 success: 	1
4717
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
4718
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
4719
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
4720
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
4721
f_charbig = '#NULL#';
4722
INSERT INTO t1
4723
SET f_int1 = NULL , f_int2 = -@max_row,
4724
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
4725
f_charbig = '#NULL#';
4726
# check null success:    1
4727
	
4728
# check null-1 success: 	1
4729
UPDATE t1 SET f_int1 = -@max_row
4730
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
4731
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
4732
	
4733
# check null-2 success: 	1
4734
UPDATE t1 SET f_int1 = NULL
4735
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
4736
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
4737
	
4738
# check null-3 success: 	1
4739
DELETE FROM t1
4740
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
4741
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
4742
	
4743
# check null-4 success: 	1
4744
DELETE FROM t1
4745
WHERE f_int1 = 0 AND f_int2 = 0
4746
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
4747
AND f_charbig = '#NULL#';
4748
SET AUTOCOMMIT= 0;
4749
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
4750
SELECT f_int1, f_int1, '', '', 'was inserted'
4751
FROM t0_template source_tab
4752
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
4753
	
4754
# check transactions-1 success: 	1
4755
COMMIT WORK;
4756
	
4757
# check transactions-2 success: 	1
4758
ROLLBACK WORK;
4759
	
4760
# check transactions-3 success: 	1
4761
DELETE FROM t1 WHERE f_charbig = 'was inserted';
4762
COMMIT WORK;
4763
ROLLBACK WORK;
4764
	
4765
# check transactions-4 success: 	1
4766
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
4767
SELECT f_int1, f_int1, '', '', 'was inserted'
4768
FROM t0_template source_tab
4769
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
4770
	
4771
# check transactions-5 success: 	1
4772
ROLLBACK WORK;
4773
	
4774
# check transactions-6 success: 	1
4775
# INFO: Storage engine used for t1 seems to be transactional.
4776
COMMIT;
4777
	
4778
# check transactions-7 success: 	1
4779
DELETE FROM t1 WHERE f_charbig = 'was inserted';
4780
COMMIT WORK;
4781
SET @@session.sql_mode = 'traditional';
4782
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
4783
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
4784
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
4785
'', '', 'was inserted' FROM t0_template
4786
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
4787
ERROR 22012: Division by 0
4788
COMMIT;
4789
	
4790
# check transactions-8 success: 	1
4791
# INFO: Storage engine used for t1 seems to be able to revert
4792
#       changes made by the failing statement.
4793
SET @@session.sql_mode = '';
4794
SET AUTOCOMMIT= 1;
4795
DELETE FROM t1 WHERE f_charbig = 'was inserted';
4796
COMMIT WORK;
4797
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
4798
	
4799
# check special-1 success: 	1
4800
UPDATE t1 SET f_charbig = '';
4801
	
4802
# check special-2 success: 	1
4803
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
4804
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
4805
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
4806
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4807
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4808
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4809
'just inserted' FROM t0_template
4810
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4811
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
4812
BEGIN
4813
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4814
f_charbig = 'updated by trigger'
4815
      WHERE f_int1 = new.f_int1;
4816
END|
4817
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4818
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
4819
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4820
	
4821
# check trigger-1 success: 	1
4822
DROP TRIGGER trg_1;
4823
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4824
f_int2 = CAST(f_char1 AS SIGNED INT),
4825
f_charbig = 'just inserted'
4826
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4827
DELETE FROM t0_aux
4828
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4829
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4830
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4831
'just inserted' FROM t0_template
4832
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4833
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
4834
BEGIN
4835
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4836
f_charbig = 'updated by trigger'
4837
      WHERE f_int1 = new.f_int1;
4838
END|
4839
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4840
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
4841
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4842
	
4843
# check trigger-2 success: 	1
4844
DROP TRIGGER trg_1;
4845
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4846
f_int2 = CAST(f_char1 AS SIGNED INT),
4847
f_charbig = 'just inserted'
4848
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4849
DELETE FROM t0_aux
4850
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4851
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4852
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4853
'just inserted' FROM t0_template
4854
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4855
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
4856
BEGIN
4857
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4858
f_charbig = 'updated by trigger'
4859
      WHERE f_int1 = new.f_int1;
4860
END|
4861
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
4862
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
4863
	
4864
# check trigger-3 success: 	1
4865
DROP TRIGGER trg_1;
4866
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4867
f_int2 = CAST(f_char1 AS SIGNED INT),
4868
f_charbig = 'just inserted'
4869
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4870
DELETE FROM t0_aux
4871
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4872
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4873
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4874
'just inserted' FROM t0_template
4875
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4876
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
4877
BEGIN
4878
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4879
f_charbig = 'updated by trigger'
4880
      WHERE f_int1 = - old.f_int1;
4881
END|
4882
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
4883
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
4884
	
4885
# check trigger-4 success: 	1
4886
DROP TRIGGER trg_1;
4887
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4888
f_int2 = CAST(f_char1 AS SIGNED INT),
4889
f_charbig = 'just inserted'
4890
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4891
DELETE FROM t0_aux
4892
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4893
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4894
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4895
'just inserted' FROM t0_template
4896
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4897
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
4898
BEGIN
4899
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4900
f_charbig = 'updated by trigger'
4901
      WHERE f_int1 = new.f_int1;
4902
END|
4903
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
4904
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
4905
	
4906
# check trigger-5 success: 	1
4907
DROP TRIGGER trg_1;
4908
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4909
f_int2 = CAST(f_char1 AS SIGNED INT),
4910
f_charbig = 'just inserted'
4911
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4912
DELETE FROM t0_aux
4913
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4914
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4915
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4916
'just inserted' FROM t0_template
4917
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4918
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
4919
BEGIN
4920
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4921
f_charbig = 'updated by trigger'
4922
      WHERE f_int1 = - old.f_int1;
4923
END|
4924
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
4925
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
4926
	
4927
# check trigger-6 success: 	1
4928
DROP TRIGGER trg_1;
4929
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4930
f_int2 = CAST(f_char1 AS SIGNED INT),
4931
f_charbig = 'just inserted'
4932
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4933
DELETE FROM t0_aux
4934
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4935
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4936
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4937
'just inserted' FROM t0_template
4938
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4939
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
4940
BEGIN
4941
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4942
f_charbig = 'updated by trigger'
4943
      WHERE f_int1 = - old.f_int1;
4944
END|
4945
DELETE FROM t0_aux
4946
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
4947
	
4948
# check trigger-7 success: 	1
4949
DROP TRIGGER trg_1;
4950
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4951
f_int2 = CAST(f_char1 AS SIGNED INT),
4952
f_charbig = 'just inserted'
4953
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4954
DELETE FROM t0_aux
4955
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4956
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
4957
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
4958
'just inserted' FROM t0_template
4959
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4960
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
4961
BEGIN
4962
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
4963
f_charbig = 'updated by trigger'
4964
      WHERE f_int1 = - old.f_int1;
4965
END|
4966
DELETE FROM t0_aux
4967
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
4968
	
4969
# check trigger-8 success: 	1
4970
DROP TRIGGER trg_1;
4971
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4972
f_int2 = CAST(f_char1 AS SIGNED INT),
4973
f_charbig = 'just inserted'
4974
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
4975
DELETE FROM t0_aux
4976
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4977
DELETE FROM t1
4978
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
4979
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
4980
BEGIN
4981
SET new.f_int1 = old.f_int1 + @max_row,
4982
new.f_int2 = old.f_int2 - @max_row,
4983
new.f_charbig = '####updated per update trigger####';
4984
END|
4985
UPDATE t1
4986
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
4987
f_charbig = '####updated per update statement itself####';
4988
	
4989
# check trigger-9 success: 	1
4990
DROP TRIGGER trg_2;
4991
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
4992
f_int2 = CAST(f_char1 AS SIGNED INT),
4993
f_charbig = CONCAT('===',f_char1,'===');
4994
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
4995
BEGIN
4996
SET new.f_int1 = new.f_int1 + @max_row,
4997
new.f_int2 = new.f_int2 - @max_row,
4998
new.f_charbig = '####updated per update trigger####';
4999
END|
5000
UPDATE t1
5001
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
5002
f_charbig = '####updated per update statement itself####';
5003
	
5004
# check trigger-10 success: 	1
5005
DROP TRIGGER trg_2;
5006
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5007
f_int2 = CAST(f_char1 AS SIGNED INT),
5008
f_charbig = CONCAT('===',f_char1,'===');
5009
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
5010
BEGIN
5011
SET new.f_int1 = @my_max1 + @counter,
5012
new.f_int2 = @my_min2 - @counter,
5013
new.f_charbig = '####updated per insert trigger####';
5014
SET @counter = @counter + 1;
5015
END|
5016
SET @counter = 1;
5017
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
5018
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
5019
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
5020
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
5021
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
5022
ORDER BY f_int1;
5023
DROP TRIGGER trg_3;
5024
	
5025
# check trigger-11 success: 	1
5026
DELETE FROM t1
5027
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
5028
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
5029
AND f_charbig = '####updated per insert trigger####';
5030
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
5031
BEGIN
5032
SET new.f_int1 = @my_max1 + @counter,
5033
new.f_int2 = @my_min2 - @counter,
5034
new.f_charbig = '####updated per insert trigger####';
5035
SET @counter = @counter + 1;
5036
END|
5037
SET @counter = 1;
5038
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
5039
INSERT INTO t1 (f_char1, f_char2, f_charbig)
5040
SELECT CAST(f_int1 AS CHAR),
5041
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
5042
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
5043
ORDER BY f_int1;
5044
DROP TRIGGER trg_3;
5045
	
5046
# check trigger-12 success: 	1
5047
DELETE FROM t1
5048
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
5049
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
5050
AND f_charbig = '####updated per insert trigger####';
5051
ANALYZE  TABLE t1;
5052
Table	Op	Msg_type	Msg_text
5053
test.t1	analyze	note	The storage engine for the table doesn't support analyze
5054
CHECK    TABLE t1 EXTENDED;
5055
Table	Op	Msg_type	Msg_text
5056
test.t1	check	note	The storage engine for the table doesn't support check
5057
CHECKSUM TABLE t1 EXTENDED;
5058
Table	Checksum
5059
test.t1	<some_value>
5060
OPTIMIZE TABLE t1;
5061
Table	Op	Msg_type	Msg_text
5062
test.t1	optimize	note	The storage engine for the table doesn't support optimize
5063
# check layout success:    1
5064
REPAIR   TABLE t1 EXTENDED;
5065
Table	Op	Msg_type	Msg_text
5066
test.t1	repair	note	The storage engine for the table doesn't support repair
5067
# check layout success:    1
5068
TRUNCATE t1;
5069
	
5070
# check TRUNCATE success: 	1
5071
# check layout success:    1
5072
# End usability test (inc/partition_check.inc)
5073
DROP TABLE t1;
5074
CREATE TABLE t1 (
5075
f_int1 INTEGER,
5076
f_int2 INTEGER,
5077
f_char1 CHAR(20),
5078
f_char2 CHAR(20),
5079
f_charbig VARCHAR(1000)
5080
5081
)
5082
PARTITION BY RANGE((f_int1 + f_int2) DIV 2)
5083
(PARTITION parta VALUES LESS THAN (0),
5084
PARTITION partb VALUES LESS THAN (5),
5085
PARTITION partc VALUES LESS THAN (10),
5086
PARTITION partd VALUES LESS THAN (10 + 5),
5087
PARTITION parte VALUES LESS THAN (20),
5088
PARTITION partf VALUES LESS THAN (2147483646));
5089
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
5090
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
5091
# Start usability test (inc/partition_check.inc)
5092
create_command
5093
SHOW CREATE TABLE t1;
5094
Table	Create Table
5095
t1	CREATE TABLE `t1` (
5096
  `f_int1` int(11) DEFAULT NULL,
5097
  `f_int2` int(11) DEFAULT NULL,
5098
  `f_char1` char(20) DEFAULT NULL,
5099
  `f_char2` char(20) DEFAULT NULL,
5100
  `f_charbig` varchar(1000) DEFAULT NULL
5101
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE ((f_int1 + f_int2) DIV 2) (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION parte VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
5102
5103
unified filelist
5104
$MYSQLTEST_VARDIR/master-data/test/t1.frm
5105
$MYSQLTEST_VARDIR/master-data/test/t1.par
5106
5107
# check prerequisites-1 success:    1
5108
# check COUNT(*) success:    1
5109
# check MIN/MAX(f_int1) success:    1
5110
# check MIN/MAX(f_int2) success:    1
5111
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
5112
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
5113
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
5114
WHERE f_int1 IN (2,3);
5115
# check prerequisites-3 success:    1
5116
DELETE FROM t1 WHERE f_charbig = 'delete me';
5117
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
5118
# check read via f_int1 success: 1
5119
# check read via f_int2 success: 1
5120
	
5121
# check multiple-1 success: 	1
5122
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
5123
	
5124
# check multiple-2 success: 	1
5125
INSERT INTO t1 SELECT * FROM t0_template
5126
WHERE MOD(f_int1,3) = 0;
5127
	
5128
# check multiple-3 success: 	1
5129
UPDATE t1 SET f_int1 = f_int1 + @max_row
5130
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
5131
AND @max_row_div2 + @max_row_div4;
5132
	
5133
# check multiple-4 success: 	1
5134
DELETE FROM t1
5135
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
5136
AND @max_row_div2 + @max_row_div4 + @max_row;
5137
	
5138
# check multiple-5 success: 	1
5139
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
5140
INSERT INTO t1
5141
SET f_int1 = @cur_value , f_int2 = @cur_value,
5142
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
5143
f_charbig = '#SINGLE#';
5144
	
5145
# check single-1 success: 	1
5146
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
5147
INSERT INTO t1
5148
SET f_int1 = @cur_value , f_int2 = @cur_value,
5149
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
5150
f_charbig = '#SINGLE#';
5151
	
5152
# check single-2 success: 	1
5153
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
5154
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
5155
UPDATE t1 SET f_int1 = @cur_value2
5156
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
5157
	
5158
# check single-3 success: 	1
5159
SET @cur_value1= -1;
5160
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
5161
UPDATE t1 SET f_int1 = @cur_value1
5162
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
5163
	
5164
# check single-4 success: 	1
5165
SELECT MAX(f_int1) INTO @cur_value FROM t1;
5166
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
5167
	
5168
# check single-5 success: 	1
5169
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
5170
	
5171
# check single-6 success: 	1
5172
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
5173
ERROR HY000: Table has no partition for value 2147483647
5174
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
5175
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
5176
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
5177
f_charbig = '#NULL#';
5178
INSERT INTO t1
5179
SET f_int1 = NULL , f_int2 = -@max_row,
5180
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
5181
f_charbig = '#NULL#';
5182
# check null success:    1
5183
	
5184
# check null-1 success: 	1
5185
UPDATE t1 SET f_int1 = -@max_row
5186
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
5187
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
5188
	
5189
# check null-2 success: 	1
5190
UPDATE t1 SET f_int1 = NULL
5191
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
5192
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
5193
	
5194
# check null-3 success: 	1
5195
DELETE FROM t1
5196
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
5197
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
5198
	
5199
# check null-4 success: 	1
5200
DELETE FROM t1
5201
WHERE f_int1 = 0 AND f_int2 = 0
5202
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
5203
AND f_charbig = '#NULL#';
5204
SET AUTOCOMMIT= 0;
5205
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
5206
SELECT f_int1, f_int1, '', '', 'was inserted'
5207
FROM t0_template source_tab
5208
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
5209
	
5210
# check transactions-1 success: 	1
5211
COMMIT WORK;
5212
	
5213
# check transactions-2 success: 	1
5214
ROLLBACK WORK;
5215
	
5216
# check transactions-3 success: 	1
5217
DELETE FROM t1 WHERE f_charbig = 'was inserted';
5218
COMMIT WORK;
5219
ROLLBACK WORK;
5220
	
5221
# check transactions-4 success: 	1
5222
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
5223
SELECT f_int1, f_int1, '', '', 'was inserted'
5224
FROM t0_template source_tab
5225
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
5226
	
5227
# check transactions-5 success: 	1
5228
ROLLBACK WORK;
5229
	
5230
# check transactions-6 success: 	1
5231
# INFO: Storage engine used for t1 seems to be transactional.
5232
COMMIT;
5233
	
5234
# check transactions-7 success: 	1
5235
DELETE FROM t1 WHERE f_charbig = 'was inserted';
5236
COMMIT WORK;
5237
SET @@session.sql_mode = 'traditional';
5238
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
5239
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
5240
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
5241
'', '', 'was inserted' FROM t0_template
5242
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
5243
ERROR 22012: Division by 0
5244
COMMIT;
5245
	
5246
# check transactions-8 success: 	1
5247
# INFO: Storage engine used for t1 seems to be able to revert
5248
#       changes made by the failing statement.
5249
SET @@session.sql_mode = '';
5250
SET AUTOCOMMIT= 1;
5251
DELETE FROM t1 WHERE f_charbig = 'was inserted';
5252
COMMIT WORK;
5253
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
5254
	
5255
# check special-1 success: 	1
5256
UPDATE t1 SET f_charbig = '';
5257
	
5258
# check special-2 success: 	1
5259
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
5260
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
5261
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
5262
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5263
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5264
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5265
'just inserted' FROM t0_template
5266
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5267
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
5268
BEGIN
5269
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5270
f_charbig = 'updated by trigger'
5271
      WHERE f_int1 = new.f_int1;
5272
END|
5273
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5274
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
5275
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5276
	
5277
# check trigger-1 success: 	1
5278
DROP TRIGGER trg_1;
5279
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5280
f_int2 = CAST(f_char1 AS SIGNED INT),
5281
f_charbig = 'just inserted'
5282
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5283
DELETE FROM t0_aux
5284
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5285
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5286
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5287
'just inserted' FROM t0_template
5288
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5289
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
5290
BEGIN
5291
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5292
f_charbig = 'updated by trigger'
5293
      WHERE f_int1 = new.f_int1;
5294
END|
5295
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5296
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
5297
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5298
	
5299
# check trigger-2 success: 	1
5300
DROP TRIGGER trg_1;
5301
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5302
f_int2 = CAST(f_char1 AS SIGNED INT),
5303
f_charbig = 'just inserted'
5304
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5305
DELETE FROM t0_aux
5306
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5307
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5308
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5309
'just inserted' FROM t0_template
5310
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5311
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
5312
BEGIN
5313
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5314
f_charbig = 'updated by trigger'
5315
      WHERE f_int1 = new.f_int1;
5316
END|
5317
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
5318
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
5319
	
5320
# check trigger-3 success: 	1
5321
DROP TRIGGER trg_1;
5322
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5323
f_int2 = CAST(f_char1 AS SIGNED INT),
5324
f_charbig = 'just inserted'
5325
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5326
DELETE FROM t0_aux
5327
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5328
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5329
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5330
'just inserted' FROM t0_template
5331
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5332
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
5333
BEGIN
5334
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5335
f_charbig = 'updated by trigger'
5336
      WHERE f_int1 = - old.f_int1;
5337
END|
5338
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
5339
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
5340
	
5341
# check trigger-4 success: 	1
5342
DROP TRIGGER trg_1;
5343
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5344
f_int2 = CAST(f_char1 AS SIGNED INT),
5345
f_charbig = 'just inserted'
5346
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5347
DELETE FROM t0_aux
5348
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5349
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5350
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5351
'just inserted' FROM t0_template
5352
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5353
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
5354
BEGIN
5355
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5356
f_charbig = 'updated by trigger'
5357
      WHERE f_int1 = new.f_int1;
5358
END|
5359
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
5360
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
5361
	
5362
# check trigger-5 success: 	1
5363
DROP TRIGGER trg_1;
5364
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5365
f_int2 = CAST(f_char1 AS SIGNED INT),
5366
f_charbig = 'just inserted'
5367
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5368
DELETE FROM t0_aux
5369
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5370
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5371
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5372
'just inserted' FROM t0_template
5373
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5374
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
5375
BEGIN
5376
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5377
f_charbig = 'updated by trigger'
5378
      WHERE f_int1 = - old.f_int1;
5379
END|
5380
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
5381
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
5382
	
5383
# check trigger-6 success: 	1
5384
DROP TRIGGER trg_1;
5385
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5386
f_int2 = CAST(f_char1 AS SIGNED INT),
5387
f_charbig = 'just inserted'
5388
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5389
DELETE FROM t0_aux
5390
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5391
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5392
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5393
'just inserted' FROM t0_template
5394
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5395
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
5396
BEGIN
5397
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5398
f_charbig = 'updated by trigger'
5399
      WHERE f_int1 = - old.f_int1;
5400
END|
5401
DELETE FROM t0_aux
5402
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
5403
	
5404
# check trigger-7 success: 	1
5405
DROP TRIGGER trg_1;
5406
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5407
f_int2 = CAST(f_char1 AS SIGNED INT),
5408
f_charbig = 'just inserted'
5409
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5410
DELETE FROM t0_aux
5411
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5412
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5413
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5414
'just inserted' FROM t0_template
5415
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5416
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
5417
BEGIN
5418
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5419
f_charbig = 'updated by trigger'
5420
      WHERE f_int1 = - old.f_int1;
5421
END|
5422
DELETE FROM t0_aux
5423
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
5424
	
5425
# check trigger-8 success: 	1
5426
DROP TRIGGER trg_1;
5427
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5428
f_int2 = CAST(f_char1 AS SIGNED INT),
5429
f_charbig = 'just inserted'
5430
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5431
DELETE FROM t0_aux
5432
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5433
DELETE FROM t1
5434
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5435
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
5436
BEGIN
5437
SET new.f_int1 = old.f_int1 + @max_row,
5438
new.f_int2 = old.f_int2 - @max_row,
5439
new.f_charbig = '####updated per update trigger####';
5440
END|
5441
UPDATE t1
5442
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
5443
f_charbig = '####updated per update statement itself####';
5444
	
5445
# check trigger-9 success: 	1
5446
DROP TRIGGER trg_2;
5447
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5448
f_int2 = CAST(f_char1 AS SIGNED INT),
5449
f_charbig = CONCAT('===',f_char1,'===');
5450
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
5451
BEGIN
5452
SET new.f_int1 = new.f_int1 + @max_row,
5453
new.f_int2 = new.f_int2 - @max_row,
5454
new.f_charbig = '####updated per update trigger####';
5455
END|
5456
UPDATE t1
5457
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
5458
f_charbig = '####updated per update statement itself####';
5459
	
5460
# check trigger-10 success: 	1
5461
DROP TRIGGER trg_2;
5462
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5463
f_int2 = CAST(f_char1 AS SIGNED INT),
5464
f_charbig = CONCAT('===',f_char1,'===');
5465
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
5466
BEGIN
5467
SET new.f_int1 = @my_max1 + @counter,
5468
new.f_int2 = @my_min2 - @counter,
5469
new.f_charbig = '####updated per insert trigger####';
5470
SET @counter = @counter + 1;
5471
END|
5472
SET @counter = 1;
5473
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
5474
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
5475
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
5476
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
5477
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
5478
ORDER BY f_int1;
5479
DROP TRIGGER trg_3;
5480
	
5481
# check trigger-11 success: 	1
5482
DELETE FROM t1
5483
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
5484
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
5485
AND f_charbig = '####updated per insert trigger####';
5486
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
5487
BEGIN
5488
SET new.f_int1 = @my_max1 + @counter,
5489
new.f_int2 = @my_min2 - @counter,
5490
new.f_charbig = '####updated per insert trigger####';
5491
SET @counter = @counter + 1;
5492
END|
5493
SET @counter = 1;
5494
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
5495
INSERT INTO t1 (f_char1, f_char2, f_charbig)
5496
SELECT CAST(f_int1 AS CHAR),
5497
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
5498
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
5499
ORDER BY f_int1;
5500
DROP TRIGGER trg_3;
5501
	
5502
# check trigger-12 success: 	1
5503
DELETE FROM t1
5504
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
5505
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
5506
AND f_charbig = '####updated per insert trigger####';
5507
ANALYZE  TABLE t1;
5508
Table	Op	Msg_type	Msg_text
5509
test.t1	analyze	note	The storage engine for the table doesn't support analyze
5510
CHECK    TABLE t1 EXTENDED;
5511
Table	Op	Msg_type	Msg_text
5512
test.t1	check	note	The storage engine for the table doesn't support check
5513
CHECKSUM TABLE t1 EXTENDED;
5514
Table	Checksum
5515
test.t1	<some_value>
5516
OPTIMIZE TABLE t1;
5517
Table	Op	Msg_type	Msg_text
5518
test.t1	optimize	note	The storage engine for the table doesn't support optimize
5519
# check layout success:    1
5520
REPAIR   TABLE t1 EXTENDED;
5521
Table	Op	Msg_type	Msg_text
5522
test.t1	repair	note	The storage engine for the table doesn't support repair
5523
# check layout success:    1
5524
TRUNCATE t1;
5525
	
5526
# check TRUNCATE success: 	1
5527
# check layout success:    1
5528
# End usability test (inc/partition_check.inc)
5529
DROP TABLE t1;
5530
CREATE TABLE t1 (
5531
f_int1 INTEGER,
5532
f_int2 INTEGER,
5533
f_char1 CHAR(20),
5534
f_char2 CHAR(20),
5535
f_charbig VARCHAR(1000)
5536
5537
)
5538
PARTITION BY RANGE(f_int1) SUBPARTITION BY HASH(f_int2) SUBPARTITIONS 2
5539
(PARTITION parta VALUES LESS THAN (0),
5540
PARTITION partb VALUES LESS THAN (5),
5541
PARTITION partc VALUES LESS THAN (10),
5542
PARTITION partd VALUES LESS THAN (2147483646));
5543
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
5544
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
5545
# Start usability test (inc/partition_check.inc)
5546
create_command
5547
SHOW CREATE TABLE t1;
5548
Table	Create Table
5549
t1	CREATE TABLE `t1` (
5550
  `f_int1` int(11) DEFAULT NULL,
5551
  `f_int2` int(11) DEFAULT NULL,
5552
  `f_char1` char(20) DEFAULT NULL,
5553
  `f_char2` char(20) DEFAULT NULL,
5554
  `f_charbig` varchar(1000) DEFAULT NULL
5555
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) SUBPARTITION BY HASH (f_int2) SUBPARTITIONS 2 (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
5556
5557
unified filelist
5558
$MYSQLTEST_VARDIR/master-data/test/t1.frm
5559
$MYSQLTEST_VARDIR/master-data/test/t1.par
5560
5561
# check prerequisites-1 success:    1
5562
# check COUNT(*) success:    1
5563
# check MIN/MAX(f_int1) success:    1
5564
# check MIN/MAX(f_int2) success:    1
5565
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
5566
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
5567
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
5568
WHERE f_int1 IN (2,3);
5569
# check prerequisites-3 success:    1
5570
DELETE FROM t1 WHERE f_charbig = 'delete me';
5571
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
5572
# check read via f_int1 success: 1
5573
# check read via f_int2 success: 1
5574
	
5575
# check multiple-1 success: 	1
5576
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
5577
	
5578
# check multiple-2 success: 	1
5579
INSERT INTO t1 SELECT * FROM t0_template
5580
WHERE MOD(f_int1,3) = 0;
5581
	
5582
# check multiple-3 success: 	1
5583
UPDATE t1 SET f_int1 = f_int1 + @max_row
5584
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
5585
AND @max_row_div2 + @max_row_div4;
5586
	
5587
# check multiple-4 success: 	1
5588
DELETE FROM t1
5589
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
5590
AND @max_row_div2 + @max_row_div4 + @max_row;
5591
	
5592
# check multiple-5 success: 	1
5593
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
5594
INSERT INTO t1
5595
SET f_int1 = @cur_value , f_int2 = @cur_value,
5596
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
5597
f_charbig = '#SINGLE#';
5598
	
5599
# check single-1 success: 	1
5600
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
5601
INSERT INTO t1
5602
SET f_int1 = @cur_value , f_int2 = @cur_value,
5603
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
5604
f_charbig = '#SINGLE#';
5605
	
5606
# check single-2 success: 	1
5607
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
5608
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
5609
UPDATE t1 SET f_int1 = @cur_value2
5610
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
5611
	
5612
# check single-3 success: 	1
5613
SET @cur_value1= -1;
5614
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
5615
UPDATE t1 SET f_int1 = @cur_value1
5616
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
5617
	
5618
# check single-4 success: 	1
5619
SELECT MAX(f_int1) INTO @cur_value FROM t1;
5620
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
5621
	
5622
# check single-5 success: 	1
5623
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
5624
	
5625
# check single-6 success: 	1
5626
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
5627
ERROR HY000: Table has no partition for value 2147483647
5628
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
5629
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
5630
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
5631
f_charbig = '#NULL#';
5632
INSERT INTO t1
5633
SET f_int1 = NULL , f_int2 = -@max_row,
5634
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
5635
f_charbig = '#NULL#';
5636
# check null success:    1
5637
	
5638
# check null-1 success: 	1
5639
UPDATE t1 SET f_int1 = -@max_row
5640
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
5641
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
5642
	
5643
# check null-2 success: 	1
5644
UPDATE t1 SET f_int1 = NULL
5645
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
5646
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
5647
	
5648
# check null-3 success: 	1
5649
DELETE FROM t1
5650
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
5651
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
5652
	
5653
# check null-4 success: 	1
5654
DELETE FROM t1
5655
WHERE f_int1 = 0 AND f_int2 = 0
5656
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
5657
AND f_charbig = '#NULL#';
5658
SET AUTOCOMMIT= 0;
5659
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
5660
SELECT f_int1, f_int1, '', '', 'was inserted'
5661
FROM t0_template source_tab
5662
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
5663
	
5664
# check transactions-1 success: 	1
5665
COMMIT WORK;
5666
	
5667
# check transactions-2 success: 	1
5668
ROLLBACK WORK;
5669
	
5670
# check transactions-3 success: 	1
5671
DELETE FROM t1 WHERE f_charbig = 'was inserted';
5672
COMMIT WORK;
5673
ROLLBACK WORK;
5674
	
5675
# check transactions-4 success: 	1
5676
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
5677
SELECT f_int1, f_int1, '', '', 'was inserted'
5678
FROM t0_template source_tab
5679
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
5680
	
5681
# check transactions-5 success: 	1
5682
ROLLBACK WORK;
5683
	
5684
# check transactions-6 success: 	1
5685
# INFO: Storage engine used for t1 seems to be transactional.
5686
COMMIT;
5687
	
5688
# check transactions-7 success: 	1
5689
DELETE FROM t1 WHERE f_charbig = 'was inserted';
5690
COMMIT WORK;
5691
SET @@session.sql_mode = 'traditional';
5692
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
5693
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
5694
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
5695
'', '', 'was inserted' FROM t0_template
5696
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
5697
ERROR 22012: Division by 0
5698
COMMIT;
5699
	
5700
# check transactions-8 success: 	1
5701
# INFO: Storage engine used for t1 seems to be able to revert
5702
#       changes made by the failing statement.
5703
SET @@session.sql_mode = '';
5704
SET AUTOCOMMIT= 1;
5705
DELETE FROM t1 WHERE f_charbig = 'was inserted';
5706
COMMIT WORK;
5707
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
5708
	
5709
# check special-1 success: 	1
5710
UPDATE t1 SET f_charbig = '';
5711
	
5712
# check special-2 success: 	1
5713
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
5714
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
5715
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
5716
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5717
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5718
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5719
'just inserted' FROM t0_template
5720
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5721
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
5722
BEGIN
5723
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5724
f_charbig = 'updated by trigger'
5725
      WHERE f_int1 = new.f_int1;
5726
END|
5727
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5728
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
5729
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5730
	
5731
# check trigger-1 success: 	1
5732
DROP TRIGGER trg_1;
5733
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5734
f_int2 = CAST(f_char1 AS SIGNED INT),
5735
f_charbig = 'just inserted'
5736
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5737
DELETE FROM t0_aux
5738
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5739
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5740
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5741
'just inserted' FROM t0_template
5742
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5743
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
5744
BEGIN
5745
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5746
f_charbig = 'updated by trigger'
5747
      WHERE f_int1 = new.f_int1;
5748
END|
5749
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5750
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
5751
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5752
	
5753
# check trigger-2 success: 	1
5754
DROP TRIGGER trg_1;
5755
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5756
f_int2 = CAST(f_char1 AS SIGNED INT),
5757
f_charbig = 'just inserted'
5758
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5759
DELETE FROM t0_aux
5760
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5761
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5762
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5763
'just inserted' FROM t0_template
5764
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5765
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
5766
BEGIN
5767
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5768
f_charbig = 'updated by trigger'
5769
      WHERE f_int1 = new.f_int1;
5770
END|
5771
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
5772
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
5773
	
5774
# check trigger-3 success: 	1
5775
DROP TRIGGER trg_1;
5776
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5777
f_int2 = CAST(f_char1 AS SIGNED INT),
5778
f_charbig = 'just inserted'
5779
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5780
DELETE FROM t0_aux
5781
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5782
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5783
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5784
'just inserted' FROM t0_template
5785
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5786
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
5787
BEGIN
5788
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5789
f_charbig = 'updated by trigger'
5790
      WHERE f_int1 = - old.f_int1;
5791
END|
5792
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
5793
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
5794
	
5795
# check trigger-4 success: 	1
5796
DROP TRIGGER trg_1;
5797
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5798
f_int2 = CAST(f_char1 AS SIGNED INT),
5799
f_charbig = 'just inserted'
5800
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5801
DELETE FROM t0_aux
5802
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5803
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5804
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5805
'just inserted' FROM t0_template
5806
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5807
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
5808
BEGIN
5809
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5810
f_charbig = 'updated by trigger'
5811
      WHERE f_int1 = new.f_int1;
5812
END|
5813
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
5814
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
5815
	
5816
# check trigger-5 success: 	1
5817
DROP TRIGGER trg_1;
5818
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5819
f_int2 = CAST(f_char1 AS SIGNED INT),
5820
f_charbig = 'just inserted'
5821
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5822
DELETE FROM t0_aux
5823
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5824
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5825
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5826
'just inserted' FROM t0_template
5827
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5828
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
5829
BEGIN
5830
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5831
f_charbig = 'updated by trigger'
5832
      WHERE f_int1 = - old.f_int1;
5833
END|
5834
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
5835
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
5836
	
5837
# check trigger-6 success: 	1
5838
DROP TRIGGER trg_1;
5839
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5840
f_int2 = CAST(f_char1 AS SIGNED INT),
5841
f_charbig = 'just inserted'
5842
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5843
DELETE FROM t0_aux
5844
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5845
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5846
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5847
'just inserted' FROM t0_template
5848
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5849
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
5850
BEGIN
5851
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5852
f_charbig = 'updated by trigger'
5853
      WHERE f_int1 = - old.f_int1;
5854
END|
5855
DELETE FROM t0_aux
5856
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
5857
	
5858
# check trigger-7 success: 	1
5859
DROP TRIGGER trg_1;
5860
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5861
f_int2 = CAST(f_char1 AS SIGNED INT),
5862
f_charbig = 'just inserted'
5863
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5864
DELETE FROM t0_aux
5865
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5866
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
5867
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
5868
'just inserted' FROM t0_template
5869
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5870
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
5871
BEGIN
5872
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
5873
f_charbig = 'updated by trigger'
5874
      WHERE f_int1 = - old.f_int1;
5875
END|
5876
DELETE FROM t0_aux
5877
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
5878
	
5879
# check trigger-8 success: 	1
5880
DROP TRIGGER trg_1;
5881
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5882
f_int2 = CAST(f_char1 AS SIGNED INT),
5883
f_charbig = 'just inserted'
5884
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
5885
DELETE FROM t0_aux
5886
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5887
DELETE FROM t1
5888
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
5889
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
5890
BEGIN
5891
SET new.f_int1 = old.f_int1 + @max_row,
5892
new.f_int2 = old.f_int2 - @max_row,
5893
new.f_charbig = '####updated per update trigger####';
5894
END|
5895
UPDATE t1
5896
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
5897
f_charbig = '####updated per update statement itself####';
5898
	
5899
# check trigger-9 success: 	1
5900
DROP TRIGGER trg_2;
5901
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5902
f_int2 = CAST(f_char1 AS SIGNED INT),
5903
f_charbig = CONCAT('===',f_char1,'===');
5904
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
5905
BEGIN
5906
SET new.f_int1 = new.f_int1 + @max_row,
5907
new.f_int2 = new.f_int2 - @max_row,
5908
new.f_charbig = '####updated per update trigger####';
5909
END|
5910
UPDATE t1
5911
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
5912
f_charbig = '####updated per update statement itself####';
5913
	
5914
# check trigger-10 success: 	1
5915
DROP TRIGGER trg_2;
5916
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
5917
f_int2 = CAST(f_char1 AS SIGNED INT),
5918
f_charbig = CONCAT('===',f_char1,'===');
5919
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
5920
BEGIN
5921
SET new.f_int1 = @my_max1 + @counter,
5922
new.f_int2 = @my_min2 - @counter,
5923
new.f_charbig = '####updated per insert trigger####';
5924
SET @counter = @counter + 1;
5925
END|
5926
SET @counter = 1;
5927
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
5928
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
5929
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
5930
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
5931
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
5932
ORDER BY f_int1;
5933
DROP TRIGGER trg_3;
5934
	
5935
# check trigger-11 success: 	1
5936
DELETE FROM t1
5937
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
5938
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
5939
AND f_charbig = '####updated per insert trigger####';
5940
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
5941
BEGIN
5942
SET new.f_int1 = @my_max1 + @counter,
5943
new.f_int2 = @my_min2 - @counter,
5944
new.f_charbig = '####updated per insert trigger####';
5945
SET @counter = @counter + 1;
5946
END|
5947
SET @counter = 1;
5948
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
5949
INSERT INTO t1 (f_char1, f_char2, f_charbig)
5950
SELECT CAST(f_int1 AS CHAR),
5951
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
5952
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
5953
ORDER BY f_int1;
5954
DROP TRIGGER trg_3;
5955
	
5956
# check trigger-12 success: 	1
5957
DELETE FROM t1
5958
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
5959
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
5960
AND f_charbig = '####updated per insert trigger####';
5961
ANALYZE  TABLE t1;
5962
Table	Op	Msg_type	Msg_text
5963
test.t1	analyze	note	The storage engine for the table doesn't support analyze
5964
CHECK    TABLE t1 EXTENDED;
5965
Table	Op	Msg_type	Msg_text
5966
test.t1	check	note	The storage engine for the table doesn't support check
5967
CHECKSUM TABLE t1 EXTENDED;
5968
Table	Checksum
5969
test.t1	<some_value>
5970
OPTIMIZE TABLE t1;
5971
Table	Op	Msg_type	Msg_text
5972
test.t1	optimize	note	The storage engine for the table doesn't support optimize
5973
# check layout success:    1
5974
REPAIR   TABLE t1 EXTENDED;
5975
Table	Op	Msg_type	Msg_text
5976
test.t1	repair	note	The storage engine for the table doesn't support repair
5977
# check layout success:    1
5978
TRUNCATE t1;
5979
	
5980
# check TRUNCATE success: 	1
5981
# check layout success:    1
5982
# End usability test (inc/partition_check.inc)
5983
DROP TABLE t1;
5984
CREATE TABLE t1 (
5985
f_int1 INTEGER,
5986
f_int2 INTEGER,
5987
f_char1 CHAR(20),
5988
f_char2 CHAR(20),
5989
f_charbig VARCHAR(1000)
5990
5991
)
5992
PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int2)
5993
(PARTITION part1 VALUES LESS THAN (0)
5994
(SUBPARTITION subpart11, SUBPARTITION subpart12),
5995
PARTITION part2 VALUES LESS THAN (5)
5996
(SUBPARTITION subpart21, SUBPARTITION subpart22),
5997
PARTITION part3 VALUES LESS THAN (10)
5998
(SUBPARTITION subpart31, SUBPARTITION subpart32),
5999
PARTITION part4 VALUES LESS THAN (2147483646)
6000
(SUBPARTITION subpart41, SUBPARTITION subpart42));
6001
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
6002
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
6003
# Start usability test (inc/partition_check.inc)
6004
create_command
6005
SHOW CREATE TABLE t1;
6006
Table	Create Table
6007
t1	CREATE TABLE `t1` (
6008
  `f_int1` int(11) DEFAULT NULL,
6009
  `f_int2` int(11) DEFAULT NULL,
6010
  `f_char1` char(20) DEFAULT NULL,
6011
  `f_char2` char(20) DEFAULT NULL,
6012
  `f_charbig` varchar(1000) DEFAULT NULL
6013
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), PARTITION part2 VALUES LESS THAN (5) (SUBPARTITION subpart21 ENGINE = InnoDB, SUBPARTITION subpart22 ENGINE = InnoDB), PARTITION part3 VALUES LESS THAN (10) (SUBPARTITION subpart31 ENGINE = InnoDB, SUBPARTITION subpart32 ENGINE = InnoDB), PARTITION part4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41 ENGINE = InnoDB, SUBPARTITION subpart42 ENGINE = InnoDB)) */
6014
6015
unified filelist
6016
$MYSQLTEST_VARDIR/master-data/test/t1.frm
6017
$MYSQLTEST_VARDIR/master-data/test/t1.par
6018
6019
# check prerequisites-1 success:    1
6020
# check COUNT(*) success:    1
6021
# check MIN/MAX(f_int1) success:    1
6022
# check MIN/MAX(f_int2) success:    1
6023
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
6024
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
6025
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
6026
WHERE f_int1 IN (2,3);
6027
# check prerequisites-3 success:    1
6028
DELETE FROM t1 WHERE f_charbig = 'delete me';
6029
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
6030
# check read via f_int1 success: 1
6031
# check read via f_int2 success: 1
6032
	
6033
# check multiple-1 success: 	1
6034
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
6035
	
6036
# check multiple-2 success: 	1
6037
INSERT INTO t1 SELECT * FROM t0_template
6038
WHERE MOD(f_int1,3) = 0;
6039
	
6040
# check multiple-3 success: 	1
6041
UPDATE t1 SET f_int1 = f_int1 + @max_row
6042
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
6043
AND @max_row_div2 + @max_row_div4;
6044
	
6045
# check multiple-4 success: 	1
6046
DELETE FROM t1
6047
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
6048
AND @max_row_div2 + @max_row_div4 + @max_row;
6049
	
6050
# check multiple-5 success: 	1
6051
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
6052
INSERT INTO t1
6053
SET f_int1 = @cur_value , f_int2 = @cur_value,
6054
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
6055
f_charbig = '#SINGLE#';
6056
	
6057
# check single-1 success: 	1
6058
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
6059
INSERT INTO t1
6060
SET f_int1 = @cur_value , f_int2 = @cur_value,
6061
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
6062
f_charbig = '#SINGLE#';
6063
	
6064
# check single-2 success: 	1
6065
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
6066
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
6067
UPDATE t1 SET f_int1 = @cur_value2
6068
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
6069
	
6070
# check single-3 success: 	1
6071
SET @cur_value1= -1;
6072
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
6073
UPDATE t1 SET f_int1 = @cur_value1
6074
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
6075
	
6076
# check single-4 success: 	1
6077
SELECT MAX(f_int1) INTO @cur_value FROM t1;
6078
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
6079
	
6080
# check single-5 success: 	1
6081
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
6082
	
6083
# check single-6 success: 	1
6084
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
6085
ERROR HY000: Table has no partition for value 2147483647
6086
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
6087
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
6088
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
6089
f_charbig = '#NULL#';
6090
INSERT INTO t1
6091
SET f_int1 = NULL , f_int2 = -@max_row,
6092
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
6093
f_charbig = '#NULL#';
6094
# check null success:    1
6095
	
6096
# check null-1 success: 	1
6097
UPDATE t1 SET f_int1 = -@max_row
6098
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
6099
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
6100
	
6101
# check null-2 success: 	1
6102
UPDATE t1 SET f_int1 = NULL
6103
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
6104
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
6105
	
6106
# check null-3 success: 	1
6107
DELETE FROM t1
6108
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
6109
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
6110
	
6111
# check null-4 success: 	1
6112
DELETE FROM t1
6113
WHERE f_int1 = 0 AND f_int2 = 0
6114
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
6115
AND f_charbig = '#NULL#';
6116
SET AUTOCOMMIT= 0;
6117
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
6118
SELECT f_int1, f_int1, '', '', 'was inserted'
6119
FROM t0_template source_tab
6120
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
6121
	
6122
# check transactions-1 success: 	1
6123
COMMIT WORK;
6124
	
6125
# check transactions-2 success: 	1
6126
ROLLBACK WORK;
6127
	
6128
# check transactions-3 success: 	1
6129
DELETE FROM t1 WHERE f_charbig = 'was inserted';
6130
COMMIT WORK;
6131
ROLLBACK WORK;
6132
	
6133
# check transactions-4 success: 	1
6134
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
6135
SELECT f_int1, f_int1, '', '', 'was inserted'
6136
FROM t0_template source_tab
6137
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
6138
	
6139
# check transactions-5 success: 	1
6140
ROLLBACK WORK;
6141
	
6142
# check transactions-6 success: 	1
6143
# INFO: Storage engine used for t1 seems to be transactional.
6144
COMMIT;
6145
	
6146
# check transactions-7 success: 	1
6147
DELETE FROM t1 WHERE f_charbig = 'was inserted';
6148
COMMIT WORK;
6149
SET @@session.sql_mode = 'traditional';
6150
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
6151
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
6152
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
6153
'', '', 'was inserted' FROM t0_template
6154
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
6155
ERROR 22012: Division by 0
6156
COMMIT;
6157
	
6158
# check transactions-8 success: 	1
6159
# INFO: Storage engine used for t1 seems to be able to revert
6160
#       changes made by the failing statement.
6161
SET @@session.sql_mode = '';
6162
SET AUTOCOMMIT= 1;
6163
DELETE FROM t1 WHERE f_charbig = 'was inserted';
6164
COMMIT WORK;
6165
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
6166
	
6167
# check special-1 success: 	1
6168
UPDATE t1 SET f_charbig = '';
6169
	
6170
# check special-2 success: 	1
6171
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
6172
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
6173
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
6174
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6175
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6176
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6177
'just inserted' FROM t0_template
6178
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6179
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
6180
BEGIN
6181
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6182
f_charbig = 'updated by trigger'
6183
      WHERE f_int1 = new.f_int1;
6184
END|
6185
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6186
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
6187
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6188
	
6189
# check trigger-1 success: 	1
6190
DROP TRIGGER trg_1;
6191
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6192
f_int2 = CAST(f_char1 AS SIGNED INT),
6193
f_charbig = 'just inserted'
6194
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6195
DELETE FROM t0_aux
6196
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6197
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6198
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6199
'just inserted' FROM t0_template
6200
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6201
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
6202
BEGIN
6203
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6204
f_charbig = 'updated by trigger'
6205
      WHERE f_int1 = new.f_int1;
6206
END|
6207
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6208
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
6209
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6210
	
6211
# check trigger-2 success: 	1
6212
DROP TRIGGER trg_1;
6213
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6214
f_int2 = CAST(f_char1 AS SIGNED INT),
6215
f_charbig = 'just inserted'
6216
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6217
DELETE FROM t0_aux
6218
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6219
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6220
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6221
'just inserted' FROM t0_template
6222
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6223
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
6224
BEGIN
6225
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6226
f_charbig = 'updated by trigger'
6227
      WHERE f_int1 = new.f_int1;
6228
END|
6229
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
6230
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
6231
	
6232
# check trigger-3 success: 	1
6233
DROP TRIGGER trg_1;
6234
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6235
f_int2 = CAST(f_char1 AS SIGNED INT),
6236
f_charbig = 'just inserted'
6237
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6238
DELETE FROM t0_aux
6239
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6240
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6241
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6242
'just inserted' FROM t0_template
6243
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6244
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
6245
BEGIN
6246
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6247
f_charbig = 'updated by trigger'
6248
      WHERE f_int1 = - old.f_int1;
6249
END|
6250
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
6251
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
6252
	
6253
# check trigger-4 success: 	1
6254
DROP TRIGGER trg_1;
6255
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6256
f_int2 = CAST(f_char1 AS SIGNED INT),
6257
f_charbig = 'just inserted'
6258
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6259
DELETE FROM t0_aux
6260
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6261
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6262
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6263
'just inserted' FROM t0_template
6264
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6265
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
6266
BEGIN
6267
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6268
f_charbig = 'updated by trigger'
6269
      WHERE f_int1 = new.f_int1;
6270
END|
6271
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
6272
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
6273
	
6274
# check trigger-5 success: 	1
6275
DROP TRIGGER trg_1;
6276
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6277
f_int2 = CAST(f_char1 AS SIGNED INT),
6278
f_charbig = 'just inserted'
6279
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6280
DELETE FROM t0_aux
6281
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6282
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6283
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6284
'just inserted' FROM t0_template
6285
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6286
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
6287
BEGIN
6288
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6289
f_charbig = 'updated by trigger'
6290
      WHERE f_int1 = - old.f_int1;
6291
END|
6292
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
6293
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
6294
	
6295
# check trigger-6 success: 	1
6296
DROP TRIGGER trg_1;
6297
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6298
f_int2 = CAST(f_char1 AS SIGNED INT),
6299
f_charbig = 'just inserted'
6300
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6301
DELETE FROM t0_aux
6302
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6303
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6304
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6305
'just inserted' FROM t0_template
6306
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6307
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
6308
BEGIN
6309
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6310
f_charbig = 'updated by trigger'
6311
      WHERE f_int1 = - old.f_int1;
6312
END|
6313
DELETE FROM t0_aux
6314
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
6315
	
6316
# check trigger-7 success: 	1
6317
DROP TRIGGER trg_1;
6318
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6319
f_int2 = CAST(f_char1 AS SIGNED INT),
6320
f_charbig = 'just inserted'
6321
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6322
DELETE FROM t0_aux
6323
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6324
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6325
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6326
'just inserted' FROM t0_template
6327
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6328
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
6329
BEGIN
6330
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6331
f_charbig = 'updated by trigger'
6332
      WHERE f_int1 = - old.f_int1;
6333
END|
6334
DELETE FROM t0_aux
6335
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
6336
	
6337
# check trigger-8 success: 	1
6338
DROP TRIGGER trg_1;
6339
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6340
f_int2 = CAST(f_char1 AS SIGNED INT),
6341
f_charbig = 'just inserted'
6342
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6343
DELETE FROM t0_aux
6344
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6345
DELETE FROM t1
6346
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6347
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
6348
BEGIN
6349
SET new.f_int1 = old.f_int1 + @max_row,
6350
new.f_int2 = old.f_int2 - @max_row,
6351
new.f_charbig = '####updated per update trigger####';
6352
END|
6353
UPDATE t1
6354
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
6355
f_charbig = '####updated per update statement itself####';
6356
	
6357
# check trigger-9 success: 	1
6358
DROP TRIGGER trg_2;
6359
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6360
f_int2 = CAST(f_char1 AS SIGNED INT),
6361
f_charbig = CONCAT('===',f_char1,'===');
6362
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
6363
BEGIN
6364
SET new.f_int1 = new.f_int1 + @max_row,
6365
new.f_int2 = new.f_int2 - @max_row,
6366
new.f_charbig = '####updated per update trigger####';
6367
END|
6368
UPDATE t1
6369
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
6370
f_charbig = '####updated per update statement itself####';
6371
	
6372
# check trigger-10 success: 	1
6373
DROP TRIGGER trg_2;
6374
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6375
f_int2 = CAST(f_char1 AS SIGNED INT),
6376
f_charbig = CONCAT('===',f_char1,'===');
6377
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
6378
BEGIN
6379
SET new.f_int1 = @my_max1 + @counter,
6380
new.f_int2 = @my_min2 - @counter,
6381
new.f_charbig = '####updated per insert trigger####';
6382
SET @counter = @counter + 1;
6383
END|
6384
SET @counter = 1;
6385
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
6386
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
6387
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
6388
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
6389
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
6390
ORDER BY f_int1;
6391
DROP TRIGGER trg_3;
6392
	
6393
# check trigger-11 success: 	1
6394
DELETE FROM t1
6395
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
6396
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
6397
AND f_charbig = '####updated per insert trigger####';
6398
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
6399
BEGIN
6400
SET new.f_int1 = @my_max1 + @counter,
6401
new.f_int2 = @my_min2 - @counter,
6402
new.f_charbig = '####updated per insert trigger####';
6403
SET @counter = @counter + 1;
6404
END|
6405
SET @counter = 1;
6406
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
6407
INSERT INTO t1 (f_char1, f_char2, f_charbig)
6408
SELECT CAST(f_int1 AS CHAR),
6409
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
6410
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
6411
ORDER BY f_int1;
6412
DROP TRIGGER trg_3;
6413
	
6414
# check trigger-12 success: 	1
6415
DELETE FROM t1
6416
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
6417
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
6418
AND f_charbig = '####updated per insert trigger####';
6419
ANALYZE  TABLE t1;
6420
Table	Op	Msg_type	Msg_text
6421
test.t1	analyze	note	The storage engine for the table doesn't support analyze
6422
CHECK    TABLE t1 EXTENDED;
6423
Table	Op	Msg_type	Msg_text
6424
test.t1	check	note	The storage engine for the table doesn't support check
6425
CHECKSUM TABLE t1 EXTENDED;
6426
Table	Checksum
6427
test.t1	<some_value>
6428
OPTIMIZE TABLE t1;
6429
Table	Op	Msg_type	Msg_text
6430
test.t1	optimize	note	The storage engine for the table doesn't support optimize
6431
# check layout success:    1
6432
REPAIR   TABLE t1 EXTENDED;
6433
Table	Op	Msg_type	Msg_text
6434
test.t1	repair	note	The storage engine for the table doesn't support repair
6435
# check layout success:    1
6436
TRUNCATE t1;
6437
	
6438
# check TRUNCATE success: 	1
6439
# check layout success:    1
6440
# End usability test (inc/partition_check.inc)
6441
DROP TABLE t1;
6442
CREATE TABLE t1 (
6443
f_int1 INTEGER,
6444
f_int2 INTEGER,
6445
f_char1 CHAR(20),
6446
f_char2 CHAR(20),
6447
f_charbig VARCHAR(1000)
6448
6449
)
6450
PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int2 + 1)
6451
(PARTITION part1 VALUES IN (0)
6452
(SUBPARTITION sp11, SUBPARTITION sp12),
6453
PARTITION part2 VALUES IN (1)
6454
(SUBPARTITION sp21, SUBPARTITION sp22),
6455
PARTITION part3 VALUES IN (2)
6456
(SUBPARTITION sp31, SUBPARTITION sp32),
6457
PARTITION part4 VALUES IN (NULL)
6458
(SUBPARTITION sp41, SUBPARTITION sp42));
6459
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
6460
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
6461
# Start usability test (inc/partition_check.inc)
6462
create_command
6463
SHOW CREATE TABLE t1;
6464
Table	Create Table
6465
t1	CREATE TABLE `t1` (
6466
  `f_int1` int(11) DEFAULT NULL,
6467
  `f_int2` int(11) DEFAULT NULL,
6468
  `f_char1` char(20) DEFAULT NULL,
6469
  `f_char2` char(20) DEFAULT NULL,
6470
  `f_charbig` varchar(1000) DEFAULT NULL
6471
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,3))) SUBPARTITION BY HASH (f_int2 + 1) (PARTITION part1 VALUES IN (0) (SUBPARTITION sp11 ENGINE = InnoDB, SUBPARTITION sp12 ENGINE = InnoDB), PARTITION part2 VALUES IN (1) (SUBPARTITION sp21 ENGINE = InnoDB, SUBPARTITION sp22 ENGINE = InnoDB), PARTITION part3 VALUES IN (2) (SUBPARTITION sp31 ENGINE = InnoDB, SUBPARTITION sp32 ENGINE = InnoDB), PARTITION part4 VALUES IN (NULL) (SUBPARTITION sp41 ENGINE = InnoDB, SUBPARTITION sp42 ENGINE = InnoDB)) */
6472
6473
unified filelist
6474
$MYSQLTEST_VARDIR/master-data/test/t1.frm
6475
$MYSQLTEST_VARDIR/master-data/test/t1.par
6476
6477
# check prerequisites-1 success:    1
6478
# check COUNT(*) success:    1
6479
# check MIN/MAX(f_int1) success:    1
6480
# check MIN/MAX(f_int2) success:    1
6481
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
6482
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
6483
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
6484
WHERE f_int1 IN (2,3);
6485
# check prerequisites-3 success:    1
6486
DELETE FROM t1 WHERE f_charbig = 'delete me';
6487
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
6488
# check read via f_int1 success: 1
6489
# check read via f_int2 success: 1
6490
	
6491
# check multiple-1 success: 	1
6492
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
6493
	
6494
# check multiple-2 success: 	1
6495
INSERT INTO t1 SELECT * FROM t0_template
6496
WHERE MOD(f_int1,3) = 0;
6497
	
6498
# check multiple-3 success: 	1
6499
UPDATE t1 SET f_int1 = f_int1 + @max_row
6500
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
6501
AND @max_row_div2 + @max_row_div4;
6502
	
6503
# check multiple-4 success: 	1
6504
DELETE FROM t1
6505
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
6506
AND @max_row_div2 + @max_row_div4 + @max_row;
6507
	
6508
# check multiple-5 success: 	1
6509
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
6510
INSERT INTO t1
6511
SET f_int1 = @cur_value , f_int2 = @cur_value,
6512
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
6513
f_charbig = '#SINGLE#';
6514
	
6515
# check single-1 success: 	1
6516
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
6517
INSERT INTO t1
6518
SET f_int1 = @cur_value , f_int2 = @cur_value,
6519
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
6520
f_charbig = '#SINGLE#';
6521
	
6522
# check single-2 success: 	1
6523
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
6524
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
6525
UPDATE t1 SET f_int1 = @cur_value2
6526
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
6527
	
6528
# check single-3 success: 	1
6529
SET @cur_value1= -1;
6530
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
6531
UPDATE t1 SET f_int1 = @cur_value1
6532
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
6533
	
6534
# check single-4 success: 	1
6535
SELECT MAX(f_int1) INTO @cur_value FROM t1;
6536
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
6537
	
6538
# check single-5 success: 	1
6539
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
6540
	
6541
# check single-6 success: 	1
6542
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
6543
	
6544
# check single-7 success: 	1
6545
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
6546
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
6547
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
6548
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
6549
f_charbig = '#NULL#';
6550
INSERT INTO t1
6551
SET f_int1 = NULL , f_int2 = -@max_row,
6552
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
6553
f_charbig = '#NULL#';
6554
# check null success:    1
6555
	
6556
# check null-1 success: 	1
6557
UPDATE t1 SET f_int1 = -@max_row
6558
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
6559
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
6560
	
6561
# check null-2 success: 	1
6562
UPDATE t1 SET f_int1 = NULL
6563
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
6564
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
6565
	
6566
# check null-3 success: 	1
6567
DELETE FROM t1
6568
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
6569
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
6570
	
6571
# check null-4 success: 	1
6572
DELETE FROM t1
6573
WHERE f_int1 = 0 AND f_int2 = 0
6574
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
6575
AND f_charbig = '#NULL#';
6576
SET AUTOCOMMIT= 0;
6577
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
6578
SELECT f_int1, f_int1, '', '', 'was inserted'
6579
FROM t0_template source_tab
6580
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
6581
	
6582
# check transactions-1 success: 	1
6583
COMMIT WORK;
6584
	
6585
# check transactions-2 success: 	1
6586
ROLLBACK WORK;
6587
	
6588
# check transactions-3 success: 	1
6589
DELETE FROM t1 WHERE f_charbig = 'was inserted';
6590
COMMIT WORK;
6591
ROLLBACK WORK;
6592
	
6593
# check transactions-4 success: 	1
6594
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
6595
SELECT f_int1, f_int1, '', '', 'was inserted'
6596
FROM t0_template source_tab
6597
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
6598
	
6599
# check transactions-5 success: 	1
6600
ROLLBACK WORK;
6601
	
6602
# check transactions-6 success: 	1
6603
# INFO: Storage engine used for t1 seems to be transactional.
6604
COMMIT;
6605
	
6606
# check transactions-7 success: 	1
6607
DELETE FROM t1 WHERE f_charbig = 'was inserted';
6608
COMMIT WORK;
6609
SET @@session.sql_mode = 'traditional';
6610
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
6611
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
6612
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
6613
'', '', 'was inserted' FROM t0_template
6614
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
6615
ERROR 22012: Division by 0
6616
COMMIT;
6617
	
6618
# check transactions-8 success: 	1
6619
# INFO: Storage engine used for t1 seems to be able to revert
6620
#       changes made by the failing statement.
6621
SET @@session.sql_mode = '';
6622
SET AUTOCOMMIT= 1;
6623
DELETE FROM t1 WHERE f_charbig = 'was inserted';
6624
COMMIT WORK;
6625
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
6626
	
6627
# check special-1 success: 	1
6628
UPDATE t1 SET f_charbig = '';
6629
	
6630
# check special-2 success: 	1
6631
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
6632
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
6633
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
6634
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6635
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6636
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6637
'just inserted' FROM t0_template
6638
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6639
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
6640
BEGIN
6641
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6642
f_charbig = 'updated by trigger'
6643
      WHERE f_int1 = new.f_int1;
6644
END|
6645
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6646
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
6647
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6648
	
6649
# check trigger-1 success: 	1
6650
DROP TRIGGER trg_1;
6651
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6652
f_int2 = CAST(f_char1 AS SIGNED INT),
6653
f_charbig = 'just inserted'
6654
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6655
DELETE FROM t0_aux
6656
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6657
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6658
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6659
'just inserted' FROM t0_template
6660
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6661
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
6662
BEGIN
6663
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6664
f_charbig = 'updated by trigger'
6665
      WHERE f_int1 = new.f_int1;
6666
END|
6667
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6668
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
6669
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6670
	
6671
# check trigger-2 success: 	1
6672
DROP TRIGGER trg_1;
6673
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6674
f_int2 = CAST(f_char1 AS SIGNED INT),
6675
f_charbig = 'just inserted'
6676
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6677
DELETE FROM t0_aux
6678
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6679
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6680
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6681
'just inserted' FROM t0_template
6682
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6683
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
6684
BEGIN
6685
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6686
f_charbig = 'updated by trigger'
6687
      WHERE f_int1 = new.f_int1;
6688
END|
6689
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
6690
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
6691
	
6692
# check trigger-3 success: 	1
6693
DROP TRIGGER trg_1;
6694
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6695
f_int2 = CAST(f_char1 AS SIGNED INT),
6696
f_charbig = 'just inserted'
6697
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6698
DELETE FROM t0_aux
6699
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6700
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6701
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6702
'just inserted' FROM t0_template
6703
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6704
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
6705
BEGIN
6706
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6707
f_charbig = 'updated by trigger'
6708
      WHERE f_int1 = - old.f_int1;
6709
END|
6710
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
6711
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
6712
	
6713
# check trigger-4 success: 	1
6714
DROP TRIGGER trg_1;
6715
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6716
f_int2 = CAST(f_char1 AS SIGNED INT),
6717
f_charbig = 'just inserted'
6718
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6719
DELETE FROM t0_aux
6720
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6721
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6722
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6723
'just inserted' FROM t0_template
6724
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6725
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
6726
BEGIN
6727
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6728
f_charbig = 'updated by trigger'
6729
      WHERE f_int1 = new.f_int1;
6730
END|
6731
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
6732
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
6733
	
6734
# check trigger-5 success: 	1
6735
DROP TRIGGER trg_1;
6736
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6737
f_int2 = CAST(f_char1 AS SIGNED INT),
6738
f_charbig = 'just inserted'
6739
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6740
DELETE FROM t0_aux
6741
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6742
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6743
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6744
'just inserted' FROM t0_template
6745
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6746
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
6747
BEGIN
6748
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6749
f_charbig = 'updated by trigger'
6750
      WHERE f_int1 = - old.f_int1;
6751
END|
6752
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
6753
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
6754
	
6755
# check trigger-6 success: 	1
6756
DROP TRIGGER trg_1;
6757
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6758
f_int2 = CAST(f_char1 AS SIGNED INT),
6759
f_charbig = 'just inserted'
6760
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6761
DELETE FROM t0_aux
6762
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6763
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6764
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6765
'just inserted' FROM t0_template
6766
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6767
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
6768
BEGIN
6769
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6770
f_charbig = 'updated by trigger'
6771
      WHERE f_int1 = - old.f_int1;
6772
END|
6773
DELETE FROM t0_aux
6774
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
6775
	
6776
# check trigger-7 success: 	1
6777
DROP TRIGGER trg_1;
6778
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6779
f_int2 = CAST(f_char1 AS SIGNED INT),
6780
f_charbig = 'just inserted'
6781
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6782
DELETE FROM t0_aux
6783
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6784
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
6785
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
6786
'just inserted' FROM t0_template
6787
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6788
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
6789
BEGIN
6790
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
6791
f_charbig = 'updated by trigger'
6792
      WHERE f_int1 = - old.f_int1;
6793
END|
6794
DELETE FROM t0_aux
6795
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
6796
	
6797
# check trigger-8 success: 	1
6798
DROP TRIGGER trg_1;
6799
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6800
f_int2 = CAST(f_char1 AS SIGNED INT),
6801
f_charbig = 'just inserted'
6802
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
6803
DELETE FROM t0_aux
6804
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6805
DELETE FROM t1
6806
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
6807
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
6808
BEGIN
6809
SET new.f_int1 = old.f_int1 + @max_row,
6810
new.f_int2 = old.f_int2 - @max_row,
6811
new.f_charbig = '####updated per update trigger####';
6812
END|
6813
UPDATE t1
6814
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
6815
f_charbig = '####updated per update statement itself####';
6816
	
6817
# check trigger-9 success: 	1
6818
DROP TRIGGER trg_2;
6819
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6820
f_int2 = CAST(f_char1 AS SIGNED INT),
6821
f_charbig = CONCAT('===',f_char1,'===');
6822
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
6823
BEGIN
6824
SET new.f_int1 = new.f_int1 + @max_row,
6825
new.f_int2 = new.f_int2 - @max_row,
6826
new.f_charbig = '####updated per update trigger####';
6827
END|
6828
UPDATE t1
6829
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
6830
f_charbig = '####updated per update statement itself####';
6831
	
6832
# check trigger-10 success: 	1
6833
DROP TRIGGER trg_2;
6834
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
6835
f_int2 = CAST(f_char1 AS SIGNED INT),
6836
f_charbig = CONCAT('===',f_char1,'===');
6837
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
6838
BEGIN
6839
SET new.f_int1 = @my_max1 + @counter,
6840
new.f_int2 = @my_min2 - @counter,
6841
new.f_charbig = '####updated per insert trigger####';
6842
SET @counter = @counter + 1;
6843
END|
6844
SET @counter = 1;
6845
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
6846
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
6847
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
6848
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
6849
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
6850
ORDER BY f_int1;
6851
DROP TRIGGER trg_3;
6852
	
6853
# check trigger-11 success: 	1
6854
DELETE FROM t1
6855
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
6856
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
6857
AND f_charbig = '####updated per insert trigger####';
6858
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
6859
BEGIN
6860
SET new.f_int1 = @my_max1 + @counter,
6861
new.f_int2 = @my_min2 - @counter,
6862
new.f_charbig = '####updated per insert trigger####';
6863
SET @counter = @counter + 1;
6864
END|
6865
SET @counter = 1;
6866
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
6867
INSERT INTO t1 (f_char1, f_char2, f_charbig)
6868
SELECT CAST(f_int1 AS CHAR),
6869
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
6870
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
6871
ORDER BY f_int1;
6872
DROP TRIGGER trg_3;
6873
	
6874
# check trigger-12 success: 	1
6875
DELETE FROM t1
6876
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
6877
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
6878
AND f_charbig = '####updated per insert trigger####';
6879
ANALYZE  TABLE t1;
6880
Table	Op	Msg_type	Msg_text
6881
test.t1	analyze	note	The storage engine for the table doesn't support analyze
6882
CHECK    TABLE t1 EXTENDED;
6883
Table	Op	Msg_type	Msg_text
6884
test.t1	check	note	The storage engine for the table doesn't support check
6885
CHECKSUM TABLE t1 EXTENDED;
6886
Table	Checksum
6887
test.t1	<some_value>
6888
OPTIMIZE TABLE t1;
6889
Table	Op	Msg_type	Msg_text
6890
test.t1	optimize	note	The storage engine for the table doesn't support optimize
6891
# check layout success:    1
6892
REPAIR   TABLE t1 EXTENDED;
6893
Table	Op	Msg_type	Msg_text
6894
test.t1	repair	note	The storage engine for the table doesn't support repair
6895
# check layout success:    1
6896
TRUNCATE t1;
6897
	
6898
# check TRUNCATE success: 	1
6899
# check layout success:    1
6900
# End usability test (inc/partition_check.inc)
6901
DROP TABLE t1;
6902
CREATE TABLE t1 (
6903
f_int1 INTEGER,
6904
f_int2 INTEGER,
6905
f_char1 CHAR(20),
6906
f_char2 CHAR(20),
6907
f_charbig VARCHAR(1000)
6908
6909
)
6910
PARTITION BY LIST(ABS(MOD(f_int1,2)))
6911
SUBPARTITION BY KEY(f_int2)  SUBPARTITIONS 3
6912
(PARTITION part1 VALUES IN (0),
6913
PARTITION part2 VALUES IN (1),
6914
PARTITION part3 VALUES IN (NULL));
6915
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
6916
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
6917
# Start usability test (inc/partition_check.inc)
6918
create_command
6919
SHOW CREATE TABLE t1;
6920
Table	Create Table
6921
t1	CREATE TABLE `t1` (
6922
  `f_int1` int(11) DEFAULT NULL,
6923
  `f_int2` int(11) DEFAULT NULL,
6924
  `f_char1` char(20) DEFAULT NULL,
6925
  `f_char2` char(20) DEFAULT NULL,
6926
  `f_charbig` varchar(1000) DEFAULT NULL
6927
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
6928
6929
unified filelist
6930
$MYSQLTEST_VARDIR/master-data/test/t1.frm
6931
$MYSQLTEST_VARDIR/master-data/test/t1.par
6932
6933
# check prerequisites-1 success:    1
6934
# check COUNT(*) success:    1
6935
# check MIN/MAX(f_int1) success:    1
6936
# check MIN/MAX(f_int2) success:    1
6937
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
6938
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
6939
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
6940
WHERE f_int1 IN (2,3);
6941
# check prerequisites-3 success:    1
6942
DELETE FROM t1 WHERE f_charbig = 'delete me';
6943
# INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
6944
# check read via f_int1 success: 1
6945
# check read via f_int2 success: 1
6946
	
6947
# check multiple-1 success: 	1
6948
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
6949
	
6950
# check multiple-2 success: 	1
6951
INSERT INTO t1 SELECT * FROM t0_template
6952
WHERE MOD(f_int1,3) = 0;
6953
	
6954
# check multiple-3 success: 	1
6955
UPDATE t1 SET f_int1 = f_int1 + @max_row
6956
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
6957
AND @max_row_div2 + @max_row_div4;
6958
	
6959
# check multiple-4 success: 	1
6960
DELETE FROM t1
6961
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
6962
AND @max_row_div2 + @max_row_div4 + @max_row;
6963
	
6964
# check multiple-5 success: 	1
6965
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
6966
INSERT INTO t1
6967
SET f_int1 = @cur_value , f_int2 = @cur_value,
6968
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
6969
f_charbig = '#SINGLE#';
6970
	
6971
# check single-1 success: 	1
6972
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
6973
INSERT INTO t1
6974
SET f_int1 = @cur_value , f_int2 = @cur_value,
6975
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
6976
f_charbig = '#SINGLE#';
6977
	
6978
# check single-2 success: 	1
6979
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
6980
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
6981
UPDATE t1 SET f_int1 = @cur_value2
6982
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
6983
	
6984
# check single-3 success: 	1
6985
SET @cur_value1= -1;
6986
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
6987
UPDATE t1 SET f_int1 = @cur_value1
6988
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
6989
	
6990
# check single-4 success: 	1
6991
SELECT MAX(f_int1) INTO @cur_value FROM t1;
6992
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
6993
	
6994
# check single-5 success: 	1
6995
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
6996
	
6997
# check single-6 success: 	1
6998
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
6999
	
7000
# check single-7 success: 	1
7001
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
7002
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
7003
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
7004
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
7005
f_charbig = '#NULL#';
7006
INSERT INTO t1
7007
SET f_int1 = NULL , f_int2 = -@max_row,
7008
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
7009
f_charbig = '#NULL#';
7010
# check null success:    1
7011
	
7012
# check null-1 success: 	1
7013
UPDATE t1 SET f_int1 = -@max_row
7014
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
7015
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
7016
	
7017
# check null-2 success: 	1
7018
UPDATE t1 SET f_int1 = NULL
7019
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
7020
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
7021
	
7022
# check null-3 success: 	1
7023
DELETE FROM t1
7024
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
7025
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
7026
	
7027
# check null-4 success: 	1
7028
DELETE FROM t1
7029
WHERE f_int1 = 0 AND f_int2 = 0
7030
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
7031
AND f_charbig = '#NULL#';
7032
SET AUTOCOMMIT= 0;
7033
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7034
SELECT f_int1, f_int1, '', '', 'was inserted'
7035
FROM t0_template source_tab
7036
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
7037
	
7038
# check transactions-1 success: 	1
7039
COMMIT WORK;
7040
	
7041
# check transactions-2 success: 	1
7042
ROLLBACK WORK;
7043
	
7044
# check transactions-3 success: 	1
7045
DELETE FROM t1 WHERE f_charbig = 'was inserted';
7046
COMMIT WORK;
7047
ROLLBACK WORK;
7048
	
7049
# check transactions-4 success: 	1
7050
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7051
SELECT f_int1, f_int1, '', '', 'was inserted'
7052
FROM t0_template source_tab
7053
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
7054
	
7055
# check transactions-5 success: 	1
7056
ROLLBACK WORK;
7057
	
7058
# check transactions-6 success: 	1
7059
# INFO: Storage engine used for t1 seems to be transactional.
7060
COMMIT;
7061
	
7062
# check transactions-7 success: 	1
7063
DELETE FROM t1 WHERE f_charbig = 'was inserted';
7064
COMMIT WORK;
7065
SET @@session.sql_mode = 'traditional';
7066
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
7067
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7068
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
7069
'', '', 'was inserted' FROM t0_template
7070
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
7071
ERROR 22012: Division by 0
7072
COMMIT;
7073
	
7074
# check transactions-8 success: 	1
7075
# INFO: Storage engine used for t1 seems to be able to revert
7076
#       changes made by the failing statement.
7077
SET @@session.sql_mode = '';
7078
SET AUTOCOMMIT= 1;
7079
DELETE FROM t1 WHERE f_charbig = 'was inserted';
7080
COMMIT WORK;
7081
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
7082
	
7083
# check special-1 success: 	1
7084
UPDATE t1 SET f_charbig = '';
7085
	
7086
# check special-2 success: 	1
7087
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
7088
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
7089
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
7090
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7091
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7092
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7093
'just inserted' FROM t0_template
7094
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7095
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
7096
BEGIN
7097
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7098
f_charbig = 'updated by trigger'
7099
      WHERE f_int1 = new.f_int1;
7100
END|
7101
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7102
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
7103
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7104
	
7105
# check trigger-1 success: 	1
7106
DROP TRIGGER trg_1;
7107
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7108
f_int2 = CAST(f_char1 AS SIGNED INT),
7109
f_charbig = 'just inserted'
7110
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7111
DELETE FROM t0_aux
7112
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7113
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7114
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7115
'just inserted' FROM t0_template
7116
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7117
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
7118
BEGIN
7119
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7120
f_charbig = 'updated by trigger'
7121
      WHERE f_int1 = new.f_int1;
7122
END|
7123
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7124
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
7125
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7126
	
7127
# check trigger-2 success: 	1
7128
DROP TRIGGER trg_1;
7129
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7130
f_int2 = CAST(f_char1 AS SIGNED INT),
7131
f_charbig = 'just inserted'
7132
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7133
DELETE FROM t0_aux
7134
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7135
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7136
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7137
'just inserted' FROM t0_template
7138
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7139
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
7140
BEGIN
7141
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7142
f_charbig = 'updated by trigger'
7143
      WHERE f_int1 = new.f_int1;
7144
END|
7145
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
7146
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
7147
	
7148
# check trigger-3 success: 	1
7149
DROP TRIGGER trg_1;
7150
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7151
f_int2 = CAST(f_char1 AS SIGNED INT),
7152
f_charbig = 'just inserted'
7153
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7154
DELETE FROM t0_aux
7155
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7156
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7157
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7158
'just inserted' FROM t0_template
7159
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7160
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
7161
BEGIN
7162
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7163
f_charbig = 'updated by trigger'
7164
      WHERE f_int1 = - old.f_int1;
7165
END|
7166
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
7167
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
7168
	
7169
# check trigger-4 success: 	1
7170
DROP TRIGGER trg_1;
7171
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7172
f_int2 = CAST(f_char1 AS SIGNED INT),
7173
f_charbig = 'just inserted'
7174
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7175
DELETE FROM t0_aux
7176
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7177
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7178
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7179
'just inserted' FROM t0_template
7180
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7181
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
7182
BEGIN
7183
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7184
f_charbig = 'updated by trigger'
7185
      WHERE f_int1 = new.f_int1;
7186
END|
7187
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
7188
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
7189
	
7190
# check trigger-5 success: 	1
7191
DROP TRIGGER trg_1;
7192
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7193
f_int2 = CAST(f_char1 AS SIGNED INT),
7194
f_charbig = 'just inserted'
7195
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7196
DELETE FROM t0_aux
7197
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7198
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7199
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7200
'just inserted' FROM t0_template
7201
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7202
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
7203
BEGIN
7204
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7205
f_charbig = 'updated by trigger'
7206
      WHERE f_int1 = - old.f_int1;
7207
END|
7208
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
7209
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
7210
	
7211
# check trigger-6 success: 	1
7212
DROP TRIGGER trg_1;
7213
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7214
f_int2 = CAST(f_char1 AS SIGNED INT),
7215
f_charbig = 'just inserted'
7216
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7217
DELETE FROM t0_aux
7218
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7219
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7220
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7221
'just inserted' FROM t0_template
7222
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7223
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
7224
BEGIN
7225
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7226
f_charbig = 'updated by trigger'
7227
      WHERE f_int1 = - old.f_int1;
7228
END|
7229
DELETE FROM t0_aux
7230
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
7231
	
7232
# check trigger-7 success: 	1
7233
DROP TRIGGER trg_1;
7234
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7235
f_int2 = CAST(f_char1 AS SIGNED INT),
7236
f_charbig = 'just inserted'
7237
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7238
DELETE FROM t0_aux
7239
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7240
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7241
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7242
'just inserted' FROM t0_template
7243
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7244
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
7245
BEGIN
7246
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7247
f_charbig = 'updated by trigger'
7248
      WHERE f_int1 = - old.f_int1;
7249
END|
7250
DELETE FROM t0_aux
7251
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
7252
	
7253
# check trigger-8 success: 	1
7254
DROP TRIGGER trg_1;
7255
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7256
f_int2 = CAST(f_char1 AS SIGNED INT),
7257
f_charbig = 'just inserted'
7258
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7259
DELETE FROM t0_aux
7260
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7261
DELETE FROM t1
7262
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7263
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
7264
BEGIN
7265
SET new.f_int1 = old.f_int1 + @max_row,
7266
new.f_int2 = old.f_int2 - @max_row,
7267
new.f_charbig = '####updated per update trigger####';
7268
END|
7269
UPDATE t1
7270
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
7271
f_charbig = '####updated per update statement itself####';
7272
	
7273
# check trigger-9 success: 	1
7274
DROP TRIGGER trg_2;
7275
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7276
f_int2 = CAST(f_char1 AS SIGNED INT),
7277
f_charbig = CONCAT('===',f_char1,'===');
7278
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
7279
BEGIN
7280
SET new.f_int1 = new.f_int1 + @max_row,
7281
new.f_int2 = new.f_int2 - @max_row,
7282
new.f_charbig = '####updated per update trigger####';
7283
END|
7284
UPDATE t1
7285
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
7286
f_charbig = '####updated per update statement itself####';
7287
	
7288
# check trigger-10 success: 	1
7289
DROP TRIGGER trg_2;
7290
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7291
f_int2 = CAST(f_char1 AS SIGNED INT),
7292
f_charbig = CONCAT('===',f_char1,'===');
7293
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
7294
BEGIN
7295
SET new.f_int1 = @my_max1 + @counter,
7296
new.f_int2 = @my_min2 - @counter,
7297
new.f_charbig = '####updated per insert trigger####';
7298
SET @counter = @counter + 1;
7299
END|
7300
SET @counter = 1;
7301
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
7302
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7303
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
7304
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
7305
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
7306
ORDER BY f_int1;
7307
DROP TRIGGER trg_3;
7308
	
7309
# check trigger-11 success: 	1
7310
DELETE FROM t1
7311
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
7312
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
7313
AND f_charbig = '####updated per insert trigger####';
7314
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
7315
BEGIN
7316
SET new.f_int1 = @my_max1 + @counter,
7317
new.f_int2 = @my_min2 - @counter,
7318
new.f_charbig = '####updated per insert trigger####';
7319
SET @counter = @counter + 1;
7320
END|
7321
SET @counter = 1;
7322
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
7323
INSERT INTO t1 (f_char1, f_char2, f_charbig)
7324
SELECT CAST(f_int1 AS CHAR),
7325
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
7326
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
7327
ORDER BY f_int1;
7328
DROP TRIGGER trg_3;
7329
	
7330
# check trigger-12 success: 	1
7331
DELETE FROM t1
7332
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
7333
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
7334
AND f_charbig = '####updated per insert trigger####';
7335
ANALYZE  TABLE t1;
7336
Table	Op	Msg_type	Msg_text
7337
test.t1	analyze	note	The storage engine for the table doesn't support analyze
7338
CHECK    TABLE t1 EXTENDED;
7339
Table	Op	Msg_type	Msg_text
7340
test.t1	check	note	The storage engine for the table doesn't support check
7341
CHECKSUM TABLE t1 EXTENDED;
7342
Table	Checksum
7343
test.t1	<some_value>
7344
OPTIMIZE TABLE t1;
7345
Table	Op	Msg_type	Msg_text
7346
test.t1	optimize	note	The storage engine for the table doesn't support optimize
7347
# check layout success:    1
7348
REPAIR   TABLE t1 EXTENDED;
7349
Table	Op	Msg_type	Msg_text
7350
test.t1	repair	note	The storage engine for the table doesn't support repair
7351
# check layout success:    1
7352
TRUNCATE t1;
7353
	
7354
# check TRUNCATE success: 	1
7355
# check layout success:    1
7356
# End usability test (inc/partition_check.inc)
7357
DROP TABLE t1;
7358
#------------------------------------------------------------------------
7359
#  2   Tables with PRIMARY KEY and/or UNIQUE INDEXes
7360
#        The partitioning function contains one column.
7361
#------------------------------------------------------------------------
7362
#  2.5 PRIMARY KEY + UNIQUE INDEX consisting of two columns
7363
DROP TABLE IF EXISTS t1;
7364
CREATE TABLE t1 (
7365
f_int1 INTEGER,
7366
f_int2 INTEGER,
7367
f_char1 CHAR(20),
7368
f_char2 CHAR(20),
7369
f_charbig VARCHAR(1000)
7370
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
7371
)
7372
PARTITION BY HASH(f_int1) PARTITIONS 2;
7373
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
7374
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
7375
# Start usability test (inc/partition_check.inc)
7376
create_command
7377
SHOW CREATE TABLE t1;
7378
Table	Create Table
7379
t1	CREATE TABLE `t1` (
7380
  `f_int1` int(11) NOT NULL DEFAULT '0',
7381
  `f_int2` int(11) NOT NULL DEFAULT '0',
7382
  `f_char1` char(20) DEFAULT NULL,
7383
  `f_char2` char(20) DEFAULT NULL,
7384
  `f_charbig` varchar(1000) DEFAULT NULL,
7385
  PRIMARY KEY (`f_int2`,`f_int1`),
7386
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
7387
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (f_int1) PARTITIONS 2  */
7388
7389
unified filelist
7390
$MYSQLTEST_VARDIR/master-data/test/t1.frm
7391
$MYSQLTEST_VARDIR/master-data/test/t1.par
7392
7393
# check prerequisites-1 success:    1
7394
# check COUNT(*) success:    1
7395
# check MIN/MAX(f_int1) success:    1
7396
# check MIN/MAX(f_int2) success:    1
7397
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7398
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
7399
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
7400
WHERE f_int1 IN (2,3);
7401
ERROR 23000: Can't write; duplicate key in table 't1'
7402
# check prerequisites-3 success:    1
7403
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
7404
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7405
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
7406
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
7407
WHERE f_int1 IN (2,3);
7408
DELETE FROM t1 WHERE f_charbig = 'delete me';
7409
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7410
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
7411
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
7412
WHERE f_int1 IN (2,3);
7413
DELETE FROM t1 WHERE f_charbig = 'delete me';
7414
# check read via f_int1 success: 1
7415
# check read via f_int2 success: 1
7416
	
7417
# check multiple-1 success: 	1
7418
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
7419
	
7420
# check multiple-2 success: 	1
7421
INSERT INTO t1 SELECT * FROM t0_template
7422
WHERE MOD(f_int1,3) = 0;
7423
	
7424
# check multiple-3 success: 	1
7425
UPDATE t1 SET f_int1 = f_int1 + @max_row
7426
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
7427
AND @max_row_div2 + @max_row_div4;
7428
	
7429
# check multiple-4 success: 	1
7430
DELETE FROM t1
7431
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
7432
AND @max_row_div2 + @max_row_div4 + @max_row;
7433
	
7434
# check multiple-5 success: 	1
7435
SELECT COUNT(*) INTO @try_count FROM t0_template
7436
WHERE MOD(f_int1,3) = 0
7437
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
7438
SELECT COUNT(*) INTO @clash_count
7439
FROM t1 INNER JOIN t0_template USING(f_int1)
7440
WHERE MOD(f_int1,3) = 0
7441
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
7442
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
7443
INSERT INTO t1
7444
SET f_int1 = @cur_value , f_int2 = @cur_value,
7445
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
7446
f_charbig = '#SINGLE#';
7447
	
7448
# check single-1 success: 	1
7449
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
7450
INSERT INTO t1
7451
SET f_int1 = @cur_value , f_int2 = @cur_value,
7452
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
7453
f_charbig = '#SINGLE#';
7454
	
7455
# check single-2 success: 	1
7456
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
7457
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
7458
UPDATE t1 SET f_int1 = @cur_value2
7459
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
7460
	
7461
# check single-3 success: 	1
7462
SET @cur_value1= -1;
7463
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
7464
UPDATE t1 SET f_int1 = @cur_value1
7465
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
7466
	
7467
# check single-4 success: 	1
7468
SELECT MAX(f_int1) INTO @cur_value FROM t1;
7469
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
7470
	
7471
# check single-5 success: 	1
7472
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
7473
	
7474
# check single-6 success: 	1
7475
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
7476
	
7477
# check single-7 success: 	1
7478
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
7479
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
7480
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
7481
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
7482
f_charbig = '#NULL#';
7483
INSERT INTO t1
7484
SET f_int1 = NULL , f_int2 = -@max_row,
7485
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
7486
f_charbig = '#NULL#';
7487
ERROR 23000: Column 'f_int1' cannot be null
7488
# check null success:    1
7489
DELETE FROM t1
7490
WHERE f_int1 = 0 AND f_int2 = 0
7491
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
7492
AND f_charbig = '#NULL#';
7493
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7494
SELECT f_int1, f_int1, '', '', 'was inserted'
7495
   FROM t0_template source_tab
7496
WHERE MOD(f_int1,3) = 0
7497
AND f_int1 BETWEEN @max_row_div2 AND @max_row
7498
ON DUPLICATE KEY
7499
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
7500
f_int2 = 2 * @max_row + source_tab.f_int1,
7501
f_charbig = 'was updated';
7502
	
7503
# check unique-1-a success: 	1
7504
	
7505
# check unique-1-b success: 	1
7506
DELETE FROM t1 WHERE f_charbig = 'was inserted';
7507
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7508
f_int2 = CAST(f_char1 AS SIGNED INT),
7509
f_charbig = CONCAT('===',f_char1,'===')
7510
WHERE f_charbig = 'was updated';
7511
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7512
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
7513
   FROM t0_template source_tab
7514
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
7515
	
7516
# check replace success: 	1
7517
DELETE FROM t1
7518
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
7519
DELETE FROM t1
7520
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
7521
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
7522
UPDATE t1 SET f_int2 = f_int1,
7523
f_char1 = CAST(f_int1 AS CHAR),
7524
f_char2 = CAST(f_int1 AS CHAR),
7525
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
7526
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
7527
SET AUTOCOMMIT= 0;
7528
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7529
SELECT f_int1, f_int1, '', '', 'was inserted'
7530
FROM t0_template source_tab
7531
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
7532
	
7533
# check transactions-1 success: 	1
7534
COMMIT WORK;
7535
	
7536
# check transactions-2 success: 	1
7537
ROLLBACK WORK;
7538
	
7539
# check transactions-3 success: 	1
7540
DELETE FROM t1 WHERE f_charbig = 'was inserted';
7541
COMMIT WORK;
7542
ROLLBACK WORK;
7543
	
7544
# check transactions-4 success: 	1
7545
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7546
SELECT f_int1, f_int1, '', '', 'was inserted'
7547
FROM t0_template source_tab
7548
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
7549
	
7550
# check transactions-5 success: 	1
7551
ROLLBACK WORK;
7552
	
7553
# check transactions-6 success: 	1
7554
# INFO: Storage engine used for t1 seems to be transactional.
7555
COMMIT;
7556
	
7557
# check transactions-7 success: 	1
7558
DELETE FROM t1 WHERE f_charbig = 'was inserted';
7559
COMMIT WORK;
7560
SET @@session.sql_mode = 'traditional';
7561
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
7562
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7563
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
7564
'', '', 'was inserted' FROM t0_template
7565
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
7566
ERROR 22012: Division by 0
7567
COMMIT;
7568
	
7569
# check transactions-8 success: 	1
7570
# INFO: Storage engine used for t1 seems to be able to revert
7571
#       changes made by the failing statement.
7572
SET @@session.sql_mode = '';
7573
SET AUTOCOMMIT= 1;
7574
DELETE FROM t1 WHERE f_charbig = 'was inserted';
7575
COMMIT WORK;
7576
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
7577
	
7578
# check special-1 success: 	1
7579
UPDATE t1 SET f_charbig = '';
7580
	
7581
# check special-2 success: 	1
7582
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
7583
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
7584
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
7585
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7586
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7587
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7588
'just inserted' FROM t0_template
7589
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7590
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
7591
BEGIN
7592
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7593
f_charbig = 'updated by trigger'
7594
      WHERE f_int1 = new.f_int1;
7595
END|
7596
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7597
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
7598
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7599
	
7600
# check trigger-1 success: 	1
7601
DROP TRIGGER trg_1;
7602
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7603
f_int2 = CAST(f_char1 AS SIGNED INT),
7604
f_charbig = 'just inserted'
7605
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7606
DELETE FROM t0_aux
7607
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7608
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7609
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7610
'just inserted' FROM t0_template
7611
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7612
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
7613
BEGIN
7614
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7615
f_charbig = 'updated by trigger'
7616
      WHERE f_int1 = new.f_int1;
7617
END|
7618
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7619
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
7620
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7621
	
7622
# check trigger-2 success: 	1
7623
DROP TRIGGER trg_1;
7624
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7625
f_int2 = CAST(f_char1 AS SIGNED INT),
7626
f_charbig = 'just inserted'
7627
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7628
DELETE FROM t0_aux
7629
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7630
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7631
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7632
'just inserted' FROM t0_template
7633
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7634
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
7635
BEGIN
7636
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7637
f_charbig = 'updated by trigger'
7638
      WHERE f_int1 = new.f_int1;
7639
END|
7640
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
7641
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
7642
	
7643
# check trigger-3 success: 	1
7644
DROP TRIGGER trg_1;
7645
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7646
f_int2 = CAST(f_char1 AS SIGNED INT),
7647
f_charbig = 'just inserted'
7648
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7649
DELETE FROM t0_aux
7650
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7651
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7652
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7653
'just inserted' FROM t0_template
7654
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7655
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
7656
BEGIN
7657
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7658
f_charbig = 'updated by trigger'
7659
      WHERE f_int1 = - old.f_int1;
7660
END|
7661
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
7662
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
7663
	
7664
# check trigger-4 success: 	1
7665
DROP TRIGGER trg_1;
7666
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7667
f_int2 = CAST(f_char1 AS SIGNED INT),
7668
f_charbig = 'just inserted'
7669
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7670
DELETE FROM t0_aux
7671
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7672
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7673
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7674
'just inserted' FROM t0_template
7675
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7676
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
7677
BEGIN
7678
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7679
f_charbig = 'updated by trigger'
7680
      WHERE f_int1 = new.f_int1;
7681
END|
7682
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
7683
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
7684
	
7685
# check trigger-5 success: 	1
7686
DROP TRIGGER trg_1;
7687
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7688
f_int2 = CAST(f_char1 AS SIGNED INT),
7689
f_charbig = 'just inserted'
7690
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7691
DELETE FROM t0_aux
7692
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7693
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7694
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7695
'just inserted' FROM t0_template
7696
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7697
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
7698
BEGIN
7699
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7700
f_charbig = 'updated by trigger'
7701
      WHERE f_int1 = - old.f_int1;
7702
END|
7703
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
7704
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
7705
	
7706
# check trigger-6 success: 	1
7707
DROP TRIGGER trg_1;
7708
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7709
f_int2 = CAST(f_char1 AS SIGNED INT),
7710
f_charbig = 'just inserted'
7711
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7712
DELETE FROM t0_aux
7713
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7714
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7715
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7716
'just inserted' FROM t0_template
7717
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7718
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
7719
BEGIN
7720
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7721
f_charbig = 'updated by trigger'
7722
      WHERE f_int1 = - old.f_int1;
7723
END|
7724
DELETE FROM t0_aux
7725
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
7726
	
7727
# check trigger-7 success: 	1
7728
DROP TRIGGER trg_1;
7729
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7730
f_int2 = CAST(f_char1 AS SIGNED INT),
7731
f_charbig = 'just inserted'
7732
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7733
DELETE FROM t0_aux
7734
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7735
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
7736
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
7737
'just inserted' FROM t0_template
7738
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7739
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
7740
BEGIN
7741
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
7742
f_charbig = 'updated by trigger'
7743
      WHERE f_int1 = - old.f_int1;
7744
END|
7745
DELETE FROM t0_aux
7746
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
7747
	
7748
# check trigger-8 success: 	1
7749
DROP TRIGGER trg_1;
7750
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7751
f_int2 = CAST(f_char1 AS SIGNED INT),
7752
f_charbig = 'just inserted'
7753
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
7754
DELETE FROM t0_aux
7755
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7756
DELETE FROM t1
7757
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
7758
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
7759
BEGIN
7760
SET new.f_int1 = old.f_int1 + @max_row,
7761
new.f_int2 = old.f_int2 - @max_row,
7762
new.f_charbig = '####updated per update trigger####';
7763
END|
7764
UPDATE t1
7765
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
7766
f_charbig = '####updated per update statement itself####';
7767
	
7768
# check trigger-9 success: 	1
7769
DROP TRIGGER trg_2;
7770
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7771
f_int2 = CAST(f_char1 AS SIGNED INT),
7772
f_charbig = CONCAT('===',f_char1,'===');
7773
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
7774
BEGIN
7775
SET new.f_int1 = new.f_int1 + @max_row,
7776
new.f_int2 = new.f_int2 - @max_row,
7777
new.f_charbig = '####updated per update trigger####';
7778
END|
7779
UPDATE t1
7780
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
7781
f_charbig = '####updated per update statement itself####';
7782
	
7783
# check trigger-10 success: 	1
7784
DROP TRIGGER trg_2;
7785
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7786
f_int2 = CAST(f_char1 AS SIGNED INT),
7787
f_charbig = CONCAT('===',f_char1,'===');
7788
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
7789
BEGIN
7790
SET new.f_int1 = @my_max1 + @counter,
7791
new.f_int2 = @my_min2 - @counter,
7792
new.f_charbig = '####updated per insert trigger####';
7793
SET @counter = @counter + 1;
7794
END|
7795
SET @counter = 1;
7796
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
7797
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7798
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
7799
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
7800
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
7801
ORDER BY f_int1;
7802
DROP TRIGGER trg_3;
7803
	
7804
# check trigger-11 success: 	1
7805
DELETE FROM t1
7806
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
7807
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
7808
AND f_charbig = '####updated per insert trigger####';
7809
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
7810
BEGIN
7811
SET new.f_int1 = @my_max1 + @counter,
7812
new.f_int2 = @my_min2 - @counter,
7813
new.f_charbig = '####updated per insert trigger####';
7814
SET @counter = @counter + 1;
7815
END|
7816
SET @counter = 1;
7817
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
7818
INSERT INTO t1 (f_char1, f_char2, f_charbig)
7819
SELECT CAST(f_int1 AS CHAR),
7820
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
7821
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
7822
ORDER BY f_int1;
7823
DROP TRIGGER trg_3;
7824
	
7825
# check trigger-12 success: 	1
7826
DELETE FROM t1
7827
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
7828
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
7829
AND f_charbig = '####updated per insert trigger####';
7830
ANALYZE  TABLE t1;
7831
Table	Op	Msg_type	Msg_text
7832
test.t1	analyze	note	The storage engine for the table doesn't support analyze
7833
CHECK    TABLE t1 EXTENDED;
7834
Table	Op	Msg_type	Msg_text
7835
test.t1	check	note	The storage engine for the table doesn't support check
7836
CHECKSUM TABLE t1 EXTENDED;
7837
Table	Checksum
7838
test.t1	<some_value>
7839
OPTIMIZE TABLE t1;
7840
Table	Op	Msg_type	Msg_text
7841
test.t1	optimize	note	The storage engine for the table doesn't support optimize
7842
# check layout success:    1
7843
REPAIR   TABLE t1 EXTENDED;
7844
Table	Op	Msg_type	Msg_text
7845
test.t1	repair	note	The storage engine for the table doesn't support repair
7846
# check layout success:    1
7847
TRUNCATE t1;
7848
	
7849
# check TRUNCATE success: 	1
7850
# check layout success:    1
7851
# End usability test (inc/partition_check.inc)
7852
DROP TABLE t1;
7853
CREATE TABLE t1 (
7854
f_int1 INTEGER,
7855
f_int2 INTEGER,
7856
f_char1 CHAR(20),
7857
f_char2 CHAR(20),
7858
f_charbig VARCHAR(1000)
7859
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
7860
)
7861
PARTITION BY KEY(f_int1) PARTITIONS 5;
7862
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
7863
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
7864
# Start usability test (inc/partition_check.inc)
7865
create_command
7866
SHOW CREATE TABLE t1;
7867
Table	Create Table
7868
t1	CREATE TABLE `t1` (
7869
  `f_int1` int(11) NOT NULL DEFAULT '0',
7870
  `f_int2` int(11) NOT NULL DEFAULT '0',
7871
  `f_char1` char(20) DEFAULT NULL,
7872
  `f_char2` char(20) DEFAULT NULL,
7873
  `f_charbig` varchar(1000) DEFAULT NULL,
7874
  PRIMARY KEY (`f_int2`,`f_int1`),
7875
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
7876
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5  */
7877
7878
unified filelist
7879
$MYSQLTEST_VARDIR/master-data/test/t1.frm
7880
$MYSQLTEST_VARDIR/master-data/test/t1.par
7881
7882
# check prerequisites-1 success:    1
7883
# check COUNT(*) success:    1
7884
# check MIN/MAX(f_int1) success:    1
7885
# check MIN/MAX(f_int2) success:    1
7886
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7887
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
7888
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
7889
WHERE f_int1 IN (2,3);
7890
ERROR 23000: Can't write; duplicate key in table 't1'
7891
# check prerequisites-3 success:    1
7892
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
7893
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7894
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
7895
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
7896
WHERE f_int1 IN (2,3);
7897
DELETE FROM t1 WHERE f_charbig = 'delete me';
7898
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7899
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
7900
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
7901
WHERE f_int1 IN (2,3);
7902
DELETE FROM t1 WHERE f_charbig = 'delete me';
7903
# check read via f_int1 success: 1
7904
# check read via f_int2 success: 1
7905
	
7906
# check multiple-1 success: 	1
7907
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
7908
	
7909
# check multiple-2 success: 	1
7910
INSERT INTO t1 SELECT * FROM t0_template
7911
WHERE MOD(f_int1,3) = 0;
7912
	
7913
# check multiple-3 success: 	1
7914
UPDATE t1 SET f_int1 = f_int1 + @max_row
7915
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
7916
AND @max_row_div2 + @max_row_div4;
7917
	
7918
# check multiple-4 success: 	1
7919
DELETE FROM t1
7920
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
7921
AND @max_row_div2 + @max_row_div4 + @max_row;
7922
	
7923
# check multiple-5 success: 	1
7924
SELECT COUNT(*) INTO @try_count FROM t0_template
7925
WHERE MOD(f_int1,3) = 0
7926
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
7927
SELECT COUNT(*) INTO @clash_count
7928
FROM t1 INNER JOIN t0_template USING(f_int1)
7929
WHERE MOD(f_int1,3) = 0
7930
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
7931
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
7932
INSERT INTO t1
7933
SET f_int1 = @cur_value , f_int2 = @cur_value,
7934
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
7935
f_charbig = '#SINGLE#';
7936
	
7937
# check single-1 success: 	1
7938
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
7939
INSERT INTO t1
7940
SET f_int1 = @cur_value , f_int2 = @cur_value,
7941
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
7942
f_charbig = '#SINGLE#';
7943
	
7944
# check single-2 success: 	1
7945
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
7946
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
7947
UPDATE t1 SET f_int1 = @cur_value2
7948
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
7949
	
7950
# check single-3 success: 	1
7951
SET @cur_value1= -1;
7952
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
7953
UPDATE t1 SET f_int1 = @cur_value1
7954
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
7955
	
7956
# check single-4 success: 	1
7957
SELECT MAX(f_int1) INTO @cur_value FROM t1;
7958
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
7959
	
7960
# check single-5 success: 	1
7961
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
7962
	
7963
# check single-6 success: 	1
7964
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
7965
	
7966
# check single-7 success: 	1
7967
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
7968
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
7969
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
7970
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
7971
f_charbig = '#NULL#';
7972
INSERT INTO t1
7973
SET f_int1 = NULL , f_int2 = -@max_row,
7974
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
7975
f_charbig = '#NULL#';
7976
ERROR 23000: Column 'f_int1' cannot be null
7977
# check null success:    1
7978
DELETE FROM t1
7979
WHERE f_int1 = 0 AND f_int2 = 0
7980
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
7981
AND f_charbig = '#NULL#';
7982
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
7983
SELECT f_int1, f_int1, '', '', 'was inserted'
7984
   FROM t0_template source_tab
7985
WHERE MOD(f_int1,3) = 0
7986
AND f_int1 BETWEEN @max_row_div2 AND @max_row
7987
ON DUPLICATE KEY
7988
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
7989
f_int2 = 2 * @max_row + source_tab.f_int1,
7990
f_charbig = 'was updated';
7991
	
7992
# check unique-1-a success: 	1
7993
	
7994
# check unique-1-b success: 	1
7995
DELETE FROM t1 WHERE f_charbig = 'was inserted';
7996
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
7997
f_int2 = CAST(f_char1 AS SIGNED INT),
7998
f_charbig = CONCAT('===',f_char1,'===')
7999
WHERE f_charbig = 'was updated';
8000
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8001
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
8002
   FROM t0_template source_tab
8003
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
8004
	
8005
# check replace success: 	1
8006
DELETE FROM t1
8007
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
8008
DELETE FROM t1
8009
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
8010
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
8011
UPDATE t1 SET f_int2 = f_int1,
8012
f_char1 = CAST(f_int1 AS CHAR),
8013
f_char2 = CAST(f_int1 AS CHAR),
8014
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
8015
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
8016
SET AUTOCOMMIT= 0;
8017
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8018
SELECT f_int1, f_int1, '', '', 'was inserted'
8019
FROM t0_template source_tab
8020
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
8021
	
8022
# check transactions-1 success: 	1
8023
COMMIT WORK;
8024
	
8025
# check transactions-2 success: 	1
8026
ROLLBACK WORK;
8027
	
8028
# check transactions-3 success: 	1
8029
DELETE FROM t1 WHERE f_charbig = 'was inserted';
8030
COMMIT WORK;
8031
ROLLBACK WORK;
8032
	
8033
# check transactions-4 success: 	1
8034
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8035
SELECT f_int1, f_int1, '', '', 'was inserted'
8036
FROM t0_template source_tab
8037
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
8038
	
8039
# check transactions-5 success: 	1
8040
ROLLBACK WORK;
8041
	
8042
# check transactions-6 success: 	1
8043
# INFO: Storage engine used for t1 seems to be transactional.
8044
COMMIT;
8045
	
8046
# check transactions-7 success: 	1
8047
DELETE FROM t1 WHERE f_charbig = 'was inserted';
8048
COMMIT WORK;
8049
SET @@session.sql_mode = 'traditional';
8050
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
8051
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8052
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
8053
'', '', 'was inserted' FROM t0_template
8054
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
8055
ERROR 22012: Division by 0
8056
COMMIT;
8057
	
8058
# check transactions-8 success: 	1
8059
# INFO: Storage engine used for t1 seems to be able to revert
8060
#       changes made by the failing statement.
8061
SET @@session.sql_mode = '';
8062
SET AUTOCOMMIT= 1;
8063
DELETE FROM t1 WHERE f_charbig = 'was inserted';
8064
COMMIT WORK;
8065
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
8066
	
8067
# check special-1 success: 	1
8068
UPDATE t1 SET f_charbig = '';
8069
	
8070
# check special-2 success: 	1
8071
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
8072
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
8073
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
8074
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8075
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8076
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8077
'just inserted' FROM t0_template
8078
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8079
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
8080
BEGIN
8081
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8082
f_charbig = 'updated by trigger'
8083
      WHERE f_int1 = new.f_int1;
8084
END|
8085
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8086
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
8087
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8088
	
8089
# check trigger-1 success: 	1
8090
DROP TRIGGER trg_1;
8091
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8092
f_int2 = CAST(f_char1 AS SIGNED INT),
8093
f_charbig = 'just inserted'
8094
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8095
DELETE FROM t0_aux
8096
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8097
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8098
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8099
'just inserted' FROM t0_template
8100
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8101
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
8102
BEGIN
8103
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8104
f_charbig = 'updated by trigger'
8105
      WHERE f_int1 = new.f_int1;
8106
END|
8107
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8108
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
8109
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8110
	
8111
# check trigger-2 success: 	1
8112
DROP TRIGGER trg_1;
8113
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8114
f_int2 = CAST(f_char1 AS SIGNED INT),
8115
f_charbig = 'just inserted'
8116
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8117
DELETE FROM t0_aux
8118
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8119
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8120
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8121
'just inserted' FROM t0_template
8122
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8123
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
8124
BEGIN
8125
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8126
f_charbig = 'updated by trigger'
8127
      WHERE f_int1 = new.f_int1;
8128
END|
8129
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
8130
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
8131
	
8132
# check trigger-3 success: 	1
8133
DROP TRIGGER trg_1;
8134
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8135
f_int2 = CAST(f_char1 AS SIGNED INT),
8136
f_charbig = 'just inserted'
8137
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8138
DELETE FROM t0_aux
8139
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8140
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8141
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8142
'just inserted' FROM t0_template
8143
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8144
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
8145
BEGIN
8146
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8147
f_charbig = 'updated by trigger'
8148
      WHERE f_int1 = - old.f_int1;
8149
END|
8150
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
8151
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
8152
	
8153
# check trigger-4 success: 	1
8154
DROP TRIGGER trg_1;
8155
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8156
f_int2 = CAST(f_char1 AS SIGNED INT),
8157
f_charbig = 'just inserted'
8158
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8159
DELETE FROM t0_aux
8160
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8161
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8162
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8163
'just inserted' FROM t0_template
8164
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8165
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
8166
BEGIN
8167
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8168
f_charbig = 'updated by trigger'
8169
      WHERE f_int1 = new.f_int1;
8170
END|
8171
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
8172
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
8173
	
8174
# check trigger-5 success: 	1
8175
DROP TRIGGER trg_1;
8176
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8177
f_int2 = CAST(f_char1 AS SIGNED INT),
8178
f_charbig = 'just inserted'
8179
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8180
DELETE FROM t0_aux
8181
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8182
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8183
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8184
'just inserted' FROM t0_template
8185
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8186
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
8187
BEGIN
8188
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8189
f_charbig = 'updated by trigger'
8190
      WHERE f_int1 = - old.f_int1;
8191
END|
8192
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
8193
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
8194
	
8195
# check trigger-6 success: 	1
8196
DROP TRIGGER trg_1;
8197
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8198
f_int2 = CAST(f_char1 AS SIGNED INT),
8199
f_charbig = 'just inserted'
8200
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8201
DELETE FROM t0_aux
8202
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8203
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8204
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8205
'just inserted' FROM t0_template
8206
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8207
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
8208
BEGIN
8209
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8210
f_charbig = 'updated by trigger'
8211
      WHERE f_int1 = - old.f_int1;
8212
END|
8213
DELETE FROM t0_aux
8214
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
8215
	
8216
# check trigger-7 success: 	1
8217
DROP TRIGGER trg_1;
8218
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8219
f_int2 = CAST(f_char1 AS SIGNED INT),
8220
f_charbig = 'just inserted'
8221
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8222
DELETE FROM t0_aux
8223
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8224
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8225
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8226
'just inserted' FROM t0_template
8227
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8228
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
8229
BEGIN
8230
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8231
f_charbig = 'updated by trigger'
8232
      WHERE f_int1 = - old.f_int1;
8233
END|
8234
DELETE FROM t0_aux
8235
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
8236
	
8237
# check trigger-8 success: 	1
8238
DROP TRIGGER trg_1;
8239
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8240
f_int2 = CAST(f_char1 AS SIGNED INT),
8241
f_charbig = 'just inserted'
8242
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8243
DELETE FROM t0_aux
8244
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8245
DELETE FROM t1
8246
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8247
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
8248
BEGIN
8249
SET new.f_int1 = old.f_int1 + @max_row,
8250
new.f_int2 = old.f_int2 - @max_row,
8251
new.f_charbig = '####updated per update trigger####';
8252
END|
8253
UPDATE t1
8254
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
8255
f_charbig = '####updated per update statement itself####';
8256
	
8257
# check trigger-9 success: 	1
8258
DROP TRIGGER trg_2;
8259
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8260
f_int2 = CAST(f_char1 AS SIGNED INT),
8261
f_charbig = CONCAT('===',f_char1,'===');
8262
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
8263
BEGIN
8264
SET new.f_int1 = new.f_int1 + @max_row,
8265
new.f_int2 = new.f_int2 - @max_row,
8266
new.f_charbig = '####updated per update trigger####';
8267
END|
8268
UPDATE t1
8269
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
8270
f_charbig = '####updated per update statement itself####';
8271
	
8272
# check trigger-10 success: 	1
8273
DROP TRIGGER trg_2;
8274
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8275
f_int2 = CAST(f_char1 AS SIGNED INT),
8276
f_charbig = CONCAT('===',f_char1,'===');
8277
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
8278
BEGIN
8279
SET new.f_int1 = @my_max1 + @counter,
8280
new.f_int2 = @my_min2 - @counter,
8281
new.f_charbig = '####updated per insert trigger####';
8282
SET @counter = @counter + 1;
8283
END|
8284
SET @counter = 1;
8285
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
8286
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8287
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
8288
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
8289
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
8290
ORDER BY f_int1;
8291
DROP TRIGGER trg_3;
8292
	
8293
# check trigger-11 success: 	1
8294
DELETE FROM t1
8295
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
8296
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
8297
AND f_charbig = '####updated per insert trigger####';
8298
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
8299
BEGIN
8300
SET new.f_int1 = @my_max1 + @counter,
8301
new.f_int2 = @my_min2 - @counter,
8302
new.f_charbig = '####updated per insert trigger####';
8303
SET @counter = @counter + 1;
8304
END|
8305
SET @counter = 1;
8306
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
8307
INSERT INTO t1 (f_char1, f_char2, f_charbig)
8308
SELECT CAST(f_int1 AS CHAR),
8309
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
8310
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
8311
ORDER BY f_int1;
8312
DROP TRIGGER trg_3;
8313
	
8314
# check trigger-12 success: 	1
8315
DELETE FROM t1
8316
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
8317
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
8318
AND f_charbig = '####updated per insert trigger####';
8319
ANALYZE  TABLE t1;
8320
Table	Op	Msg_type	Msg_text
8321
test.t1	analyze	note	The storage engine for the table doesn't support analyze
8322
CHECK    TABLE t1 EXTENDED;
8323
Table	Op	Msg_type	Msg_text
8324
test.t1	check	note	The storage engine for the table doesn't support check
8325
CHECKSUM TABLE t1 EXTENDED;
8326
Table	Checksum
8327
test.t1	<some_value>
8328
OPTIMIZE TABLE t1;
8329
Table	Op	Msg_type	Msg_text
8330
test.t1	optimize	note	The storage engine for the table doesn't support optimize
8331
# check layout success:    1
8332
REPAIR   TABLE t1 EXTENDED;
8333
Table	Op	Msg_type	Msg_text
8334
test.t1	repair	note	The storage engine for the table doesn't support repair
8335
# check layout success:    1
8336
TRUNCATE t1;
8337
	
8338
# check TRUNCATE success: 	1
8339
# check layout success:    1
8340
# End usability test (inc/partition_check.inc)
8341
DROP TABLE t1;
8342
CREATE TABLE t1 (
8343
f_int1 INTEGER,
8344
f_int2 INTEGER,
8345
f_char1 CHAR(20),
8346
f_char2 CHAR(20),
8347
f_charbig VARCHAR(1000)
8348
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
8349
)
8350
PARTITION BY LIST(MOD(f_int1,4))
8351
(PARTITION part_3 VALUES IN (-3),
8352
PARTITION part_2 VALUES IN (-2),
8353
PARTITION part_1 VALUES IN (-1),
8354
PARTITION part_N VALUES IN (NULL),
8355
PARTITION part0 VALUES IN (0),
8356
PARTITION part1 VALUES IN (1),
8357
PARTITION part2 VALUES IN (2),
8358
PARTITION part3 VALUES IN (3));
8359
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
8360
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
8361
# Start usability test (inc/partition_check.inc)
8362
create_command
8363
SHOW CREATE TABLE t1;
8364
Table	Create Table
8365
t1	CREATE TABLE `t1` (
8366
  `f_int1` int(11) NOT NULL DEFAULT '0',
8367
  `f_int2` int(11) NOT NULL DEFAULT '0',
8368
  `f_char1` char(20) DEFAULT NULL,
8369
  `f_char2` char(20) DEFAULT NULL,
8370
  `f_charbig` varchar(1000) DEFAULT NULL,
8371
  PRIMARY KEY (`f_int2`,`f_int1`),
8372
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
8373
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3) ENGINE = InnoDB, PARTITION part_2 VALUES IN (-2) ENGINE = InnoDB, PARTITION part_1 VALUES IN (-1) ENGINE = InnoDB, PARTITION part_N VALUES IN (NULL) ENGINE = InnoDB, PARTITION part0 VALUES IN (0) ENGINE = InnoDB, PARTITION part1 VALUES IN (1) ENGINE = InnoDB, PARTITION part2 VALUES IN (2) ENGINE = InnoDB, PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
8374
8375
unified filelist
8376
$MYSQLTEST_VARDIR/master-data/test/t1.frm
8377
$MYSQLTEST_VARDIR/master-data/test/t1.par
8378
8379
# check prerequisites-1 success:    1
8380
# check COUNT(*) success:    1
8381
# check MIN/MAX(f_int1) success:    1
8382
# check MIN/MAX(f_int2) success:    1
8383
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8384
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
8385
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
8386
WHERE f_int1 IN (2,3);
8387
ERROR 23000: Can't write; duplicate key in table 't1'
8388
# check prerequisites-3 success:    1
8389
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
8390
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8391
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
8392
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
8393
WHERE f_int1 IN (2,3);
8394
DELETE FROM t1 WHERE f_charbig = 'delete me';
8395
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8396
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
8397
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
8398
WHERE f_int1 IN (2,3);
8399
DELETE FROM t1 WHERE f_charbig = 'delete me';
8400
# check read via f_int1 success: 1
8401
# check read via f_int2 success: 1
8402
	
8403
# check multiple-1 success: 	1
8404
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
8405
	
8406
# check multiple-2 success: 	1
8407
INSERT INTO t1 SELECT * FROM t0_template
8408
WHERE MOD(f_int1,3) = 0;
8409
	
8410
# check multiple-3 success: 	1
8411
UPDATE t1 SET f_int1 = f_int1 + @max_row
8412
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
8413
AND @max_row_div2 + @max_row_div4;
8414
	
8415
# check multiple-4 success: 	1
8416
DELETE FROM t1
8417
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
8418
AND @max_row_div2 + @max_row_div4 + @max_row;
8419
	
8420
# check multiple-5 success: 	1
8421
SELECT COUNT(*) INTO @try_count FROM t0_template
8422
WHERE MOD(f_int1,3) = 0
8423
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
8424
SELECT COUNT(*) INTO @clash_count
8425
FROM t1 INNER JOIN t0_template USING(f_int1)
8426
WHERE MOD(f_int1,3) = 0
8427
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
8428
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
8429
INSERT INTO t1
8430
SET f_int1 = @cur_value , f_int2 = @cur_value,
8431
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
8432
f_charbig = '#SINGLE#';
8433
	
8434
# check single-1 success: 	1
8435
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
8436
INSERT INTO t1
8437
SET f_int1 = @cur_value , f_int2 = @cur_value,
8438
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
8439
f_charbig = '#SINGLE#';
8440
	
8441
# check single-2 success: 	1
8442
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
8443
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
8444
UPDATE t1 SET f_int1 = @cur_value2
8445
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
8446
	
8447
# check single-3 success: 	1
8448
SET @cur_value1= -1;
8449
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
8450
UPDATE t1 SET f_int1 = @cur_value1
8451
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
8452
	
8453
# check single-4 success: 	1
8454
SELECT MAX(f_int1) INTO @cur_value FROM t1;
8455
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
8456
	
8457
# check single-5 success: 	1
8458
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
8459
	
8460
# check single-6 success: 	1
8461
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
8462
	
8463
# check single-7 success: 	1
8464
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
8465
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
8466
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
8467
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
8468
f_charbig = '#NULL#';
8469
INSERT INTO t1
8470
SET f_int1 = NULL , f_int2 = -@max_row,
8471
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
8472
f_charbig = '#NULL#';
8473
ERROR 23000: Column 'f_int1' cannot be null
8474
# check null success:    1
8475
DELETE FROM t1
8476
WHERE f_int1 = 0 AND f_int2 = 0
8477
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
8478
AND f_charbig = '#NULL#';
8479
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8480
SELECT f_int1, f_int1, '', '', 'was inserted'
8481
   FROM t0_template source_tab
8482
WHERE MOD(f_int1,3) = 0
8483
AND f_int1 BETWEEN @max_row_div2 AND @max_row
8484
ON DUPLICATE KEY
8485
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
8486
f_int2 = 2 * @max_row + source_tab.f_int1,
8487
f_charbig = 'was updated';
8488
	
8489
# check unique-1-a success: 	1
8490
	
8491
# check unique-1-b success: 	1
8492
DELETE FROM t1 WHERE f_charbig = 'was inserted';
8493
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8494
f_int2 = CAST(f_char1 AS SIGNED INT),
8495
f_charbig = CONCAT('===',f_char1,'===')
8496
WHERE f_charbig = 'was updated';
8497
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8498
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
8499
   FROM t0_template source_tab
8500
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
8501
	
8502
# check replace success: 	1
8503
DELETE FROM t1
8504
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
8505
DELETE FROM t1
8506
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
8507
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
8508
UPDATE t1 SET f_int2 = f_int1,
8509
f_char1 = CAST(f_int1 AS CHAR),
8510
f_char2 = CAST(f_int1 AS CHAR),
8511
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
8512
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
8513
SET AUTOCOMMIT= 0;
8514
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8515
SELECT f_int1, f_int1, '', '', 'was inserted'
8516
FROM t0_template source_tab
8517
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
8518
	
8519
# check transactions-1 success: 	1
8520
COMMIT WORK;
8521
	
8522
# check transactions-2 success: 	1
8523
ROLLBACK WORK;
8524
	
8525
# check transactions-3 success: 	1
8526
DELETE FROM t1 WHERE f_charbig = 'was inserted';
8527
COMMIT WORK;
8528
ROLLBACK WORK;
8529
	
8530
# check transactions-4 success: 	1
8531
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8532
SELECT f_int1, f_int1, '', '', 'was inserted'
8533
FROM t0_template source_tab
8534
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
8535
	
8536
# check transactions-5 success: 	1
8537
ROLLBACK WORK;
8538
	
8539
# check transactions-6 success: 	1
8540
# INFO: Storage engine used for t1 seems to be transactional.
8541
COMMIT;
8542
	
8543
# check transactions-7 success: 	1
8544
DELETE FROM t1 WHERE f_charbig = 'was inserted';
8545
COMMIT WORK;
8546
SET @@session.sql_mode = 'traditional';
8547
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
8548
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8549
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
8550
'', '', 'was inserted' FROM t0_template
8551
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
8552
ERROR 22012: Division by 0
8553
COMMIT;
8554
	
8555
# check transactions-8 success: 	1
8556
# INFO: Storage engine used for t1 seems to be able to revert
8557
#       changes made by the failing statement.
8558
SET @@session.sql_mode = '';
8559
SET AUTOCOMMIT= 1;
8560
DELETE FROM t1 WHERE f_charbig = 'was inserted';
8561
COMMIT WORK;
8562
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
8563
	
8564
# check special-1 success: 	1
8565
UPDATE t1 SET f_charbig = '';
8566
	
8567
# check special-2 success: 	1
8568
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
8569
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
8570
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
8571
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8572
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8573
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8574
'just inserted' FROM t0_template
8575
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8576
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
8577
BEGIN
8578
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8579
f_charbig = 'updated by trigger'
8580
      WHERE f_int1 = new.f_int1;
8581
END|
8582
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8583
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
8584
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8585
	
8586
# check trigger-1 success: 	1
8587
DROP TRIGGER trg_1;
8588
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8589
f_int2 = CAST(f_char1 AS SIGNED INT),
8590
f_charbig = 'just inserted'
8591
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8592
DELETE FROM t0_aux
8593
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8594
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8595
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8596
'just inserted' FROM t0_template
8597
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8598
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
8599
BEGIN
8600
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8601
f_charbig = 'updated by trigger'
8602
      WHERE f_int1 = new.f_int1;
8603
END|
8604
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8605
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
8606
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8607
	
8608
# check trigger-2 success: 	1
8609
DROP TRIGGER trg_1;
8610
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8611
f_int2 = CAST(f_char1 AS SIGNED INT),
8612
f_charbig = 'just inserted'
8613
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8614
DELETE FROM t0_aux
8615
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8616
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8617
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8618
'just inserted' FROM t0_template
8619
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8620
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
8621
BEGIN
8622
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8623
f_charbig = 'updated by trigger'
8624
      WHERE f_int1 = new.f_int1;
8625
END|
8626
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
8627
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
8628
	
8629
# check trigger-3 success: 	1
8630
DROP TRIGGER trg_1;
8631
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8632
f_int2 = CAST(f_char1 AS SIGNED INT),
8633
f_charbig = 'just inserted'
8634
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8635
DELETE FROM t0_aux
8636
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8637
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8638
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8639
'just inserted' FROM t0_template
8640
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8641
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
8642
BEGIN
8643
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8644
f_charbig = 'updated by trigger'
8645
      WHERE f_int1 = - old.f_int1;
8646
END|
8647
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
8648
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
8649
	
8650
# check trigger-4 success: 	1
8651
DROP TRIGGER trg_1;
8652
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8653
f_int2 = CAST(f_char1 AS SIGNED INT),
8654
f_charbig = 'just inserted'
8655
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8656
DELETE FROM t0_aux
8657
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8658
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8659
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8660
'just inserted' FROM t0_template
8661
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8662
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
8663
BEGIN
8664
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8665
f_charbig = 'updated by trigger'
8666
      WHERE f_int1 = new.f_int1;
8667
END|
8668
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
8669
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
8670
	
8671
# check trigger-5 success: 	1
8672
DROP TRIGGER trg_1;
8673
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8674
f_int2 = CAST(f_char1 AS SIGNED INT),
8675
f_charbig = 'just inserted'
8676
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8677
DELETE FROM t0_aux
8678
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8679
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8680
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8681
'just inserted' FROM t0_template
8682
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8683
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
8684
BEGIN
8685
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8686
f_charbig = 'updated by trigger'
8687
      WHERE f_int1 = - old.f_int1;
8688
END|
8689
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
8690
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
8691
	
8692
# check trigger-6 success: 	1
8693
DROP TRIGGER trg_1;
8694
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8695
f_int2 = CAST(f_char1 AS SIGNED INT),
8696
f_charbig = 'just inserted'
8697
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8698
DELETE FROM t0_aux
8699
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8700
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8701
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8702
'just inserted' FROM t0_template
8703
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8704
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
8705
BEGIN
8706
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8707
f_charbig = 'updated by trigger'
8708
      WHERE f_int1 = - old.f_int1;
8709
END|
8710
DELETE FROM t0_aux
8711
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
8712
	
8713
# check trigger-7 success: 	1
8714
DROP TRIGGER trg_1;
8715
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8716
f_int2 = CAST(f_char1 AS SIGNED INT),
8717
f_charbig = 'just inserted'
8718
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8719
DELETE FROM t0_aux
8720
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8721
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
8722
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
8723
'just inserted' FROM t0_template
8724
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8725
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
8726
BEGIN
8727
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
8728
f_charbig = 'updated by trigger'
8729
      WHERE f_int1 = - old.f_int1;
8730
END|
8731
DELETE FROM t0_aux
8732
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
8733
	
8734
# check trigger-8 success: 	1
8735
DROP TRIGGER trg_1;
8736
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8737
f_int2 = CAST(f_char1 AS SIGNED INT),
8738
f_charbig = 'just inserted'
8739
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
8740
DELETE FROM t0_aux
8741
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8742
DELETE FROM t1
8743
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
8744
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
8745
BEGIN
8746
SET new.f_int1 = old.f_int1 + @max_row,
8747
new.f_int2 = old.f_int2 - @max_row,
8748
new.f_charbig = '####updated per update trigger####';
8749
END|
8750
UPDATE t1
8751
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
8752
f_charbig = '####updated per update statement itself####';
8753
	
8754
# check trigger-9 success: 	1
8755
DROP TRIGGER trg_2;
8756
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8757
f_int2 = CAST(f_char1 AS SIGNED INT),
8758
f_charbig = CONCAT('===',f_char1,'===');
8759
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
8760
BEGIN
8761
SET new.f_int1 = new.f_int1 + @max_row,
8762
new.f_int2 = new.f_int2 - @max_row,
8763
new.f_charbig = '####updated per update trigger####';
8764
END|
8765
UPDATE t1
8766
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
8767
f_charbig = '####updated per update statement itself####';
8768
	
8769
# check trigger-10 success: 	1
8770
DROP TRIGGER trg_2;
8771
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8772
f_int2 = CAST(f_char1 AS SIGNED INT),
8773
f_charbig = CONCAT('===',f_char1,'===');
8774
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
8775
BEGIN
8776
SET new.f_int1 = @my_max1 + @counter,
8777
new.f_int2 = @my_min2 - @counter,
8778
new.f_charbig = '####updated per insert trigger####';
8779
SET @counter = @counter + 1;
8780
END|
8781
SET @counter = 1;
8782
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
8783
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8784
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
8785
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
8786
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
8787
ORDER BY f_int1;
8788
DROP TRIGGER trg_3;
8789
	
8790
# check trigger-11 success: 	1
8791
DELETE FROM t1
8792
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
8793
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
8794
AND f_charbig = '####updated per insert trigger####';
8795
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
8796
BEGIN
8797
SET new.f_int1 = @my_max1 + @counter,
8798
new.f_int2 = @my_min2 - @counter,
8799
new.f_charbig = '####updated per insert trigger####';
8800
SET @counter = @counter + 1;
8801
END|
8802
SET @counter = 1;
8803
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
8804
INSERT INTO t1 (f_char1, f_char2, f_charbig)
8805
SELECT CAST(f_int1 AS CHAR),
8806
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
8807
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
8808
ORDER BY f_int1;
8809
DROP TRIGGER trg_3;
8810
	
8811
# check trigger-12 success: 	1
8812
DELETE FROM t1
8813
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
8814
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
8815
AND f_charbig = '####updated per insert trigger####';
8816
ANALYZE  TABLE t1;
8817
Table	Op	Msg_type	Msg_text
8818
test.t1	analyze	note	The storage engine for the table doesn't support analyze
8819
CHECK    TABLE t1 EXTENDED;
8820
Table	Op	Msg_type	Msg_text
8821
test.t1	check	note	The storage engine for the table doesn't support check
8822
CHECKSUM TABLE t1 EXTENDED;
8823
Table	Checksum
8824
test.t1	<some_value>
8825
OPTIMIZE TABLE t1;
8826
Table	Op	Msg_type	Msg_text
8827
test.t1	optimize	note	The storage engine for the table doesn't support optimize
8828
# check layout success:    1
8829
REPAIR   TABLE t1 EXTENDED;
8830
Table	Op	Msg_type	Msg_text
8831
test.t1	repair	note	The storage engine for the table doesn't support repair
8832
# check layout success:    1
8833
TRUNCATE t1;
8834
	
8835
# check TRUNCATE success: 	1
8836
# check layout success:    1
8837
# End usability test (inc/partition_check.inc)
8838
DROP TABLE t1;
8839
CREATE TABLE t1 (
8840
f_int1 INTEGER,
8841
f_int2 INTEGER,
8842
f_char1 CHAR(20),
8843
f_char2 CHAR(20),
8844
f_charbig VARCHAR(1000)
8845
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
8846
)
8847
PARTITION BY RANGE(f_int1)
8848
(PARTITION parta VALUES LESS THAN (0),
8849
PARTITION partb VALUES LESS THAN (5),
8850
PARTITION partc VALUES LESS THAN (10),
8851
PARTITION partd VALUES LESS THAN (10 + 5),
8852
PARTITION parte VALUES LESS THAN (20),
8853
PARTITION partf VALUES LESS THAN (2147483646));
8854
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
8855
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
8856
# Start usability test (inc/partition_check.inc)
8857
create_command
8858
SHOW CREATE TABLE t1;
8859
Table	Create Table
8860
t1	CREATE TABLE `t1` (
8861
  `f_int1` int(11) NOT NULL DEFAULT '0',
8862
  `f_int2` int(11) NOT NULL DEFAULT '0',
8863
  `f_char1` char(20) DEFAULT NULL,
8864
  `f_char2` char(20) DEFAULT NULL,
8865
  `f_charbig` varchar(1000) DEFAULT NULL,
8866
  PRIMARY KEY (`f_int2`,`f_int1`),
8867
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
8868
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION parte VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
8869
8870
unified filelist
8871
$MYSQLTEST_VARDIR/master-data/test/t1.frm
8872
$MYSQLTEST_VARDIR/master-data/test/t1.par
8873
8874
# check prerequisites-1 success:    1
8875
# check COUNT(*) success:    1
8876
# check MIN/MAX(f_int1) success:    1
8877
# check MIN/MAX(f_int2) success:    1
8878
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8879
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
8880
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
8881
WHERE f_int1 IN (2,3);
8882
ERROR 23000: Can't write; duplicate key in table 't1'
8883
# check prerequisites-3 success:    1
8884
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
8885
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8886
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
8887
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
8888
WHERE f_int1 IN (2,3);
8889
DELETE FROM t1 WHERE f_charbig = 'delete me';
8890
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8891
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
8892
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
8893
WHERE f_int1 IN (2,3);
8894
DELETE FROM t1 WHERE f_charbig = 'delete me';
8895
# check read via f_int1 success: 1
8896
# check read via f_int2 success: 1
8897
	
8898
# check multiple-1 success: 	1
8899
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
8900
	
8901
# check multiple-2 success: 	1
8902
INSERT INTO t1 SELECT * FROM t0_template
8903
WHERE MOD(f_int1,3) = 0;
8904
	
8905
# check multiple-3 success: 	1
8906
UPDATE t1 SET f_int1 = f_int1 + @max_row
8907
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
8908
AND @max_row_div2 + @max_row_div4;
8909
	
8910
# check multiple-4 success: 	1
8911
DELETE FROM t1
8912
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
8913
AND @max_row_div2 + @max_row_div4 + @max_row;
8914
	
8915
# check multiple-5 success: 	1
8916
SELECT COUNT(*) INTO @try_count FROM t0_template
8917
WHERE MOD(f_int1,3) = 0
8918
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
8919
SELECT COUNT(*) INTO @clash_count
8920
FROM t1 INNER JOIN t0_template USING(f_int1)
8921
WHERE MOD(f_int1,3) = 0
8922
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
8923
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
8924
INSERT INTO t1
8925
SET f_int1 = @cur_value , f_int2 = @cur_value,
8926
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
8927
f_charbig = '#SINGLE#';
8928
	
8929
# check single-1 success: 	1
8930
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
8931
INSERT INTO t1
8932
SET f_int1 = @cur_value , f_int2 = @cur_value,
8933
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
8934
f_charbig = '#SINGLE#';
8935
	
8936
# check single-2 success: 	1
8937
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
8938
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
8939
UPDATE t1 SET f_int1 = @cur_value2
8940
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
8941
	
8942
# check single-3 success: 	1
8943
SET @cur_value1= -1;
8944
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
8945
UPDATE t1 SET f_int1 = @cur_value1
8946
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
8947
	
8948
# check single-4 success: 	1
8949
SELECT MAX(f_int1) INTO @cur_value FROM t1;
8950
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
8951
	
8952
# check single-5 success: 	1
8953
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
8954
	
8955
# check single-6 success: 	1
8956
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
8957
ERROR HY000: Table has no partition for value 2147483647
8958
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
8959
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
8960
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
8961
f_charbig = '#NULL#';
8962
INSERT INTO t1
8963
SET f_int1 = NULL , f_int2 = -@max_row,
8964
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
8965
f_charbig = '#NULL#';
8966
ERROR 23000: Column 'f_int1' cannot be null
8967
# check null success:    1
8968
DELETE FROM t1
8969
WHERE f_int1 = 0 AND f_int2 = 0
8970
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
8971
AND f_charbig = '#NULL#';
8972
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8973
SELECT f_int1, f_int1, '', '', 'was inserted'
8974
   FROM t0_template source_tab
8975
WHERE MOD(f_int1,3) = 0
8976
AND f_int1 BETWEEN @max_row_div2 AND @max_row
8977
ON DUPLICATE KEY
8978
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
8979
f_int2 = 2 * @max_row + source_tab.f_int1,
8980
f_charbig = 'was updated';
8981
	
8982
# check unique-1-a success: 	1
8983
	
8984
# check unique-1-b success: 	1
8985
DELETE FROM t1 WHERE f_charbig = 'was inserted';
8986
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
8987
f_int2 = CAST(f_char1 AS SIGNED INT),
8988
f_charbig = CONCAT('===',f_char1,'===')
8989
WHERE f_charbig = 'was updated';
8990
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
8991
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
8992
   FROM t0_template source_tab
8993
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
8994
	
8995
# check replace success: 	1
8996
DELETE FROM t1
8997
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
8998
DELETE FROM t1
8999
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
9000
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
9001
UPDATE t1 SET f_int2 = f_int1,
9002
f_char1 = CAST(f_int1 AS CHAR),
9003
f_char2 = CAST(f_int1 AS CHAR),
9004
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
9005
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
9006
SET AUTOCOMMIT= 0;
9007
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9008
SELECT f_int1, f_int1, '', '', 'was inserted'
9009
FROM t0_template source_tab
9010
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
9011
	
9012
# check transactions-1 success: 	1
9013
COMMIT WORK;
9014
	
9015
# check transactions-2 success: 	1
9016
ROLLBACK WORK;
9017
	
9018
# check transactions-3 success: 	1
9019
DELETE FROM t1 WHERE f_charbig = 'was inserted';
9020
COMMIT WORK;
9021
ROLLBACK WORK;
9022
	
9023
# check transactions-4 success: 	1
9024
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9025
SELECT f_int1, f_int1, '', '', 'was inserted'
9026
FROM t0_template source_tab
9027
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
9028
	
9029
# check transactions-5 success: 	1
9030
ROLLBACK WORK;
9031
	
9032
# check transactions-6 success: 	1
9033
# INFO: Storage engine used for t1 seems to be transactional.
9034
COMMIT;
9035
	
9036
# check transactions-7 success: 	1
9037
DELETE FROM t1 WHERE f_charbig = 'was inserted';
9038
COMMIT WORK;
9039
SET @@session.sql_mode = 'traditional';
9040
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
9041
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9042
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
9043
'', '', 'was inserted' FROM t0_template
9044
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
9045
ERROR 22012: Division by 0
9046
COMMIT;
9047
	
9048
# check transactions-8 success: 	1
9049
# INFO: Storage engine used for t1 seems to be able to revert
9050
#       changes made by the failing statement.
9051
SET @@session.sql_mode = '';
9052
SET AUTOCOMMIT= 1;
9053
DELETE FROM t1 WHERE f_charbig = 'was inserted';
9054
COMMIT WORK;
9055
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
9056
	
9057
# check special-1 success: 	1
9058
UPDATE t1 SET f_charbig = '';
9059
	
9060
# check special-2 success: 	1
9061
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
9062
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
9063
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
9064
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9065
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9066
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9067
'just inserted' FROM t0_template
9068
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9069
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
9070
BEGIN
9071
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9072
f_charbig = 'updated by trigger'
9073
      WHERE f_int1 = new.f_int1;
9074
END|
9075
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9076
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
9077
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9078
	
9079
# check trigger-1 success: 	1
9080
DROP TRIGGER trg_1;
9081
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9082
f_int2 = CAST(f_char1 AS SIGNED INT),
9083
f_charbig = 'just inserted'
9084
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9085
DELETE FROM t0_aux
9086
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9087
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9088
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9089
'just inserted' FROM t0_template
9090
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9091
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
9092
BEGIN
9093
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9094
f_charbig = 'updated by trigger'
9095
      WHERE f_int1 = new.f_int1;
9096
END|
9097
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9098
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
9099
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9100
	
9101
# check trigger-2 success: 	1
9102
DROP TRIGGER trg_1;
9103
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9104
f_int2 = CAST(f_char1 AS SIGNED INT),
9105
f_charbig = 'just inserted'
9106
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9107
DELETE FROM t0_aux
9108
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9109
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9110
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9111
'just inserted' FROM t0_template
9112
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9113
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
9114
BEGIN
9115
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9116
f_charbig = 'updated by trigger'
9117
      WHERE f_int1 = new.f_int1;
9118
END|
9119
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
9120
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
9121
	
9122
# check trigger-3 success: 	1
9123
DROP TRIGGER trg_1;
9124
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9125
f_int2 = CAST(f_char1 AS SIGNED INT),
9126
f_charbig = 'just inserted'
9127
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9128
DELETE FROM t0_aux
9129
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9130
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9131
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9132
'just inserted' FROM t0_template
9133
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9134
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
9135
BEGIN
9136
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9137
f_charbig = 'updated by trigger'
9138
      WHERE f_int1 = - old.f_int1;
9139
END|
9140
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
9141
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
9142
	
9143
# check trigger-4 success: 	1
9144
DROP TRIGGER trg_1;
9145
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9146
f_int2 = CAST(f_char1 AS SIGNED INT),
9147
f_charbig = 'just inserted'
9148
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9149
DELETE FROM t0_aux
9150
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9151
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9152
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9153
'just inserted' FROM t0_template
9154
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9155
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
9156
BEGIN
9157
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9158
f_charbig = 'updated by trigger'
9159
      WHERE f_int1 = new.f_int1;
9160
END|
9161
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
9162
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
9163
	
9164
# check trigger-5 success: 	1
9165
DROP TRIGGER trg_1;
9166
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9167
f_int2 = CAST(f_char1 AS SIGNED INT),
9168
f_charbig = 'just inserted'
9169
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9170
DELETE FROM t0_aux
9171
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9172
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9173
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9174
'just inserted' FROM t0_template
9175
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9176
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
9177
BEGIN
9178
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9179
f_charbig = 'updated by trigger'
9180
      WHERE f_int1 = - old.f_int1;
9181
END|
9182
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
9183
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
9184
	
9185
# check trigger-6 success: 	1
9186
DROP TRIGGER trg_1;
9187
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9188
f_int2 = CAST(f_char1 AS SIGNED INT),
9189
f_charbig = 'just inserted'
9190
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9191
DELETE FROM t0_aux
9192
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9193
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9194
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9195
'just inserted' FROM t0_template
9196
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9197
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
9198
BEGIN
9199
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9200
f_charbig = 'updated by trigger'
9201
      WHERE f_int1 = - old.f_int1;
9202
END|
9203
DELETE FROM t0_aux
9204
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
9205
	
9206
# check trigger-7 success: 	1
9207
DROP TRIGGER trg_1;
9208
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9209
f_int2 = CAST(f_char1 AS SIGNED INT),
9210
f_charbig = 'just inserted'
9211
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9212
DELETE FROM t0_aux
9213
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9214
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9215
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9216
'just inserted' FROM t0_template
9217
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9218
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
9219
BEGIN
9220
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9221
f_charbig = 'updated by trigger'
9222
      WHERE f_int1 = - old.f_int1;
9223
END|
9224
DELETE FROM t0_aux
9225
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
9226
	
9227
# check trigger-8 success: 	1
9228
DROP TRIGGER trg_1;
9229
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9230
f_int2 = CAST(f_char1 AS SIGNED INT),
9231
f_charbig = 'just inserted'
9232
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9233
DELETE FROM t0_aux
9234
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9235
DELETE FROM t1
9236
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9237
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
9238
BEGIN
9239
SET new.f_int1 = old.f_int1 + @max_row,
9240
new.f_int2 = old.f_int2 - @max_row,
9241
new.f_charbig = '####updated per update trigger####';
9242
END|
9243
UPDATE t1
9244
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
9245
f_charbig = '####updated per update statement itself####';
9246
	
9247
# check trigger-9 success: 	1
9248
DROP TRIGGER trg_2;
9249
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9250
f_int2 = CAST(f_char1 AS SIGNED INT),
9251
f_charbig = CONCAT('===',f_char1,'===');
9252
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
9253
BEGIN
9254
SET new.f_int1 = new.f_int1 + @max_row,
9255
new.f_int2 = new.f_int2 - @max_row,
9256
new.f_charbig = '####updated per update trigger####';
9257
END|
9258
UPDATE t1
9259
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
9260
f_charbig = '####updated per update statement itself####';
9261
	
9262
# check trigger-10 success: 	1
9263
DROP TRIGGER trg_2;
9264
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9265
f_int2 = CAST(f_char1 AS SIGNED INT),
9266
f_charbig = CONCAT('===',f_char1,'===');
9267
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
9268
BEGIN
9269
SET new.f_int1 = @my_max1 + @counter,
9270
new.f_int2 = @my_min2 - @counter,
9271
new.f_charbig = '####updated per insert trigger####';
9272
SET @counter = @counter + 1;
9273
END|
9274
SET @counter = 1;
9275
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
9276
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9277
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
9278
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
9279
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
9280
ORDER BY f_int1;
9281
DROP TRIGGER trg_3;
9282
	
9283
# check trigger-11 success: 	1
9284
DELETE FROM t1
9285
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
9286
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
9287
AND f_charbig = '####updated per insert trigger####';
9288
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
9289
BEGIN
9290
SET new.f_int1 = @my_max1 + @counter,
9291
new.f_int2 = @my_min2 - @counter,
9292
new.f_charbig = '####updated per insert trigger####';
9293
SET @counter = @counter + 1;
9294
END|
9295
SET @counter = 1;
9296
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
9297
INSERT INTO t1 (f_char1, f_char2, f_charbig)
9298
SELECT CAST(f_int1 AS CHAR),
9299
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
9300
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
9301
ORDER BY f_int1;
9302
DROP TRIGGER trg_3;
9303
	
9304
# check trigger-12 success: 	1
9305
DELETE FROM t1
9306
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
9307
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
9308
AND f_charbig = '####updated per insert trigger####';
9309
ANALYZE  TABLE t1;
9310
Table	Op	Msg_type	Msg_text
9311
test.t1	analyze	note	The storage engine for the table doesn't support analyze
9312
CHECK    TABLE t1 EXTENDED;
9313
Table	Op	Msg_type	Msg_text
9314
test.t1	check	note	The storage engine for the table doesn't support check
9315
CHECKSUM TABLE t1 EXTENDED;
9316
Table	Checksum
9317
test.t1	<some_value>
9318
OPTIMIZE TABLE t1;
9319
Table	Op	Msg_type	Msg_text
9320
test.t1	optimize	note	The storage engine for the table doesn't support optimize
9321
# check layout success:    1
9322
REPAIR   TABLE t1 EXTENDED;
9323
Table	Op	Msg_type	Msg_text
9324
test.t1	repair	note	The storage engine for the table doesn't support repair
9325
# check layout success:    1
9326
TRUNCATE t1;
9327
	
9328
# check TRUNCATE success: 	1
9329
# check layout success:    1
9330
# End usability test (inc/partition_check.inc)
9331
DROP TABLE t1;
9332
CREATE TABLE t1 (
9333
f_int1 INTEGER,
9334
f_int2 INTEGER,
9335
f_char1 CHAR(20),
9336
f_char2 CHAR(20),
9337
f_charbig VARCHAR(1000)
9338
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
9339
)
9340
PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
9341
(PARTITION parta VALUES LESS THAN (0),
9342
PARTITION partb VALUES LESS THAN (5),
9343
PARTITION partc VALUES LESS THAN (10),
9344
PARTITION partd VALUES LESS THAN (2147483646));
9345
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
9346
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
9347
# Start usability test (inc/partition_check.inc)
9348
create_command
9349
SHOW CREATE TABLE t1;
9350
Table	Create Table
9351
t1	CREATE TABLE `t1` (
9352
  `f_int1` int(11) NOT NULL DEFAULT '0',
9353
  `f_int2` int(11) NOT NULL DEFAULT '0',
9354
  `f_char1` char(20) DEFAULT NULL,
9355
  `f_char2` char(20) DEFAULT NULL,
9356
  `f_charbig` varchar(1000) DEFAULT NULL,
9357
  PRIMARY KEY (`f_int2`,`f_int1`),
9358
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
9359
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1 DIV 2) SUBPARTITION BY HASH (f_int1) SUBPARTITIONS 2 (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
9360
9361
unified filelist
9362
$MYSQLTEST_VARDIR/master-data/test/t1.frm
9363
$MYSQLTEST_VARDIR/master-data/test/t1.par
9364
9365
# check prerequisites-1 success:    1
9366
# check COUNT(*) success:    1
9367
# check MIN/MAX(f_int1) success:    1
9368
# check MIN/MAX(f_int2) success:    1
9369
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9370
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
9371
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
9372
WHERE f_int1 IN (2,3);
9373
ERROR 23000: Can't write; duplicate key in table 't1'
9374
# check prerequisites-3 success:    1
9375
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
9376
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9377
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
9378
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
9379
WHERE f_int1 IN (2,3);
9380
DELETE FROM t1 WHERE f_charbig = 'delete me';
9381
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9382
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
9383
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
9384
WHERE f_int1 IN (2,3);
9385
DELETE FROM t1 WHERE f_charbig = 'delete me';
9386
# check read via f_int1 success: 1
9387
# check read via f_int2 success: 1
9388
	
9389
# check multiple-1 success: 	1
9390
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
9391
	
9392
# check multiple-2 success: 	1
9393
INSERT INTO t1 SELECT * FROM t0_template
9394
WHERE MOD(f_int1,3) = 0;
9395
	
9396
# check multiple-3 success: 	1
9397
UPDATE t1 SET f_int1 = f_int1 + @max_row
9398
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
9399
AND @max_row_div2 + @max_row_div4;
9400
	
9401
# check multiple-4 success: 	1
9402
DELETE FROM t1
9403
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
9404
AND @max_row_div2 + @max_row_div4 + @max_row;
9405
	
9406
# check multiple-5 success: 	1
9407
SELECT COUNT(*) INTO @try_count FROM t0_template
9408
WHERE MOD(f_int1,3) = 0
9409
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
9410
SELECT COUNT(*) INTO @clash_count
9411
FROM t1 INNER JOIN t0_template USING(f_int1)
9412
WHERE MOD(f_int1,3) = 0
9413
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
9414
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
9415
INSERT INTO t1
9416
SET f_int1 = @cur_value , f_int2 = @cur_value,
9417
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
9418
f_charbig = '#SINGLE#';
9419
	
9420
# check single-1 success: 	1
9421
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
9422
INSERT INTO t1
9423
SET f_int1 = @cur_value , f_int2 = @cur_value,
9424
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
9425
f_charbig = '#SINGLE#';
9426
	
9427
# check single-2 success: 	1
9428
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
9429
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
9430
UPDATE t1 SET f_int1 = @cur_value2
9431
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
9432
	
9433
# check single-3 success: 	1
9434
SET @cur_value1= -1;
9435
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
9436
UPDATE t1 SET f_int1 = @cur_value1
9437
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
9438
	
9439
# check single-4 success: 	1
9440
SELECT MAX(f_int1) INTO @cur_value FROM t1;
9441
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
9442
	
9443
# check single-5 success: 	1
9444
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
9445
	
9446
# check single-6 success: 	1
9447
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
9448
	
9449
# check single-7 success: 	1
9450
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
9451
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
9452
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
9453
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
9454
f_charbig = '#NULL#';
9455
INSERT INTO t1
9456
SET f_int1 = NULL , f_int2 = -@max_row,
9457
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
9458
f_charbig = '#NULL#';
9459
ERROR 23000: Column 'f_int1' cannot be null
9460
# check null success:    1
9461
DELETE FROM t1
9462
WHERE f_int1 = 0 AND f_int2 = 0
9463
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
9464
AND f_charbig = '#NULL#';
9465
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9466
SELECT f_int1, f_int1, '', '', 'was inserted'
9467
   FROM t0_template source_tab
9468
WHERE MOD(f_int1,3) = 0
9469
AND f_int1 BETWEEN @max_row_div2 AND @max_row
9470
ON DUPLICATE KEY
9471
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
9472
f_int2 = 2 * @max_row + source_tab.f_int1,
9473
f_charbig = 'was updated';
9474
	
9475
# check unique-1-a success: 	1
9476
	
9477
# check unique-1-b success: 	1
9478
DELETE FROM t1 WHERE f_charbig = 'was inserted';
9479
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9480
f_int2 = CAST(f_char1 AS SIGNED INT),
9481
f_charbig = CONCAT('===',f_char1,'===')
9482
WHERE f_charbig = 'was updated';
9483
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9484
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
9485
   FROM t0_template source_tab
9486
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
9487
	
9488
# check replace success: 	1
9489
DELETE FROM t1
9490
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
9491
DELETE FROM t1
9492
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
9493
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
9494
UPDATE t1 SET f_int2 = f_int1,
9495
f_char1 = CAST(f_int1 AS CHAR),
9496
f_char2 = CAST(f_int1 AS CHAR),
9497
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
9498
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
9499
SET AUTOCOMMIT= 0;
9500
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9501
SELECT f_int1, f_int1, '', '', 'was inserted'
9502
FROM t0_template source_tab
9503
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
9504
	
9505
# check transactions-1 success: 	1
9506
COMMIT WORK;
9507
	
9508
# check transactions-2 success: 	1
9509
ROLLBACK WORK;
9510
	
9511
# check transactions-3 success: 	1
9512
DELETE FROM t1 WHERE f_charbig = 'was inserted';
9513
COMMIT WORK;
9514
ROLLBACK WORK;
9515
	
9516
# check transactions-4 success: 	1
9517
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9518
SELECT f_int1, f_int1, '', '', 'was inserted'
9519
FROM t0_template source_tab
9520
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
9521
	
9522
# check transactions-5 success: 	1
9523
ROLLBACK WORK;
9524
	
9525
# check transactions-6 success: 	1
9526
# INFO: Storage engine used for t1 seems to be transactional.
9527
COMMIT;
9528
	
9529
# check transactions-7 success: 	1
9530
DELETE FROM t1 WHERE f_charbig = 'was inserted';
9531
COMMIT WORK;
9532
SET @@session.sql_mode = 'traditional';
9533
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
9534
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9535
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
9536
'', '', 'was inserted' FROM t0_template
9537
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
9538
ERROR 22012: Division by 0
9539
COMMIT;
9540
	
9541
# check transactions-8 success: 	1
9542
# INFO: Storage engine used for t1 seems to be able to revert
9543
#       changes made by the failing statement.
9544
SET @@session.sql_mode = '';
9545
SET AUTOCOMMIT= 1;
9546
DELETE FROM t1 WHERE f_charbig = 'was inserted';
9547
COMMIT WORK;
9548
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
9549
	
9550
# check special-1 success: 	1
9551
UPDATE t1 SET f_charbig = '';
9552
	
9553
# check special-2 success: 	1
9554
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
9555
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
9556
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
9557
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9558
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9559
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9560
'just inserted' FROM t0_template
9561
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9562
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
9563
BEGIN
9564
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9565
f_charbig = 'updated by trigger'
9566
      WHERE f_int1 = new.f_int1;
9567
END|
9568
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9569
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
9570
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9571
	
9572
# check trigger-1 success: 	1
9573
DROP TRIGGER trg_1;
9574
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9575
f_int2 = CAST(f_char1 AS SIGNED INT),
9576
f_charbig = 'just inserted'
9577
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9578
DELETE FROM t0_aux
9579
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9580
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9581
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9582
'just inserted' FROM t0_template
9583
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9584
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
9585
BEGIN
9586
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9587
f_charbig = 'updated by trigger'
9588
      WHERE f_int1 = new.f_int1;
9589
END|
9590
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9591
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
9592
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9593
	
9594
# check trigger-2 success: 	1
9595
DROP TRIGGER trg_1;
9596
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9597
f_int2 = CAST(f_char1 AS SIGNED INT),
9598
f_charbig = 'just inserted'
9599
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9600
DELETE FROM t0_aux
9601
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9602
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9603
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9604
'just inserted' FROM t0_template
9605
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9606
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
9607
BEGIN
9608
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9609
f_charbig = 'updated by trigger'
9610
      WHERE f_int1 = new.f_int1;
9611
END|
9612
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
9613
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
9614
	
9615
# check trigger-3 success: 	1
9616
DROP TRIGGER trg_1;
9617
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9618
f_int2 = CAST(f_char1 AS SIGNED INT),
9619
f_charbig = 'just inserted'
9620
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9621
DELETE FROM t0_aux
9622
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9623
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9624
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9625
'just inserted' FROM t0_template
9626
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9627
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
9628
BEGIN
9629
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9630
f_charbig = 'updated by trigger'
9631
      WHERE f_int1 = - old.f_int1;
9632
END|
9633
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
9634
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
9635
	
9636
# check trigger-4 success: 	1
9637
DROP TRIGGER trg_1;
9638
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9639
f_int2 = CAST(f_char1 AS SIGNED INT),
9640
f_charbig = 'just inserted'
9641
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9642
DELETE FROM t0_aux
9643
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9644
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9645
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9646
'just inserted' FROM t0_template
9647
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9648
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
9649
BEGIN
9650
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9651
f_charbig = 'updated by trigger'
9652
      WHERE f_int1 = new.f_int1;
9653
END|
9654
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
9655
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
9656
	
9657
# check trigger-5 success: 	1
9658
DROP TRIGGER trg_1;
9659
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9660
f_int2 = CAST(f_char1 AS SIGNED INT),
9661
f_charbig = 'just inserted'
9662
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9663
DELETE FROM t0_aux
9664
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9665
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9666
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9667
'just inserted' FROM t0_template
9668
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9669
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
9670
BEGIN
9671
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9672
f_charbig = 'updated by trigger'
9673
      WHERE f_int1 = - old.f_int1;
9674
END|
9675
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
9676
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
9677
	
9678
# check trigger-6 success: 	1
9679
DROP TRIGGER trg_1;
9680
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9681
f_int2 = CAST(f_char1 AS SIGNED INT),
9682
f_charbig = 'just inserted'
9683
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9684
DELETE FROM t0_aux
9685
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9686
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9687
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9688
'just inserted' FROM t0_template
9689
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9690
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
9691
BEGIN
9692
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9693
f_charbig = 'updated by trigger'
9694
      WHERE f_int1 = - old.f_int1;
9695
END|
9696
DELETE FROM t0_aux
9697
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
9698
	
9699
# check trigger-7 success: 	1
9700
DROP TRIGGER trg_1;
9701
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9702
f_int2 = CAST(f_char1 AS SIGNED INT),
9703
f_charbig = 'just inserted'
9704
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9705
DELETE FROM t0_aux
9706
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9707
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
9708
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
9709
'just inserted' FROM t0_template
9710
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9711
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
9712
BEGIN
9713
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
9714
f_charbig = 'updated by trigger'
9715
      WHERE f_int1 = - old.f_int1;
9716
END|
9717
DELETE FROM t0_aux
9718
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
9719
	
9720
# check trigger-8 success: 	1
9721
DROP TRIGGER trg_1;
9722
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9723
f_int2 = CAST(f_char1 AS SIGNED INT),
9724
f_charbig = 'just inserted'
9725
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
9726
DELETE FROM t0_aux
9727
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9728
DELETE FROM t1
9729
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
9730
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
9731
BEGIN
9732
SET new.f_int1 = old.f_int1 + @max_row,
9733
new.f_int2 = old.f_int2 - @max_row,
9734
new.f_charbig = '####updated per update trigger####';
9735
END|
9736
UPDATE t1
9737
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
9738
f_charbig = '####updated per update statement itself####';
9739
	
9740
# check trigger-9 success: 	1
9741
DROP TRIGGER trg_2;
9742
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9743
f_int2 = CAST(f_char1 AS SIGNED INT),
9744
f_charbig = CONCAT('===',f_char1,'===');
9745
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
9746
BEGIN
9747
SET new.f_int1 = new.f_int1 + @max_row,
9748
new.f_int2 = new.f_int2 - @max_row,
9749
new.f_charbig = '####updated per update trigger####';
9750
END|
9751
UPDATE t1
9752
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
9753
f_charbig = '####updated per update statement itself####';
9754
	
9755
# check trigger-10 success: 	1
9756
DROP TRIGGER trg_2;
9757
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9758
f_int2 = CAST(f_char1 AS SIGNED INT),
9759
f_charbig = CONCAT('===',f_char1,'===');
9760
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
9761
BEGIN
9762
SET new.f_int1 = @my_max1 + @counter,
9763
new.f_int2 = @my_min2 - @counter,
9764
new.f_charbig = '####updated per insert trigger####';
9765
SET @counter = @counter + 1;
9766
END|
9767
SET @counter = 1;
9768
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
9769
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9770
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
9771
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
9772
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
9773
ORDER BY f_int1;
9774
DROP TRIGGER trg_3;
9775
	
9776
# check trigger-11 success: 	1
9777
DELETE FROM t1
9778
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
9779
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
9780
AND f_charbig = '####updated per insert trigger####';
9781
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
9782
BEGIN
9783
SET new.f_int1 = @my_max1 + @counter,
9784
new.f_int2 = @my_min2 - @counter,
9785
new.f_charbig = '####updated per insert trigger####';
9786
SET @counter = @counter + 1;
9787
END|
9788
SET @counter = 1;
9789
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
9790
INSERT INTO t1 (f_char1, f_char2, f_charbig)
9791
SELECT CAST(f_int1 AS CHAR),
9792
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
9793
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
9794
ORDER BY f_int1;
9795
DROP TRIGGER trg_3;
9796
	
9797
# check trigger-12 success: 	1
9798
DELETE FROM t1
9799
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
9800
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
9801
AND f_charbig = '####updated per insert trigger####';
9802
ANALYZE  TABLE t1;
9803
Table	Op	Msg_type	Msg_text
9804
test.t1	analyze	note	The storage engine for the table doesn't support analyze
9805
CHECK    TABLE t1 EXTENDED;
9806
Table	Op	Msg_type	Msg_text
9807
test.t1	check	note	The storage engine for the table doesn't support check
9808
CHECKSUM TABLE t1 EXTENDED;
9809
Table	Checksum
9810
test.t1	<some_value>
9811
OPTIMIZE TABLE t1;
9812
Table	Op	Msg_type	Msg_text
9813
test.t1	optimize	note	The storage engine for the table doesn't support optimize
9814
# check layout success:    1
9815
REPAIR   TABLE t1 EXTENDED;
9816
Table	Op	Msg_type	Msg_text
9817
test.t1	repair	note	The storage engine for the table doesn't support repair
9818
# check layout success:    1
9819
TRUNCATE t1;
9820
	
9821
# check TRUNCATE success: 	1
9822
# check layout success:    1
9823
# End usability test (inc/partition_check.inc)
9824
DROP TABLE t1;
9825
CREATE TABLE t1 (
9826
f_int1 INTEGER,
9827
f_int2 INTEGER,
9828
f_char1 CHAR(20),
9829
f_char2 CHAR(20),
9830
f_charbig VARCHAR(1000)
9831
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
9832
)
9833
PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1)
9834
(PARTITION part1 VALUES LESS THAN (0)
9835
(SUBPARTITION subpart11, SUBPARTITION subpart12),
9836
PARTITION part2 VALUES LESS THAN (5)
9837
(SUBPARTITION subpart21, SUBPARTITION subpart22),
9838
PARTITION part3 VALUES LESS THAN (10)
9839
(SUBPARTITION subpart31, SUBPARTITION subpart32),
9840
PARTITION part4 VALUES LESS THAN (2147483646)
9841
(SUBPARTITION subpart41, SUBPARTITION subpart42));
9842
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
9843
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
9844
# Start usability test (inc/partition_check.inc)
9845
create_command
9846
SHOW CREATE TABLE t1;
9847
Table	Create Table
9848
t1	CREATE TABLE `t1` (
9849
  `f_int1` int(11) NOT NULL DEFAULT '0',
9850
  `f_int2` int(11) NOT NULL DEFAULT '0',
9851
  `f_char1` char(20) DEFAULT NULL,
9852
  `f_char2` char(20) DEFAULT NULL,
9853
  `f_charbig` varchar(1000) DEFAULT NULL,
9854
  PRIMARY KEY (`f_int2`,`f_int1`),
9855
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
9856
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), PARTITION part2 VALUES LESS THAN (5) (SUBPARTITION subpart21 ENGINE = InnoDB, SUBPARTITION subpart22 ENGINE = InnoDB), PARTITION part3 VALUES LESS THAN (10) (SUBPARTITION subpart31 ENGINE = InnoDB, SUBPARTITION subpart32 ENGINE = InnoDB), PARTITION part4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41 ENGINE = InnoDB, SUBPARTITION subpart42 ENGINE = InnoDB)) */
9857
9858
unified filelist
9859
$MYSQLTEST_VARDIR/master-data/test/t1.frm
9860
$MYSQLTEST_VARDIR/master-data/test/t1.par
9861
9862
# check prerequisites-1 success:    1
9863
# check COUNT(*) success:    1
9864
# check MIN/MAX(f_int1) success:    1
9865
# check MIN/MAX(f_int2) success:    1
9866
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9867
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
9868
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
9869
WHERE f_int1 IN (2,3);
9870
ERROR 23000: Can't write; duplicate key in table 't1'
9871
# check prerequisites-3 success:    1
9872
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
9873
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9874
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
9875
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
9876
WHERE f_int1 IN (2,3);
9877
DELETE FROM t1 WHERE f_charbig = 'delete me';
9878
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9879
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
9880
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
9881
WHERE f_int1 IN (2,3);
9882
DELETE FROM t1 WHERE f_charbig = 'delete me';
9883
# check read via f_int1 success: 1
9884
# check read via f_int2 success: 1
9885
	
9886
# check multiple-1 success: 	1
9887
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
9888
	
9889
# check multiple-2 success: 	1
9890
INSERT INTO t1 SELECT * FROM t0_template
9891
WHERE MOD(f_int1,3) = 0;
9892
	
9893
# check multiple-3 success: 	1
9894
UPDATE t1 SET f_int1 = f_int1 + @max_row
9895
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
9896
AND @max_row_div2 + @max_row_div4;
9897
	
9898
# check multiple-4 success: 	1
9899
DELETE FROM t1
9900
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
9901
AND @max_row_div2 + @max_row_div4 + @max_row;
9902
	
9903
# check multiple-5 success: 	1
9904
SELECT COUNT(*) INTO @try_count FROM t0_template
9905
WHERE MOD(f_int1,3) = 0
9906
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
9907
SELECT COUNT(*) INTO @clash_count
9908
FROM t1 INNER JOIN t0_template USING(f_int1)
9909
WHERE MOD(f_int1,3) = 0
9910
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
9911
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
9912
INSERT INTO t1
9913
SET f_int1 = @cur_value , f_int2 = @cur_value,
9914
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
9915
f_charbig = '#SINGLE#';
9916
	
9917
# check single-1 success: 	1
9918
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
9919
INSERT INTO t1
9920
SET f_int1 = @cur_value , f_int2 = @cur_value,
9921
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
9922
f_charbig = '#SINGLE#';
9923
	
9924
# check single-2 success: 	1
9925
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
9926
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
9927
UPDATE t1 SET f_int1 = @cur_value2
9928
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
9929
	
9930
# check single-3 success: 	1
9931
SET @cur_value1= -1;
9932
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
9933
UPDATE t1 SET f_int1 = @cur_value1
9934
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
9935
	
9936
# check single-4 success: 	1
9937
SELECT MAX(f_int1) INTO @cur_value FROM t1;
9938
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
9939
	
9940
# check single-5 success: 	1
9941
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
9942
	
9943
# check single-6 success: 	1
9944
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
9945
ERROR HY000: Table has no partition for value 2147483647
9946
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
9947
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
9948
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
9949
f_charbig = '#NULL#';
9950
INSERT INTO t1
9951
SET f_int1 = NULL , f_int2 = -@max_row,
9952
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
9953
f_charbig = '#NULL#';
9954
ERROR 23000: Column 'f_int1' cannot be null
9955
# check null success:    1
9956
DELETE FROM t1
9957
WHERE f_int1 = 0 AND f_int2 = 0
9958
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
9959
AND f_charbig = '#NULL#';
9960
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9961
SELECT f_int1, f_int1, '', '', 'was inserted'
9962
   FROM t0_template source_tab
9963
WHERE MOD(f_int1,3) = 0
9964
AND f_int1 BETWEEN @max_row_div2 AND @max_row
9965
ON DUPLICATE KEY
9966
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
9967
f_int2 = 2 * @max_row + source_tab.f_int1,
9968
f_charbig = 'was updated';
9969
	
9970
# check unique-1-a success: 	1
9971
	
9972
# check unique-1-b success: 	1
9973
DELETE FROM t1 WHERE f_charbig = 'was inserted';
9974
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
9975
f_int2 = CAST(f_char1 AS SIGNED INT),
9976
f_charbig = CONCAT('===',f_char1,'===')
9977
WHERE f_charbig = 'was updated';
9978
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9979
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
9980
   FROM t0_template source_tab
9981
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
9982
	
9983
# check replace success: 	1
9984
DELETE FROM t1
9985
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
9986
DELETE FROM t1
9987
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
9988
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
9989
UPDATE t1 SET f_int2 = f_int1,
9990
f_char1 = CAST(f_int1 AS CHAR),
9991
f_char2 = CAST(f_int1 AS CHAR),
9992
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
9993
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
9994
SET AUTOCOMMIT= 0;
9995
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
9996
SELECT f_int1, f_int1, '', '', 'was inserted'
9997
FROM t0_template source_tab
9998
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
9999
	
10000
# check transactions-1 success: 	1
10001
COMMIT WORK;
10002
	
10003
# check transactions-2 success: 	1
10004
ROLLBACK WORK;
10005
	
10006
# check transactions-3 success: 	1
10007
DELETE FROM t1 WHERE f_charbig = 'was inserted';
10008
COMMIT WORK;
10009
ROLLBACK WORK;
10010
	
10011
# check transactions-4 success: 	1
10012
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10013
SELECT f_int1, f_int1, '', '', 'was inserted'
10014
FROM t0_template source_tab
10015
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
10016
	
10017
# check transactions-5 success: 	1
10018
ROLLBACK WORK;
10019
	
10020
# check transactions-6 success: 	1
10021
# INFO: Storage engine used for t1 seems to be transactional.
10022
COMMIT;
10023
	
10024
# check transactions-7 success: 	1
10025
DELETE FROM t1 WHERE f_charbig = 'was inserted';
10026
COMMIT WORK;
10027
SET @@session.sql_mode = 'traditional';
10028
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
10029
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10030
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
10031
'', '', 'was inserted' FROM t0_template
10032
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
10033
ERROR 22012: Division by 0
10034
COMMIT;
10035
	
10036
# check transactions-8 success: 	1
10037
# INFO: Storage engine used for t1 seems to be able to revert
10038
#       changes made by the failing statement.
10039
SET @@session.sql_mode = '';
10040
SET AUTOCOMMIT= 1;
10041
DELETE FROM t1 WHERE f_charbig = 'was inserted';
10042
COMMIT WORK;
10043
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
10044
	
10045
# check special-1 success: 	1
10046
UPDATE t1 SET f_charbig = '';
10047
	
10048
# check special-2 success: 	1
10049
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
10050
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
10051
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
10052
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10053
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10054
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10055
'just inserted' FROM t0_template
10056
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10057
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
10058
BEGIN
10059
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10060
f_charbig = 'updated by trigger'
10061
      WHERE f_int1 = new.f_int1;
10062
END|
10063
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10064
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
10065
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10066
	
10067
# check trigger-1 success: 	1
10068
DROP TRIGGER trg_1;
10069
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10070
f_int2 = CAST(f_char1 AS SIGNED INT),
10071
f_charbig = 'just inserted'
10072
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10073
DELETE FROM t0_aux
10074
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10075
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10076
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10077
'just inserted' FROM t0_template
10078
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10079
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
10080
BEGIN
10081
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10082
f_charbig = 'updated by trigger'
10083
      WHERE f_int1 = new.f_int1;
10084
END|
10085
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10086
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
10087
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10088
	
10089
# check trigger-2 success: 	1
10090
DROP TRIGGER trg_1;
10091
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10092
f_int2 = CAST(f_char1 AS SIGNED INT),
10093
f_charbig = 'just inserted'
10094
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10095
DELETE FROM t0_aux
10096
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10097
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10098
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10099
'just inserted' FROM t0_template
10100
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10101
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
10102
BEGIN
10103
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10104
f_charbig = 'updated by trigger'
10105
      WHERE f_int1 = new.f_int1;
10106
END|
10107
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
10108
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
10109
	
10110
# check trigger-3 success: 	1
10111
DROP TRIGGER trg_1;
10112
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10113
f_int2 = CAST(f_char1 AS SIGNED INT),
10114
f_charbig = 'just inserted'
10115
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10116
DELETE FROM t0_aux
10117
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10118
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10119
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10120
'just inserted' FROM t0_template
10121
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10122
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
10123
BEGIN
10124
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10125
f_charbig = 'updated by trigger'
10126
      WHERE f_int1 = - old.f_int1;
10127
END|
10128
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
10129
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
10130
	
10131
# check trigger-4 success: 	1
10132
DROP TRIGGER trg_1;
10133
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10134
f_int2 = CAST(f_char1 AS SIGNED INT),
10135
f_charbig = 'just inserted'
10136
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10137
DELETE FROM t0_aux
10138
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10139
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10140
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10141
'just inserted' FROM t0_template
10142
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10143
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
10144
BEGIN
10145
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10146
f_charbig = 'updated by trigger'
10147
      WHERE f_int1 = new.f_int1;
10148
END|
10149
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
10150
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
10151
	
10152
# check trigger-5 success: 	1
10153
DROP TRIGGER trg_1;
10154
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10155
f_int2 = CAST(f_char1 AS SIGNED INT),
10156
f_charbig = 'just inserted'
10157
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10158
DELETE FROM t0_aux
10159
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10160
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10161
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10162
'just inserted' FROM t0_template
10163
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10164
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
10165
BEGIN
10166
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10167
f_charbig = 'updated by trigger'
10168
      WHERE f_int1 = - old.f_int1;
10169
END|
10170
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
10171
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
10172
	
10173
# check trigger-6 success: 	1
10174
DROP TRIGGER trg_1;
10175
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10176
f_int2 = CAST(f_char1 AS SIGNED INT),
10177
f_charbig = 'just inserted'
10178
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10179
DELETE FROM t0_aux
10180
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10181
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10182
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10183
'just inserted' FROM t0_template
10184
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10185
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
10186
BEGIN
10187
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10188
f_charbig = 'updated by trigger'
10189
      WHERE f_int1 = - old.f_int1;
10190
END|
10191
DELETE FROM t0_aux
10192
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
10193
	
10194
# check trigger-7 success: 	1
10195
DROP TRIGGER trg_1;
10196
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10197
f_int2 = CAST(f_char1 AS SIGNED INT),
10198
f_charbig = 'just inserted'
10199
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10200
DELETE FROM t0_aux
10201
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10202
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10203
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10204
'just inserted' FROM t0_template
10205
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10206
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
10207
BEGIN
10208
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10209
f_charbig = 'updated by trigger'
10210
      WHERE f_int1 = - old.f_int1;
10211
END|
10212
DELETE FROM t0_aux
10213
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
10214
	
10215
# check trigger-8 success: 	1
10216
DROP TRIGGER trg_1;
10217
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10218
f_int2 = CAST(f_char1 AS SIGNED INT),
10219
f_charbig = 'just inserted'
10220
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10221
DELETE FROM t0_aux
10222
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10223
DELETE FROM t1
10224
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10225
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
10226
BEGIN
10227
SET new.f_int1 = old.f_int1 + @max_row,
10228
new.f_int2 = old.f_int2 - @max_row,
10229
new.f_charbig = '####updated per update trigger####';
10230
END|
10231
UPDATE t1
10232
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
10233
f_charbig = '####updated per update statement itself####';
10234
	
10235
# check trigger-9 success: 	1
10236
DROP TRIGGER trg_2;
10237
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10238
f_int2 = CAST(f_char1 AS SIGNED INT),
10239
f_charbig = CONCAT('===',f_char1,'===');
10240
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
10241
BEGIN
10242
SET new.f_int1 = new.f_int1 + @max_row,
10243
new.f_int2 = new.f_int2 - @max_row,
10244
new.f_charbig = '####updated per update trigger####';
10245
END|
10246
UPDATE t1
10247
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
10248
f_charbig = '####updated per update statement itself####';
10249
	
10250
# check trigger-10 success: 	1
10251
DROP TRIGGER trg_2;
10252
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10253
f_int2 = CAST(f_char1 AS SIGNED INT),
10254
f_charbig = CONCAT('===',f_char1,'===');
10255
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
10256
BEGIN
10257
SET new.f_int1 = @my_max1 + @counter,
10258
new.f_int2 = @my_min2 - @counter,
10259
new.f_charbig = '####updated per insert trigger####';
10260
SET @counter = @counter + 1;
10261
END|
10262
SET @counter = 1;
10263
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
10264
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10265
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
10266
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
10267
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
10268
ORDER BY f_int1;
10269
DROP TRIGGER trg_3;
10270
	
10271
# check trigger-11 success: 	1
10272
DELETE FROM t1
10273
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
10274
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
10275
AND f_charbig = '####updated per insert trigger####';
10276
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
10277
BEGIN
10278
SET new.f_int1 = @my_max1 + @counter,
10279
new.f_int2 = @my_min2 - @counter,
10280
new.f_charbig = '####updated per insert trigger####';
10281
SET @counter = @counter + 1;
10282
END|
10283
SET @counter = 1;
10284
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
10285
INSERT INTO t1 (f_char1, f_char2, f_charbig)
10286
SELECT CAST(f_int1 AS CHAR),
10287
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
10288
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
10289
ORDER BY f_int1;
10290
DROP TRIGGER trg_3;
10291
	
10292
# check trigger-12 success: 	1
10293
DELETE FROM t1
10294
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
10295
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
10296
AND f_charbig = '####updated per insert trigger####';
10297
ANALYZE  TABLE t1;
10298
Table	Op	Msg_type	Msg_text
10299
test.t1	analyze	note	The storage engine for the table doesn't support analyze
10300
CHECK    TABLE t1 EXTENDED;
10301
Table	Op	Msg_type	Msg_text
10302
test.t1	check	note	The storage engine for the table doesn't support check
10303
CHECKSUM TABLE t1 EXTENDED;
10304
Table	Checksum
10305
test.t1	<some_value>
10306
OPTIMIZE TABLE t1;
10307
Table	Op	Msg_type	Msg_text
10308
test.t1	optimize	note	The storage engine for the table doesn't support optimize
10309
# check layout success:    1
10310
REPAIR   TABLE t1 EXTENDED;
10311
Table	Op	Msg_type	Msg_text
10312
test.t1	repair	note	The storage engine for the table doesn't support repair
10313
# check layout success:    1
10314
TRUNCATE t1;
10315
	
10316
# check TRUNCATE success: 	1
10317
# check layout success:    1
10318
# End usability test (inc/partition_check.inc)
10319
DROP TABLE t1;
10320
CREATE TABLE t1 (
10321
f_int1 INTEGER,
10322
f_int2 INTEGER,
10323
f_char1 CHAR(20),
10324
f_char2 CHAR(20),
10325
f_charbig VARCHAR(1000)
10326
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
10327
)
10328
PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1)
10329
(PARTITION part1 VALUES IN (0)
10330
(SUBPARTITION sp11,
10331
SUBPARTITION sp12),
10332
PARTITION part2 VALUES IN (1)
10333
(SUBPARTITION sp21,
10334
SUBPARTITION sp22),
10335
PARTITION part3 VALUES IN (2)
10336
(SUBPARTITION sp31, 
10337
SUBPARTITION sp32),
10338
PARTITION part4 VALUES IN (NULL)
10339
(SUBPARTITION sp41,
10340
SUBPARTITION sp42));
10341
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
10342
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
10343
# Start usability test (inc/partition_check.inc)
10344
create_command
10345
SHOW CREATE TABLE t1;
10346
Table	Create Table
10347
t1	CREATE TABLE `t1` (
10348
  `f_int1` int(11) NOT NULL DEFAULT '0',
10349
  `f_int2` int(11) NOT NULL DEFAULT '0',
10350
  `f_char1` char(20) DEFAULT NULL,
10351
  `f_char2` char(20) DEFAULT NULL,
10352
  `f_charbig` varchar(1000) DEFAULT NULL,
10353
  PRIMARY KEY (`f_int2`,`f_int1`),
10354
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
10355
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,3))) SUBPARTITION BY HASH (f_int1 + 1) (PARTITION part1 VALUES IN (0) (SUBPARTITION sp11 ENGINE = InnoDB, SUBPARTITION sp12 ENGINE = InnoDB), PARTITION part2 VALUES IN (1) (SUBPARTITION sp21 ENGINE = InnoDB, SUBPARTITION sp22 ENGINE = InnoDB), PARTITION part3 VALUES IN (2) (SUBPARTITION sp31 ENGINE = InnoDB, SUBPARTITION sp32 ENGINE = InnoDB), PARTITION part4 VALUES IN (NULL) (SUBPARTITION sp41 ENGINE = InnoDB, SUBPARTITION sp42 ENGINE = InnoDB)) */
10356
10357
unified filelist
10358
$MYSQLTEST_VARDIR/master-data/test/t1.frm
10359
$MYSQLTEST_VARDIR/master-data/test/t1.par
10360
10361
# check prerequisites-1 success:    1
10362
# check COUNT(*) success:    1
10363
# check MIN/MAX(f_int1) success:    1
10364
# check MIN/MAX(f_int2) success:    1
10365
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10366
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
10367
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
10368
WHERE f_int1 IN (2,3);
10369
ERROR 23000: Can't write; duplicate key in table 't1'
10370
# check prerequisites-3 success:    1
10371
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
10372
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10373
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
10374
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
10375
WHERE f_int1 IN (2,3);
10376
DELETE FROM t1 WHERE f_charbig = 'delete me';
10377
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10378
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
10379
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
10380
WHERE f_int1 IN (2,3);
10381
DELETE FROM t1 WHERE f_charbig = 'delete me';
10382
# check read via f_int1 success: 1
10383
# check read via f_int2 success: 1
10384
	
10385
# check multiple-1 success: 	1
10386
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
10387
	
10388
# check multiple-2 success: 	1
10389
INSERT INTO t1 SELECT * FROM t0_template
10390
WHERE MOD(f_int1,3) = 0;
10391
	
10392
# check multiple-3 success: 	1
10393
UPDATE t1 SET f_int1 = f_int1 + @max_row
10394
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
10395
AND @max_row_div2 + @max_row_div4;
10396
	
10397
# check multiple-4 success: 	1
10398
DELETE FROM t1
10399
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
10400
AND @max_row_div2 + @max_row_div4 + @max_row;
10401
	
10402
# check multiple-5 success: 	1
10403
SELECT COUNT(*) INTO @try_count FROM t0_template
10404
WHERE MOD(f_int1,3) = 0
10405
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
10406
SELECT COUNT(*) INTO @clash_count
10407
FROM t1 INNER JOIN t0_template USING(f_int1)
10408
WHERE MOD(f_int1,3) = 0
10409
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
10410
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
10411
INSERT INTO t1
10412
SET f_int1 = @cur_value , f_int2 = @cur_value,
10413
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
10414
f_charbig = '#SINGLE#';
10415
	
10416
# check single-1 success: 	1
10417
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
10418
INSERT INTO t1
10419
SET f_int1 = @cur_value , f_int2 = @cur_value,
10420
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
10421
f_charbig = '#SINGLE#';
10422
	
10423
# check single-2 success: 	1
10424
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
10425
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
10426
UPDATE t1 SET f_int1 = @cur_value2
10427
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
10428
	
10429
# check single-3 success: 	1
10430
SET @cur_value1= -1;
10431
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
10432
UPDATE t1 SET f_int1 = @cur_value1
10433
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
10434
	
10435
# check single-4 success: 	1
10436
SELECT MAX(f_int1) INTO @cur_value FROM t1;
10437
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
10438
	
10439
# check single-5 success: 	1
10440
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
10441
	
10442
# check single-6 success: 	1
10443
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
10444
	
10445
# check single-7 success: 	1
10446
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
10447
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
10448
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
10449
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
10450
f_charbig = '#NULL#';
10451
INSERT INTO t1
10452
SET f_int1 = NULL , f_int2 = -@max_row,
10453
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
10454
f_charbig = '#NULL#';
10455
ERROR 23000: Column 'f_int1' cannot be null
10456
# check null success:    1
10457
DELETE FROM t1
10458
WHERE f_int1 = 0 AND f_int2 = 0
10459
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
10460
AND f_charbig = '#NULL#';
10461
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10462
SELECT f_int1, f_int1, '', '', 'was inserted'
10463
   FROM t0_template source_tab
10464
WHERE MOD(f_int1,3) = 0
10465
AND f_int1 BETWEEN @max_row_div2 AND @max_row
10466
ON DUPLICATE KEY
10467
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
10468
f_int2 = 2 * @max_row + source_tab.f_int1,
10469
f_charbig = 'was updated';
10470
	
10471
# check unique-1-a success: 	1
10472
	
10473
# check unique-1-b success: 	1
10474
DELETE FROM t1 WHERE f_charbig = 'was inserted';
10475
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10476
f_int2 = CAST(f_char1 AS SIGNED INT),
10477
f_charbig = CONCAT('===',f_char1,'===')
10478
WHERE f_charbig = 'was updated';
10479
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10480
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
10481
   FROM t0_template source_tab
10482
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
10483
	
10484
# check replace success: 	1
10485
DELETE FROM t1
10486
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
10487
DELETE FROM t1
10488
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
10489
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
10490
UPDATE t1 SET f_int2 = f_int1,
10491
f_char1 = CAST(f_int1 AS CHAR),
10492
f_char2 = CAST(f_int1 AS CHAR),
10493
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
10494
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
10495
SET AUTOCOMMIT= 0;
10496
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10497
SELECT f_int1, f_int1, '', '', 'was inserted'
10498
FROM t0_template source_tab
10499
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
10500
	
10501
# check transactions-1 success: 	1
10502
COMMIT WORK;
10503
	
10504
# check transactions-2 success: 	1
10505
ROLLBACK WORK;
10506
	
10507
# check transactions-3 success: 	1
10508
DELETE FROM t1 WHERE f_charbig = 'was inserted';
10509
COMMIT WORK;
10510
ROLLBACK WORK;
10511
	
10512
# check transactions-4 success: 	1
10513
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10514
SELECT f_int1, f_int1, '', '', 'was inserted'
10515
FROM t0_template source_tab
10516
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
10517
	
10518
# check transactions-5 success: 	1
10519
ROLLBACK WORK;
10520
	
10521
# check transactions-6 success: 	1
10522
# INFO: Storage engine used for t1 seems to be transactional.
10523
COMMIT;
10524
	
10525
# check transactions-7 success: 	1
10526
DELETE FROM t1 WHERE f_charbig = 'was inserted';
10527
COMMIT WORK;
10528
SET @@session.sql_mode = 'traditional';
10529
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
10530
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10531
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
10532
'', '', 'was inserted' FROM t0_template
10533
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
10534
ERROR 22012: Division by 0
10535
COMMIT;
10536
	
10537
# check transactions-8 success: 	1
10538
# INFO: Storage engine used for t1 seems to be able to revert
10539
#       changes made by the failing statement.
10540
SET @@session.sql_mode = '';
10541
SET AUTOCOMMIT= 1;
10542
DELETE FROM t1 WHERE f_charbig = 'was inserted';
10543
COMMIT WORK;
10544
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
10545
	
10546
# check special-1 success: 	1
10547
UPDATE t1 SET f_charbig = '';
10548
	
10549
# check special-2 success: 	1
10550
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
10551
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
10552
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
10553
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10554
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10555
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10556
'just inserted' FROM t0_template
10557
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10558
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
10559
BEGIN
10560
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10561
f_charbig = 'updated by trigger'
10562
      WHERE f_int1 = new.f_int1;
10563
END|
10564
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10565
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
10566
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10567
	
10568
# check trigger-1 success: 	1
10569
DROP TRIGGER trg_1;
10570
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10571
f_int2 = CAST(f_char1 AS SIGNED INT),
10572
f_charbig = 'just inserted'
10573
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10574
DELETE FROM t0_aux
10575
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10576
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10577
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10578
'just inserted' FROM t0_template
10579
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10580
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
10581
BEGIN
10582
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10583
f_charbig = 'updated by trigger'
10584
      WHERE f_int1 = new.f_int1;
10585
END|
10586
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10587
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
10588
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10589
	
10590
# check trigger-2 success: 	1
10591
DROP TRIGGER trg_1;
10592
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10593
f_int2 = CAST(f_char1 AS SIGNED INT),
10594
f_charbig = 'just inserted'
10595
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10596
DELETE FROM t0_aux
10597
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10598
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10599
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10600
'just inserted' FROM t0_template
10601
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10602
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
10603
BEGIN
10604
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10605
f_charbig = 'updated by trigger'
10606
      WHERE f_int1 = new.f_int1;
10607
END|
10608
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
10609
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
10610
	
10611
# check trigger-3 success: 	1
10612
DROP TRIGGER trg_1;
10613
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10614
f_int2 = CAST(f_char1 AS SIGNED INT),
10615
f_charbig = 'just inserted'
10616
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10617
DELETE FROM t0_aux
10618
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10619
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10620
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10621
'just inserted' FROM t0_template
10622
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10623
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
10624
BEGIN
10625
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10626
f_charbig = 'updated by trigger'
10627
      WHERE f_int1 = - old.f_int1;
10628
END|
10629
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
10630
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
10631
	
10632
# check trigger-4 success: 	1
10633
DROP TRIGGER trg_1;
10634
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10635
f_int2 = CAST(f_char1 AS SIGNED INT),
10636
f_charbig = 'just inserted'
10637
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10638
DELETE FROM t0_aux
10639
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10640
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10641
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10642
'just inserted' FROM t0_template
10643
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10644
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
10645
BEGIN
10646
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10647
f_charbig = 'updated by trigger'
10648
      WHERE f_int1 = new.f_int1;
10649
END|
10650
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
10651
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
10652
	
10653
# check trigger-5 success: 	1
10654
DROP TRIGGER trg_1;
10655
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10656
f_int2 = CAST(f_char1 AS SIGNED INT),
10657
f_charbig = 'just inserted'
10658
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10659
DELETE FROM t0_aux
10660
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10661
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10662
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10663
'just inserted' FROM t0_template
10664
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10665
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
10666
BEGIN
10667
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10668
f_charbig = 'updated by trigger'
10669
      WHERE f_int1 = - old.f_int1;
10670
END|
10671
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
10672
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
10673
	
10674
# check trigger-6 success: 	1
10675
DROP TRIGGER trg_1;
10676
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10677
f_int2 = CAST(f_char1 AS SIGNED INT),
10678
f_charbig = 'just inserted'
10679
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10680
DELETE FROM t0_aux
10681
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10682
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10683
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10684
'just inserted' FROM t0_template
10685
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10686
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
10687
BEGIN
10688
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10689
f_charbig = 'updated by trigger'
10690
      WHERE f_int1 = - old.f_int1;
10691
END|
10692
DELETE FROM t0_aux
10693
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
10694
	
10695
# check trigger-7 success: 	1
10696
DROP TRIGGER trg_1;
10697
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10698
f_int2 = CAST(f_char1 AS SIGNED INT),
10699
f_charbig = 'just inserted'
10700
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10701
DELETE FROM t0_aux
10702
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10703
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
10704
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
10705
'just inserted' FROM t0_template
10706
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10707
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
10708
BEGIN
10709
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
10710
f_charbig = 'updated by trigger'
10711
      WHERE f_int1 = - old.f_int1;
10712
END|
10713
DELETE FROM t0_aux
10714
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
10715
	
10716
# check trigger-8 success: 	1
10717
DROP TRIGGER trg_1;
10718
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10719
f_int2 = CAST(f_char1 AS SIGNED INT),
10720
f_charbig = 'just inserted'
10721
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
10722
DELETE FROM t0_aux
10723
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10724
DELETE FROM t1
10725
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
10726
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
10727
BEGIN
10728
SET new.f_int1 = old.f_int1 + @max_row,
10729
new.f_int2 = old.f_int2 - @max_row,
10730
new.f_charbig = '####updated per update trigger####';
10731
END|
10732
UPDATE t1
10733
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
10734
f_charbig = '####updated per update statement itself####';
10735
	
10736
# check trigger-9 success: 	1
10737
DROP TRIGGER trg_2;
10738
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10739
f_int2 = CAST(f_char1 AS SIGNED INT),
10740
f_charbig = CONCAT('===',f_char1,'===');
10741
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
10742
BEGIN
10743
SET new.f_int1 = new.f_int1 + @max_row,
10744
new.f_int2 = new.f_int2 - @max_row,
10745
new.f_charbig = '####updated per update trigger####';
10746
END|
10747
UPDATE t1
10748
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
10749
f_charbig = '####updated per update statement itself####';
10750
	
10751
# check trigger-10 success: 	1
10752
DROP TRIGGER trg_2;
10753
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10754
f_int2 = CAST(f_char1 AS SIGNED INT),
10755
f_charbig = CONCAT('===',f_char1,'===');
10756
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
10757
BEGIN
10758
SET new.f_int1 = @my_max1 + @counter,
10759
new.f_int2 = @my_min2 - @counter,
10760
new.f_charbig = '####updated per insert trigger####';
10761
SET @counter = @counter + 1;
10762
END|
10763
SET @counter = 1;
10764
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
10765
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10766
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
10767
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
10768
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
10769
ORDER BY f_int1;
10770
DROP TRIGGER trg_3;
10771
	
10772
# check trigger-11 success: 	1
10773
DELETE FROM t1
10774
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
10775
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
10776
AND f_charbig = '####updated per insert trigger####';
10777
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
10778
BEGIN
10779
SET new.f_int1 = @my_max1 + @counter,
10780
new.f_int2 = @my_min2 - @counter,
10781
new.f_charbig = '####updated per insert trigger####';
10782
SET @counter = @counter + 1;
10783
END|
10784
SET @counter = 1;
10785
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
10786
INSERT INTO t1 (f_char1, f_char2, f_charbig)
10787
SELECT CAST(f_int1 AS CHAR),
10788
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
10789
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
10790
ORDER BY f_int1;
10791
DROP TRIGGER trg_3;
10792
	
10793
# check trigger-12 success: 	1
10794
DELETE FROM t1
10795
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
10796
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
10797
AND f_charbig = '####updated per insert trigger####';
10798
ANALYZE  TABLE t1;
10799
Table	Op	Msg_type	Msg_text
10800
test.t1	analyze	note	The storage engine for the table doesn't support analyze
10801
CHECK    TABLE t1 EXTENDED;
10802
Table	Op	Msg_type	Msg_text
10803
test.t1	check	note	The storage engine for the table doesn't support check
10804
CHECKSUM TABLE t1 EXTENDED;
10805
Table	Checksum
10806
test.t1	<some_value>
10807
OPTIMIZE TABLE t1;
10808
Table	Op	Msg_type	Msg_text
10809
test.t1	optimize	note	The storage engine for the table doesn't support optimize
10810
# check layout success:    1
10811
REPAIR   TABLE t1 EXTENDED;
10812
Table	Op	Msg_type	Msg_text
10813
test.t1	repair	note	The storage engine for the table doesn't support repair
10814
# check layout success:    1
10815
TRUNCATE t1;
10816
	
10817
# check TRUNCATE success: 	1
10818
# check layout success:    1
10819
# End usability test (inc/partition_check.inc)
10820
DROP TABLE t1;
10821
CREATE TABLE t1 (
10822
f_int1 INTEGER,
10823
f_int2 INTEGER,
10824
f_char1 CHAR(20),
10825
f_char2 CHAR(20),
10826
f_charbig VARCHAR(1000)
10827
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
10828
)
10829
PARTITION BY LIST(ABS(MOD(f_int1,2)))
10830
SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3
10831
(PARTITION part1 VALUES IN (0),
10832
PARTITION part2 VALUES IN (1),
10833
PARTITION part3 VALUES IN (NULL));
10834
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
10835
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
10836
# Start usability test (inc/partition_check.inc)
10837
create_command
10838
SHOW CREATE TABLE t1;
10839
Table	Create Table
10840
t1	CREATE TABLE `t1` (
10841
  `f_int1` int(11) NOT NULL DEFAULT '0',
10842
  `f_int2` int(11) NOT NULL DEFAULT '0',
10843
  `f_char1` char(20) DEFAULT NULL,
10844
  `f_char2` char(20) DEFAULT NULL,
10845
  `f_charbig` varchar(1000) DEFAULT NULL,
10846
  PRIMARY KEY (`f_int2`,`f_int1`),
10847
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
10848
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
10849
10850
unified filelist
10851
$MYSQLTEST_VARDIR/master-data/test/t1.frm
10852
$MYSQLTEST_VARDIR/master-data/test/t1.par
10853
10854
# check prerequisites-1 success:    1
10855
# check COUNT(*) success:    1
10856
# check MIN/MAX(f_int1) success:    1
10857
# check MIN/MAX(f_int2) success:    1
10858
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10859
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
10860
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
10861
WHERE f_int1 IN (2,3);
10862
ERROR 23000: Can't write; duplicate key in table 't1'
10863
# check prerequisites-3 success:    1
10864
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
10865
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10866
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
10867
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
10868
WHERE f_int1 IN (2,3);
10869
DELETE FROM t1 WHERE f_charbig = 'delete me';
10870
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10871
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
10872
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
10873
WHERE f_int1 IN (2,3);
10874
DELETE FROM t1 WHERE f_charbig = 'delete me';
10875
# check read via f_int1 success: 1
10876
# check read via f_int2 success: 1
10877
	
10878
# check multiple-1 success: 	1
10879
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
10880
	
10881
# check multiple-2 success: 	1
10882
INSERT INTO t1 SELECT * FROM t0_template
10883
WHERE MOD(f_int1,3) = 0;
10884
	
10885
# check multiple-3 success: 	1
10886
UPDATE t1 SET f_int1 = f_int1 + @max_row
10887
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
10888
AND @max_row_div2 + @max_row_div4;
10889
	
10890
# check multiple-4 success: 	1
10891
DELETE FROM t1
10892
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
10893
AND @max_row_div2 + @max_row_div4 + @max_row;
10894
	
10895
# check multiple-5 success: 	1
10896
SELECT COUNT(*) INTO @try_count FROM t0_template
10897
WHERE MOD(f_int1,3) = 0
10898
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
10899
SELECT COUNT(*) INTO @clash_count
10900
FROM t1 INNER JOIN t0_template USING(f_int1)
10901
WHERE MOD(f_int1,3) = 0
10902
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
10903
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
10904
INSERT INTO t1
10905
SET f_int1 = @cur_value , f_int2 = @cur_value,
10906
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
10907
f_charbig = '#SINGLE#';
10908
	
10909
# check single-1 success: 	1
10910
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
10911
INSERT INTO t1
10912
SET f_int1 = @cur_value , f_int2 = @cur_value,
10913
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
10914
f_charbig = '#SINGLE#';
10915
	
10916
# check single-2 success: 	1
10917
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
10918
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
10919
UPDATE t1 SET f_int1 = @cur_value2
10920
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
10921
	
10922
# check single-3 success: 	1
10923
SET @cur_value1= -1;
10924
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
10925
UPDATE t1 SET f_int1 = @cur_value1
10926
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
10927
	
10928
# check single-4 success: 	1
10929
SELECT MAX(f_int1) INTO @cur_value FROM t1;
10930
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
10931
	
10932
# check single-5 success: 	1
10933
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
10934
	
10935
# check single-6 success: 	1
10936
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
10937
	
10938
# check single-7 success: 	1
10939
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
10940
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
10941
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
10942
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
10943
f_charbig = '#NULL#';
10944
INSERT INTO t1
10945
SET f_int1 = NULL , f_int2 = -@max_row,
10946
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
10947
f_charbig = '#NULL#';
10948
ERROR 23000: Column 'f_int1' cannot be null
10949
# check null success:    1
10950
DELETE FROM t1
10951
WHERE f_int1 = 0 AND f_int2 = 0
10952
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
10953
AND f_charbig = '#NULL#';
10954
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10955
SELECT f_int1, f_int1, '', '', 'was inserted'
10956
   FROM t0_template source_tab
10957
WHERE MOD(f_int1,3) = 0
10958
AND f_int1 BETWEEN @max_row_div2 AND @max_row
10959
ON DUPLICATE KEY
10960
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
10961
f_int2 = 2 * @max_row + source_tab.f_int1,
10962
f_charbig = 'was updated';
10963
	
10964
# check unique-1-a success: 	1
10965
	
10966
# check unique-1-b success: 	1
10967
DELETE FROM t1 WHERE f_charbig = 'was inserted';
10968
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
10969
f_int2 = CAST(f_char1 AS SIGNED INT),
10970
f_charbig = CONCAT('===',f_char1,'===')
10971
WHERE f_charbig = 'was updated';
10972
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10973
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
10974
   FROM t0_template source_tab
10975
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
10976
	
10977
# check replace success: 	1
10978
DELETE FROM t1
10979
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
10980
DELETE FROM t1
10981
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
10982
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
10983
UPDATE t1 SET f_int2 = f_int1,
10984
f_char1 = CAST(f_int1 AS CHAR),
10985
f_char2 = CAST(f_int1 AS CHAR),
10986
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
10987
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
10988
SET AUTOCOMMIT= 0;
10989
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
10990
SELECT f_int1, f_int1, '', '', 'was inserted'
10991
FROM t0_template source_tab
10992
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
10993
	
10994
# check transactions-1 success: 	1
10995
COMMIT WORK;
10996
	
10997
# check transactions-2 success: 	1
10998
ROLLBACK WORK;
10999
	
11000
# check transactions-3 success: 	1
11001
DELETE FROM t1 WHERE f_charbig = 'was inserted';
11002
COMMIT WORK;
11003
ROLLBACK WORK;
11004
	
11005
# check transactions-4 success: 	1
11006
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11007
SELECT f_int1, f_int1, '', '', 'was inserted'
11008
FROM t0_template source_tab
11009
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
11010
	
11011
# check transactions-5 success: 	1
11012
ROLLBACK WORK;
11013
	
11014
# check transactions-6 success: 	1
11015
# INFO: Storage engine used for t1 seems to be transactional.
11016
COMMIT;
11017
	
11018
# check transactions-7 success: 	1
11019
DELETE FROM t1 WHERE f_charbig = 'was inserted';
11020
COMMIT WORK;
11021
SET @@session.sql_mode = 'traditional';
11022
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
11023
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11024
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
11025
'', '', 'was inserted' FROM t0_template
11026
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
11027
ERROR 22012: Division by 0
11028
COMMIT;
11029
	
11030
# check transactions-8 success: 	1
11031
# INFO: Storage engine used for t1 seems to be able to revert
11032
#       changes made by the failing statement.
11033
SET @@session.sql_mode = '';
11034
SET AUTOCOMMIT= 1;
11035
DELETE FROM t1 WHERE f_charbig = 'was inserted';
11036
COMMIT WORK;
11037
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
11038
	
11039
# check special-1 success: 	1
11040
UPDATE t1 SET f_charbig = '';
11041
	
11042
# check special-2 success: 	1
11043
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
11044
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
11045
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
11046
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11047
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11048
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11049
'just inserted' FROM t0_template
11050
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11051
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
11052
BEGIN
11053
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11054
f_charbig = 'updated by trigger'
11055
      WHERE f_int1 = new.f_int1;
11056
END|
11057
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11058
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
11059
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11060
	
11061
# check trigger-1 success: 	1
11062
DROP TRIGGER trg_1;
11063
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11064
f_int2 = CAST(f_char1 AS SIGNED INT),
11065
f_charbig = 'just inserted'
11066
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11067
DELETE FROM t0_aux
11068
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11069
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11070
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11071
'just inserted' FROM t0_template
11072
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11073
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
11074
BEGIN
11075
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11076
f_charbig = 'updated by trigger'
11077
      WHERE f_int1 = new.f_int1;
11078
END|
11079
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11080
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
11081
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11082
	
11083
# check trigger-2 success: 	1
11084
DROP TRIGGER trg_1;
11085
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11086
f_int2 = CAST(f_char1 AS SIGNED INT),
11087
f_charbig = 'just inserted'
11088
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11089
DELETE FROM t0_aux
11090
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11091
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11092
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11093
'just inserted' FROM t0_template
11094
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11095
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
11096
BEGIN
11097
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11098
f_charbig = 'updated by trigger'
11099
      WHERE f_int1 = new.f_int1;
11100
END|
11101
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
11102
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
11103
	
11104
# check trigger-3 success: 	1
11105
DROP TRIGGER trg_1;
11106
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11107
f_int2 = CAST(f_char1 AS SIGNED INT),
11108
f_charbig = 'just inserted'
11109
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11110
DELETE FROM t0_aux
11111
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11112
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11113
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11114
'just inserted' FROM t0_template
11115
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11116
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
11117
BEGIN
11118
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11119
f_charbig = 'updated by trigger'
11120
      WHERE f_int1 = - old.f_int1;
11121
END|
11122
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
11123
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
11124
	
11125
# check trigger-4 success: 	1
11126
DROP TRIGGER trg_1;
11127
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11128
f_int2 = CAST(f_char1 AS SIGNED INT),
11129
f_charbig = 'just inserted'
11130
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11131
DELETE FROM t0_aux
11132
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11133
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11134
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11135
'just inserted' FROM t0_template
11136
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11137
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
11138
BEGIN
11139
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11140
f_charbig = 'updated by trigger'
11141
      WHERE f_int1 = new.f_int1;
11142
END|
11143
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
11144
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
11145
	
11146
# check trigger-5 success: 	1
11147
DROP TRIGGER trg_1;
11148
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11149
f_int2 = CAST(f_char1 AS SIGNED INT),
11150
f_charbig = 'just inserted'
11151
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11152
DELETE FROM t0_aux
11153
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11154
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11155
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11156
'just inserted' FROM t0_template
11157
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11158
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
11159
BEGIN
11160
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11161
f_charbig = 'updated by trigger'
11162
      WHERE f_int1 = - old.f_int1;
11163
END|
11164
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
11165
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
11166
	
11167
# check trigger-6 success: 	1
11168
DROP TRIGGER trg_1;
11169
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11170
f_int2 = CAST(f_char1 AS SIGNED INT),
11171
f_charbig = 'just inserted'
11172
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11173
DELETE FROM t0_aux
11174
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11175
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11176
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11177
'just inserted' FROM t0_template
11178
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11179
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
11180
BEGIN
11181
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11182
f_charbig = 'updated by trigger'
11183
      WHERE f_int1 = - old.f_int1;
11184
END|
11185
DELETE FROM t0_aux
11186
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
11187
	
11188
# check trigger-7 success: 	1
11189
DROP TRIGGER trg_1;
11190
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11191
f_int2 = CAST(f_char1 AS SIGNED INT),
11192
f_charbig = 'just inserted'
11193
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11194
DELETE FROM t0_aux
11195
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11196
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11197
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11198
'just inserted' FROM t0_template
11199
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11200
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
11201
BEGIN
11202
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11203
f_charbig = 'updated by trigger'
11204
      WHERE f_int1 = - old.f_int1;
11205
END|
11206
DELETE FROM t0_aux
11207
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
11208
	
11209
# check trigger-8 success: 	1
11210
DROP TRIGGER trg_1;
11211
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11212
f_int2 = CAST(f_char1 AS SIGNED INT),
11213
f_charbig = 'just inserted'
11214
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11215
DELETE FROM t0_aux
11216
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11217
DELETE FROM t1
11218
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11219
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
11220
BEGIN
11221
SET new.f_int1 = old.f_int1 + @max_row,
11222
new.f_int2 = old.f_int2 - @max_row,
11223
new.f_charbig = '####updated per update trigger####';
11224
END|
11225
UPDATE t1
11226
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
11227
f_charbig = '####updated per update statement itself####';
11228
	
11229
# check trigger-9 success: 	1
11230
DROP TRIGGER trg_2;
11231
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11232
f_int2 = CAST(f_char1 AS SIGNED INT),
11233
f_charbig = CONCAT('===',f_char1,'===');
11234
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
11235
BEGIN
11236
SET new.f_int1 = new.f_int1 + @max_row,
11237
new.f_int2 = new.f_int2 - @max_row,
11238
new.f_charbig = '####updated per update trigger####';
11239
END|
11240
UPDATE t1
11241
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
11242
f_charbig = '####updated per update statement itself####';
11243
	
11244
# check trigger-10 success: 	1
11245
DROP TRIGGER trg_2;
11246
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11247
f_int2 = CAST(f_char1 AS SIGNED INT),
11248
f_charbig = CONCAT('===',f_char1,'===');
11249
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
11250
BEGIN
11251
SET new.f_int1 = @my_max1 + @counter,
11252
new.f_int2 = @my_min2 - @counter,
11253
new.f_charbig = '####updated per insert trigger####';
11254
SET @counter = @counter + 1;
11255
END|
11256
SET @counter = 1;
11257
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
11258
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11259
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
11260
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
11261
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
11262
ORDER BY f_int1;
11263
DROP TRIGGER trg_3;
11264
	
11265
# check trigger-11 success: 	1
11266
DELETE FROM t1
11267
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
11268
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
11269
AND f_charbig = '####updated per insert trigger####';
11270
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
11271
BEGIN
11272
SET new.f_int1 = @my_max1 + @counter,
11273
new.f_int2 = @my_min2 - @counter,
11274
new.f_charbig = '####updated per insert trigger####';
11275
SET @counter = @counter + 1;
11276
END|
11277
SET @counter = 1;
11278
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
11279
INSERT INTO t1 (f_char1, f_char2, f_charbig)
11280
SELECT CAST(f_int1 AS CHAR),
11281
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
11282
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
11283
ORDER BY f_int1;
11284
DROP TRIGGER trg_3;
11285
	
11286
# check trigger-12 success: 	1
11287
DELETE FROM t1
11288
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
11289
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
11290
AND f_charbig = '####updated per insert trigger####';
11291
ANALYZE  TABLE t1;
11292
Table	Op	Msg_type	Msg_text
11293
test.t1	analyze	note	The storage engine for the table doesn't support analyze
11294
CHECK    TABLE t1 EXTENDED;
11295
Table	Op	Msg_type	Msg_text
11296
test.t1	check	note	The storage engine for the table doesn't support check
11297
CHECKSUM TABLE t1 EXTENDED;
11298
Table	Checksum
11299
test.t1	<some_value>
11300
OPTIMIZE TABLE t1;
11301
Table	Op	Msg_type	Msg_text
11302
test.t1	optimize	note	The storage engine for the table doesn't support optimize
11303
# check layout success:    1
11304
REPAIR   TABLE t1 EXTENDED;
11305
Table	Op	Msg_type	Msg_text
11306
test.t1	repair	note	The storage engine for the table doesn't support repair
11307
# check layout success:    1
11308
TRUNCATE t1;
11309
	
11310
# check TRUNCATE success: 	1
11311
# check layout success:    1
11312
# End usability test (inc/partition_check.inc)
11313
DROP TABLE t1;
11314
DROP TABLE IF EXISTS t1;
11315
CREATE TABLE t1 (
11316
f_int1 INTEGER,
11317
f_int2 INTEGER,
11318
f_char1 CHAR(20),
11319
f_char2 CHAR(20),
11320
f_charbig VARCHAR(1000)
11321
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
11322
)
11323
PARTITION BY HASH(f_int1) PARTITIONS 2;
11324
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
11325
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
11326
# Start usability test (inc/partition_check.inc)
11327
create_command
11328
SHOW CREATE TABLE t1;
11329
Table	Create Table
11330
t1	CREATE TABLE `t1` (
11331
  `f_int1` int(11) NOT NULL DEFAULT '0',
11332
  `f_int2` int(11) NOT NULL DEFAULT '0',
11333
  `f_char1` char(20) DEFAULT NULL,
11334
  `f_char2` char(20) DEFAULT NULL,
11335
  `f_charbig` varchar(1000) DEFAULT NULL,
11336
  PRIMARY KEY (`f_int1`,`f_int2`),
11337
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
11338
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (f_int1) PARTITIONS 2  */
11339
11340
unified filelist
11341
$MYSQLTEST_VARDIR/master-data/test/t1.frm
11342
$MYSQLTEST_VARDIR/master-data/test/t1.par
11343
11344
# check prerequisites-1 success:    1
11345
# check COUNT(*) success:    1
11346
# check MIN/MAX(f_int1) success:    1
11347
# check MIN/MAX(f_int2) success:    1
11348
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11349
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
11350
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
11351
WHERE f_int1 IN (2,3);
11352
ERROR 23000: Can't write; duplicate key in table 't1'
11353
# check prerequisites-3 success:    1
11354
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
11355
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11356
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
11357
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
11358
WHERE f_int1 IN (2,3);
11359
DELETE FROM t1 WHERE f_charbig = 'delete me';
11360
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11361
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
11362
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
11363
WHERE f_int1 IN (2,3);
11364
DELETE FROM t1 WHERE f_charbig = 'delete me';
11365
# check read via f_int1 success: 1
11366
# check read via f_int2 success: 1
11367
	
11368
# check multiple-1 success: 	1
11369
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
11370
	
11371
# check multiple-2 success: 	1
11372
INSERT INTO t1 SELECT * FROM t0_template
11373
WHERE MOD(f_int1,3) = 0;
11374
	
11375
# check multiple-3 success: 	1
11376
UPDATE t1 SET f_int1 = f_int1 + @max_row
11377
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
11378
AND @max_row_div2 + @max_row_div4;
11379
	
11380
# check multiple-4 success: 	1
11381
DELETE FROM t1
11382
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
11383
AND @max_row_div2 + @max_row_div4 + @max_row;
11384
	
11385
# check multiple-5 success: 	1
11386
SELECT COUNT(*) INTO @try_count FROM t0_template
11387
WHERE MOD(f_int1,3) = 0
11388
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
11389
SELECT COUNT(*) INTO @clash_count
11390
FROM t1 INNER JOIN t0_template USING(f_int1)
11391
WHERE MOD(f_int1,3) = 0
11392
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
11393
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
11394
INSERT INTO t1
11395
SET f_int1 = @cur_value , f_int2 = @cur_value,
11396
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
11397
f_charbig = '#SINGLE#';
11398
	
11399
# check single-1 success: 	1
11400
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
11401
INSERT INTO t1
11402
SET f_int1 = @cur_value , f_int2 = @cur_value,
11403
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
11404
f_charbig = '#SINGLE#';
11405
	
11406
# check single-2 success: 	1
11407
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
11408
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
11409
UPDATE t1 SET f_int1 = @cur_value2
11410
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
11411
	
11412
# check single-3 success: 	1
11413
SET @cur_value1= -1;
11414
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
11415
UPDATE t1 SET f_int1 = @cur_value1
11416
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
11417
	
11418
# check single-4 success: 	1
11419
SELECT MAX(f_int1) INTO @cur_value FROM t1;
11420
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
11421
	
11422
# check single-5 success: 	1
11423
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
11424
	
11425
# check single-6 success: 	1
11426
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
11427
	
11428
# check single-7 success: 	1
11429
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
11430
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
11431
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
11432
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
11433
f_charbig = '#NULL#';
11434
INSERT INTO t1
11435
SET f_int1 = NULL , f_int2 = -@max_row,
11436
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
11437
f_charbig = '#NULL#';
11438
ERROR 23000: Column 'f_int1' cannot be null
11439
# check null success:    1
11440
DELETE FROM t1
11441
WHERE f_int1 = 0 AND f_int2 = 0
11442
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
11443
AND f_charbig = '#NULL#';
11444
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11445
SELECT f_int1, f_int1, '', '', 'was inserted'
11446
   FROM t0_template source_tab
11447
WHERE MOD(f_int1,3) = 0
11448
AND f_int1 BETWEEN @max_row_div2 AND @max_row
11449
ON DUPLICATE KEY
11450
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
11451
f_int2 = 2 * @max_row + source_tab.f_int1,
11452
f_charbig = 'was updated';
11453
	
11454
# check unique-1-a success: 	1
11455
	
11456
# check unique-1-b success: 	1
11457
DELETE FROM t1 WHERE f_charbig = 'was inserted';
11458
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11459
f_int2 = CAST(f_char1 AS SIGNED INT),
11460
f_charbig = CONCAT('===',f_char1,'===')
11461
WHERE f_charbig = 'was updated';
11462
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11463
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
11464
   FROM t0_template source_tab
11465
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
11466
	
11467
# check replace success: 	1
11468
DELETE FROM t1
11469
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
11470
DELETE FROM t1
11471
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
11472
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
11473
UPDATE t1 SET f_int2 = f_int1,
11474
f_char1 = CAST(f_int1 AS CHAR),
11475
f_char2 = CAST(f_int1 AS CHAR),
11476
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
11477
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
11478
SET AUTOCOMMIT= 0;
11479
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11480
SELECT f_int1, f_int1, '', '', 'was inserted'
11481
FROM t0_template source_tab
11482
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
11483
	
11484
# check transactions-1 success: 	1
11485
COMMIT WORK;
11486
	
11487
# check transactions-2 success: 	1
11488
ROLLBACK WORK;
11489
	
11490
# check transactions-3 success: 	1
11491
DELETE FROM t1 WHERE f_charbig = 'was inserted';
11492
COMMIT WORK;
11493
ROLLBACK WORK;
11494
	
11495
# check transactions-4 success: 	1
11496
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11497
SELECT f_int1, f_int1, '', '', 'was inserted'
11498
FROM t0_template source_tab
11499
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
11500
	
11501
# check transactions-5 success: 	1
11502
ROLLBACK WORK;
11503
	
11504
# check transactions-6 success: 	1
11505
# INFO: Storage engine used for t1 seems to be transactional.
11506
COMMIT;
11507
	
11508
# check transactions-7 success: 	1
11509
DELETE FROM t1 WHERE f_charbig = 'was inserted';
11510
COMMIT WORK;
11511
SET @@session.sql_mode = 'traditional';
11512
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
11513
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11514
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
11515
'', '', 'was inserted' FROM t0_template
11516
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
11517
ERROR 22012: Division by 0
11518
COMMIT;
11519
	
11520
# check transactions-8 success: 	1
11521
# INFO: Storage engine used for t1 seems to be able to revert
11522
#       changes made by the failing statement.
11523
SET @@session.sql_mode = '';
11524
SET AUTOCOMMIT= 1;
11525
DELETE FROM t1 WHERE f_charbig = 'was inserted';
11526
COMMIT WORK;
11527
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
11528
	
11529
# check special-1 success: 	1
11530
UPDATE t1 SET f_charbig = '';
11531
	
11532
# check special-2 success: 	1
11533
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
11534
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
11535
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
11536
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11537
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11538
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11539
'just inserted' FROM t0_template
11540
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11541
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
11542
BEGIN
11543
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11544
f_charbig = 'updated by trigger'
11545
      WHERE f_int1 = new.f_int1;
11546
END|
11547
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11548
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
11549
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11550
	
11551
# check trigger-1 success: 	1
11552
DROP TRIGGER trg_1;
11553
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11554
f_int2 = CAST(f_char1 AS SIGNED INT),
11555
f_charbig = 'just inserted'
11556
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11557
DELETE FROM t0_aux
11558
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11559
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11560
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11561
'just inserted' FROM t0_template
11562
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11563
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
11564
BEGIN
11565
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11566
f_charbig = 'updated by trigger'
11567
      WHERE f_int1 = new.f_int1;
11568
END|
11569
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11570
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
11571
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11572
	
11573
# check trigger-2 success: 	1
11574
DROP TRIGGER trg_1;
11575
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11576
f_int2 = CAST(f_char1 AS SIGNED INT),
11577
f_charbig = 'just inserted'
11578
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11579
DELETE FROM t0_aux
11580
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11581
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11582
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11583
'just inserted' FROM t0_template
11584
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11585
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
11586
BEGIN
11587
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11588
f_charbig = 'updated by trigger'
11589
      WHERE f_int1 = new.f_int1;
11590
END|
11591
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
11592
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
11593
	
11594
# check trigger-3 success: 	1
11595
DROP TRIGGER trg_1;
11596
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11597
f_int2 = CAST(f_char1 AS SIGNED INT),
11598
f_charbig = 'just inserted'
11599
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11600
DELETE FROM t0_aux
11601
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11602
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11603
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11604
'just inserted' FROM t0_template
11605
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11606
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
11607
BEGIN
11608
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11609
f_charbig = 'updated by trigger'
11610
      WHERE f_int1 = - old.f_int1;
11611
END|
11612
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
11613
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
11614
	
11615
# check trigger-4 success: 	1
11616
DROP TRIGGER trg_1;
11617
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11618
f_int2 = CAST(f_char1 AS SIGNED INT),
11619
f_charbig = 'just inserted'
11620
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11621
DELETE FROM t0_aux
11622
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11623
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11624
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11625
'just inserted' FROM t0_template
11626
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11627
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
11628
BEGIN
11629
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11630
f_charbig = 'updated by trigger'
11631
      WHERE f_int1 = new.f_int1;
11632
END|
11633
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
11634
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
11635
	
11636
# check trigger-5 success: 	1
11637
DROP TRIGGER trg_1;
11638
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11639
f_int2 = CAST(f_char1 AS SIGNED INT),
11640
f_charbig = 'just inserted'
11641
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11642
DELETE FROM t0_aux
11643
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11644
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11645
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11646
'just inserted' FROM t0_template
11647
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11648
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
11649
BEGIN
11650
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11651
f_charbig = 'updated by trigger'
11652
      WHERE f_int1 = - old.f_int1;
11653
END|
11654
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
11655
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
11656
	
11657
# check trigger-6 success: 	1
11658
DROP TRIGGER trg_1;
11659
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11660
f_int2 = CAST(f_char1 AS SIGNED INT),
11661
f_charbig = 'just inserted'
11662
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11663
DELETE FROM t0_aux
11664
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11665
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11666
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11667
'just inserted' FROM t0_template
11668
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11669
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
11670
BEGIN
11671
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11672
f_charbig = 'updated by trigger'
11673
      WHERE f_int1 = - old.f_int1;
11674
END|
11675
DELETE FROM t0_aux
11676
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
11677
	
11678
# check trigger-7 success: 	1
11679
DROP TRIGGER trg_1;
11680
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11681
f_int2 = CAST(f_char1 AS SIGNED INT),
11682
f_charbig = 'just inserted'
11683
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11684
DELETE FROM t0_aux
11685
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11686
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
11687
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
11688
'just inserted' FROM t0_template
11689
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11690
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
11691
BEGIN
11692
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
11693
f_charbig = 'updated by trigger'
11694
      WHERE f_int1 = - old.f_int1;
11695
END|
11696
DELETE FROM t0_aux
11697
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
11698
	
11699
# check trigger-8 success: 	1
11700
DROP TRIGGER trg_1;
11701
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11702
f_int2 = CAST(f_char1 AS SIGNED INT),
11703
f_charbig = 'just inserted'
11704
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
11705
DELETE FROM t0_aux
11706
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11707
DELETE FROM t1
11708
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
11709
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
11710
BEGIN
11711
SET new.f_int1 = old.f_int1 + @max_row,
11712
new.f_int2 = old.f_int2 - @max_row,
11713
new.f_charbig = '####updated per update trigger####';
11714
END|
11715
UPDATE t1
11716
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
11717
f_charbig = '####updated per update statement itself####';
11718
	
11719
# check trigger-9 success: 	1
11720
DROP TRIGGER trg_2;
11721
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11722
f_int2 = CAST(f_char1 AS SIGNED INT),
11723
f_charbig = CONCAT('===',f_char1,'===');
11724
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
11725
BEGIN
11726
SET new.f_int1 = new.f_int1 + @max_row,
11727
new.f_int2 = new.f_int2 - @max_row,
11728
new.f_charbig = '####updated per update trigger####';
11729
END|
11730
UPDATE t1
11731
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
11732
f_charbig = '####updated per update statement itself####';
11733
	
11734
# check trigger-10 success: 	1
11735
DROP TRIGGER trg_2;
11736
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11737
f_int2 = CAST(f_char1 AS SIGNED INT),
11738
f_charbig = CONCAT('===',f_char1,'===');
11739
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
11740
BEGIN
11741
SET new.f_int1 = @my_max1 + @counter,
11742
new.f_int2 = @my_min2 - @counter,
11743
new.f_charbig = '####updated per insert trigger####';
11744
SET @counter = @counter + 1;
11745
END|
11746
SET @counter = 1;
11747
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
11748
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11749
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
11750
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
11751
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
11752
ORDER BY f_int1;
11753
DROP TRIGGER trg_3;
11754
	
11755
# check trigger-11 success: 	1
11756
DELETE FROM t1
11757
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
11758
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
11759
AND f_charbig = '####updated per insert trigger####';
11760
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
11761
BEGIN
11762
SET new.f_int1 = @my_max1 + @counter,
11763
new.f_int2 = @my_min2 - @counter,
11764
new.f_charbig = '####updated per insert trigger####';
11765
SET @counter = @counter + 1;
11766
END|
11767
SET @counter = 1;
11768
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
11769
INSERT INTO t1 (f_char1, f_char2, f_charbig)
11770
SELECT CAST(f_int1 AS CHAR),
11771
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
11772
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
11773
ORDER BY f_int1;
11774
DROP TRIGGER trg_3;
11775
	
11776
# check trigger-12 success: 	1
11777
DELETE FROM t1
11778
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
11779
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
11780
AND f_charbig = '####updated per insert trigger####';
11781
ANALYZE  TABLE t1;
11782
Table	Op	Msg_type	Msg_text
11783
test.t1	analyze	note	The storage engine for the table doesn't support analyze
11784
CHECK    TABLE t1 EXTENDED;
11785
Table	Op	Msg_type	Msg_text
11786
test.t1	check	note	The storage engine for the table doesn't support check
11787
CHECKSUM TABLE t1 EXTENDED;
11788
Table	Checksum
11789
test.t1	<some_value>
11790
OPTIMIZE TABLE t1;
11791
Table	Op	Msg_type	Msg_text
11792
test.t1	optimize	note	The storage engine for the table doesn't support optimize
11793
# check layout success:    1
11794
REPAIR   TABLE t1 EXTENDED;
11795
Table	Op	Msg_type	Msg_text
11796
test.t1	repair	note	The storage engine for the table doesn't support repair
11797
# check layout success:    1
11798
TRUNCATE t1;
11799
	
11800
# check TRUNCATE success: 	1
11801
# check layout success:    1
11802
# End usability test (inc/partition_check.inc)
11803
DROP TABLE t1;
11804
CREATE TABLE t1 (
11805
f_int1 INTEGER,
11806
f_int2 INTEGER,
11807
f_char1 CHAR(20),
11808
f_char2 CHAR(20),
11809
f_charbig VARCHAR(1000)
11810
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
11811
)
11812
PARTITION BY KEY(f_int1) PARTITIONS 5;
11813
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
11814
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
11815
# Start usability test (inc/partition_check.inc)
11816
create_command
11817
SHOW CREATE TABLE t1;
11818
Table	Create Table
11819
t1	CREATE TABLE `t1` (
11820
  `f_int1` int(11) NOT NULL DEFAULT '0',
11821
  `f_int2` int(11) NOT NULL DEFAULT '0',
11822
  `f_char1` char(20) DEFAULT NULL,
11823
  `f_char2` char(20) DEFAULT NULL,
11824
  `f_charbig` varchar(1000) DEFAULT NULL,
11825
  PRIMARY KEY (`f_int1`,`f_int2`),
11826
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
11827
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5  */
11828
11829
unified filelist
11830
$MYSQLTEST_VARDIR/master-data/test/t1.frm
11831
$MYSQLTEST_VARDIR/master-data/test/t1.par
11832
11833
# check prerequisites-1 success:    1
11834
# check COUNT(*) success:    1
11835
# check MIN/MAX(f_int1) success:    1
11836
# check MIN/MAX(f_int2) success:    1
11837
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11838
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
11839
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
11840
WHERE f_int1 IN (2,3);
11841
ERROR 23000: Can't write; duplicate key in table 't1'
11842
# check prerequisites-3 success:    1
11843
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
11844
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11845
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
11846
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
11847
WHERE f_int1 IN (2,3);
11848
DELETE FROM t1 WHERE f_charbig = 'delete me';
11849
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11850
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
11851
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
11852
WHERE f_int1 IN (2,3);
11853
DELETE FROM t1 WHERE f_charbig = 'delete me';
11854
# check read via f_int1 success: 1
11855
# check read via f_int2 success: 1
11856
	
11857
# check multiple-1 success: 	1
11858
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
11859
	
11860
# check multiple-2 success: 	1
11861
INSERT INTO t1 SELECT * FROM t0_template
11862
WHERE MOD(f_int1,3) = 0;
11863
	
11864
# check multiple-3 success: 	1
11865
UPDATE t1 SET f_int1 = f_int1 + @max_row
11866
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
11867
AND @max_row_div2 + @max_row_div4;
11868
	
11869
# check multiple-4 success: 	1
11870
DELETE FROM t1
11871
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
11872
AND @max_row_div2 + @max_row_div4 + @max_row;
11873
	
11874
# check multiple-5 success: 	1
11875
SELECT COUNT(*) INTO @try_count FROM t0_template
11876
WHERE MOD(f_int1,3) = 0
11877
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
11878
SELECT COUNT(*) INTO @clash_count
11879
FROM t1 INNER JOIN t0_template USING(f_int1)
11880
WHERE MOD(f_int1,3) = 0
11881
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
11882
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
11883
INSERT INTO t1
11884
SET f_int1 = @cur_value , f_int2 = @cur_value,
11885
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
11886
f_charbig = '#SINGLE#';
11887
	
11888
# check single-1 success: 	1
11889
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
11890
INSERT INTO t1
11891
SET f_int1 = @cur_value , f_int2 = @cur_value,
11892
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
11893
f_charbig = '#SINGLE#';
11894
	
11895
# check single-2 success: 	1
11896
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
11897
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
11898
UPDATE t1 SET f_int1 = @cur_value2
11899
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
11900
	
11901
# check single-3 success: 	1
11902
SET @cur_value1= -1;
11903
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
11904
UPDATE t1 SET f_int1 = @cur_value1
11905
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
11906
	
11907
# check single-4 success: 	1
11908
SELECT MAX(f_int1) INTO @cur_value FROM t1;
11909
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
11910
	
11911
# check single-5 success: 	1
11912
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
11913
	
11914
# check single-6 success: 	1
11915
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
11916
	
11917
# check single-7 success: 	1
11918
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
11919
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
11920
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
11921
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
11922
f_charbig = '#NULL#';
11923
INSERT INTO t1
11924
SET f_int1 = NULL , f_int2 = -@max_row,
11925
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
11926
f_charbig = '#NULL#';
11927
ERROR 23000: Column 'f_int1' cannot be null
11928
# check null success:    1
11929
DELETE FROM t1
11930
WHERE f_int1 = 0 AND f_int2 = 0
11931
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
11932
AND f_charbig = '#NULL#';
11933
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11934
SELECT f_int1, f_int1, '', '', 'was inserted'
11935
   FROM t0_template source_tab
11936
WHERE MOD(f_int1,3) = 0
11937
AND f_int1 BETWEEN @max_row_div2 AND @max_row
11938
ON DUPLICATE KEY
11939
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
11940
f_int2 = 2 * @max_row + source_tab.f_int1,
11941
f_charbig = 'was updated';
11942
	
11943
# check unique-1-a success: 	1
11944
	
11945
# check unique-1-b success: 	1
11946
DELETE FROM t1 WHERE f_charbig = 'was inserted';
11947
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
11948
f_int2 = CAST(f_char1 AS SIGNED INT),
11949
f_charbig = CONCAT('===',f_char1,'===')
11950
WHERE f_charbig = 'was updated';
11951
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11952
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
11953
   FROM t0_template source_tab
11954
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
11955
	
11956
# check replace success: 	1
11957
DELETE FROM t1
11958
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
11959
DELETE FROM t1
11960
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
11961
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
11962
UPDATE t1 SET f_int2 = f_int1,
11963
f_char1 = CAST(f_int1 AS CHAR),
11964
f_char2 = CAST(f_int1 AS CHAR),
11965
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
11966
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
11967
SET AUTOCOMMIT= 0;
11968
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11969
SELECT f_int1, f_int1, '', '', 'was inserted'
11970
FROM t0_template source_tab
11971
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
11972
	
11973
# check transactions-1 success: 	1
11974
COMMIT WORK;
11975
	
11976
# check transactions-2 success: 	1
11977
ROLLBACK WORK;
11978
	
11979
# check transactions-3 success: 	1
11980
DELETE FROM t1 WHERE f_charbig = 'was inserted';
11981
COMMIT WORK;
11982
ROLLBACK WORK;
11983
	
11984
# check transactions-4 success: 	1
11985
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
11986
SELECT f_int1, f_int1, '', '', 'was inserted'
11987
FROM t0_template source_tab
11988
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
11989
	
11990
# check transactions-5 success: 	1
11991
ROLLBACK WORK;
11992
	
11993
# check transactions-6 success: 	1
11994
# INFO: Storage engine used for t1 seems to be transactional.
11995
COMMIT;
11996
	
11997
# check transactions-7 success: 	1
11998
DELETE FROM t1 WHERE f_charbig = 'was inserted';
11999
COMMIT WORK;
12000
SET @@session.sql_mode = 'traditional';
12001
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
12002
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12003
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
12004
'', '', 'was inserted' FROM t0_template
12005
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
12006
ERROR 22012: Division by 0
12007
COMMIT;
12008
	
12009
# check transactions-8 success: 	1
12010
# INFO: Storage engine used for t1 seems to be able to revert
12011
#       changes made by the failing statement.
12012
SET @@session.sql_mode = '';
12013
SET AUTOCOMMIT= 1;
12014
DELETE FROM t1 WHERE f_charbig = 'was inserted';
12015
COMMIT WORK;
12016
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
12017
	
12018
# check special-1 success: 	1
12019
UPDATE t1 SET f_charbig = '';
12020
	
12021
# check special-2 success: 	1
12022
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
12023
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
12024
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
12025
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12026
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12027
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12028
'just inserted' FROM t0_template
12029
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12030
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
12031
BEGIN
12032
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12033
f_charbig = 'updated by trigger'
12034
      WHERE f_int1 = new.f_int1;
12035
END|
12036
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12037
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
12038
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12039
	
12040
# check trigger-1 success: 	1
12041
DROP TRIGGER trg_1;
12042
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12043
f_int2 = CAST(f_char1 AS SIGNED INT),
12044
f_charbig = 'just inserted'
12045
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12046
DELETE FROM t0_aux
12047
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12048
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12049
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12050
'just inserted' FROM t0_template
12051
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12052
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
12053
BEGIN
12054
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12055
f_charbig = 'updated by trigger'
12056
      WHERE f_int1 = new.f_int1;
12057
END|
12058
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12059
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
12060
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12061
	
12062
# check trigger-2 success: 	1
12063
DROP TRIGGER trg_1;
12064
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12065
f_int2 = CAST(f_char1 AS SIGNED INT),
12066
f_charbig = 'just inserted'
12067
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12068
DELETE FROM t0_aux
12069
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12070
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12071
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12072
'just inserted' FROM t0_template
12073
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12074
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
12075
BEGIN
12076
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12077
f_charbig = 'updated by trigger'
12078
      WHERE f_int1 = new.f_int1;
12079
END|
12080
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
12081
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
12082
	
12083
# check trigger-3 success: 	1
12084
DROP TRIGGER trg_1;
12085
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12086
f_int2 = CAST(f_char1 AS SIGNED INT),
12087
f_charbig = 'just inserted'
12088
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12089
DELETE FROM t0_aux
12090
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12091
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12092
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12093
'just inserted' FROM t0_template
12094
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12095
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
12096
BEGIN
12097
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12098
f_charbig = 'updated by trigger'
12099
      WHERE f_int1 = - old.f_int1;
12100
END|
12101
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
12102
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
12103
	
12104
# check trigger-4 success: 	1
12105
DROP TRIGGER trg_1;
12106
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12107
f_int2 = CAST(f_char1 AS SIGNED INT),
12108
f_charbig = 'just inserted'
12109
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12110
DELETE FROM t0_aux
12111
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12112
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12113
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12114
'just inserted' FROM t0_template
12115
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12116
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
12117
BEGIN
12118
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12119
f_charbig = 'updated by trigger'
12120
      WHERE f_int1 = new.f_int1;
12121
END|
12122
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
12123
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
12124
	
12125
# check trigger-5 success: 	1
12126
DROP TRIGGER trg_1;
12127
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12128
f_int2 = CAST(f_char1 AS SIGNED INT),
12129
f_charbig = 'just inserted'
12130
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12131
DELETE FROM t0_aux
12132
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12133
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12134
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12135
'just inserted' FROM t0_template
12136
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12137
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
12138
BEGIN
12139
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12140
f_charbig = 'updated by trigger'
12141
      WHERE f_int1 = - old.f_int1;
12142
END|
12143
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
12144
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
12145
	
12146
# check trigger-6 success: 	1
12147
DROP TRIGGER trg_1;
12148
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12149
f_int2 = CAST(f_char1 AS SIGNED INT),
12150
f_charbig = 'just inserted'
12151
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12152
DELETE FROM t0_aux
12153
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12154
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12155
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12156
'just inserted' FROM t0_template
12157
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12158
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
12159
BEGIN
12160
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12161
f_charbig = 'updated by trigger'
12162
      WHERE f_int1 = - old.f_int1;
12163
END|
12164
DELETE FROM t0_aux
12165
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
12166
	
12167
# check trigger-7 success: 	1
12168
DROP TRIGGER trg_1;
12169
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12170
f_int2 = CAST(f_char1 AS SIGNED INT),
12171
f_charbig = 'just inserted'
12172
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12173
DELETE FROM t0_aux
12174
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12175
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12176
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12177
'just inserted' FROM t0_template
12178
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12179
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
12180
BEGIN
12181
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12182
f_charbig = 'updated by trigger'
12183
      WHERE f_int1 = - old.f_int1;
12184
END|
12185
DELETE FROM t0_aux
12186
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
12187
	
12188
# check trigger-8 success: 	1
12189
DROP TRIGGER trg_1;
12190
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12191
f_int2 = CAST(f_char1 AS SIGNED INT),
12192
f_charbig = 'just inserted'
12193
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12194
DELETE FROM t0_aux
12195
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12196
DELETE FROM t1
12197
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12198
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
12199
BEGIN
12200
SET new.f_int1 = old.f_int1 + @max_row,
12201
new.f_int2 = old.f_int2 - @max_row,
12202
new.f_charbig = '####updated per update trigger####';
12203
END|
12204
UPDATE t1
12205
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
12206
f_charbig = '####updated per update statement itself####';
12207
	
12208
# check trigger-9 success: 	1
12209
DROP TRIGGER trg_2;
12210
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12211
f_int2 = CAST(f_char1 AS SIGNED INT),
12212
f_charbig = CONCAT('===',f_char1,'===');
12213
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
12214
BEGIN
12215
SET new.f_int1 = new.f_int1 + @max_row,
12216
new.f_int2 = new.f_int2 - @max_row,
12217
new.f_charbig = '####updated per update trigger####';
12218
END|
12219
UPDATE t1
12220
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
12221
f_charbig = '####updated per update statement itself####';
12222
	
12223
# check trigger-10 success: 	1
12224
DROP TRIGGER trg_2;
12225
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12226
f_int2 = CAST(f_char1 AS SIGNED INT),
12227
f_charbig = CONCAT('===',f_char1,'===');
12228
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
12229
BEGIN
12230
SET new.f_int1 = @my_max1 + @counter,
12231
new.f_int2 = @my_min2 - @counter,
12232
new.f_charbig = '####updated per insert trigger####';
12233
SET @counter = @counter + 1;
12234
END|
12235
SET @counter = 1;
12236
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
12237
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12238
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
12239
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
12240
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
12241
ORDER BY f_int1;
12242
DROP TRIGGER trg_3;
12243
	
12244
# check trigger-11 success: 	1
12245
DELETE FROM t1
12246
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
12247
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
12248
AND f_charbig = '####updated per insert trigger####';
12249
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
12250
BEGIN
12251
SET new.f_int1 = @my_max1 + @counter,
12252
new.f_int2 = @my_min2 - @counter,
12253
new.f_charbig = '####updated per insert trigger####';
12254
SET @counter = @counter + 1;
12255
END|
12256
SET @counter = 1;
12257
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
12258
INSERT INTO t1 (f_char1, f_char2, f_charbig)
12259
SELECT CAST(f_int1 AS CHAR),
12260
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
12261
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
12262
ORDER BY f_int1;
12263
DROP TRIGGER trg_3;
12264
	
12265
# check trigger-12 success: 	1
12266
DELETE FROM t1
12267
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
12268
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
12269
AND f_charbig = '####updated per insert trigger####';
12270
ANALYZE  TABLE t1;
12271
Table	Op	Msg_type	Msg_text
12272
test.t1	analyze	note	The storage engine for the table doesn't support analyze
12273
CHECK    TABLE t1 EXTENDED;
12274
Table	Op	Msg_type	Msg_text
12275
test.t1	check	note	The storage engine for the table doesn't support check
12276
CHECKSUM TABLE t1 EXTENDED;
12277
Table	Checksum
12278
test.t1	<some_value>
12279
OPTIMIZE TABLE t1;
12280
Table	Op	Msg_type	Msg_text
12281
test.t1	optimize	note	The storage engine for the table doesn't support optimize
12282
# check layout success:    1
12283
REPAIR   TABLE t1 EXTENDED;
12284
Table	Op	Msg_type	Msg_text
12285
test.t1	repair	note	The storage engine for the table doesn't support repair
12286
# check layout success:    1
12287
TRUNCATE t1;
12288
	
12289
# check TRUNCATE success: 	1
12290
# check layout success:    1
12291
# End usability test (inc/partition_check.inc)
12292
DROP TABLE t1;
12293
CREATE TABLE t1 (
12294
f_int1 INTEGER,
12295
f_int2 INTEGER,
12296
f_char1 CHAR(20),
12297
f_char2 CHAR(20),
12298
f_charbig VARCHAR(1000)
12299
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
12300
)
12301
PARTITION BY LIST(MOD(f_int1,4))
12302
(PARTITION part_3 VALUES IN (-3),
12303
PARTITION part_2 VALUES IN (-2),
12304
PARTITION part_1 VALUES IN (-1),
12305
PARTITION part_N VALUES IN (NULL),
12306
PARTITION part0 VALUES IN (0),
12307
PARTITION part1 VALUES IN (1),
12308
PARTITION part2 VALUES IN (2),
12309
PARTITION part3 VALUES IN (3));
12310
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
12311
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
12312
# Start usability test (inc/partition_check.inc)
12313
create_command
12314
SHOW CREATE TABLE t1;
12315
Table	Create Table
12316
t1	CREATE TABLE `t1` (
12317
  `f_int1` int(11) NOT NULL DEFAULT '0',
12318
  `f_int2` int(11) NOT NULL DEFAULT '0',
12319
  `f_char1` char(20) DEFAULT NULL,
12320
  `f_char2` char(20) DEFAULT NULL,
12321
  `f_charbig` varchar(1000) DEFAULT NULL,
12322
  PRIMARY KEY (`f_int1`,`f_int2`),
12323
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
12324
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3) ENGINE = InnoDB, PARTITION part_2 VALUES IN (-2) ENGINE = InnoDB, PARTITION part_1 VALUES IN (-1) ENGINE = InnoDB, PARTITION part_N VALUES IN (NULL) ENGINE = InnoDB, PARTITION part0 VALUES IN (0) ENGINE = InnoDB, PARTITION part1 VALUES IN (1) ENGINE = InnoDB, PARTITION part2 VALUES IN (2) ENGINE = InnoDB, PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
12325
12326
unified filelist
12327
$MYSQLTEST_VARDIR/master-data/test/t1.frm
12328
$MYSQLTEST_VARDIR/master-data/test/t1.par
12329
12330
# check prerequisites-1 success:    1
12331
# check COUNT(*) success:    1
12332
# check MIN/MAX(f_int1) success:    1
12333
# check MIN/MAX(f_int2) success:    1
12334
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12335
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
12336
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
12337
WHERE f_int1 IN (2,3);
12338
ERROR 23000: Can't write; duplicate key in table 't1'
12339
# check prerequisites-3 success:    1
12340
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
12341
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12342
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
12343
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
12344
WHERE f_int1 IN (2,3);
12345
DELETE FROM t1 WHERE f_charbig = 'delete me';
12346
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12347
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
12348
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
12349
WHERE f_int1 IN (2,3);
12350
DELETE FROM t1 WHERE f_charbig = 'delete me';
12351
# check read via f_int1 success: 1
12352
# check read via f_int2 success: 1
12353
	
12354
# check multiple-1 success: 	1
12355
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
12356
	
12357
# check multiple-2 success: 	1
12358
INSERT INTO t1 SELECT * FROM t0_template
12359
WHERE MOD(f_int1,3) = 0;
12360
	
12361
# check multiple-3 success: 	1
12362
UPDATE t1 SET f_int1 = f_int1 + @max_row
12363
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
12364
AND @max_row_div2 + @max_row_div4;
12365
	
12366
# check multiple-4 success: 	1
12367
DELETE FROM t1
12368
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
12369
AND @max_row_div2 + @max_row_div4 + @max_row;
12370
	
12371
# check multiple-5 success: 	1
12372
SELECT COUNT(*) INTO @try_count FROM t0_template
12373
WHERE MOD(f_int1,3) = 0
12374
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
12375
SELECT COUNT(*) INTO @clash_count
12376
FROM t1 INNER JOIN t0_template USING(f_int1)
12377
WHERE MOD(f_int1,3) = 0
12378
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
12379
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
12380
INSERT INTO t1
12381
SET f_int1 = @cur_value , f_int2 = @cur_value,
12382
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
12383
f_charbig = '#SINGLE#';
12384
	
12385
# check single-1 success: 	1
12386
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
12387
INSERT INTO t1
12388
SET f_int1 = @cur_value , f_int2 = @cur_value,
12389
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
12390
f_charbig = '#SINGLE#';
12391
	
12392
# check single-2 success: 	1
12393
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
12394
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
12395
UPDATE t1 SET f_int1 = @cur_value2
12396
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
12397
	
12398
# check single-3 success: 	1
12399
SET @cur_value1= -1;
12400
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
12401
UPDATE t1 SET f_int1 = @cur_value1
12402
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
12403
	
12404
# check single-4 success: 	1
12405
SELECT MAX(f_int1) INTO @cur_value FROM t1;
12406
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
12407
	
12408
# check single-5 success: 	1
12409
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
12410
	
12411
# check single-6 success: 	1
12412
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
12413
	
12414
# check single-7 success: 	1
12415
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
12416
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
12417
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
12418
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
12419
f_charbig = '#NULL#';
12420
INSERT INTO t1
12421
SET f_int1 = NULL , f_int2 = -@max_row,
12422
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
12423
f_charbig = '#NULL#';
12424
ERROR 23000: Column 'f_int1' cannot be null
12425
# check null success:    1
12426
DELETE FROM t1
12427
WHERE f_int1 = 0 AND f_int2 = 0
12428
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
12429
AND f_charbig = '#NULL#';
12430
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12431
SELECT f_int1, f_int1, '', '', 'was inserted'
12432
   FROM t0_template source_tab
12433
WHERE MOD(f_int1,3) = 0
12434
AND f_int1 BETWEEN @max_row_div2 AND @max_row
12435
ON DUPLICATE KEY
12436
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
12437
f_int2 = 2 * @max_row + source_tab.f_int1,
12438
f_charbig = 'was updated';
12439
	
12440
# check unique-1-a success: 	1
12441
	
12442
# check unique-1-b success: 	1
12443
DELETE FROM t1 WHERE f_charbig = 'was inserted';
12444
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12445
f_int2 = CAST(f_char1 AS SIGNED INT),
12446
f_charbig = CONCAT('===',f_char1,'===')
12447
WHERE f_charbig = 'was updated';
12448
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12449
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
12450
   FROM t0_template source_tab
12451
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
12452
	
12453
# check replace success: 	1
12454
DELETE FROM t1
12455
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
12456
DELETE FROM t1
12457
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
12458
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
12459
UPDATE t1 SET f_int2 = f_int1,
12460
f_char1 = CAST(f_int1 AS CHAR),
12461
f_char2 = CAST(f_int1 AS CHAR),
12462
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
12463
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
12464
SET AUTOCOMMIT= 0;
12465
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12466
SELECT f_int1, f_int1, '', '', 'was inserted'
12467
FROM t0_template source_tab
12468
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
12469
	
12470
# check transactions-1 success: 	1
12471
COMMIT WORK;
12472
	
12473
# check transactions-2 success: 	1
12474
ROLLBACK WORK;
12475
	
12476
# check transactions-3 success: 	1
12477
DELETE FROM t1 WHERE f_charbig = 'was inserted';
12478
COMMIT WORK;
12479
ROLLBACK WORK;
12480
	
12481
# check transactions-4 success: 	1
12482
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12483
SELECT f_int1, f_int1, '', '', 'was inserted'
12484
FROM t0_template source_tab
12485
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
12486
	
12487
# check transactions-5 success: 	1
12488
ROLLBACK WORK;
12489
	
12490
# check transactions-6 success: 	1
12491
# INFO: Storage engine used for t1 seems to be transactional.
12492
COMMIT;
12493
	
12494
# check transactions-7 success: 	1
12495
DELETE FROM t1 WHERE f_charbig = 'was inserted';
12496
COMMIT WORK;
12497
SET @@session.sql_mode = 'traditional';
12498
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
12499
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12500
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
12501
'', '', 'was inserted' FROM t0_template
12502
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
12503
ERROR 22012: Division by 0
12504
COMMIT;
12505
	
12506
# check transactions-8 success: 	1
12507
# INFO: Storage engine used for t1 seems to be able to revert
12508
#       changes made by the failing statement.
12509
SET @@session.sql_mode = '';
12510
SET AUTOCOMMIT= 1;
12511
DELETE FROM t1 WHERE f_charbig = 'was inserted';
12512
COMMIT WORK;
12513
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
12514
	
12515
# check special-1 success: 	1
12516
UPDATE t1 SET f_charbig = '';
12517
	
12518
# check special-2 success: 	1
12519
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
12520
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
12521
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
12522
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12523
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12524
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12525
'just inserted' FROM t0_template
12526
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12527
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
12528
BEGIN
12529
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12530
f_charbig = 'updated by trigger'
12531
      WHERE f_int1 = new.f_int1;
12532
END|
12533
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12534
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
12535
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12536
	
12537
# check trigger-1 success: 	1
12538
DROP TRIGGER trg_1;
12539
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12540
f_int2 = CAST(f_char1 AS SIGNED INT),
12541
f_charbig = 'just inserted'
12542
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12543
DELETE FROM t0_aux
12544
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12545
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12546
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12547
'just inserted' FROM t0_template
12548
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12549
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
12550
BEGIN
12551
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12552
f_charbig = 'updated by trigger'
12553
      WHERE f_int1 = new.f_int1;
12554
END|
12555
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12556
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
12557
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12558
	
12559
# check trigger-2 success: 	1
12560
DROP TRIGGER trg_1;
12561
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12562
f_int2 = CAST(f_char1 AS SIGNED INT),
12563
f_charbig = 'just inserted'
12564
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12565
DELETE FROM t0_aux
12566
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12567
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12568
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12569
'just inserted' FROM t0_template
12570
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12571
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
12572
BEGIN
12573
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12574
f_charbig = 'updated by trigger'
12575
      WHERE f_int1 = new.f_int1;
12576
END|
12577
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
12578
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
12579
	
12580
# check trigger-3 success: 	1
12581
DROP TRIGGER trg_1;
12582
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12583
f_int2 = CAST(f_char1 AS SIGNED INT),
12584
f_charbig = 'just inserted'
12585
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12586
DELETE FROM t0_aux
12587
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12588
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12589
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12590
'just inserted' FROM t0_template
12591
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12592
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
12593
BEGIN
12594
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12595
f_charbig = 'updated by trigger'
12596
      WHERE f_int1 = - old.f_int1;
12597
END|
12598
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
12599
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
12600
	
12601
# check trigger-4 success: 	1
12602
DROP TRIGGER trg_1;
12603
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12604
f_int2 = CAST(f_char1 AS SIGNED INT),
12605
f_charbig = 'just inserted'
12606
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12607
DELETE FROM t0_aux
12608
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12609
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12610
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12611
'just inserted' FROM t0_template
12612
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12613
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
12614
BEGIN
12615
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12616
f_charbig = 'updated by trigger'
12617
      WHERE f_int1 = new.f_int1;
12618
END|
12619
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
12620
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
12621
	
12622
# check trigger-5 success: 	1
12623
DROP TRIGGER trg_1;
12624
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12625
f_int2 = CAST(f_char1 AS SIGNED INT),
12626
f_charbig = 'just inserted'
12627
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12628
DELETE FROM t0_aux
12629
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12630
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12631
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12632
'just inserted' FROM t0_template
12633
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12634
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
12635
BEGIN
12636
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12637
f_charbig = 'updated by trigger'
12638
      WHERE f_int1 = - old.f_int1;
12639
END|
12640
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
12641
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
12642
	
12643
# check trigger-6 success: 	1
12644
DROP TRIGGER trg_1;
12645
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12646
f_int2 = CAST(f_char1 AS SIGNED INT),
12647
f_charbig = 'just inserted'
12648
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12649
DELETE FROM t0_aux
12650
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12651
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12652
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12653
'just inserted' FROM t0_template
12654
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12655
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
12656
BEGIN
12657
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12658
f_charbig = 'updated by trigger'
12659
      WHERE f_int1 = - old.f_int1;
12660
END|
12661
DELETE FROM t0_aux
12662
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
12663
	
12664
# check trigger-7 success: 	1
12665
DROP TRIGGER trg_1;
12666
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12667
f_int2 = CAST(f_char1 AS SIGNED INT),
12668
f_charbig = 'just inserted'
12669
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12670
DELETE FROM t0_aux
12671
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12672
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
12673
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
12674
'just inserted' FROM t0_template
12675
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12676
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
12677
BEGIN
12678
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
12679
f_charbig = 'updated by trigger'
12680
      WHERE f_int1 = - old.f_int1;
12681
END|
12682
DELETE FROM t0_aux
12683
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
12684
	
12685
# check trigger-8 success: 	1
12686
DROP TRIGGER trg_1;
12687
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12688
f_int2 = CAST(f_char1 AS SIGNED INT),
12689
f_charbig = 'just inserted'
12690
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
12691
DELETE FROM t0_aux
12692
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12693
DELETE FROM t1
12694
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
12695
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
12696
BEGIN
12697
SET new.f_int1 = old.f_int1 + @max_row,
12698
new.f_int2 = old.f_int2 - @max_row,
12699
new.f_charbig = '####updated per update trigger####';
12700
END|
12701
UPDATE t1
12702
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
12703
f_charbig = '####updated per update statement itself####';
12704
	
12705
# check trigger-9 success: 	1
12706
DROP TRIGGER trg_2;
12707
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12708
f_int2 = CAST(f_char1 AS SIGNED INT),
12709
f_charbig = CONCAT('===',f_char1,'===');
12710
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
12711
BEGIN
12712
SET new.f_int1 = new.f_int1 + @max_row,
12713
new.f_int2 = new.f_int2 - @max_row,
12714
new.f_charbig = '####updated per update trigger####';
12715
END|
12716
UPDATE t1
12717
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
12718
f_charbig = '####updated per update statement itself####';
12719
	
12720
# check trigger-10 success: 	1
12721
DROP TRIGGER trg_2;
12722
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12723
f_int2 = CAST(f_char1 AS SIGNED INT),
12724
f_charbig = CONCAT('===',f_char1,'===');
12725
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
12726
BEGIN
12727
SET new.f_int1 = @my_max1 + @counter,
12728
new.f_int2 = @my_min2 - @counter,
12729
new.f_charbig = '####updated per insert trigger####';
12730
SET @counter = @counter + 1;
12731
END|
12732
SET @counter = 1;
12733
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
12734
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12735
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
12736
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
12737
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
12738
ORDER BY f_int1;
12739
DROP TRIGGER trg_3;
12740
	
12741
# check trigger-11 success: 	1
12742
DELETE FROM t1
12743
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
12744
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
12745
AND f_charbig = '####updated per insert trigger####';
12746
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
12747
BEGIN
12748
SET new.f_int1 = @my_max1 + @counter,
12749
new.f_int2 = @my_min2 - @counter,
12750
new.f_charbig = '####updated per insert trigger####';
12751
SET @counter = @counter + 1;
12752
END|
12753
SET @counter = 1;
12754
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
12755
INSERT INTO t1 (f_char1, f_char2, f_charbig)
12756
SELECT CAST(f_int1 AS CHAR),
12757
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
12758
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
12759
ORDER BY f_int1;
12760
DROP TRIGGER trg_3;
12761
	
12762
# check trigger-12 success: 	1
12763
DELETE FROM t1
12764
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
12765
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
12766
AND f_charbig = '####updated per insert trigger####';
12767
ANALYZE  TABLE t1;
12768
Table	Op	Msg_type	Msg_text
12769
test.t1	analyze	note	The storage engine for the table doesn't support analyze
12770
CHECK    TABLE t1 EXTENDED;
12771
Table	Op	Msg_type	Msg_text
12772
test.t1	check	note	The storage engine for the table doesn't support check
12773
CHECKSUM TABLE t1 EXTENDED;
12774
Table	Checksum
12775
test.t1	<some_value>
12776
OPTIMIZE TABLE t1;
12777
Table	Op	Msg_type	Msg_text
12778
test.t1	optimize	note	The storage engine for the table doesn't support optimize
12779
# check layout success:    1
12780
REPAIR   TABLE t1 EXTENDED;
12781
Table	Op	Msg_type	Msg_text
12782
test.t1	repair	note	The storage engine for the table doesn't support repair
12783
# check layout success:    1
12784
TRUNCATE t1;
12785
	
12786
# check TRUNCATE success: 	1
12787
# check layout success:    1
12788
# End usability test (inc/partition_check.inc)
12789
DROP TABLE t1;
12790
CREATE TABLE t1 (
12791
f_int1 INTEGER,
12792
f_int2 INTEGER,
12793
f_char1 CHAR(20),
12794
f_char2 CHAR(20),
12795
f_charbig VARCHAR(1000)
12796
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
12797
)
12798
PARTITION BY RANGE(f_int1)
12799
(PARTITION parta VALUES LESS THAN (0),
12800
PARTITION partb VALUES LESS THAN (5),
12801
PARTITION partc VALUES LESS THAN (10),
12802
PARTITION partd VALUES LESS THAN (10 + 5),
12803
PARTITION parte VALUES LESS THAN (20),
12804
PARTITION partf VALUES LESS THAN (2147483646));
12805
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
12806
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
12807
# Start usability test (inc/partition_check.inc)
12808
create_command
12809
SHOW CREATE TABLE t1;
12810
Table	Create Table
12811
t1	CREATE TABLE `t1` (
12812
  `f_int1` int(11) NOT NULL DEFAULT '0',
12813
  `f_int2` int(11) NOT NULL DEFAULT '0',
12814
  `f_char1` char(20) DEFAULT NULL,
12815
  `f_char2` char(20) DEFAULT NULL,
12816
  `f_charbig` varchar(1000) DEFAULT NULL,
12817
  PRIMARY KEY (`f_int1`,`f_int2`),
12818
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
12819
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION parte VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
12820
12821
unified filelist
12822
$MYSQLTEST_VARDIR/master-data/test/t1.frm
12823
$MYSQLTEST_VARDIR/master-data/test/t1.par
12824
12825
# check prerequisites-1 success:    1
12826
# check COUNT(*) success:    1
12827
# check MIN/MAX(f_int1) success:    1
12828
# check MIN/MAX(f_int2) success:    1
12829
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12830
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
12831
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
12832
WHERE f_int1 IN (2,3);
12833
ERROR 23000: Can't write; duplicate key in table 't1'
12834
# check prerequisites-3 success:    1
12835
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
12836
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12837
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
12838
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
12839
WHERE f_int1 IN (2,3);
12840
DELETE FROM t1 WHERE f_charbig = 'delete me';
12841
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12842
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
12843
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
12844
WHERE f_int1 IN (2,3);
12845
DELETE FROM t1 WHERE f_charbig = 'delete me';
12846
# check read via f_int1 success: 1
12847
# check read via f_int2 success: 1
12848
	
12849
# check multiple-1 success: 	1
12850
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
12851
	
12852
# check multiple-2 success: 	1
12853
INSERT INTO t1 SELECT * FROM t0_template
12854
WHERE MOD(f_int1,3) = 0;
12855
	
12856
# check multiple-3 success: 	1
12857
UPDATE t1 SET f_int1 = f_int1 + @max_row
12858
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
12859
AND @max_row_div2 + @max_row_div4;
12860
	
12861
# check multiple-4 success: 	1
12862
DELETE FROM t1
12863
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
12864
AND @max_row_div2 + @max_row_div4 + @max_row;
12865
	
12866
# check multiple-5 success: 	1
12867
SELECT COUNT(*) INTO @try_count FROM t0_template
12868
WHERE MOD(f_int1,3) = 0
12869
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
12870
SELECT COUNT(*) INTO @clash_count
12871
FROM t1 INNER JOIN t0_template USING(f_int1)
12872
WHERE MOD(f_int1,3) = 0
12873
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
12874
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
12875
INSERT INTO t1
12876
SET f_int1 = @cur_value , f_int2 = @cur_value,
12877
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
12878
f_charbig = '#SINGLE#';
12879
	
12880
# check single-1 success: 	1
12881
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
12882
INSERT INTO t1
12883
SET f_int1 = @cur_value , f_int2 = @cur_value,
12884
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
12885
f_charbig = '#SINGLE#';
12886
	
12887
# check single-2 success: 	1
12888
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
12889
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
12890
UPDATE t1 SET f_int1 = @cur_value2
12891
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
12892
	
12893
# check single-3 success: 	1
12894
SET @cur_value1= -1;
12895
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
12896
UPDATE t1 SET f_int1 = @cur_value1
12897
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
12898
	
12899
# check single-4 success: 	1
12900
SELECT MAX(f_int1) INTO @cur_value FROM t1;
12901
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
12902
	
12903
# check single-5 success: 	1
12904
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
12905
	
12906
# check single-6 success: 	1
12907
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
12908
ERROR HY000: Table has no partition for value 2147483647
12909
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
12910
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
12911
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
12912
f_charbig = '#NULL#';
12913
INSERT INTO t1
12914
SET f_int1 = NULL , f_int2 = -@max_row,
12915
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
12916
f_charbig = '#NULL#';
12917
ERROR 23000: Column 'f_int1' cannot be null
12918
# check null success:    1
12919
DELETE FROM t1
12920
WHERE f_int1 = 0 AND f_int2 = 0
12921
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
12922
AND f_charbig = '#NULL#';
12923
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12924
SELECT f_int1, f_int1, '', '', 'was inserted'
12925
   FROM t0_template source_tab
12926
WHERE MOD(f_int1,3) = 0
12927
AND f_int1 BETWEEN @max_row_div2 AND @max_row
12928
ON DUPLICATE KEY
12929
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
12930
f_int2 = 2 * @max_row + source_tab.f_int1,
12931
f_charbig = 'was updated';
12932
	
12933
# check unique-1-a success: 	1
12934
	
12935
# check unique-1-b success: 	1
12936
DELETE FROM t1 WHERE f_charbig = 'was inserted';
12937
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
12938
f_int2 = CAST(f_char1 AS SIGNED INT),
12939
f_charbig = CONCAT('===',f_char1,'===')
12940
WHERE f_charbig = 'was updated';
12941
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12942
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
12943
   FROM t0_template source_tab
12944
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
12945
	
12946
# check replace success: 	1
12947
DELETE FROM t1
12948
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
12949
DELETE FROM t1
12950
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
12951
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
12952
UPDATE t1 SET f_int2 = f_int1,
12953
f_char1 = CAST(f_int1 AS CHAR),
12954
f_char2 = CAST(f_int1 AS CHAR),
12955
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
12956
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
12957
SET AUTOCOMMIT= 0;
12958
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12959
SELECT f_int1, f_int1, '', '', 'was inserted'
12960
FROM t0_template source_tab
12961
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
12962
	
12963
# check transactions-1 success: 	1
12964
COMMIT WORK;
12965
	
12966
# check transactions-2 success: 	1
12967
ROLLBACK WORK;
12968
	
12969
# check transactions-3 success: 	1
12970
DELETE FROM t1 WHERE f_charbig = 'was inserted';
12971
COMMIT WORK;
12972
ROLLBACK WORK;
12973
	
12974
# check transactions-4 success: 	1
12975
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12976
SELECT f_int1, f_int1, '', '', 'was inserted'
12977
FROM t0_template source_tab
12978
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
12979
	
12980
# check transactions-5 success: 	1
12981
ROLLBACK WORK;
12982
	
12983
# check transactions-6 success: 	1
12984
# INFO: Storage engine used for t1 seems to be transactional.
12985
COMMIT;
12986
	
12987
# check transactions-7 success: 	1
12988
DELETE FROM t1 WHERE f_charbig = 'was inserted';
12989
COMMIT WORK;
12990
SET @@session.sql_mode = 'traditional';
12991
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
12992
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
12993
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
12994
'', '', 'was inserted' FROM t0_template
12995
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
12996
ERROR 22012: Division by 0
12997
COMMIT;
12998
	
12999
# check transactions-8 success: 	1
13000
# INFO: Storage engine used for t1 seems to be able to revert
13001
#       changes made by the failing statement.
13002
SET @@session.sql_mode = '';
13003
SET AUTOCOMMIT= 1;
13004
DELETE FROM t1 WHERE f_charbig = 'was inserted';
13005
COMMIT WORK;
13006
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
13007
	
13008
# check special-1 success: 	1
13009
UPDATE t1 SET f_charbig = '';
13010
	
13011
# check special-2 success: 	1
13012
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
13013
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
13014
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
13015
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13016
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13017
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13018
'just inserted' FROM t0_template
13019
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13020
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
13021
BEGIN
13022
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13023
f_charbig = 'updated by trigger'
13024
      WHERE f_int1 = new.f_int1;
13025
END|
13026
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13027
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
13028
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13029
	
13030
# check trigger-1 success: 	1
13031
DROP TRIGGER trg_1;
13032
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13033
f_int2 = CAST(f_char1 AS SIGNED INT),
13034
f_charbig = 'just inserted'
13035
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13036
DELETE FROM t0_aux
13037
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13038
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13039
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13040
'just inserted' FROM t0_template
13041
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13042
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
13043
BEGIN
13044
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13045
f_charbig = 'updated by trigger'
13046
      WHERE f_int1 = new.f_int1;
13047
END|
13048
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13049
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
13050
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13051
	
13052
# check trigger-2 success: 	1
13053
DROP TRIGGER trg_1;
13054
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13055
f_int2 = CAST(f_char1 AS SIGNED INT),
13056
f_charbig = 'just inserted'
13057
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13058
DELETE FROM t0_aux
13059
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13060
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13061
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13062
'just inserted' FROM t0_template
13063
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13064
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
13065
BEGIN
13066
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13067
f_charbig = 'updated by trigger'
13068
      WHERE f_int1 = new.f_int1;
13069
END|
13070
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
13071
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
13072
	
13073
# check trigger-3 success: 	1
13074
DROP TRIGGER trg_1;
13075
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13076
f_int2 = CAST(f_char1 AS SIGNED INT),
13077
f_charbig = 'just inserted'
13078
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13079
DELETE FROM t0_aux
13080
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13081
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13082
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13083
'just inserted' FROM t0_template
13084
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13085
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
13086
BEGIN
13087
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13088
f_charbig = 'updated by trigger'
13089
      WHERE f_int1 = - old.f_int1;
13090
END|
13091
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
13092
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
13093
	
13094
# check trigger-4 success: 	1
13095
DROP TRIGGER trg_1;
13096
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13097
f_int2 = CAST(f_char1 AS SIGNED INT),
13098
f_charbig = 'just inserted'
13099
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13100
DELETE FROM t0_aux
13101
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13102
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13103
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13104
'just inserted' FROM t0_template
13105
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13106
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
13107
BEGIN
13108
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13109
f_charbig = 'updated by trigger'
13110
      WHERE f_int1 = new.f_int1;
13111
END|
13112
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
13113
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
13114
	
13115
# check trigger-5 success: 	1
13116
DROP TRIGGER trg_1;
13117
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13118
f_int2 = CAST(f_char1 AS SIGNED INT),
13119
f_charbig = 'just inserted'
13120
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13121
DELETE FROM t0_aux
13122
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13123
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13124
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13125
'just inserted' FROM t0_template
13126
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13127
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
13128
BEGIN
13129
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13130
f_charbig = 'updated by trigger'
13131
      WHERE f_int1 = - old.f_int1;
13132
END|
13133
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
13134
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
13135
	
13136
# check trigger-6 success: 	1
13137
DROP TRIGGER trg_1;
13138
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13139
f_int2 = CAST(f_char1 AS SIGNED INT),
13140
f_charbig = 'just inserted'
13141
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13142
DELETE FROM t0_aux
13143
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13144
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13145
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13146
'just inserted' FROM t0_template
13147
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13148
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
13149
BEGIN
13150
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13151
f_charbig = 'updated by trigger'
13152
      WHERE f_int1 = - old.f_int1;
13153
END|
13154
DELETE FROM t0_aux
13155
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
13156
	
13157
# check trigger-7 success: 	1
13158
DROP TRIGGER trg_1;
13159
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13160
f_int2 = CAST(f_char1 AS SIGNED INT),
13161
f_charbig = 'just inserted'
13162
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13163
DELETE FROM t0_aux
13164
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13165
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13166
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13167
'just inserted' FROM t0_template
13168
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13169
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
13170
BEGIN
13171
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13172
f_charbig = 'updated by trigger'
13173
      WHERE f_int1 = - old.f_int1;
13174
END|
13175
DELETE FROM t0_aux
13176
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
13177
	
13178
# check trigger-8 success: 	1
13179
DROP TRIGGER trg_1;
13180
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13181
f_int2 = CAST(f_char1 AS SIGNED INT),
13182
f_charbig = 'just inserted'
13183
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13184
DELETE FROM t0_aux
13185
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13186
DELETE FROM t1
13187
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13188
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
13189
BEGIN
13190
SET new.f_int1 = old.f_int1 + @max_row,
13191
new.f_int2 = old.f_int2 - @max_row,
13192
new.f_charbig = '####updated per update trigger####';
13193
END|
13194
UPDATE t1
13195
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
13196
f_charbig = '####updated per update statement itself####';
13197
	
13198
# check trigger-9 success: 	1
13199
DROP TRIGGER trg_2;
13200
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13201
f_int2 = CAST(f_char1 AS SIGNED INT),
13202
f_charbig = CONCAT('===',f_char1,'===');
13203
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
13204
BEGIN
13205
SET new.f_int1 = new.f_int1 + @max_row,
13206
new.f_int2 = new.f_int2 - @max_row,
13207
new.f_charbig = '####updated per update trigger####';
13208
END|
13209
UPDATE t1
13210
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
13211
f_charbig = '####updated per update statement itself####';
13212
	
13213
# check trigger-10 success: 	1
13214
DROP TRIGGER trg_2;
13215
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13216
f_int2 = CAST(f_char1 AS SIGNED INT),
13217
f_charbig = CONCAT('===',f_char1,'===');
13218
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
13219
BEGIN
13220
SET new.f_int1 = @my_max1 + @counter,
13221
new.f_int2 = @my_min2 - @counter,
13222
new.f_charbig = '####updated per insert trigger####';
13223
SET @counter = @counter + 1;
13224
END|
13225
SET @counter = 1;
13226
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
13227
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13228
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
13229
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
13230
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
13231
ORDER BY f_int1;
13232
DROP TRIGGER trg_3;
13233
	
13234
# check trigger-11 success: 	1
13235
DELETE FROM t1
13236
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
13237
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
13238
AND f_charbig = '####updated per insert trigger####';
13239
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
13240
BEGIN
13241
SET new.f_int1 = @my_max1 + @counter,
13242
new.f_int2 = @my_min2 - @counter,
13243
new.f_charbig = '####updated per insert trigger####';
13244
SET @counter = @counter + 1;
13245
END|
13246
SET @counter = 1;
13247
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
13248
INSERT INTO t1 (f_char1, f_char2, f_charbig)
13249
SELECT CAST(f_int1 AS CHAR),
13250
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
13251
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
13252
ORDER BY f_int1;
13253
DROP TRIGGER trg_3;
13254
	
13255
# check trigger-12 success: 	1
13256
DELETE FROM t1
13257
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
13258
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
13259
AND f_charbig = '####updated per insert trigger####';
13260
ANALYZE  TABLE t1;
13261
Table	Op	Msg_type	Msg_text
13262
test.t1	analyze	note	The storage engine for the table doesn't support analyze
13263
CHECK    TABLE t1 EXTENDED;
13264
Table	Op	Msg_type	Msg_text
13265
test.t1	check	note	The storage engine for the table doesn't support check
13266
CHECKSUM TABLE t1 EXTENDED;
13267
Table	Checksum
13268
test.t1	<some_value>
13269
OPTIMIZE TABLE t1;
13270
Table	Op	Msg_type	Msg_text
13271
test.t1	optimize	note	The storage engine for the table doesn't support optimize
13272
# check layout success:    1
13273
REPAIR   TABLE t1 EXTENDED;
13274
Table	Op	Msg_type	Msg_text
13275
test.t1	repair	note	The storage engine for the table doesn't support repair
13276
# check layout success:    1
13277
TRUNCATE t1;
13278
	
13279
# check TRUNCATE success: 	1
13280
# check layout success:    1
13281
# End usability test (inc/partition_check.inc)
13282
DROP TABLE t1;
13283
CREATE TABLE t1 (
13284
f_int1 INTEGER,
13285
f_int2 INTEGER,
13286
f_char1 CHAR(20),
13287
f_char2 CHAR(20),
13288
f_charbig VARCHAR(1000)
13289
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
13290
)
13291
PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
13292
(PARTITION parta VALUES LESS THAN (0),
13293
PARTITION partb VALUES LESS THAN (5),
13294
PARTITION partc VALUES LESS THAN (10),
13295
PARTITION partd VALUES LESS THAN (2147483646));
13296
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
13297
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
13298
# Start usability test (inc/partition_check.inc)
13299
create_command
13300
SHOW CREATE TABLE t1;
13301
Table	Create Table
13302
t1	CREATE TABLE `t1` (
13303
  `f_int1` int(11) NOT NULL DEFAULT '0',
13304
  `f_int2` int(11) NOT NULL DEFAULT '0',
13305
  `f_char1` char(20) DEFAULT NULL,
13306
  `f_char2` char(20) DEFAULT NULL,
13307
  `f_charbig` varchar(1000) DEFAULT NULL,
13308
  PRIMARY KEY (`f_int1`,`f_int2`),
13309
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
13310
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1 DIV 2) SUBPARTITION BY HASH (f_int1) SUBPARTITIONS 2 (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
13311
13312
unified filelist
13313
$MYSQLTEST_VARDIR/master-data/test/t1.frm
13314
$MYSQLTEST_VARDIR/master-data/test/t1.par
13315
13316
# check prerequisites-1 success:    1
13317
# check COUNT(*) success:    1
13318
# check MIN/MAX(f_int1) success:    1
13319
# check MIN/MAX(f_int2) success:    1
13320
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13321
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
13322
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
13323
WHERE f_int1 IN (2,3);
13324
ERROR 23000: Can't write; duplicate key in table 't1'
13325
# check prerequisites-3 success:    1
13326
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
13327
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13328
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
13329
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
13330
WHERE f_int1 IN (2,3);
13331
DELETE FROM t1 WHERE f_charbig = 'delete me';
13332
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13333
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
13334
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
13335
WHERE f_int1 IN (2,3);
13336
DELETE FROM t1 WHERE f_charbig = 'delete me';
13337
# check read via f_int1 success: 1
13338
# check read via f_int2 success: 1
13339
	
13340
# check multiple-1 success: 	1
13341
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
13342
	
13343
# check multiple-2 success: 	1
13344
INSERT INTO t1 SELECT * FROM t0_template
13345
WHERE MOD(f_int1,3) = 0;
13346
	
13347
# check multiple-3 success: 	1
13348
UPDATE t1 SET f_int1 = f_int1 + @max_row
13349
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
13350
AND @max_row_div2 + @max_row_div4;
13351
	
13352
# check multiple-4 success: 	1
13353
DELETE FROM t1
13354
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
13355
AND @max_row_div2 + @max_row_div4 + @max_row;
13356
	
13357
# check multiple-5 success: 	1
13358
SELECT COUNT(*) INTO @try_count FROM t0_template
13359
WHERE MOD(f_int1,3) = 0
13360
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
13361
SELECT COUNT(*) INTO @clash_count
13362
FROM t1 INNER JOIN t0_template USING(f_int1)
13363
WHERE MOD(f_int1,3) = 0
13364
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
13365
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
13366
INSERT INTO t1
13367
SET f_int1 = @cur_value , f_int2 = @cur_value,
13368
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
13369
f_charbig = '#SINGLE#';
13370
	
13371
# check single-1 success: 	1
13372
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
13373
INSERT INTO t1
13374
SET f_int1 = @cur_value , f_int2 = @cur_value,
13375
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
13376
f_charbig = '#SINGLE#';
13377
	
13378
# check single-2 success: 	1
13379
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
13380
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
13381
UPDATE t1 SET f_int1 = @cur_value2
13382
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
13383
	
13384
# check single-3 success: 	1
13385
SET @cur_value1= -1;
13386
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
13387
UPDATE t1 SET f_int1 = @cur_value1
13388
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
13389
	
13390
# check single-4 success: 	1
13391
SELECT MAX(f_int1) INTO @cur_value FROM t1;
13392
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
13393
	
13394
# check single-5 success: 	1
13395
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
13396
	
13397
# check single-6 success: 	1
13398
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
13399
	
13400
# check single-7 success: 	1
13401
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
13402
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
13403
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
13404
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
13405
f_charbig = '#NULL#';
13406
INSERT INTO t1
13407
SET f_int1 = NULL , f_int2 = -@max_row,
13408
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
13409
f_charbig = '#NULL#';
13410
ERROR 23000: Column 'f_int1' cannot be null
13411
# check null success:    1
13412
DELETE FROM t1
13413
WHERE f_int1 = 0 AND f_int2 = 0
13414
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
13415
AND f_charbig = '#NULL#';
13416
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13417
SELECT f_int1, f_int1, '', '', 'was inserted'
13418
   FROM t0_template source_tab
13419
WHERE MOD(f_int1,3) = 0
13420
AND f_int1 BETWEEN @max_row_div2 AND @max_row
13421
ON DUPLICATE KEY
13422
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
13423
f_int2 = 2 * @max_row + source_tab.f_int1,
13424
f_charbig = 'was updated';
13425
	
13426
# check unique-1-a success: 	1
13427
	
13428
# check unique-1-b success: 	1
13429
DELETE FROM t1 WHERE f_charbig = 'was inserted';
13430
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13431
f_int2 = CAST(f_char1 AS SIGNED INT),
13432
f_charbig = CONCAT('===',f_char1,'===')
13433
WHERE f_charbig = 'was updated';
13434
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13435
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
13436
   FROM t0_template source_tab
13437
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
13438
	
13439
# check replace success: 	1
13440
DELETE FROM t1
13441
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
13442
DELETE FROM t1
13443
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
13444
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
13445
UPDATE t1 SET f_int2 = f_int1,
13446
f_char1 = CAST(f_int1 AS CHAR),
13447
f_char2 = CAST(f_int1 AS CHAR),
13448
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
13449
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
13450
SET AUTOCOMMIT= 0;
13451
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13452
SELECT f_int1, f_int1, '', '', 'was inserted'
13453
FROM t0_template source_tab
13454
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
13455
	
13456
# check transactions-1 success: 	1
13457
COMMIT WORK;
13458
	
13459
# check transactions-2 success: 	1
13460
ROLLBACK WORK;
13461
	
13462
# check transactions-3 success: 	1
13463
DELETE FROM t1 WHERE f_charbig = 'was inserted';
13464
COMMIT WORK;
13465
ROLLBACK WORK;
13466
	
13467
# check transactions-4 success: 	1
13468
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13469
SELECT f_int1, f_int1, '', '', 'was inserted'
13470
FROM t0_template source_tab
13471
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
13472
	
13473
# check transactions-5 success: 	1
13474
ROLLBACK WORK;
13475
	
13476
# check transactions-6 success: 	1
13477
# INFO: Storage engine used for t1 seems to be transactional.
13478
COMMIT;
13479
	
13480
# check transactions-7 success: 	1
13481
DELETE FROM t1 WHERE f_charbig = 'was inserted';
13482
COMMIT WORK;
13483
SET @@session.sql_mode = 'traditional';
13484
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
13485
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13486
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
13487
'', '', 'was inserted' FROM t0_template
13488
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
13489
ERROR 22012: Division by 0
13490
COMMIT;
13491
	
13492
# check transactions-8 success: 	1
13493
# INFO: Storage engine used for t1 seems to be able to revert
13494
#       changes made by the failing statement.
13495
SET @@session.sql_mode = '';
13496
SET AUTOCOMMIT= 1;
13497
DELETE FROM t1 WHERE f_charbig = 'was inserted';
13498
COMMIT WORK;
13499
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
13500
	
13501
# check special-1 success: 	1
13502
UPDATE t1 SET f_charbig = '';
13503
	
13504
# check special-2 success: 	1
13505
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
13506
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
13507
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
13508
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13509
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13510
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13511
'just inserted' FROM t0_template
13512
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13513
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
13514
BEGIN
13515
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13516
f_charbig = 'updated by trigger'
13517
      WHERE f_int1 = new.f_int1;
13518
END|
13519
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13520
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
13521
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13522
	
13523
# check trigger-1 success: 	1
13524
DROP TRIGGER trg_1;
13525
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13526
f_int2 = CAST(f_char1 AS SIGNED INT),
13527
f_charbig = 'just inserted'
13528
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13529
DELETE FROM t0_aux
13530
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13531
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13532
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13533
'just inserted' FROM t0_template
13534
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13535
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
13536
BEGIN
13537
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13538
f_charbig = 'updated by trigger'
13539
      WHERE f_int1 = new.f_int1;
13540
END|
13541
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13542
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
13543
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13544
	
13545
# check trigger-2 success: 	1
13546
DROP TRIGGER trg_1;
13547
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13548
f_int2 = CAST(f_char1 AS SIGNED INT),
13549
f_charbig = 'just inserted'
13550
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13551
DELETE FROM t0_aux
13552
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13553
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13554
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13555
'just inserted' FROM t0_template
13556
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13557
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
13558
BEGIN
13559
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13560
f_charbig = 'updated by trigger'
13561
      WHERE f_int1 = new.f_int1;
13562
END|
13563
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
13564
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
13565
	
13566
# check trigger-3 success: 	1
13567
DROP TRIGGER trg_1;
13568
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13569
f_int2 = CAST(f_char1 AS SIGNED INT),
13570
f_charbig = 'just inserted'
13571
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13572
DELETE FROM t0_aux
13573
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13574
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13575
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13576
'just inserted' FROM t0_template
13577
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13578
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
13579
BEGIN
13580
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13581
f_charbig = 'updated by trigger'
13582
      WHERE f_int1 = - old.f_int1;
13583
END|
13584
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
13585
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
13586
	
13587
# check trigger-4 success: 	1
13588
DROP TRIGGER trg_1;
13589
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13590
f_int2 = CAST(f_char1 AS SIGNED INT),
13591
f_charbig = 'just inserted'
13592
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13593
DELETE FROM t0_aux
13594
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13595
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13596
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13597
'just inserted' FROM t0_template
13598
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13599
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
13600
BEGIN
13601
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13602
f_charbig = 'updated by trigger'
13603
      WHERE f_int1 = new.f_int1;
13604
END|
13605
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
13606
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
13607
	
13608
# check trigger-5 success: 	1
13609
DROP TRIGGER trg_1;
13610
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13611
f_int2 = CAST(f_char1 AS SIGNED INT),
13612
f_charbig = 'just inserted'
13613
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13614
DELETE FROM t0_aux
13615
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13616
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13617
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13618
'just inserted' FROM t0_template
13619
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13620
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
13621
BEGIN
13622
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13623
f_charbig = 'updated by trigger'
13624
      WHERE f_int1 = - old.f_int1;
13625
END|
13626
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
13627
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
13628
	
13629
# check trigger-6 success: 	1
13630
DROP TRIGGER trg_1;
13631
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13632
f_int2 = CAST(f_char1 AS SIGNED INT),
13633
f_charbig = 'just inserted'
13634
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13635
DELETE FROM t0_aux
13636
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13637
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13638
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13639
'just inserted' FROM t0_template
13640
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13641
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
13642
BEGIN
13643
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13644
f_charbig = 'updated by trigger'
13645
      WHERE f_int1 = - old.f_int1;
13646
END|
13647
DELETE FROM t0_aux
13648
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
13649
	
13650
# check trigger-7 success: 	1
13651
DROP TRIGGER trg_1;
13652
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13653
f_int2 = CAST(f_char1 AS SIGNED INT),
13654
f_charbig = 'just inserted'
13655
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13656
DELETE FROM t0_aux
13657
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13658
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
13659
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
13660
'just inserted' FROM t0_template
13661
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13662
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
13663
BEGIN
13664
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
13665
f_charbig = 'updated by trigger'
13666
      WHERE f_int1 = - old.f_int1;
13667
END|
13668
DELETE FROM t0_aux
13669
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
13670
	
13671
# check trigger-8 success: 	1
13672
DROP TRIGGER trg_1;
13673
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13674
f_int2 = CAST(f_char1 AS SIGNED INT),
13675
f_charbig = 'just inserted'
13676
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
13677
DELETE FROM t0_aux
13678
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13679
DELETE FROM t1
13680
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
13681
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
13682
BEGIN
13683
SET new.f_int1 = old.f_int1 + @max_row,
13684
new.f_int2 = old.f_int2 - @max_row,
13685
new.f_charbig = '####updated per update trigger####';
13686
END|
13687
UPDATE t1
13688
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
13689
f_charbig = '####updated per update statement itself####';
13690
	
13691
# check trigger-9 success: 	1
13692
DROP TRIGGER trg_2;
13693
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13694
f_int2 = CAST(f_char1 AS SIGNED INT),
13695
f_charbig = CONCAT('===',f_char1,'===');
13696
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
13697
BEGIN
13698
SET new.f_int1 = new.f_int1 + @max_row,
13699
new.f_int2 = new.f_int2 - @max_row,
13700
new.f_charbig = '####updated per update trigger####';
13701
END|
13702
UPDATE t1
13703
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
13704
f_charbig = '####updated per update statement itself####';
13705
	
13706
# check trigger-10 success: 	1
13707
DROP TRIGGER trg_2;
13708
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13709
f_int2 = CAST(f_char1 AS SIGNED INT),
13710
f_charbig = CONCAT('===',f_char1,'===');
13711
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
13712
BEGIN
13713
SET new.f_int1 = @my_max1 + @counter,
13714
new.f_int2 = @my_min2 - @counter,
13715
new.f_charbig = '####updated per insert trigger####';
13716
SET @counter = @counter + 1;
13717
END|
13718
SET @counter = 1;
13719
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
13720
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13721
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
13722
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
13723
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
13724
ORDER BY f_int1;
13725
DROP TRIGGER trg_3;
13726
	
13727
# check trigger-11 success: 	1
13728
DELETE FROM t1
13729
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
13730
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
13731
AND f_charbig = '####updated per insert trigger####';
13732
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
13733
BEGIN
13734
SET new.f_int1 = @my_max1 + @counter,
13735
new.f_int2 = @my_min2 - @counter,
13736
new.f_charbig = '####updated per insert trigger####';
13737
SET @counter = @counter + 1;
13738
END|
13739
SET @counter = 1;
13740
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
13741
INSERT INTO t1 (f_char1, f_char2, f_charbig)
13742
SELECT CAST(f_int1 AS CHAR),
13743
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
13744
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
13745
ORDER BY f_int1;
13746
DROP TRIGGER trg_3;
13747
	
13748
# check trigger-12 success: 	1
13749
DELETE FROM t1
13750
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
13751
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
13752
AND f_charbig = '####updated per insert trigger####';
13753
ANALYZE  TABLE t1;
13754
Table	Op	Msg_type	Msg_text
13755
test.t1	analyze	note	The storage engine for the table doesn't support analyze
13756
CHECK    TABLE t1 EXTENDED;
13757
Table	Op	Msg_type	Msg_text
13758
test.t1	check	note	The storage engine for the table doesn't support check
13759
CHECKSUM TABLE t1 EXTENDED;
13760
Table	Checksum
13761
test.t1	<some_value>
13762
OPTIMIZE TABLE t1;
13763
Table	Op	Msg_type	Msg_text
13764
test.t1	optimize	note	The storage engine for the table doesn't support optimize
13765
# check layout success:    1
13766
REPAIR   TABLE t1 EXTENDED;
13767
Table	Op	Msg_type	Msg_text
13768
test.t1	repair	note	The storage engine for the table doesn't support repair
13769
# check layout success:    1
13770
TRUNCATE t1;
13771
	
13772
# check TRUNCATE success: 	1
13773
# check layout success:    1
13774
# End usability test (inc/partition_check.inc)
13775
DROP TABLE t1;
13776
CREATE TABLE t1 (
13777
f_int1 INTEGER,
13778
f_int2 INTEGER,
13779
f_char1 CHAR(20),
13780
f_char2 CHAR(20),
13781
f_charbig VARCHAR(1000)
13782
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
13783
)
13784
PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1)
13785
(PARTITION part1 VALUES LESS THAN (0)
13786
(SUBPARTITION subpart11, SUBPARTITION subpart12),
13787
PARTITION part2 VALUES LESS THAN (5)
13788
(SUBPARTITION subpart21, SUBPARTITION subpart22),
13789
PARTITION part3 VALUES LESS THAN (10)
13790
(SUBPARTITION subpart31, SUBPARTITION subpart32),
13791
PARTITION part4 VALUES LESS THAN (2147483646)
13792
(SUBPARTITION subpart41, SUBPARTITION subpart42));
13793
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
13794
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
13795
# Start usability test (inc/partition_check.inc)
13796
create_command
13797
SHOW CREATE TABLE t1;
13798
Table	Create Table
13799
t1	CREATE TABLE `t1` (
13800
  `f_int1` int(11) NOT NULL DEFAULT '0',
13801
  `f_int2` int(11) NOT NULL DEFAULT '0',
13802
  `f_char1` char(20) DEFAULT NULL,
13803
  `f_char2` char(20) DEFAULT NULL,
13804
  `f_charbig` varchar(1000) DEFAULT NULL,
13805
  PRIMARY KEY (`f_int1`,`f_int2`),
13806
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
13807
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), PARTITION part2 VALUES LESS THAN (5) (SUBPARTITION subpart21 ENGINE = InnoDB, SUBPARTITION subpart22 ENGINE = InnoDB), PARTITION part3 VALUES LESS THAN (10) (SUBPARTITION subpart31 ENGINE = InnoDB, SUBPARTITION subpart32 ENGINE = InnoDB), PARTITION part4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41 ENGINE = InnoDB, SUBPARTITION subpart42 ENGINE = InnoDB)) */
13808
13809
unified filelist
13810
$MYSQLTEST_VARDIR/master-data/test/t1.frm
13811
$MYSQLTEST_VARDIR/master-data/test/t1.par
13812
13813
# check prerequisites-1 success:    1
13814
# check COUNT(*) success:    1
13815
# check MIN/MAX(f_int1) success:    1
13816
# check MIN/MAX(f_int2) success:    1
13817
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13818
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
13819
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
13820
WHERE f_int1 IN (2,3);
13821
ERROR 23000: Can't write; duplicate key in table 't1'
13822
# check prerequisites-3 success:    1
13823
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
13824
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13825
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
13826
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
13827
WHERE f_int1 IN (2,3);
13828
DELETE FROM t1 WHERE f_charbig = 'delete me';
13829
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13830
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
13831
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
13832
WHERE f_int1 IN (2,3);
13833
DELETE FROM t1 WHERE f_charbig = 'delete me';
13834
# check read via f_int1 success: 1
13835
# check read via f_int2 success: 1
13836
	
13837
# check multiple-1 success: 	1
13838
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
13839
	
13840
# check multiple-2 success: 	1
13841
INSERT INTO t1 SELECT * FROM t0_template
13842
WHERE MOD(f_int1,3) = 0;
13843
	
13844
# check multiple-3 success: 	1
13845
UPDATE t1 SET f_int1 = f_int1 + @max_row
13846
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
13847
AND @max_row_div2 + @max_row_div4;
13848
	
13849
# check multiple-4 success: 	1
13850
DELETE FROM t1
13851
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
13852
AND @max_row_div2 + @max_row_div4 + @max_row;
13853
	
13854
# check multiple-5 success: 	1
13855
SELECT COUNT(*) INTO @try_count FROM t0_template
13856
WHERE MOD(f_int1,3) = 0
13857
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
13858
SELECT COUNT(*) INTO @clash_count
13859
FROM t1 INNER JOIN t0_template USING(f_int1)
13860
WHERE MOD(f_int1,3) = 0
13861
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
13862
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
13863
INSERT INTO t1
13864
SET f_int1 = @cur_value , f_int2 = @cur_value,
13865
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
13866
f_charbig = '#SINGLE#';
13867
	
13868
# check single-1 success: 	1
13869
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
13870
INSERT INTO t1
13871
SET f_int1 = @cur_value , f_int2 = @cur_value,
13872
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
13873
f_charbig = '#SINGLE#';
13874
	
13875
# check single-2 success: 	1
13876
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
13877
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
13878
UPDATE t1 SET f_int1 = @cur_value2
13879
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
13880
	
13881
# check single-3 success: 	1
13882
SET @cur_value1= -1;
13883
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
13884
UPDATE t1 SET f_int1 = @cur_value1
13885
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
13886
	
13887
# check single-4 success: 	1
13888
SELECT MAX(f_int1) INTO @cur_value FROM t1;
13889
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
13890
	
13891
# check single-5 success: 	1
13892
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
13893
	
13894
# check single-6 success: 	1
13895
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
13896
ERROR HY000: Table has no partition for value 2147483647
13897
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
13898
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
13899
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
13900
f_charbig = '#NULL#';
13901
INSERT INTO t1
13902
SET f_int1 = NULL , f_int2 = -@max_row,
13903
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
13904
f_charbig = '#NULL#';
13905
ERROR 23000: Column 'f_int1' cannot be null
13906
# check null success:    1
13907
DELETE FROM t1
13908
WHERE f_int1 = 0 AND f_int2 = 0
13909
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
13910
AND f_charbig = '#NULL#';
13911
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13912
SELECT f_int1, f_int1, '', '', 'was inserted'
13913
   FROM t0_template source_tab
13914
WHERE MOD(f_int1,3) = 0
13915
AND f_int1 BETWEEN @max_row_div2 AND @max_row
13916
ON DUPLICATE KEY
13917
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
13918
f_int2 = 2 * @max_row + source_tab.f_int1,
13919
f_charbig = 'was updated';
13920
	
13921
# check unique-1-a success: 	1
13922
	
13923
# check unique-1-b success: 	1
13924
DELETE FROM t1 WHERE f_charbig = 'was inserted';
13925
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
13926
f_int2 = CAST(f_char1 AS SIGNED INT),
13927
f_charbig = CONCAT('===',f_char1,'===')
13928
WHERE f_charbig = 'was updated';
13929
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13930
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
13931
   FROM t0_template source_tab
13932
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
13933
	
13934
# check replace success: 	1
13935
DELETE FROM t1
13936
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
13937
DELETE FROM t1
13938
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
13939
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
13940
UPDATE t1 SET f_int2 = f_int1,
13941
f_char1 = CAST(f_int1 AS CHAR),
13942
f_char2 = CAST(f_int1 AS CHAR),
13943
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
13944
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
13945
SET AUTOCOMMIT= 0;
13946
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13947
SELECT f_int1, f_int1, '', '', 'was inserted'
13948
FROM t0_template source_tab
13949
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
13950
	
13951
# check transactions-1 success: 	1
13952
COMMIT WORK;
13953
	
13954
# check transactions-2 success: 	1
13955
ROLLBACK WORK;
13956
	
13957
# check transactions-3 success: 	1
13958
DELETE FROM t1 WHERE f_charbig = 'was inserted';
13959
COMMIT WORK;
13960
ROLLBACK WORK;
13961
	
13962
# check transactions-4 success: 	1
13963
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13964
SELECT f_int1, f_int1, '', '', 'was inserted'
13965
FROM t0_template source_tab
13966
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
13967
	
13968
# check transactions-5 success: 	1
13969
ROLLBACK WORK;
13970
	
13971
# check transactions-6 success: 	1
13972
# INFO: Storage engine used for t1 seems to be transactional.
13973
COMMIT;
13974
	
13975
# check transactions-7 success: 	1
13976
DELETE FROM t1 WHERE f_charbig = 'was inserted';
13977
COMMIT WORK;
13978
SET @@session.sql_mode = 'traditional';
13979
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
13980
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
13981
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
13982
'', '', 'was inserted' FROM t0_template
13983
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
13984
ERROR 22012: Division by 0
13985
COMMIT;
13986
	
13987
# check transactions-8 success: 	1
13988
# INFO: Storage engine used for t1 seems to be able to revert
13989
#       changes made by the failing statement.
13990
SET @@session.sql_mode = '';
13991
SET AUTOCOMMIT= 1;
13992
DELETE FROM t1 WHERE f_charbig = 'was inserted';
13993
COMMIT WORK;
13994
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
13995
	
13996
# check special-1 success: 	1
13997
UPDATE t1 SET f_charbig = '';
13998
	
13999
# check special-2 success: 	1
14000
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
14001
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
14002
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
14003
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14004
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14005
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14006
'just inserted' FROM t0_template
14007
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14008
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
14009
BEGIN
14010
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14011
f_charbig = 'updated by trigger'
14012
      WHERE f_int1 = new.f_int1;
14013
END|
14014
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14015
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
14016
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14017
	
14018
# check trigger-1 success: 	1
14019
DROP TRIGGER trg_1;
14020
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14021
f_int2 = CAST(f_char1 AS SIGNED INT),
14022
f_charbig = 'just inserted'
14023
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14024
DELETE FROM t0_aux
14025
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14026
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14027
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14028
'just inserted' FROM t0_template
14029
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14030
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
14031
BEGIN
14032
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14033
f_charbig = 'updated by trigger'
14034
      WHERE f_int1 = new.f_int1;
14035
END|
14036
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14037
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
14038
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14039
	
14040
# check trigger-2 success: 	1
14041
DROP TRIGGER trg_1;
14042
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14043
f_int2 = CAST(f_char1 AS SIGNED INT),
14044
f_charbig = 'just inserted'
14045
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14046
DELETE FROM t0_aux
14047
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14048
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14049
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14050
'just inserted' FROM t0_template
14051
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14052
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
14053
BEGIN
14054
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14055
f_charbig = 'updated by trigger'
14056
      WHERE f_int1 = new.f_int1;
14057
END|
14058
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
14059
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
14060
	
14061
# check trigger-3 success: 	1
14062
DROP TRIGGER trg_1;
14063
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14064
f_int2 = CAST(f_char1 AS SIGNED INT),
14065
f_charbig = 'just inserted'
14066
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14067
DELETE FROM t0_aux
14068
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14069
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14070
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14071
'just inserted' FROM t0_template
14072
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14073
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
14074
BEGIN
14075
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14076
f_charbig = 'updated by trigger'
14077
      WHERE f_int1 = - old.f_int1;
14078
END|
14079
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
14080
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
14081
	
14082
# check trigger-4 success: 	1
14083
DROP TRIGGER trg_1;
14084
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14085
f_int2 = CAST(f_char1 AS SIGNED INT),
14086
f_charbig = 'just inserted'
14087
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14088
DELETE FROM t0_aux
14089
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14090
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14091
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14092
'just inserted' FROM t0_template
14093
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14094
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
14095
BEGIN
14096
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14097
f_charbig = 'updated by trigger'
14098
      WHERE f_int1 = new.f_int1;
14099
END|
14100
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
14101
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
14102
	
14103
# check trigger-5 success: 	1
14104
DROP TRIGGER trg_1;
14105
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14106
f_int2 = CAST(f_char1 AS SIGNED INT),
14107
f_charbig = 'just inserted'
14108
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14109
DELETE FROM t0_aux
14110
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14111
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14112
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14113
'just inserted' FROM t0_template
14114
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14115
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
14116
BEGIN
14117
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14118
f_charbig = 'updated by trigger'
14119
      WHERE f_int1 = - old.f_int1;
14120
END|
14121
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
14122
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
14123
	
14124
# check trigger-6 success: 	1
14125
DROP TRIGGER trg_1;
14126
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14127
f_int2 = CAST(f_char1 AS SIGNED INT),
14128
f_charbig = 'just inserted'
14129
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14130
DELETE FROM t0_aux
14131
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14132
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14133
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14134
'just inserted' FROM t0_template
14135
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14136
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
14137
BEGIN
14138
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14139
f_charbig = 'updated by trigger'
14140
      WHERE f_int1 = - old.f_int1;
14141
END|
14142
DELETE FROM t0_aux
14143
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
14144
	
14145
# check trigger-7 success: 	1
14146
DROP TRIGGER trg_1;
14147
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14148
f_int2 = CAST(f_char1 AS SIGNED INT),
14149
f_charbig = 'just inserted'
14150
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14151
DELETE FROM t0_aux
14152
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14153
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14154
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14155
'just inserted' FROM t0_template
14156
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14157
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
14158
BEGIN
14159
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14160
f_charbig = 'updated by trigger'
14161
      WHERE f_int1 = - old.f_int1;
14162
END|
14163
DELETE FROM t0_aux
14164
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
14165
	
14166
# check trigger-8 success: 	1
14167
DROP TRIGGER trg_1;
14168
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14169
f_int2 = CAST(f_char1 AS SIGNED INT),
14170
f_charbig = 'just inserted'
14171
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14172
DELETE FROM t0_aux
14173
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14174
DELETE FROM t1
14175
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14176
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
14177
BEGIN
14178
SET new.f_int1 = old.f_int1 + @max_row,
14179
new.f_int2 = old.f_int2 - @max_row,
14180
new.f_charbig = '####updated per update trigger####';
14181
END|
14182
UPDATE t1
14183
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
14184
f_charbig = '####updated per update statement itself####';
14185
	
14186
# check trigger-9 success: 	1
14187
DROP TRIGGER trg_2;
14188
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14189
f_int2 = CAST(f_char1 AS SIGNED INT),
14190
f_charbig = CONCAT('===',f_char1,'===');
14191
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
14192
BEGIN
14193
SET new.f_int1 = new.f_int1 + @max_row,
14194
new.f_int2 = new.f_int2 - @max_row,
14195
new.f_charbig = '####updated per update trigger####';
14196
END|
14197
UPDATE t1
14198
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
14199
f_charbig = '####updated per update statement itself####';
14200
	
14201
# check trigger-10 success: 	1
14202
DROP TRIGGER trg_2;
14203
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14204
f_int2 = CAST(f_char1 AS SIGNED INT),
14205
f_charbig = CONCAT('===',f_char1,'===');
14206
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
14207
BEGIN
14208
SET new.f_int1 = @my_max1 + @counter,
14209
new.f_int2 = @my_min2 - @counter,
14210
new.f_charbig = '####updated per insert trigger####';
14211
SET @counter = @counter + 1;
14212
END|
14213
SET @counter = 1;
14214
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
14215
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14216
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
14217
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
14218
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
14219
ORDER BY f_int1;
14220
DROP TRIGGER trg_3;
14221
	
14222
# check trigger-11 success: 	1
14223
DELETE FROM t1
14224
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
14225
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
14226
AND f_charbig = '####updated per insert trigger####';
14227
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
14228
BEGIN
14229
SET new.f_int1 = @my_max1 + @counter,
14230
new.f_int2 = @my_min2 - @counter,
14231
new.f_charbig = '####updated per insert trigger####';
14232
SET @counter = @counter + 1;
14233
END|
14234
SET @counter = 1;
14235
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
14236
INSERT INTO t1 (f_char1, f_char2, f_charbig)
14237
SELECT CAST(f_int1 AS CHAR),
14238
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
14239
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
14240
ORDER BY f_int1;
14241
DROP TRIGGER trg_3;
14242
	
14243
# check trigger-12 success: 	1
14244
DELETE FROM t1
14245
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
14246
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
14247
AND f_charbig = '####updated per insert trigger####';
14248
ANALYZE  TABLE t1;
14249
Table	Op	Msg_type	Msg_text
14250
test.t1	analyze	note	The storage engine for the table doesn't support analyze
14251
CHECK    TABLE t1 EXTENDED;
14252
Table	Op	Msg_type	Msg_text
14253
test.t1	check	note	The storage engine for the table doesn't support check
14254
CHECKSUM TABLE t1 EXTENDED;
14255
Table	Checksum
14256
test.t1	<some_value>
14257
OPTIMIZE TABLE t1;
14258
Table	Op	Msg_type	Msg_text
14259
test.t1	optimize	note	The storage engine for the table doesn't support optimize
14260
# check layout success:    1
14261
REPAIR   TABLE t1 EXTENDED;
14262
Table	Op	Msg_type	Msg_text
14263
test.t1	repair	note	The storage engine for the table doesn't support repair
14264
# check layout success:    1
14265
TRUNCATE t1;
14266
	
14267
# check TRUNCATE success: 	1
14268
# check layout success:    1
14269
# End usability test (inc/partition_check.inc)
14270
DROP TABLE t1;
14271
CREATE TABLE t1 (
14272
f_int1 INTEGER,
14273
f_int2 INTEGER,
14274
f_char1 CHAR(20),
14275
f_char2 CHAR(20),
14276
f_charbig VARCHAR(1000)
14277
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
14278
)
14279
PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1)
14280
(PARTITION part1 VALUES IN (0)
14281
(SUBPARTITION sp11,
14282
SUBPARTITION sp12),
14283
PARTITION part2 VALUES IN (1)
14284
(SUBPARTITION sp21,
14285
SUBPARTITION sp22),
14286
PARTITION part3 VALUES IN (2)
14287
(SUBPARTITION sp31, 
14288
SUBPARTITION sp32),
14289
PARTITION part4 VALUES IN (NULL)
14290
(SUBPARTITION sp41,
14291
SUBPARTITION sp42));
14292
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
14293
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
14294
# Start usability test (inc/partition_check.inc)
14295
create_command
14296
SHOW CREATE TABLE t1;
14297
Table	Create Table
14298
t1	CREATE TABLE `t1` (
14299
  `f_int1` int(11) NOT NULL DEFAULT '0',
14300
  `f_int2` int(11) NOT NULL DEFAULT '0',
14301
  `f_char1` char(20) DEFAULT NULL,
14302
  `f_char2` char(20) DEFAULT NULL,
14303
  `f_charbig` varchar(1000) DEFAULT NULL,
14304
  PRIMARY KEY (`f_int1`,`f_int2`),
14305
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
14306
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,3))) SUBPARTITION BY HASH (f_int1 + 1) (PARTITION part1 VALUES IN (0) (SUBPARTITION sp11 ENGINE = InnoDB, SUBPARTITION sp12 ENGINE = InnoDB), PARTITION part2 VALUES IN (1) (SUBPARTITION sp21 ENGINE = InnoDB, SUBPARTITION sp22 ENGINE = InnoDB), PARTITION part3 VALUES IN (2) (SUBPARTITION sp31 ENGINE = InnoDB, SUBPARTITION sp32 ENGINE = InnoDB), PARTITION part4 VALUES IN (NULL) (SUBPARTITION sp41 ENGINE = InnoDB, SUBPARTITION sp42 ENGINE = InnoDB)) */
14307
14308
unified filelist
14309
$MYSQLTEST_VARDIR/master-data/test/t1.frm
14310
$MYSQLTEST_VARDIR/master-data/test/t1.par
14311
14312
# check prerequisites-1 success:    1
14313
# check COUNT(*) success:    1
14314
# check MIN/MAX(f_int1) success:    1
14315
# check MIN/MAX(f_int2) success:    1
14316
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14317
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
14318
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
14319
WHERE f_int1 IN (2,3);
14320
ERROR 23000: Can't write; duplicate key in table 't1'
14321
# check prerequisites-3 success:    1
14322
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
14323
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14324
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
14325
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
14326
WHERE f_int1 IN (2,3);
14327
DELETE FROM t1 WHERE f_charbig = 'delete me';
14328
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14329
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
14330
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
14331
WHERE f_int1 IN (2,3);
14332
DELETE FROM t1 WHERE f_charbig = 'delete me';
14333
# check read via f_int1 success: 1
14334
# check read via f_int2 success: 1
14335
	
14336
# check multiple-1 success: 	1
14337
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
14338
	
14339
# check multiple-2 success: 	1
14340
INSERT INTO t1 SELECT * FROM t0_template
14341
WHERE MOD(f_int1,3) = 0;
14342
	
14343
# check multiple-3 success: 	1
14344
UPDATE t1 SET f_int1 = f_int1 + @max_row
14345
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
14346
AND @max_row_div2 + @max_row_div4;
14347
	
14348
# check multiple-4 success: 	1
14349
DELETE FROM t1
14350
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
14351
AND @max_row_div2 + @max_row_div4 + @max_row;
14352
	
14353
# check multiple-5 success: 	1
14354
SELECT COUNT(*) INTO @try_count FROM t0_template
14355
WHERE MOD(f_int1,3) = 0
14356
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
14357
SELECT COUNT(*) INTO @clash_count
14358
FROM t1 INNER JOIN t0_template USING(f_int1)
14359
WHERE MOD(f_int1,3) = 0
14360
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
14361
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
14362
INSERT INTO t1
14363
SET f_int1 = @cur_value , f_int2 = @cur_value,
14364
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
14365
f_charbig = '#SINGLE#';
14366
	
14367
# check single-1 success: 	1
14368
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
14369
INSERT INTO t1
14370
SET f_int1 = @cur_value , f_int2 = @cur_value,
14371
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
14372
f_charbig = '#SINGLE#';
14373
	
14374
# check single-2 success: 	1
14375
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
14376
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
14377
UPDATE t1 SET f_int1 = @cur_value2
14378
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
14379
	
14380
# check single-3 success: 	1
14381
SET @cur_value1= -1;
14382
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
14383
UPDATE t1 SET f_int1 = @cur_value1
14384
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
14385
	
14386
# check single-4 success: 	1
14387
SELECT MAX(f_int1) INTO @cur_value FROM t1;
14388
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
14389
	
14390
# check single-5 success: 	1
14391
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
14392
	
14393
# check single-6 success: 	1
14394
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
14395
	
14396
# check single-7 success: 	1
14397
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
14398
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
14399
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
14400
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
14401
f_charbig = '#NULL#';
14402
INSERT INTO t1
14403
SET f_int1 = NULL , f_int2 = -@max_row,
14404
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
14405
f_charbig = '#NULL#';
14406
ERROR 23000: Column 'f_int1' cannot be null
14407
# check null success:    1
14408
DELETE FROM t1
14409
WHERE f_int1 = 0 AND f_int2 = 0
14410
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
14411
AND f_charbig = '#NULL#';
14412
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14413
SELECT f_int1, f_int1, '', '', 'was inserted'
14414
   FROM t0_template source_tab
14415
WHERE MOD(f_int1,3) = 0
14416
AND f_int1 BETWEEN @max_row_div2 AND @max_row
14417
ON DUPLICATE KEY
14418
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
14419
f_int2 = 2 * @max_row + source_tab.f_int1,
14420
f_charbig = 'was updated';
14421
	
14422
# check unique-1-a success: 	1
14423
	
14424
# check unique-1-b success: 	1
14425
DELETE FROM t1 WHERE f_charbig = 'was inserted';
14426
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14427
f_int2 = CAST(f_char1 AS SIGNED INT),
14428
f_charbig = CONCAT('===',f_char1,'===')
14429
WHERE f_charbig = 'was updated';
14430
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14431
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
14432
   FROM t0_template source_tab
14433
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
14434
	
14435
# check replace success: 	1
14436
DELETE FROM t1
14437
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
14438
DELETE FROM t1
14439
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
14440
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
14441
UPDATE t1 SET f_int2 = f_int1,
14442
f_char1 = CAST(f_int1 AS CHAR),
14443
f_char2 = CAST(f_int1 AS CHAR),
14444
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
14445
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
14446
SET AUTOCOMMIT= 0;
14447
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14448
SELECT f_int1, f_int1, '', '', 'was inserted'
14449
FROM t0_template source_tab
14450
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
14451
	
14452
# check transactions-1 success: 	1
14453
COMMIT WORK;
14454
	
14455
# check transactions-2 success: 	1
14456
ROLLBACK WORK;
14457
	
14458
# check transactions-3 success: 	1
14459
DELETE FROM t1 WHERE f_charbig = 'was inserted';
14460
COMMIT WORK;
14461
ROLLBACK WORK;
14462
	
14463
# check transactions-4 success: 	1
14464
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14465
SELECT f_int1, f_int1, '', '', 'was inserted'
14466
FROM t0_template source_tab
14467
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
14468
	
14469
# check transactions-5 success: 	1
14470
ROLLBACK WORK;
14471
	
14472
# check transactions-6 success: 	1
14473
# INFO: Storage engine used for t1 seems to be transactional.
14474
COMMIT;
14475
	
14476
# check transactions-7 success: 	1
14477
DELETE FROM t1 WHERE f_charbig = 'was inserted';
14478
COMMIT WORK;
14479
SET @@session.sql_mode = 'traditional';
14480
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
14481
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14482
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
14483
'', '', 'was inserted' FROM t0_template
14484
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
14485
ERROR 22012: Division by 0
14486
COMMIT;
14487
	
14488
# check transactions-8 success: 	1
14489
# INFO: Storage engine used for t1 seems to be able to revert
14490
#       changes made by the failing statement.
14491
SET @@session.sql_mode = '';
14492
SET AUTOCOMMIT= 1;
14493
DELETE FROM t1 WHERE f_charbig = 'was inserted';
14494
COMMIT WORK;
14495
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
14496
	
14497
# check special-1 success: 	1
14498
UPDATE t1 SET f_charbig = '';
14499
	
14500
# check special-2 success: 	1
14501
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
14502
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
14503
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
14504
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14505
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14506
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14507
'just inserted' FROM t0_template
14508
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14509
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
14510
BEGIN
14511
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14512
f_charbig = 'updated by trigger'
14513
      WHERE f_int1 = new.f_int1;
14514
END|
14515
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14516
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
14517
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14518
	
14519
# check trigger-1 success: 	1
14520
DROP TRIGGER trg_1;
14521
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14522
f_int2 = CAST(f_char1 AS SIGNED INT),
14523
f_charbig = 'just inserted'
14524
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14525
DELETE FROM t0_aux
14526
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14527
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14528
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14529
'just inserted' FROM t0_template
14530
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14531
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
14532
BEGIN
14533
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14534
f_charbig = 'updated by trigger'
14535
      WHERE f_int1 = new.f_int1;
14536
END|
14537
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14538
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
14539
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14540
	
14541
# check trigger-2 success: 	1
14542
DROP TRIGGER trg_1;
14543
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14544
f_int2 = CAST(f_char1 AS SIGNED INT),
14545
f_charbig = 'just inserted'
14546
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14547
DELETE FROM t0_aux
14548
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14549
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14550
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14551
'just inserted' FROM t0_template
14552
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14553
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
14554
BEGIN
14555
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14556
f_charbig = 'updated by trigger'
14557
      WHERE f_int1 = new.f_int1;
14558
END|
14559
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
14560
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
14561
	
14562
# check trigger-3 success: 	1
14563
DROP TRIGGER trg_1;
14564
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14565
f_int2 = CAST(f_char1 AS SIGNED INT),
14566
f_charbig = 'just inserted'
14567
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14568
DELETE FROM t0_aux
14569
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14570
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14571
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14572
'just inserted' FROM t0_template
14573
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14574
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
14575
BEGIN
14576
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14577
f_charbig = 'updated by trigger'
14578
      WHERE f_int1 = - old.f_int1;
14579
END|
14580
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
14581
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
14582
	
14583
# check trigger-4 success: 	1
14584
DROP TRIGGER trg_1;
14585
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14586
f_int2 = CAST(f_char1 AS SIGNED INT),
14587
f_charbig = 'just inserted'
14588
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14589
DELETE FROM t0_aux
14590
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14591
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14592
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14593
'just inserted' FROM t0_template
14594
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14595
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
14596
BEGIN
14597
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14598
f_charbig = 'updated by trigger'
14599
      WHERE f_int1 = new.f_int1;
14600
END|
14601
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
14602
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
14603
	
14604
# check trigger-5 success: 	1
14605
DROP TRIGGER trg_1;
14606
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14607
f_int2 = CAST(f_char1 AS SIGNED INT),
14608
f_charbig = 'just inserted'
14609
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14610
DELETE FROM t0_aux
14611
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14612
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14613
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14614
'just inserted' FROM t0_template
14615
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14616
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
14617
BEGIN
14618
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14619
f_charbig = 'updated by trigger'
14620
      WHERE f_int1 = - old.f_int1;
14621
END|
14622
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
14623
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
14624
	
14625
# check trigger-6 success: 	1
14626
DROP TRIGGER trg_1;
14627
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14628
f_int2 = CAST(f_char1 AS SIGNED INT),
14629
f_charbig = 'just inserted'
14630
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14631
DELETE FROM t0_aux
14632
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14633
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14634
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14635
'just inserted' FROM t0_template
14636
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14637
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
14638
BEGIN
14639
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14640
f_charbig = 'updated by trigger'
14641
      WHERE f_int1 = - old.f_int1;
14642
END|
14643
DELETE FROM t0_aux
14644
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
14645
	
14646
# check trigger-7 success: 	1
14647
DROP TRIGGER trg_1;
14648
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14649
f_int2 = CAST(f_char1 AS SIGNED INT),
14650
f_charbig = 'just inserted'
14651
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14652
DELETE FROM t0_aux
14653
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14654
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14655
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
14656
'just inserted' FROM t0_template
14657
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14658
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
14659
BEGIN
14660
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
14661
f_charbig = 'updated by trigger'
14662
      WHERE f_int1 = - old.f_int1;
14663
END|
14664
DELETE FROM t0_aux
14665
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
14666
	
14667
# check trigger-8 success: 	1
14668
DROP TRIGGER trg_1;
14669
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14670
f_int2 = CAST(f_char1 AS SIGNED INT),
14671
f_charbig = 'just inserted'
14672
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
14673
DELETE FROM t0_aux
14674
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14675
DELETE FROM t1
14676
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14677
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
14678
BEGIN
14679
SET new.f_int1 = old.f_int1 + @max_row,
14680
new.f_int2 = old.f_int2 - @max_row,
14681
new.f_charbig = '####updated per update trigger####';
14682
END|
14683
UPDATE t1
14684
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
14685
f_charbig = '####updated per update statement itself####';
14686
	
14687
# check trigger-9 success: 	1
14688
DROP TRIGGER trg_2;
14689
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14690
f_int2 = CAST(f_char1 AS SIGNED INT),
14691
f_charbig = CONCAT('===',f_char1,'===');
14692
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
14693
BEGIN
14694
SET new.f_int1 = new.f_int1 + @max_row,
14695
new.f_int2 = new.f_int2 - @max_row,
14696
new.f_charbig = '####updated per update trigger####';
14697
END|
14698
UPDATE t1
14699
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
14700
f_charbig = '####updated per update statement itself####';
14701
	
14702
# check trigger-10 success: 	1
14703
DROP TRIGGER trg_2;
14704
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14705
f_int2 = CAST(f_char1 AS SIGNED INT),
14706
f_charbig = CONCAT('===',f_char1,'===');
14707
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
14708
BEGIN
14709
SET new.f_int1 = @my_max1 + @counter,
14710
new.f_int2 = @my_min2 - @counter,
14711
new.f_charbig = '####updated per insert trigger####';
14712
SET @counter = @counter + 1;
14713
END|
14714
SET @counter = 1;
14715
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
14716
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14717
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
14718
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
14719
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
14720
ORDER BY f_int1;
14721
DROP TRIGGER trg_3;
14722
	
14723
# check trigger-11 success: 	1
14724
DELETE FROM t1
14725
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
14726
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
14727
AND f_charbig = '####updated per insert trigger####';
14728
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
14729
BEGIN
14730
SET new.f_int1 = @my_max1 + @counter,
14731
new.f_int2 = @my_min2 - @counter,
14732
new.f_charbig = '####updated per insert trigger####';
14733
SET @counter = @counter + 1;
14734
END|
14735
SET @counter = 1;
14736
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
14737
INSERT INTO t1 (f_char1, f_char2, f_charbig)
14738
SELECT CAST(f_int1 AS CHAR),
14739
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
14740
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
14741
ORDER BY f_int1;
14742
DROP TRIGGER trg_3;
14743
	
14744
# check trigger-12 success: 	1
14745
DELETE FROM t1
14746
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
14747
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
14748
AND f_charbig = '####updated per insert trigger####';
14749
ANALYZE  TABLE t1;
14750
Table	Op	Msg_type	Msg_text
14751
test.t1	analyze	note	The storage engine for the table doesn't support analyze
14752
CHECK    TABLE t1 EXTENDED;
14753
Table	Op	Msg_type	Msg_text
14754
test.t1	check	note	The storage engine for the table doesn't support check
14755
CHECKSUM TABLE t1 EXTENDED;
14756
Table	Checksum
14757
test.t1	<some_value>
14758
OPTIMIZE TABLE t1;
14759
Table	Op	Msg_type	Msg_text
14760
test.t1	optimize	note	The storage engine for the table doesn't support optimize
14761
# check layout success:    1
14762
REPAIR   TABLE t1 EXTENDED;
14763
Table	Op	Msg_type	Msg_text
14764
test.t1	repair	note	The storage engine for the table doesn't support repair
14765
# check layout success:    1
14766
TRUNCATE t1;
14767
	
14768
# check TRUNCATE success: 	1
14769
# check layout success:    1
14770
# End usability test (inc/partition_check.inc)
14771
DROP TABLE t1;
14772
CREATE TABLE t1 (
14773
f_int1 INTEGER,
14774
f_int2 INTEGER,
14775
f_char1 CHAR(20),
14776
f_char2 CHAR(20),
14777
f_charbig VARCHAR(1000)
14778
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
14779
)
14780
PARTITION BY LIST(ABS(MOD(f_int1,2)))
14781
SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3
14782
(PARTITION part1 VALUES IN (0),
14783
PARTITION part2 VALUES IN (1),
14784
PARTITION part3 VALUES IN (NULL));
14785
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
14786
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
14787
# Start usability test (inc/partition_check.inc)
14788
create_command
14789
SHOW CREATE TABLE t1;
14790
Table	Create Table
14791
t1	CREATE TABLE `t1` (
14792
  `f_int1` int(11) NOT NULL DEFAULT '0',
14793
  `f_int2` int(11) NOT NULL DEFAULT '0',
14794
  `f_char1` char(20) DEFAULT NULL,
14795
  `f_char2` char(20) DEFAULT NULL,
14796
  `f_charbig` varchar(1000) DEFAULT NULL,
14797
  PRIMARY KEY (`f_int1`,`f_int2`),
14798
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
14799
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
14800
14801
unified filelist
14802
$MYSQLTEST_VARDIR/master-data/test/t1.frm
14803
$MYSQLTEST_VARDIR/master-data/test/t1.par
14804
14805
# check prerequisites-1 success:    1
14806
# check COUNT(*) success:    1
14807
# check MIN/MAX(f_int1) success:    1
14808
# check MIN/MAX(f_int2) success:    1
14809
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14810
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
14811
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
14812
WHERE f_int1 IN (2,3);
14813
ERROR 23000: Can't write; duplicate key in table 't1'
14814
# check prerequisites-3 success:    1
14815
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
14816
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14817
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
14818
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
14819
WHERE f_int1 IN (2,3);
14820
DELETE FROM t1 WHERE f_charbig = 'delete me';
14821
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14822
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
14823
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
14824
WHERE f_int1 IN (2,3);
14825
DELETE FROM t1 WHERE f_charbig = 'delete me';
14826
# check read via f_int1 success: 1
14827
# check read via f_int2 success: 1
14828
	
14829
# check multiple-1 success: 	1
14830
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
14831
	
14832
# check multiple-2 success: 	1
14833
INSERT INTO t1 SELECT * FROM t0_template
14834
WHERE MOD(f_int1,3) = 0;
14835
	
14836
# check multiple-3 success: 	1
14837
UPDATE t1 SET f_int1 = f_int1 + @max_row
14838
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
14839
AND @max_row_div2 + @max_row_div4;
14840
	
14841
# check multiple-4 success: 	1
14842
DELETE FROM t1
14843
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
14844
AND @max_row_div2 + @max_row_div4 + @max_row;
14845
	
14846
# check multiple-5 success: 	1
14847
SELECT COUNT(*) INTO @try_count FROM t0_template
14848
WHERE MOD(f_int1,3) = 0
14849
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
14850
SELECT COUNT(*) INTO @clash_count
14851
FROM t1 INNER JOIN t0_template USING(f_int1)
14852
WHERE MOD(f_int1,3) = 0
14853
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
14854
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
14855
INSERT INTO t1
14856
SET f_int1 = @cur_value , f_int2 = @cur_value,
14857
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
14858
f_charbig = '#SINGLE#';
14859
	
14860
# check single-1 success: 	1
14861
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
14862
INSERT INTO t1
14863
SET f_int1 = @cur_value , f_int2 = @cur_value,
14864
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
14865
f_charbig = '#SINGLE#';
14866
	
14867
# check single-2 success: 	1
14868
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
14869
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
14870
UPDATE t1 SET f_int1 = @cur_value2
14871
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
14872
	
14873
# check single-3 success: 	1
14874
SET @cur_value1= -1;
14875
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
14876
UPDATE t1 SET f_int1 = @cur_value1
14877
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
14878
	
14879
# check single-4 success: 	1
14880
SELECT MAX(f_int1) INTO @cur_value FROM t1;
14881
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
14882
	
14883
# check single-5 success: 	1
14884
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
14885
	
14886
# check single-6 success: 	1
14887
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
14888
	
14889
# check single-7 success: 	1
14890
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
14891
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
14892
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
14893
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
14894
f_charbig = '#NULL#';
14895
INSERT INTO t1
14896
SET f_int1 = NULL , f_int2 = -@max_row,
14897
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
14898
f_charbig = '#NULL#';
14899
ERROR 23000: Column 'f_int1' cannot be null
14900
# check null success:    1
14901
DELETE FROM t1
14902
WHERE f_int1 = 0 AND f_int2 = 0
14903
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
14904
AND f_charbig = '#NULL#';
14905
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14906
SELECT f_int1, f_int1, '', '', 'was inserted'
14907
   FROM t0_template source_tab
14908
WHERE MOD(f_int1,3) = 0
14909
AND f_int1 BETWEEN @max_row_div2 AND @max_row
14910
ON DUPLICATE KEY
14911
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
14912
f_int2 = 2 * @max_row + source_tab.f_int1,
14913
f_charbig = 'was updated';
14914
	
14915
# check unique-1-a success: 	1
14916
	
14917
# check unique-1-b success: 	1
14918
DELETE FROM t1 WHERE f_charbig = 'was inserted';
14919
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
14920
f_int2 = CAST(f_char1 AS SIGNED INT),
14921
f_charbig = CONCAT('===',f_char1,'===')
14922
WHERE f_charbig = 'was updated';
14923
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14924
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
14925
   FROM t0_template source_tab
14926
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
14927
	
14928
# check replace success: 	1
14929
DELETE FROM t1
14930
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
14931
DELETE FROM t1
14932
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
14933
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
14934
UPDATE t1 SET f_int2 = f_int1,
14935
f_char1 = CAST(f_int1 AS CHAR),
14936
f_char2 = CAST(f_int1 AS CHAR),
14937
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
14938
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
14939
SET AUTOCOMMIT= 0;
14940
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14941
SELECT f_int1, f_int1, '', '', 'was inserted'
14942
FROM t0_template source_tab
14943
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
14944
	
14945
# check transactions-1 success: 	1
14946
COMMIT WORK;
14947
	
14948
# check transactions-2 success: 	1
14949
ROLLBACK WORK;
14950
	
14951
# check transactions-3 success: 	1
14952
DELETE FROM t1 WHERE f_charbig = 'was inserted';
14953
COMMIT WORK;
14954
ROLLBACK WORK;
14955
	
14956
# check transactions-4 success: 	1
14957
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14958
SELECT f_int1, f_int1, '', '', 'was inserted'
14959
FROM t0_template source_tab
14960
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
14961
	
14962
# check transactions-5 success: 	1
14963
ROLLBACK WORK;
14964
	
14965
# check transactions-6 success: 	1
14966
# INFO: Storage engine used for t1 seems to be transactional.
14967
COMMIT;
14968
	
14969
# check transactions-7 success: 	1
14970
DELETE FROM t1 WHERE f_charbig = 'was inserted';
14971
COMMIT WORK;
14972
SET @@session.sql_mode = 'traditional';
14973
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
14974
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
14975
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
14976
'', '', 'was inserted' FROM t0_template
14977
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
14978
ERROR 22012: Division by 0
14979
COMMIT;
14980
	
14981
# check transactions-8 success: 	1
14982
# INFO: Storage engine used for t1 seems to be able to revert
14983
#       changes made by the failing statement.
14984
SET @@session.sql_mode = '';
14985
SET AUTOCOMMIT= 1;
14986
DELETE FROM t1 WHERE f_charbig = 'was inserted';
14987
COMMIT WORK;
14988
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
14989
	
14990
# check special-1 success: 	1
14991
UPDATE t1 SET f_charbig = '';
14992
	
14993
# check special-2 success: 	1
14994
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
14995
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
14996
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
14997
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
14998
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
14999
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15000
'just inserted' FROM t0_template
15001
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15002
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
15003
BEGIN
15004
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15005
f_charbig = 'updated by trigger'
15006
      WHERE f_int1 = new.f_int1;
15007
END|
15008
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15009
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
15010
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15011
	
15012
# check trigger-1 success: 	1
15013
DROP TRIGGER trg_1;
15014
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15015
f_int2 = CAST(f_char1 AS SIGNED INT),
15016
f_charbig = 'just inserted'
15017
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15018
DELETE FROM t0_aux
15019
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15020
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15021
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15022
'just inserted' FROM t0_template
15023
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15024
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
15025
BEGIN
15026
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15027
f_charbig = 'updated by trigger'
15028
      WHERE f_int1 = new.f_int1;
15029
END|
15030
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15031
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
15032
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15033
	
15034
# check trigger-2 success: 	1
15035
DROP TRIGGER trg_1;
15036
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15037
f_int2 = CAST(f_char1 AS SIGNED INT),
15038
f_charbig = 'just inserted'
15039
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15040
DELETE FROM t0_aux
15041
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15042
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15043
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15044
'just inserted' FROM t0_template
15045
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15046
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
15047
BEGIN
15048
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15049
f_charbig = 'updated by trigger'
15050
      WHERE f_int1 = new.f_int1;
15051
END|
15052
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
15053
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
15054
	
15055
# check trigger-3 success: 	1
15056
DROP TRIGGER trg_1;
15057
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15058
f_int2 = CAST(f_char1 AS SIGNED INT),
15059
f_charbig = 'just inserted'
15060
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15061
DELETE FROM t0_aux
15062
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15063
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15064
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15065
'just inserted' FROM t0_template
15066
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15067
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
15068
BEGIN
15069
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15070
f_charbig = 'updated by trigger'
15071
      WHERE f_int1 = - old.f_int1;
15072
END|
15073
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
15074
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
15075
	
15076
# check trigger-4 success: 	1
15077
DROP TRIGGER trg_1;
15078
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15079
f_int2 = CAST(f_char1 AS SIGNED INT),
15080
f_charbig = 'just inserted'
15081
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15082
DELETE FROM t0_aux
15083
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15084
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15085
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15086
'just inserted' FROM t0_template
15087
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15088
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
15089
BEGIN
15090
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15091
f_charbig = 'updated by trigger'
15092
      WHERE f_int1 = new.f_int1;
15093
END|
15094
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
15095
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
15096
	
15097
# check trigger-5 success: 	1
15098
DROP TRIGGER trg_1;
15099
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15100
f_int2 = CAST(f_char1 AS SIGNED INT),
15101
f_charbig = 'just inserted'
15102
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15103
DELETE FROM t0_aux
15104
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15105
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15106
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15107
'just inserted' FROM t0_template
15108
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15109
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
15110
BEGIN
15111
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15112
f_charbig = 'updated by trigger'
15113
      WHERE f_int1 = - old.f_int1;
15114
END|
15115
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
15116
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
15117
	
15118
# check trigger-6 success: 	1
15119
DROP TRIGGER trg_1;
15120
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15121
f_int2 = CAST(f_char1 AS SIGNED INT),
15122
f_charbig = 'just inserted'
15123
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15124
DELETE FROM t0_aux
15125
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15126
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15127
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15128
'just inserted' FROM t0_template
15129
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15130
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
15131
BEGIN
15132
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15133
f_charbig = 'updated by trigger'
15134
      WHERE f_int1 = - old.f_int1;
15135
END|
15136
DELETE FROM t0_aux
15137
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
15138
	
15139
# check trigger-7 success: 	1
15140
DROP TRIGGER trg_1;
15141
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15142
f_int2 = CAST(f_char1 AS SIGNED INT),
15143
f_charbig = 'just inserted'
15144
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15145
DELETE FROM t0_aux
15146
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15147
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15148
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15149
'just inserted' FROM t0_template
15150
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15151
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
15152
BEGIN
15153
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15154
f_charbig = 'updated by trigger'
15155
      WHERE f_int1 = - old.f_int1;
15156
END|
15157
DELETE FROM t0_aux
15158
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
15159
	
15160
# check trigger-8 success: 	1
15161
DROP TRIGGER trg_1;
15162
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15163
f_int2 = CAST(f_char1 AS SIGNED INT),
15164
f_charbig = 'just inserted'
15165
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15166
DELETE FROM t0_aux
15167
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15168
DELETE FROM t1
15169
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15170
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
15171
BEGIN
15172
SET new.f_int1 = old.f_int1 + @max_row,
15173
new.f_int2 = old.f_int2 - @max_row,
15174
new.f_charbig = '####updated per update trigger####';
15175
END|
15176
UPDATE t1
15177
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
15178
f_charbig = '####updated per update statement itself####';
15179
	
15180
# check trigger-9 success: 	1
15181
DROP TRIGGER trg_2;
15182
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15183
f_int2 = CAST(f_char1 AS SIGNED INT),
15184
f_charbig = CONCAT('===',f_char1,'===');
15185
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
15186
BEGIN
15187
SET new.f_int1 = new.f_int1 + @max_row,
15188
new.f_int2 = new.f_int2 - @max_row,
15189
new.f_charbig = '####updated per update trigger####';
15190
END|
15191
UPDATE t1
15192
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
15193
f_charbig = '####updated per update statement itself####';
15194
	
15195
# check trigger-10 success: 	1
15196
DROP TRIGGER trg_2;
15197
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15198
f_int2 = CAST(f_char1 AS SIGNED INT),
15199
f_charbig = CONCAT('===',f_char1,'===');
15200
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
15201
BEGIN
15202
SET new.f_int1 = @my_max1 + @counter,
15203
new.f_int2 = @my_min2 - @counter,
15204
new.f_charbig = '####updated per insert trigger####';
15205
SET @counter = @counter + 1;
15206
END|
15207
SET @counter = 1;
15208
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
15209
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15210
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
15211
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
15212
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
15213
ORDER BY f_int1;
15214
DROP TRIGGER trg_3;
15215
	
15216
# check trigger-11 success: 	1
15217
DELETE FROM t1
15218
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
15219
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
15220
AND f_charbig = '####updated per insert trigger####';
15221
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
15222
BEGIN
15223
SET new.f_int1 = @my_max1 + @counter,
15224
new.f_int2 = @my_min2 - @counter,
15225
new.f_charbig = '####updated per insert trigger####';
15226
SET @counter = @counter + 1;
15227
END|
15228
SET @counter = 1;
15229
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
15230
INSERT INTO t1 (f_char1, f_char2, f_charbig)
15231
SELECT CAST(f_int1 AS CHAR),
15232
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
15233
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
15234
ORDER BY f_int1;
15235
DROP TRIGGER trg_3;
15236
	
15237
# check trigger-12 success: 	1
15238
DELETE FROM t1
15239
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
15240
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
15241
AND f_charbig = '####updated per insert trigger####';
15242
ANALYZE  TABLE t1;
15243
Table	Op	Msg_type	Msg_text
15244
test.t1	analyze	note	The storage engine for the table doesn't support analyze
15245
CHECK    TABLE t1 EXTENDED;
15246
Table	Op	Msg_type	Msg_text
15247
test.t1	check	note	The storage engine for the table doesn't support check
15248
CHECKSUM TABLE t1 EXTENDED;
15249
Table	Checksum
15250
test.t1	<some_value>
15251
OPTIMIZE TABLE t1;
15252
Table	Op	Msg_type	Msg_text
15253
test.t1	optimize	note	The storage engine for the table doesn't support optimize
15254
# check layout success:    1
15255
REPAIR   TABLE t1 EXTENDED;
15256
Table	Op	Msg_type	Msg_text
15257
test.t1	repair	note	The storage engine for the table doesn't support repair
15258
# check layout success:    1
15259
TRUNCATE t1;
15260
	
15261
# check TRUNCATE success: 	1
15262
# check layout success:    1
15263
# End usability test (inc/partition_check.inc)
15264
DROP TABLE t1;
15265
DROP TABLE IF EXISTS t1;
15266
CREATE TABLE t1 (
15267
f_int1 INTEGER,
15268
f_int2 INTEGER,
15269
f_char1 CHAR(20),
15270
f_char2 CHAR(20),
15271
f_charbig VARCHAR(1000)
15272
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
15273
)
15274
PARTITION BY HASH(f_int1) PARTITIONS 2;
15275
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
15276
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
15277
# Start usability test (inc/partition_check.inc)
15278
create_command
15279
SHOW CREATE TABLE t1;
15280
Table	Create Table
15281
t1	CREATE TABLE `t1` (
15282
  `f_int1` int(11) DEFAULT NULL,
15283
  `f_int2` int(11) DEFAULT NULL,
15284
  `f_char1` char(20) DEFAULT NULL,
15285
  `f_char2` char(20) DEFAULT NULL,
15286
  `f_charbig` varchar(1000) DEFAULT NULL,
15287
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
15288
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
15289
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (f_int1) PARTITIONS 2  */
15290
15291
unified filelist
15292
$MYSQLTEST_VARDIR/master-data/test/t1.frm
15293
$MYSQLTEST_VARDIR/master-data/test/t1.par
15294
15295
# check prerequisites-1 success:    1
15296
# check COUNT(*) success:    1
15297
# check MIN/MAX(f_int1) success:    1
15298
# check MIN/MAX(f_int2) success:    1
15299
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15300
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
15301
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
15302
WHERE f_int1 IN (2,3);
15303
ERROR 23000: Can't write; duplicate key in table 't1'
15304
# check prerequisites-3 success:    1
15305
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
15306
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15307
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
15308
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
15309
WHERE f_int1 IN (2,3);
15310
DELETE FROM t1 WHERE f_charbig = 'delete me';
15311
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15312
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
15313
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
15314
WHERE f_int1 IN (2,3);
15315
DELETE FROM t1 WHERE f_charbig = 'delete me';
15316
# check read via f_int1 success: 1
15317
# check read via f_int2 success: 1
15318
	
15319
# check multiple-1 success: 	1
15320
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
15321
	
15322
# check multiple-2 success: 	1
15323
INSERT INTO t1 SELECT * FROM t0_template
15324
WHERE MOD(f_int1,3) = 0;
15325
	
15326
# check multiple-3 success: 	1
15327
UPDATE t1 SET f_int1 = f_int1 + @max_row
15328
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
15329
AND @max_row_div2 + @max_row_div4;
15330
	
15331
# check multiple-4 success: 	1
15332
DELETE FROM t1
15333
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
15334
AND @max_row_div2 + @max_row_div4 + @max_row;
15335
	
15336
# check multiple-5 success: 	1
15337
SELECT COUNT(*) INTO @try_count FROM t0_template
15338
WHERE MOD(f_int1,3) = 0
15339
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
15340
SELECT COUNT(*) INTO @clash_count
15341
FROM t1 INNER JOIN t0_template USING(f_int1)
15342
WHERE MOD(f_int1,3) = 0
15343
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
15344
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
15345
INSERT INTO t1
15346
SET f_int1 = @cur_value , f_int2 = @cur_value,
15347
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
15348
f_charbig = '#SINGLE#';
15349
	
15350
# check single-1 success: 	1
15351
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
15352
INSERT INTO t1
15353
SET f_int1 = @cur_value , f_int2 = @cur_value,
15354
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
15355
f_charbig = '#SINGLE#';
15356
	
15357
# check single-2 success: 	1
15358
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
15359
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
15360
UPDATE t1 SET f_int1 = @cur_value2
15361
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
15362
	
15363
# check single-3 success: 	1
15364
SET @cur_value1= -1;
15365
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
15366
UPDATE t1 SET f_int1 = @cur_value1
15367
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
15368
	
15369
# check single-4 success: 	1
15370
SELECT MAX(f_int1) INTO @cur_value FROM t1;
15371
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
15372
	
15373
# check single-5 success: 	1
15374
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
15375
	
15376
# check single-6 success: 	1
15377
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
15378
	
15379
# check single-7 success: 	1
15380
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
15381
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
15382
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
15383
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
15384
f_charbig = '#NULL#';
15385
INSERT INTO t1
15386
SET f_int1 = NULL , f_int2 = -@max_row,
15387
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
15388
f_charbig = '#NULL#';
15389
# check null success:    1
15390
	
15391
# check null-1 success: 	1
15392
UPDATE t1 SET f_int1 = -@max_row
15393
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
15394
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
15395
	
15396
# check null-2 success: 	1
15397
UPDATE t1 SET f_int1 = NULL
15398
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
15399
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
15400
	
15401
# check null-3 success: 	1
15402
DELETE FROM t1
15403
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
15404
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
15405
	
15406
# check null-4 success: 	1
15407
DELETE FROM t1
15408
WHERE f_int1 = 0 AND f_int2 = 0
15409
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
15410
AND f_charbig = '#NULL#';
15411
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15412
SELECT f_int1, f_int1, '', '', 'was inserted'
15413
   FROM t0_template source_tab
15414
WHERE MOD(f_int1,3) = 0
15415
AND f_int1 BETWEEN @max_row_div2 AND @max_row
15416
ON DUPLICATE KEY
15417
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
15418
f_int2 = 2 * @max_row + source_tab.f_int1,
15419
f_charbig = 'was updated';
15420
	
15421
# check unique-1-a success: 	1
15422
	
15423
# check unique-1-b success: 	1
15424
DELETE FROM t1 WHERE f_charbig = 'was inserted';
15425
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15426
f_int2 = CAST(f_char1 AS SIGNED INT),
15427
f_charbig = CONCAT('===',f_char1,'===')
15428
WHERE f_charbig = 'was updated';
15429
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15430
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
15431
   FROM t0_template source_tab
15432
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
15433
	
15434
# check replace success: 	1
15435
DELETE FROM t1
15436
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
15437
DELETE FROM t1
15438
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
15439
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
15440
UPDATE t1 SET f_int2 = f_int1,
15441
f_char1 = CAST(f_int1 AS CHAR),
15442
f_char2 = CAST(f_int1 AS CHAR),
15443
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
15444
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
15445
SET AUTOCOMMIT= 0;
15446
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15447
SELECT f_int1, f_int1, '', '', 'was inserted'
15448
FROM t0_template source_tab
15449
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
15450
	
15451
# check transactions-1 success: 	1
15452
COMMIT WORK;
15453
	
15454
# check transactions-2 success: 	1
15455
ROLLBACK WORK;
15456
	
15457
# check transactions-3 success: 	1
15458
DELETE FROM t1 WHERE f_charbig = 'was inserted';
15459
COMMIT WORK;
15460
ROLLBACK WORK;
15461
	
15462
# check transactions-4 success: 	1
15463
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15464
SELECT f_int1, f_int1, '', '', 'was inserted'
15465
FROM t0_template source_tab
15466
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
15467
	
15468
# check transactions-5 success: 	1
15469
ROLLBACK WORK;
15470
	
15471
# check transactions-6 success: 	1
15472
# INFO: Storage engine used for t1 seems to be transactional.
15473
COMMIT;
15474
	
15475
# check transactions-7 success: 	1
15476
DELETE FROM t1 WHERE f_charbig = 'was inserted';
15477
COMMIT WORK;
15478
SET @@session.sql_mode = 'traditional';
15479
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
15480
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15481
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
15482
'', '', 'was inserted' FROM t0_template
15483
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
15484
ERROR 22012: Division by 0
15485
COMMIT;
15486
	
15487
# check transactions-8 success: 	1
15488
# INFO: Storage engine used for t1 seems to be able to revert
15489
#       changes made by the failing statement.
15490
SET @@session.sql_mode = '';
15491
SET AUTOCOMMIT= 1;
15492
DELETE FROM t1 WHERE f_charbig = 'was inserted';
15493
COMMIT WORK;
15494
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
15495
	
15496
# check special-1 success: 	1
15497
UPDATE t1 SET f_charbig = '';
15498
	
15499
# check special-2 success: 	1
15500
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
15501
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
15502
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
15503
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15504
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15505
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15506
'just inserted' FROM t0_template
15507
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15508
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
15509
BEGIN
15510
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15511
f_charbig = 'updated by trigger'
15512
      WHERE f_int1 = new.f_int1;
15513
END|
15514
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15515
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
15516
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15517
	
15518
# check trigger-1 success: 	1
15519
DROP TRIGGER trg_1;
15520
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15521
f_int2 = CAST(f_char1 AS SIGNED INT),
15522
f_charbig = 'just inserted'
15523
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15524
DELETE FROM t0_aux
15525
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15526
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15527
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15528
'just inserted' FROM t0_template
15529
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15530
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
15531
BEGIN
15532
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15533
f_charbig = 'updated by trigger'
15534
      WHERE f_int1 = new.f_int1;
15535
END|
15536
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15537
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
15538
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15539
	
15540
# check trigger-2 success: 	1
15541
DROP TRIGGER trg_1;
15542
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15543
f_int2 = CAST(f_char1 AS SIGNED INT),
15544
f_charbig = 'just inserted'
15545
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15546
DELETE FROM t0_aux
15547
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15548
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15549
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15550
'just inserted' FROM t0_template
15551
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15552
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
15553
BEGIN
15554
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15555
f_charbig = 'updated by trigger'
15556
      WHERE f_int1 = new.f_int1;
15557
END|
15558
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
15559
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
15560
	
15561
# check trigger-3 success: 	1
15562
DROP TRIGGER trg_1;
15563
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15564
f_int2 = CAST(f_char1 AS SIGNED INT),
15565
f_charbig = 'just inserted'
15566
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15567
DELETE FROM t0_aux
15568
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15569
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15570
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15571
'just inserted' FROM t0_template
15572
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15573
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
15574
BEGIN
15575
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15576
f_charbig = 'updated by trigger'
15577
      WHERE f_int1 = - old.f_int1;
15578
END|
15579
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
15580
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
15581
	
15582
# check trigger-4 success: 	1
15583
DROP TRIGGER trg_1;
15584
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15585
f_int2 = CAST(f_char1 AS SIGNED INT),
15586
f_charbig = 'just inserted'
15587
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15588
DELETE FROM t0_aux
15589
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15590
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15591
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15592
'just inserted' FROM t0_template
15593
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15594
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
15595
BEGIN
15596
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15597
f_charbig = 'updated by trigger'
15598
      WHERE f_int1 = new.f_int1;
15599
END|
15600
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
15601
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
15602
	
15603
# check trigger-5 success: 	1
15604
DROP TRIGGER trg_1;
15605
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15606
f_int2 = CAST(f_char1 AS SIGNED INT),
15607
f_charbig = 'just inserted'
15608
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15609
DELETE FROM t0_aux
15610
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15611
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15612
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15613
'just inserted' FROM t0_template
15614
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15615
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
15616
BEGIN
15617
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15618
f_charbig = 'updated by trigger'
15619
      WHERE f_int1 = - old.f_int1;
15620
END|
15621
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
15622
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
15623
	
15624
# check trigger-6 success: 	1
15625
DROP TRIGGER trg_1;
15626
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15627
f_int2 = CAST(f_char1 AS SIGNED INT),
15628
f_charbig = 'just inserted'
15629
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15630
DELETE FROM t0_aux
15631
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15632
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15633
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15634
'just inserted' FROM t0_template
15635
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15636
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
15637
BEGIN
15638
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15639
f_charbig = 'updated by trigger'
15640
      WHERE f_int1 = - old.f_int1;
15641
END|
15642
DELETE FROM t0_aux
15643
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
15644
	
15645
# check trigger-7 success: 	1
15646
DROP TRIGGER trg_1;
15647
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15648
f_int2 = CAST(f_char1 AS SIGNED INT),
15649
f_charbig = 'just inserted'
15650
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15651
DELETE FROM t0_aux
15652
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15653
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
15654
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
15655
'just inserted' FROM t0_template
15656
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15657
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
15658
BEGIN
15659
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
15660
f_charbig = 'updated by trigger'
15661
      WHERE f_int1 = - old.f_int1;
15662
END|
15663
DELETE FROM t0_aux
15664
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
15665
	
15666
# check trigger-8 success: 	1
15667
DROP TRIGGER trg_1;
15668
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15669
f_int2 = CAST(f_char1 AS SIGNED INT),
15670
f_charbig = 'just inserted'
15671
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
15672
DELETE FROM t0_aux
15673
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15674
DELETE FROM t1
15675
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
15676
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
15677
BEGIN
15678
SET new.f_int1 = old.f_int1 + @max_row,
15679
new.f_int2 = old.f_int2 - @max_row,
15680
new.f_charbig = '####updated per update trigger####';
15681
END|
15682
UPDATE t1
15683
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
15684
f_charbig = '####updated per update statement itself####';
15685
	
15686
# check trigger-9 success: 	1
15687
DROP TRIGGER trg_2;
15688
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15689
f_int2 = CAST(f_char1 AS SIGNED INT),
15690
f_charbig = CONCAT('===',f_char1,'===');
15691
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
15692
BEGIN
15693
SET new.f_int1 = new.f_int1 + @max_row,
15694
new.f_int2 = new.f_int2 - @max_row,
15695
new.f_charbig = '####updated per update trigger####';
15696
END|
15697
UPDATE t1
15698
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
15699
f_charbig = '####updated per update statement itself####';
15700
	
15701
# check trigger-10 success: 	1
15702
DROP TRIGGER trg_2;
15703
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15704
f_int2 = CAST(f_char1 AS SIGNED INT),
15705
f_charbig = CONCAT('===',f_char1,'===');
15706
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
15707
BEGIN
15708
SET new.f_int1 = @my_max1 + @counter,
15709
new.f_int2 = @my_min2 - @counter,
15710
new.f_charbig = '####updated per insert trigger####';
15711
SET @counter = @counter + 1;
15712
END|
15713
SET @counter = 1;
15714
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
15715
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15716
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
15717
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
15718
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
15719
ORDER BY f_int1;
15720
DROP TRIGGER trg_3;
15721
	
15722
# check trigger-11 success: 	1
15723
DELETE FROM t1
15724
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
15725
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
15726
AND f_charbig = '####updated per insert trigger####';
15727
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
15728
BEGIN
15729
SET new.f_int1 = @my_max1 + @counter,
15730
new.f_int2 = @my_min2 - @counter,
15731
new.f_charbig = '####updated per insert trigger####';
15732
SET @counter = @counter + 1;
15733
END|
15734
SET @counter = 1;
15735
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
15736
INSERT INTO t1 (f_char1, f_char2, f_charbig)
15737
SELECT CAST(f_int1 AS CHAR),
15738
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
15739
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
15740
ORDER BY f_int1;
15741
DROP TRIGGER trg_3;
15742
	
15743
# check trigger-12 success: 	1
15744
DELETE FROM t1
15745
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
15746
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
15747
AND f_charbig = '####updated per insert trigger####';
15748
ANALYZE  TABLE t1;
15749
Table	Op	Msg_type	Msg_text
15750
test.t1	analyze	note	The storage engine for the table doesn't support analyze
15751
CHECK    TABLE t1 EXTENDED;
15752
Table	Op	Msg_type	Msg_text
15753
test.t1	check	note	The storage engine for the table doesn't support check
15754
CHECKSUM TABLE t1 EXTENDED;
15755
Table	Checksum
15756
test.t1	<some_value>
15757
OPTIMIZE TABLE t1;
15758
Table	Op	Msg_type	Msg_text
15759
test.t1	optimize	note	The storage engine for the table doesn't support optimize
15760
# check layout success:    1
15761
REPAIR   TABLE t1 EXTENDED;
15762
Table	Op	Msg_type	Msg_text
15763
test.t1	repair	note	The storage engine for the table doesn't support repair
15764
# check layout success:    1
15765
TRUNCATE t1;
15766
	
15767
# check TRUNCATE success: 	1
15768
# check layout success:    1
15769
# End usability test (inc/partition_check.inc)
15770
DROP TABLE t1;
15771
CREATE TABLE t1 (
15772
f_int1 INTEGER,
15773
f_int2 INTEGER,
15774
f_char1 CHAR(20),
15775
f_char2 CHAR(20),
15776
f_charbig VARCHAR(1000)
15777
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
15778
)
15779
PARTITION BY KEY(f_int1) PARTITIONS 5;
15780
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
15781
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
15782
# Start usability test (inc/partition_check.inc)
15783
create_command
15784
SHOW CREATE TABLE t1;
15785
Table	Create Table
15786
t1	CREATE TABLE `t1` (
15787
  `f_int1` int(11) DEFAULT NULL,
15788
  `f_int2` int(11) DEFAULT NULL,
15789
  `f_char1` char(20) DEFAULT NULL,
15790
  `f_char2` char(20) DEFAULT NULL,
15791
  `f_charbig` varchar(1000) DEFAULT NULL,
15792
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
15793
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
15794
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (f_int1) PARTITIONS 5  */
15795
15796
unified filelist
15797
$MYSQLTEST_VARDIR/master-data/test/t1.frm
15798
$MYSQLTEST_VARDIR/master-data/test/t1.par
15799
15800
# check prerequisites-1 success:    1
15801
# check COUNT(*) success:    1
15802
# check MIN/MAX(f_int1) success:    1
15803
# check MIN/MAX(f_int2) success:    1
15804
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15805
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
15806
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
15807
WHERE f_int1 IN (2,3);
15808
ERROR 23000: Can't write; duplicate key in table 't1'
15809
# check prerequisites-3 success:    1
15810
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
15811
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15812
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
15813
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
15814
WHERE f_int1 IN (2,3);
15815
DELETE FROM t1 WHERE f_charbig = 'delete me';
15816
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15817
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
15818
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
15819
WHERE f_int1 IN (2,3);
15820
DELETE FROM t1 WHERE f_charbig = 'delete me';
15821
# check read via f_int1 success: 1
15822
# check read via f_int2 success: 1
15823
	
15824
# check multiple-1 success: 	1
15825
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
15826
	
15827
# check multiple-2 success: 	1
15828
INSERT INTO t1 SELECT * FROM t0_template
15829
WHERE MOD(f_int1,3) = 0;
15830
	
15831
# check multiple-3 success: 	1
15832
UPDATE t1 SET f_int1 = f_int1 + @max_row
15833
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
15834
AND @max_row_div2 + @max_row_div4;
15835
	
15836
# check multiple-4 success: 	1
15837
DELETE FROM t1
15838
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
15839
AND @max_row_div2 + @max_row_div4 + @max_row;
15840
	
15841
# check multiple-5 success: 	1
15842
SELECT COUNT(*) INTO @try_count FROM t0_template
15843
WHERE MOD(f_int1,3) = 0
15844
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
15845
SELECT COUNT(*) INTO @clash_count
15846
FROM t1 INNER JOIN t0_template USING(f_int1)
15847
WHERE MOD(f_int1,3) = 0
15848
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
15849
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
15850
INSERT INTO t1
15851
SET f_int1 = @cur_value , f_int2 = @cur_value,
15852
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
15853
f_charbig = '#SINGLE#';
15854
	
15855
# check single-1 success: 	1
15856
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
15857
INSERT INTO t1
15858
SET f_int1 = @cur_value , f_int2 = @cur_value,
15859
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
15860
f_charbig = '#SINGLE#';
15861
	
15862
# check single-2 success: 	1
15863
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
15864
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
15865
UPDATE t1 SET f_int1 = @cur_value2
15866
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
15867
	
15868
# check single-3 success: 	1
15869
SET @cur_value1= -1;
15870
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
15871
UPDATE t1 SET f_int1 = @cur_value1
15872
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
15873
	
15874
# check single-4 success: 	1
15875
SELECT MAX(f_int1) INTO @cur_value FROM t1;
15876
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
15877
	
15878
# check single-5 success: 	1
15879
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
15880
	
15881
# check single-6 success: 	1
15882
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
15883
	
15884
# check single-7 success: 	1
15885
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
15886
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
15887
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
15888
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
15889
f_charbig = '#NULL#';
15890
INSERT INTO t1
15891
SET f_int1 = NULL , f_int2 = -@max_row,
15892
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
15893
f_charbig = '#NULL#';
15894
# check null success:    1
15895
	
15896
# check null-1 success: 	1
15897
UPDATE t1 SET f_int1 = -@max_row
15898
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
15899
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
15900
	
15901
# check null-2 success: 	1
15902
UPDATE t1 SET f_int1 = NULL
15903
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
15904
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
15905
	
15906
# check null-3 success: 	1
15907
DELETE FROM t1
15908
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
15909
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
15910
	
15911
# check null-4 success: 	1
15912
DELETE FROM t1
15913
WHERE f_int1 = 0 AND f_int2 = 0
15914
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
15915
AND f_charbig = '#NULL#';
15916
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15917
SELECT f_int1, f_int1, '', '', 'was inserted'
15918
   FROM t0_template source_tab
15919
WHERE MOD(f_int1,3) = 0
15920
AND f_int1 BETWEEN @max_row_div2 AND @max_row
15921
ON DUPLICATE KEY
15922
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
15923
f_int2 = 2 * @max_row + source_tab.f_int1,
15924
f_charbig = 'was updated';
15925
	
15926
# check unique-1-a success: 	1
15927
	
15928
# check unique-1-b success: 	1
15929
DELETE FROM t1 WHERE f_charbig = 'was inserted';
15930
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
15931
f_int2 = CAST(f_char1 AS SIGNED INT),
15932
f_charbig = CONCAT('===',f_char1,'===')
15933
WHERE f_charbig = 'was updated';
15934
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15935
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
15936
   FROM t0_template source_tab
15937
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
15938
	
15939
# check replace success: 	1
15940
DELETE FROM t1
15941
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
15942
DELETE FROM t1
15943
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
15944
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
15945
UPDATE t1 SET f_int2 = f_int1,
15946
f_char1 = CAST(f_int1 AS CHAR),
15947
f_char2 = CAST(f_int1 AS CHAR),
15948
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
15949
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
15950
SET AUTOCOMMIT= 0;
15951
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15952
SELECT f_int1, f_int1, '', '', 'was inserted'
15953
FROM t0_template source_tab
15954
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
15955
	
15956
# check transactions-1 success: 	1
15957
COMMIT WORK;
15958
	
15959
# check transactions-2 success: 	1
15960
ROLLBACK WORK;
15961
	
15962
# check transactions-3 success: 	1
15963
DELETE FROM t1 WHERE f_charbig = 'was inserted';
15964
COMMIT WORK;
15965
ROLLBACK WORK;
15966
	
15967
# check transactions-4 success: 	1
15968
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15969
SELECT f_int1, f_int1, '', '', 'was inserted'
15970
FROM t0_template source_tab
15971
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
15972
	
15973
# check transactions-5 success: 	1
15974
ROLLBACK WORK;
15975
	
15976
# check transactions-6 success: 	1
15977
# INFO: Storage engine used for t1 seems to be transactional.
15978
COMMIT;
15979
	
15980
# check transactions-7 success: 	1
15981
DELETE FROM t1 WHERE f_charbig = 'was inserted';
15982
COMMIT WORK;
15983
SET @@session.sql_mode = 'traditional';
15984
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
15985
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
15986
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
15987
'', '', 'was inserted' FROM t0_template
15988
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
15989
ERROR 22012: Division by 0
15990
COMMIT;
15991
	
15992
# check transactions-8 success: 	1
15993
# INFO: Storage engine used for t1 seems to be able to revert
15994
#       changes made by the failing statement.
15995
SET @@session.sql_mode = '';
15996
SET AUTOCOMMIT= 1;
15997
DELETE FROM t1 WHERE f_charbig = 'was inserted';
15998
COMMIT WORK;
15999
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
16000
	
16001
# check special-1 success: 	1
16002
UPDATE t1 SET f_charbig = '';
16003
	
16004
# check special-2 success: 	1
16005
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
16006
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
16007
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
16008
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16009
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16010
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16011
'just inserted' FROM t0_template
16012
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16013
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
16014
BEGIN
16015
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16016
f_charbig = 'updated by trigger'
16017
      WHERE f_int1 = new.f_int1;
16018
END|
16019
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16020
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
16021
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16022
	
16023
# check trigger-1 success: 	1
16024
DROP TRIGGER trg_1;
16025
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16026
f_int2 = CAST(f_char1 AS SIGNED INT),
16027
f_charbig = 'just inserted'
16028
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16029
DELETE FROM t0_aux
16030
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16031
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16032
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16033
'just inserted' FROM t0_template
16034
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16035
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
16036
BEGIN
16037
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16038
f_charbig = 'updated by trigger'
16039
      WHERE f_int1 = new.f_int1;
16040
END|
16041
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16042
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
16043
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16044
	
16045
# check trigger-2 success: 	1
16046
DROP TRIGGER trg_1;
16047
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16048
f_int2 = CAST(f_char1 AS SIGNED INT),
16049
f_charbig = 'just inserted'
16050
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16051
DELETE FROM t0_aux
16052
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16053
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16054
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16055
'just inserted' FROM t0_template
16056
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16057
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
16058
BEGIN
16059
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16060
f_charbig = 'updated by trigger'
16061
      WHERE f_int1 = new.f_int1;
16062
END|
16063
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
16064
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
16065
	
16066
# check trigger-3 success: 	1
16067
DROP TRIGGER trg_1;
16068
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16069
f_int2 = CAST(f_char1 AS SIGNED INT),
16070
f_charbig = 'just inserted'
16071
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16072
DELETE FROM t0_aux
16073
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16074
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16075
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16076
'just inserted' FROM t0_template
16077
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16078
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
16079
BEGIN
16080
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16081
f_charbig = 'updated by trigger'
16082
      WHERE f_int1 = - old.f_int1;
16083
END|
16084
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
16085
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
16086
	
16087
# check trigger-4 success: 	1
16088
DROP TRIGGER trg_1;
16089
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16090
f_int2 = CAST(f_char1 AS SIGNED INT),
16091
f_charbig = 'just inserted'
16092
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16093
DELETE FROM t0_aux
16094
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16095
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16096
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16097
'just inserted' FROM t0_template
16098
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16099
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
16100
BEGIN
16101
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16102
f_charbig = 'updated by trigger'
16103
      WHERE f_int1 = new.f_int1;
16104
END|
16105
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
16106
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
16107
	
16108
# check trigger-5 success: 	1
16109
DROP TRIGGER trg_1;
16110
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16111
f_int2 = CAST(f_char1 AS SIGNED INT),
16112
f_charbig = 'just inserted'
16113
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16114
DELETE FROM t0_aux
16115
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16116
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16117
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16118
'just inserted' FROM t0_template
16119
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16120
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
16121
BEGIN
16122
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16123
f_charbig = 'updated by trigger'
16124
      WHERE f_int1 = - old.f_int1;
16125
END|
16126
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
16127
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
16128
	
16129
# check trigger-6 success: 	1
16130
DROP TRIGGER trg_1;
16131
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16132
f_int2 = CAST(f_char1 AS SIGNED INT),
16133
f_charbig = 'just inserted'
16134
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16135
DELETE FROM t0_aux
16136
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16137
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16138
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16139
'just inserted' FROM t0_template
16140
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16141
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
16142
BEGIN
16143
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16144
f_charbig = 'updated by trigger'
16145
      WHERE f_int1 = - old.f_int1;
16146
END|
16147
DELETE FROM t0_aux
16148
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
16149
	
16150
# check trigger-7 success: 	1
16151
DROP TRIGGER trg_1;
16152
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16153
f_int2 = CAST(f_char1 AS SIGNED INT),
16154
f_charbig = 'just inserted'
16155
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16156
DELETE FROM t0_aux
16157
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16158
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16159
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16160
'just inserted' FROM t0_template
16161
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16162
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
16163
BEGIN
16164
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16165
f_charbig = 'updated by trigger'
16166
      WHERE f_int1 = - old.f_int1;
16167
END|
16168
DELETE FROM t0_aux
16169
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
16170
	
16171
# check trigger-8 success: 	1
16172
DROP TRIGGER trg_1;
16173
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16174
f_int2 = CAST(f_char1 AS SIGNED INT),
16175
f_charbig = 'just inserted'
16176
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16177
DELETE FROM t0_aux
16178
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16179
DELETE FROM t1
16180
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16181
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
16182
BEGIN
16183
SET new.f_int1 = old.f_int1 + @max_row,
16184
new.f_int2 = old.f_int2 - @max_row,
16185
new.f_charbig = '####updated per update trigger####';
16186
END|
16187
UPDATE t1
16188
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
16189
f_charbig = '####updated per update statement itself####';
16190
	
16191
# check trigger-9 success: 	1
16192
DROP TRIGGER trg_2;
16193
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16194
f_int2 = CAST(f_char1 AS SIGNED INT),
16195
f_charbig = CONCAT('===',f_char1,'===');
16196
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
16197
BEGIN
16198
SET new.f_int1 = new.f_int1 + @max_row,
16199
new.f_int2 = new.f_int2 - @max_row,
16200
new.f_charbig = '####updated per update trigger####';
16201
END|
16202
UPDATE t1
16203
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
16204
f_charbig = '####updated per update statement itself####';
16205
	
16206
# check trigger-10 success: 	1
16207
DROP TRIGGER trg_2;
16208
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16209
f_int2 = CAST(f_char1 AS SIGNED INT),
16210
f_charbig = CONCAT('===',f_char1,'===');
16211
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
16212
BEGIN
16213
SET new.f_int1 = @my_max1 + @counter,
16214
new.f_int2 = @my_min2 - @counter,
16215
new.f_charbig = '####updated per insert trigger####';
16216
SET @counter = @counter + 1;
16217
END|
16218
SET @counter = 1;
16219
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
16220
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16221
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
16222
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
16223
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
16224
ORDER BY f_int1;
16225
DROP TRIGGER trg_3;
16226
	
16227
# check trigger-11 success: 	1
16228
DELETE FROM t1
16229
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
16230
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
16231
AND f_charbig = '####updated per insert trigger####';
16232
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
16233
BEGIN
16234
SET new.f_int1 = @my_max1 + @counter,
16235
new.f_int2 = @my_min2 - @counter,
16236
new.f_charbig = '####updated per insert trigger####';
16237
SET @counter = @counter + 1;
16238
END|
16239
SET @counter = 1;
16240
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
16241
INSERT INTO t1 (f_char1, f_char2, f_charbig)
16242
SELECT CAST(f_int1 AS CHAR),
16243
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
16244
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
16245
ORDER BY f_int1;
16246
DROP TRIGGER trg_3;
16247
	
16248
# check trigger-12 success: 	1
16249
DELETE FROM t1
16250
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
16251
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
16252
AND f_charbig = '####updated per insert trigger####';
16253
ANALYZE  TABLE t1;
16254
Table	Op	Msg_type	Msg_text
16255
test.t1	analyze	note	The storage engine for the table doesn't support analyze
16256
CHECK    TABLE t1 EXTENDED;
16257
Table	Op	Msg_type	Msg_text
16258
test.t1	check	note	The storage engine for the table doesn't support check
16259
CHECKSUM TABLE t1 EXTENDED;
16260
Table	Checksum
16261
test.t1	<some_value>
16262
OPTIMIZE TABLE t1;
16263
Table	Op	Msg_type	Msg_text
16264
test.t1	optimize	note	The storage engine for the table doesn't support optimize
16265
# check layout success:    1
16266
REPAIR   TABLE t1 EXTENDED;
16267
Table	Op	Msg_type	Msg_text
16268
test.t1	repair	note	The storage engine for the table doesn't support repair
16269
# check layout success:    1
16270
TRUNCATE t1;
16271
	
16272
# check TRUNCATE success: 	1
16273
# check layout success:    1
16274
# End usability test (inc/partition_check.inc)
16275
DROP TABLE t1;
16276
CREATE TABLE t1 (
16277
f_int1 INTEGER,
16278
f_int2 INTEGER,
16279
f_char1 CHAR(20),
16280
f_char2 CHAR(20),
16281
f_charbig VARCHAR(1000)
16282
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
16283
)
16284
PARTITION BY LIST(MOD(f_int1,4))
16285
(PARTITION part_3 VALUES IN (-3),
16286
PARTITION part_2 VALUES IN (-2),
16287
PARTITION part_1 VALUES IN (-1),
16288
PARTITION part_N VALUES IN (NULL),
16289
PARTITION part0 VALUES IN (0),
16290
PARTITION part1 VALUES IN (1),
16291
PARTITION part2 VALUES IN (2),
16292
PARTITION part3 VALUES IN (3));
16293
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
16294
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
16295
# Start usability test (inc/partition_check.inc)
16296
create_command
16297
SHOW CREATE TABLE t1;
16298
Table	Create Table
16299
t1	CREATE TABLE `t1` (
16300
  `f_int1` int(11) DEFAULT NULL,
16301
  `f_int2` int(11) DEFAULT NULL,
16302
  `f_char1` char(20) DEFAULT NULL,
16303
  `f_char2` char(20) DEFAULT NULL,
16304
  `f_charbig` varchar(1000) DEFAULT NULL,
16305
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
16306
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
16307
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (MOD(f_int1,4)) (PARTITION part_3 VALUES IN (-3) ENGINE = InnoDB, PARTITION part_2 VALUES IN (-2) ENGINE = InnoDB, PARTITION part_1 VALUES IN (-1) ENGINE = InnoDB, PARTITION part_N VALUES IN (NULL) ENGINE = InnoDB, PARTITION part0 VALUES IN (0) ENGINE = InnoDB, PARTITION part1 VALUES IN (1) ENGINE = InnoDB, PARTITION part2 VALUES IN (2) ENGINE = InnoDB, PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
16308
16309
unified filelist
16310
$MYSQLTEST_VARDIR/master-data/test/t1.frm
16311
$MYSQLTEST_VARDIR/master-data/test/t1.par
16312
16313
# check prerequisites-1 success:    1
16314
# check COUNT(*) success:    1
16315
# check MIN/MAX(f_int1) success:    1
16316
# check MIN/MAX(f_int2) success:    1
16317
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16318
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
16319
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
16320
WHERE f_int1 IN (2,3);
16321
ERROR 23000: Can't write; duplicate key in table 't1'
16322
# check prerequisites-3 success:    1
16323
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
16324
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16325
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
16326
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
16327
WHERE f_int1 IN (2,3);
16328
DELETE FROM t1 WHERE f_charbig = 'delete me';
16329
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16330
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
16331
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
16332
WHERE f_int1 IN (2,3);
16333
DELETE FROM t1 WHERE f_charbig = 'delete me';
16334
# check read via f_int1 success: 1
16335
# check read via f_int2 success: 1
16336
	
16337
# check multiple-1 success: 	1
16338
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
16339
	
16340
# check multiple-2 success: 	1
16341
INSERT INTO t1 SELECT * FROM t0_template
16342
WHERE MOD(f_int1,3) = 0;
16343
	
16344
# check multiple-3 success: 	1
16345
UPDATE t1 SET f_int1 = f_int1 + @max_row
16346
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
16347
AND @max_row_div2 + @max_row_div4;
16348
	
16349
# check multiple-4 success: 	1
16350
DELETE FROM t1
16351
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
16352
AND @max_row_div2 + @max_row_div4 + @max_row;
16353
	
16354
# check multiple-5 success: 	1
16355
SELECT COUNT(*) INTO @try_count FROM t0_template
16356
WHERE MOD(f_int1,3) = 0
16357
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
16358
SELECT COUNT(*) INTO @clash_count
16359
FROM t1 INNER JOIN t0_template USING(f_int1)
16360
WHERE MOD(f_int1,3) = 0
16361
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
16362
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
16363
INSERT INTO t1
16364
SET f_int1 = @cur_value , f_int2 = @cur_value,
16365
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
16366
f_charbig = '#SINGLE#';
16367
	
16368
# check single-1 success: 	1
16369
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
16370
INSERT INTO t1
16371
SET f_int1 = @cur_value , f_int2 = @cur_value,
16372
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
16373
f_charbig = '#SINGLE#';
16374
	
16375
# check single-2 success: 	1
16376
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
16377
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
16378
UPDATE t1 SET f_int1 = @cur_value2
16379
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
16380
	
16381
# check single-3 success: 	1
16382
SET @cur_value1= -1;
16383
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
16384
UPDATE t1 SET f_int1 = @cur_value1
16385
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
16386
	
16387
# check single-4 success: 	1
16388
SELECT MAX(f_int1) INTO @cur_value FROM t1;
16389
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
16390
	
16391
# check single-5 success: 	1
16392
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
16393
	
16394
# check single-6 success: 	1
16395
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
16396
	
16397
# check single-7 success: 	1
16398
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
16399
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
16400
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
16401
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
16402
f_charbig = '#NULL#';
16403
INSERT INTO t1
16404
SET f_int1 = NULL , f_int2 = -@max_row,
16405
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
16406
f_charbig = '#NULL#';
16407
# check null success:    1
16408
	
16409
# check null-1 success: 	1
16410
UPDATE t1 SET f_int1 = -@max_row
16411
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
16412
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
16413
	
16414
# check null-2 success: 	1
16415
UPDATE t1 SET f_int1 = NULL
16416
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
16417
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
16418
	
16419
# check null-3 success: 	1
16420
DELETE FROM t1
16421
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
16422
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
16423
	
16424
# check null-4 success: 	1
16425
DELETE FROM t1
16426
WHERE f_int1 = 0 AND f_int2 = 0
16427
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
16428
AND f_charbig = '#NULL#';
16429
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16430
SELECT f_int1, f_int1, '', '', 'was inserted'
16431
   FROM t0_template source_tab
16432
WHERE MOD(f_int1,3) = 0
16433
AND f_int1 BETWEEN @max_row_div2 AND @max_row
16434
ON DUPLICATE KEY
16435
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
16436
f_int2 = 2 * @max_row + source_tab.f_int1,
16437
f_charbig = 'was updated';
16438
	
16439
# check unique-1-a success: 	1
16440
	
16441
# check unique-1-b success: 	1
16442
DELETE FROM t1 WHERE f_charbig = 'was inserted';
16443
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16444
f_int2 = CAST(f_char1 AS SIGNED INT),
16445
f_charbig = CONCAT('===',f_char1,'===')
16446
WHERE f_charbig = 'was updated';
16447
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16448
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
16449
   FROM t0_template source_tab
16450
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
16451
	
16452
# check replace success: 	1
16453
DELETE FROM t1
16454
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
16455
DELETE FROM t1
16456
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
16457
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
16458
UPDATE t1 SET f_int2 = f_int1,
16459
f_char1 = CAST(f_int1 AS CHAR),
16460
f_char2 = CAST(f_int1 AS CHAR),
16461
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
16462
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
16463
SET AUTOCOMMIT= 0;
16464
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16465
SELECT f_int1, f_int1, '', '', 'was inserted'
16466
FROM t0_template source_tab
16467
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
16468
	
16469
# check transactions-1 success: 	1
16470
COMMIT WORK;
16471
	
16472
# check transactions-2 success: 	1
16473
ROLLBACK WORK;
16474
	
16475
# check transactions-3 success: 	1
16476
DELETE FROM t1 WHERE f_charbig = 'was inserted';
16477
COMMIT WORK;
16478
ROLLBACK WORK;
16479
	
16480
# check transactions-4 success: 	1
16481
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16482
SELECT f_int1, f_int1, '', '', 'was inserted'
16483
FROM t0_template source_tab
16484
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
16485
	
16486
# check transactions-5 success: 	1
16487
ROLLBACK WORK;
16488
	
16489
# check transactions-6 success: 	1
16490
# INFO: Storage engine used for t1 seems to be transactional.
16491
COMMIT;
16492
	
16493
# check transactions-7 success: 	1
16494
DELETE FROM t1 WHERE f_charbig = 'was inserted';
16495
COMMIT WORK;
16496
SET @@session.sql_mode = 'traditional';
16497
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
16498
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16499
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
16500
'', '', 'was inserted' FROM t0_template
16501
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
16502
ERROR 22012: Division by 0
16503
COMMIT;
16504
	
16505
# check transactions-8 success: 	1
16506
# INFO: Storage engine used for t1 seems to be able to revert
16507
#       changes made by the failing statement.
16508
SET @@session.sql_mode = '';
16509
SET AUTOCOMMIT= 1;
16510
DELETE FROM t1 WHERE f_charbig = 'was inserted';
16511
COMMIT WORK;
16512
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
16513
	
16514
# check special-1 success: 	1
16515
UPDATE t1 SET f_charbig = '';
16516
	
16517
# check special-2 success: 	1
16518
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
16519
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
16520
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
16521
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16522
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16523
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16524
'just inserted' FROM t0_template
16525
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16526
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
16527
BEGIN
16528
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16529
f_charbig = 'updated by trigger'
16530
      WHERE f_int1 = new.f_int1;
16531
END|
16532
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16533
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
16534
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16535
	
16536
# check trigger-1 success: 	1
16537
DROP TRIGGER trg_1;
16538
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16539
f_int2 = CAST(f_char1 AS SIGNED INT),
16540
f_charbig = 'just inserted'
16541
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16542
DELETE FROM t0_aux
16543
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16544
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16545
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16546
'just inserted' FROM t0_template
16547
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16548
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
16549
BEGIN
16550
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16551
f_charbig = 'updated by trigger'
16552
      WHERE f_int1 = new.f_int1;
16553
END|
16554
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16555
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
16556
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16557
	
16558
# check trigger-2 success: 	1
16559
DROP TRIGGER trg_1;
16560
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16561
f_int2 = CAST(f_char1 AS SIGNED INT),
16562
f_charbig = 'just inserted'
16563
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16564
DELETE FROM t0_aux
16565
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16566
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16567
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16568
'just inserted' FROM t0_template
16569
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16570
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
16571
BEGIN
16572
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16573
f_charbig = 'updated by trigger'
16574
      WHERE f_int1 = new.f_int1;
16575
END|
16576
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
16577
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
16578
	
16579
# check trigger-3 success: 	1
16580
DROP TRIGGER trg_1;
16581
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16582
f_int2 = CAST(f_char1 AS SIGNED INT),
16583
f_charbig = 'just inserted'
16584
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16585
DELETE FROM t0_aux
16586
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16587
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16588
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16589
'just inserted' FROM t0_template
16590
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16591
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
16592
BEGIN
16593
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16594
f_charbig = 'updated by trigger'
16595
      WHERE f_int1 = - old.f_int1;
16596
END|
16597
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
16598
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
16599
	
16600
# check trigger-4 success: 	1
16601
DROP TRIGGER trg_1;
16602
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16603
f_int2 = CAST(f_char1 AS SIGNED INT),
16604
f_charbig = 'just inserted'
16605
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16606
DELETE FROM t0_aux
16607
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16608
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16609
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16610
'just inserted' FROM t0_template
16611
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16612
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
16613
BEGIN
16614
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16615
f_charbig = 'updated by trigger'
16616
      WHERE f_int1 = new.f_int1;
16617
END|
16618
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
16619
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
16620
	
16621
# check trigger-5 success: 	1
16622
DROP TRIGGER trg_1;
16623
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16624
f_int2 = CAST(f_char1 AS SIGNED INT),
16625
f_charbig = 'just inserted'
16626
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16627
DELETE FROM t0_aux
16628
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16629
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16630
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16631
'just inserted' FROM t0_template
16632
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16633
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
16634
BEGIN
16635
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16636
f_charbig = 'updated by trigger'
16637
      WHERE f_int1 = - old.f_int1;
16638
END|
16639
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
16640
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
16641
	
16642
# check trigger-6 success: 	1
16643
DROP TRIGGER trg_1;
16644
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16645
f_int2 = CAST(f_char1 AS SIGNED INT),
16646
f_charbig = 'just inserted'
16647
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16648
DELETE FROM t0_aux
16649
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16650
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16651
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16652
'just inserted' FROM t0_template
16653
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16654
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
16655
BEGIN
16656
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16657
f_charbig = 'updated by trigger'
16658
      WHERE f_int1 = - old.f_int1;
16659
END|
16660
DELETE FROM t0_aux
16661
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
16662
	
16663
# check trigger-7 success: 	1
16664
DROP TRIGGER trg_1;
16665
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16666
f_int2 = CAST(f_char1 AS SIGNED INT),
16667
f_charbig = 'just inserted'
16668
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16669
DELETE FROM t0_aux
16670
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16671
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
16672
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
16673
'just inserted' FROM t0_template
16674
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16675
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
16676
BEGIN
16677
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
16678
f_charbig = 'updated by trigger'
16679
      WHERE f_int1 = - old.f_int1;
16680
END|
16681
DELETE FROM t0_aux
16682
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
16683
	
16684
# check trigger-8 success: 	1
16685
DROP TRIGGER trg_1;
16686
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16687
f_int2 = CAST(f_char1 AS SIGNED INT),
16688
f_charbig = 'just inserted'
16689
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
16690
DELETE FROM t0_aux
16691
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16692
DELETE FROM t1
16693
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
16694
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
16695
BEGIN
16696
SET new.f_int1 = old.f_int1 + @max_row,
16697
new.f_int2 = old.f_int2 - @max_row,
16698
new.f_charbig = '####updated per update trigger####';
16699
END|
16700
UPDATE t1
16701
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
16702
f_charbig = '####updated per update statement itself####';
16703
	
16704
# check trigger-9 success: 	1
16705
DROP TRIGGER trg_2;
16706
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16707
f_int2 = CAST(f_char1 AS SIGNED INT),
16708
f_charbig = CONCAT('===',f_char1,'===');
16709
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
16710
BEGIN
16711
SET new.f_int1 = new.f_int1 + @max_row,
16712
new.f_int2 = new.f_int2 - @max_row,
16713
new.f_charbig = '####updated per update trigger####';
16714
END|
16715
UPDATE t1
16716
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
16717
f_charbig = '####updated per update statement itself####';
16718
	
16719
# check trigger-10 success: 	1
16720
DROP TRIGGER trg_2;
16721
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16722
f_int2 = CAST(f_char1 AS SIGNED INT),
16723
f_charbig = CONCAT('===',f_char1,'===');
16724
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
16725
BEGIN
16726
SET new.f_int1 = @my_max1 + @counter,
16727
new.f_int2 = @my_min2 - @counter,
16728
new.f_charbig = '####updated per insert trigger####';
16729
SET @counter = @counter + 1;
16730
END|
16731
SET @counter = 1;
16732
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
16733
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16734
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
16735
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
16736
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
16737
ORDER BY f_int1;
16738
DROP TRIGGER trg_3;
16739
	
16740
# check trigger-11 success: 	1
16741
DELETE FROM t1
16742
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
16743
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
16744
AND f_charbig = '####updated per insert trigger####';
16745
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
16746
BEGIN
16747
SET new.f_int1 = @my_max1 + @counter,
16748
new.f_int2 = @my_min2 - @counter,
16749
new.f_charbig = '####updated per insert trigger####';
16750
SET @counter = @counter + 1;
16751
END|
16752
SET @counter = 1;
16753
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
16754
INSERT INTO t1 (f_char1, f_char2, f_charbig)
16755
SELECT CAST(f_int1 AS CHAR),
16756
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
16757
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
16758
ORDER BY f_int1;
16759
DROP TRIGGER trg_3;
16760
	
16761
# check trigger-12 success: 	1
16762
DELETE FROM t1
16763
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
16764
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
16765
AND f_charbig = '####updated per insert trigger####';
16766
ANALYZE  TABLE t1;
16767
Table	Op	Msg_type	Msg_text
16768
test.t1	analyze	note	The storage engine for the table doesn't support analyze
16769
CHECK    TABLE t1 EXTENDED;
16770
Table	Op	Msg_type	Msg_text
16771
test.t1	check	note	The storage engine for the table doesn't support check
16772
CHECKSUM TABLE t1 EXTENDED;
16773
Table	Checksum
16774
test.t1	<some_value>
16775
OPTIMIZE TABLE t1;
16776
Table	Op	Msg_type	Msg_text
16777
test.t1	optimize	note	The storage engine for the table doesn't support optimize
16778
# check layout success:    1
16779
REPAIR   TABLE t1 EXTENDED;
16780
Table	Op	Msg_type	Msg_text
16781
test.t1	repair	note	The storage engine for the table doesn't support repair
16782
# check layout success:    1
16783
TRUNCATE t1;
16784
	
16785
# check TRUNCATE success: 	1
16786
# check layout success:    1
16787
# End usability test (inc/partition_check.inc)
16788
DROP TABLE t1;
16789
CREATE TABLE t1 (
16790
f_int1 INTEGER,
16791
f_int2 INTEGER,
16792
f_char1 CHAR(20),
16793
f_char2 CHAR(20),
16794
f_charbig VARCHAR(1000)
16795
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
16796
)
16797
PARTITION BY RANGE(f_int1)
16798
(PARTITION parta VALUES LESS THAN (0),
16799
PARTITION partb VALUES LESS THAN (5),
16800
PARTITION partc VALUES LESS THAN (10),
16801
PARTITION partd VALUES LESS THAN (10 + 5),
16802
PARTITION parte VALUES LESS THAN (20),
16803
PARTITION partf VALUES LESS THAN (2147483646));
16804
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
16805
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
16806
# Start usability test (inc/partition_check.inc)
16807
create_command
16808
SHOW CREATE TABLE t1;
16809
Table	Create Table
16810
t1	CREATE TABLE `t1` (
16811
  `f_int1` int(11) DEFAULT NULL,
16812
  `f_int2` int(11) DEFAULT NULL,
16813
  `f_char1` char(20) DEFAULT NULL,
16814
  `f_char2` char(20) DEFAULT NULL,
16815
  `f_charbig` varchar(1000) DEFAULT NULL,
16816
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
16817
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
16818
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION parte VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
16819
16820
unified filelist
16821
$MYSQLTEST_VARDIR/master-data/test/t1.frm
16822
$MYSQLTEST_VARDIR/master-data/test/t1.par
16823
16824
# check prerequisites-1 success:    1
16825
# check COUNT(*) success:    1
16826
# check MIN/MAX(f_int1) success:    1
16827
# check MIN/MAX(f_int2) success:    1
16828
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16829
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
16830
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
16831
WHERE f_int1 IN (2,3);
16832
ERROR 23000: Can't write; duplicate key in table 't1'
16833
# check prerequisites-3 success:    1
16834
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
16835
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16836
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
16837
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
16838
WHERE f_int1 IN (2,3);
16839
DELETE FROM t1 WHERE f_charbig = 'delete me';
16840
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16841
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
16842
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
16843
WHERE f_int1 IN (2,3);
16844
DELETE FROM t1 WHERE f_charbig = 'delete me';
16845
# check read via f_int1 success: 1
16846
# check read via f_int2 success: 1
16847
	
16848
# check multiple-1 success: 	1
16849
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
16850
	
16851
# check multiple-2 success: 	1
16852
INSERT INTO t1 SELECT * FROM t0_template
16853
WHERE MOD(f_int1,3) = 0;
16854
	
16855
# check multiple-3 success: 	1
16856
UPDATE t1 SET f_int1 = f_int1 + @max_row
16857
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
16858
AND @max_row_div2 + @max_row_div4;
16859
	
16860
# check multiple-4 success: 	1
16861
DELETE FROM t1
16862
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
16863
AND @max_row_div2 + @max_row_div4 + @max_row;
16864
	
16865
# check multiple-5 success: 	1
16866
SELECT COUNT(*) INTO @try_count FROM t0_template
16867
WHERE MOD(f_int1,3) = 0
16868
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
16869
SELECT COUNT(*) INTO @clash_count
16870
FROM t1 INNER JOIN t0_template USING(f_int1)
16871
WHERE MOD(f_int1,3) = 0
16872
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
16873
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
16874
INSERT INTO t1
16875
SET f_int1 = @cur_value , f_int2 = @cur_value,
16876
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
16877
f_charbig = '#SINGLE#';
16878
	
16879
# check single-1 success: 	1
16880
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
16881
INSERT INTO t1
16882
SET f_int1 = @cur_value , f_int2 = @cur_value,
16883
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
16884
f_charbig = '#SINGLE#';
16885
	
16886
# check single-2 success: 	1
16887
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
16888
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
16889
UPDATE t1 SET f_int1 = @cur_value2
16890
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
16891
	
16892
# check single-3 success: 	1
16893
SET @cur_value1= -1;
16894
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
16895
UPDATE t1 SET f_int1 = @cur_value1
16896
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
16897
	
16898
# check single-4 success: 	1
16899
SELECT MAX(f_int1) INTO @cur_value FROM t1;
16900
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
16901
	
16902
# check single-5 success: 	1
16903
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
16904
	
16905
# check single-6 success: 	1
16906
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
16907
ERROR HY000: Table has no partition for value 2147483647
16908
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
16909
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
16910
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
16911
f_charbig = '#NULL#';
16912
INSERT INTO t1
16913
SET f_int1 = NULL , f_int2 = -@max_row,
16914
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
16915
f_charbig = '#NULL#';
16916
# check null success:    1
16917
	
16918
# check null-1 success: 	1
16919
UPDATE t1 SET f_int1 = -@max_row
16920
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
16921
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
16922
	
16923
# check null-2 success: 	1
16924
UPDATE t1 SET f_int1 = NULL
16925
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
16926
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
16927
	
16928
# check null-3 success: 	1
16929
DELETE FROM t1
16930
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
16931
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
16932
	
16933
# check null-4 success: 	1
16934
DELETE FROM t1
16935
WHERE f_int1 = 0 AND f_int2 = 0
16936
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
16937
AND f_charbig = '#NULL#';
16938
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16939
SELECT f_int1, f_int1, '', '', 'was inserted'
16940
   FROM t0_template source_tab
16941
WHERE MOD(f_int1,3) = 0
16942
AND f_int1 BETWEEN @max_row_div2 AND @max_row
16943
ON DUPLICATE KEY
16944
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
16945
f_int2 = 2 * @max_row + source_tab.f_int1,
16946
f_charbig = 'was updated';
16947
	
16948
# check unique-1-a success: 	1
16949
	
16950
# check unique-1-b success: 	1
16951
DELETE FROM t1 WHERE f_charbig = 'was inserted';
16952
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
16953
f_int2 = CAST(f_char1 AS SIGNED INT),
16954
f_charbig = CONCAT('===',f_char1,'===')
16955
WHERE f_charbig = 'was updated';
16956
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16957
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
16958
   FROM t0_template source_tab
16959
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
16960
	
16961
# check replace success: 	1
16962
DELETE FROM t1
16963
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
16964
DELETE FROM t1
16965
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
16966
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
16967
UPDATE t1 SET f_int2 = f_int1,
16968
f_char1 = CAST(f_int1 AS CHAR),
16969
f_char2 = CAST(f_int1 AS CHAR),
16970
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
16971
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
16972
SET AUTOCOMMIT= 0;
16973
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16974
SELECT f_int1, f_int1, '', '', 'was inserted'
16975
FROM t0_template source_tab
16976
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
16977
	
16978
# check transactions-1 success: 	1
16979
COMMIT WORK;
16980
	
16981
# check transactions-2 success: 	1
16982
ROLLBACK WORK;
16983
	
16984
# check transactions-3 success: 	1
16985
DELETE FROM t1 WHERE f_charbig = 'was inserted';
16986
COMMIT WORK;
16987
ROLLBACK WORK;
16988
	
16989
# check transactions-4 success: 	1
16990
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
16991
SELECT f_int1, f_int1, '', '', 'was inserted'
16992
FROM t0_template source_tab
16993
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
16994
	
16995
# check transactions-5 success: 	1
16996
ROLLBACK WORK;
16997
	
16998
# check transactions-6 success: 	1
16999
# INFO: Storage engine used for t1 seems to be transactional.
17000
COMMIT;
17001
	
17002
# check transactions-7 success: 	1
17003
DELETE FROM t1 WHERE f_charbig = 'was inserted';
17004
COMMIT WORK;
17005
SET @@session.sql_mode = 'traditional';
17006
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
17007
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17008
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
17009
'', '', 'was inserted' FROM t0_template
17010
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
17011
ERROR 22012: Division by 0
17012
COMMIT;
17013
	
17014
# check transactions-8 success: 	1
17015
# INFO: Storage engine used for t1 seems to be able to revert
17016
#       changes made by the failing statement.
17017
SET @@session.sql_mode = '';
17018
SET AUTOCOMMIT= 1;
17019
DELETE FROM t1 WHERE f_charbig = 'was inserted';
17020
COMMIT WORK;
17021
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
17022
	
17023
# check special-1 success: 	1
17024
UPDATE t1 SET f_charbig = '';
17025
	
17026
# check special-2 success: 	1
17027
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
17028
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
17029
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
17030
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17031
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17032
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17033
'just inserted' FROM t0_template
17034
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17035
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
17036
BEGIN
17037
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17038
f_charbig = 'updated by trigger'
17039
      WHERE f_int1 = new.f_int1;
17040
END|
17041
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17042
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
17043
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17044
	
17045
# check trigger-1 success: 	1
17046
DROP TRIGGER trg_1;
17047
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17048
f_int2 = CAST(f_char1 AS SIGNED INT),
17049
f_charbig = 'just inserted'
17050
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17051
DELETE FROM t0_aux
17052
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17053
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17054
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17055
'just inserted' FROM t0_template
17056
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17057
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
17058
BEGIN
17059
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17060
f_charbig = 'updated by trigger'
17061
      WHERE f_int1 = new.f_int1;
17062
END|
17063
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17064
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
17065
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17066
	
17067
# check trigger-2 success: 	1
17068
DROP TRIGGER trg_1;
17069
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17070
f_int2 = CAST(f_char1 AS SIGNED INT),
17071
f_charbig = 'just inserted'
17072
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17073
DELETE FROM t0_aux
17074
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17075
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17076
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17077
'just inserted' FROM t0_template
17078
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17079
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
17080
BEGIN
17081
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17082
f_charbig = 'updated by trigger'
17083
      WHERE f_int1 = new.f_int1;
17084
END|
17085
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
17086
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
17087
	
17088
# check trigger-3 success: 	1
17089
DROP TRIGGER trg_1;
17090
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17091
f_int2 = CAST(f_char1 AS SIGNED INT),
17092
f_charbig = 'just inserted'
17093
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17094
DELETE FROM t0_aux
17095
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17096
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17097
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17098
'just inserted' FROM t0_template
17099
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17100
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
17101
BEGIN
17102
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17103
f_charbig = 'updated by trigger'
17104
      WHERE f_int1 = - old.f_int1;
17105
END|
17106
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
17107
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
17108
	
17109
# check trigger-4 success: 	1
17110
DROP TRIGGER trg_1;
17111
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17112
f_int2 = CAST(f_char1 AS SIGNED INT),
17113
f_charbig = 'just inserted'
17114
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17115
DELETE FROM t0_aux
17116
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17117
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17118
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17119
'just inserted' FROM t0_template
17120
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17121
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
17122
BEGIN
17123
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17124
f_charbig = 'updated by trigger'
17125
      WHERE f_int1 = new.f_int1;
17126
END|
17127
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
17128
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
17129
	
17130
# check trigger-5 success: 	1
17131
DROP TRIGGER trg_1;
17132
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17133
f_int2 = CAST(f_char1 AS SIGNED INT),
17134
f_charbig = 'just inserted'
17135
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17136
DELETE FROM t0_aux
17137
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17138
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17139
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17140
'just inserted' FROM t0_template
17141
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17142
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
17143
BEGIN
17144
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17145
f_charbig = 'updated by trigger'
17146
      WHERE f_int1 = - old.f_int1;
17147
END|
17148
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
17149
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
17150
	
17151
# check trigger-6 success: 	1
17152
DROP TRIGGER trg_1;
17153
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17154
f_int2 = CAST(f_char1 AS SIGNED INT),
17155
f_charbig = 'just inserted'
17156
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17157
DELETE FROM t0_aux
17158
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17159
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17160
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17161
'just inserted' FROM t0_template
17162
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17163
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
17164
BEGIN
17165
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17166
f_charbig = 'updated by trigger'
17167
      WHERE f_int1 = - old.f_int1;
17168
END|
17169
DELETE FROM t0_aux
17170
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
17171
	
17172
# check trigger-7 success: 	1
17173
DROP TRIGGER trg_1;
17174
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17175
f_int2 = CAST(f_char1 AS SIGNED INT),
17176
f_charbig = 'just inserted'
17177
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17178
DELETE FROM t0_aux
17179
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17180
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17181
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17182
'just inserted' FROM t0_template
17183
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17184
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
17185
BEGIN
17186
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17187
f_charbig = 'updated by trigger'
17188
      WHERE f_int1 = - old.f_int1;
17189
END|
17190
DELETE FROM t0_aux
17191
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
17192
	
17193
# check trigger-8 success: 	1
17194
DROP TRIGGER trg_1;
17195
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17196
f_int2 = CAST(f_char1 AS SIGNED INT),
17197
f_charbig = 'just inserted'
17198
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17199
DELETE FROM t0_aux
17200
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17201
DELETE FROM t1
17202
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17203
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
17204
BEGIN
17205
SET new.f_int1 = old.f_int1 + @max_row,
17206
new.f_int2 = old.f_int2 - @max_row,
17207
new.f_charbig = '####updated per update trigger####';
17208
END|
17209
UPDATE t1
17210
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
17211
f_charbig = '####updated per update statement itself####';
17212
	
17213
# check trigger-9 success: 	1
17214
DROP TRIGGER trg_2;
17215
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17216
f_int2 = CAST(f_char1 AS SIGNED INT),
17217
f_charbig = CONCAT('===',f_char1,'===');
17218
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
17219
BEGIN
17220
SET new.f_int1 = new.f_int1 + @max_row,
17221
new.f_int2 = new.f_int2 - @max_row,
17222
new.f_charbig = '####updated per update trigger####';
17223
END|
17224
UPDATE t1
17225
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
17226
f_charbig = '####updated per update statement itself####';
17227
	
17228
# check trigger-10 success: 	1
17229
DROP TRIGGER trg_2;
17230
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17231
f_int2 = CAST(f_char1 AS SIGNED INT),
17232
f_charbig = CONCAT('===',f_char1,'===');
17233
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
17234
BEGIN
17235
SET new.f_int1 = @my_max1 + @counter,
17236
new.f_int2 = @my_min2 - @counter,
17237
new.f_charbig = '####updated per insert trigger####';
17238
SET @counter = @counter + 1;
17239
END|
17240
SET @counter = 1;
17241
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
17242
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17243
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
17244
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
17245
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
17246
ORDER BY f_int1;
17247
DROP TRIGGER trg_3;
17248
	
17249
# check trigger-11 success: 	1
17250
DELETE FROM t1
17251
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
17252
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
17253
AND f_charbig = '####updated per insert trigger####';
17254
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
17255
BEGIN
17256
SET new.f_int1 = @my_max1 + @counter,
17257
new.f_int2 = @my_min2 - @counter,
17258
new.f_charbig = '####updated per insert trigger####';
17259
SET @counter = @counter + 1;
17260
END|
17261
SET @counter = 1;
17262
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
17263
INSERT INTO t1 (f_char1, f_char2, f_charbig)
17264
SELECT CAST(f_int1 AS CHAR),
17265
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
17266
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
17267
ORDER BY f_int1;
17268
DROP TRIGGER trg_3;
17269
	
17270
# check trigger-12 success: 	1
17271
DELETE FROM t1
17272
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
17273
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
17274
AND f_charbig = '####updated per insert trigger####';
17275
ANALYZE  TABLE t1;
17276
Table	Op	Msg_type	Msg_text
17277
test.t1	analyze	note	The storage engine for the table doesn't support analyze
17278
CHECK    TABLE t1 EXTENDED;
17279
Table	Op	Msg_type	Msg_text
17280
test.t1	check	note	The storage engine for the table doesn't support check
17281
CHECKSUM TABLE t1 EXTENDED;
17282
Table	Checksum
17283
test.t1	<some_value>
17284
OPTIMIZE TABLE t1;
17285
Table	Op	Msg_type	Msg_text
17286
test.t1	optimize	note	The storage engine for the table doesn't support optimize
17287
# check layout success:    1
17288
REPAIR   TABLE t1 EXTENDED;
17289
Table	Op	Msg_type	Msg_text
17290
test.t1	repair	note	The storage engine for the table doesn't support repair
17291
# check layout success:    1
17292
TRUNCATE t1;
17293
	
17294
# check TRUNCATE success: 	1
17295
# check layout success:    1
17296
# End usability test (inc/partition_check.inc)
17297
DROP TABLE t1;
17298
CREATE TABLE t1 (
17299
f_int1 INTEGER,
17300
f_int2 INTEGER,
17301
f_char1 CHAR(20),
17302
f_char2 CHAR(20),
17303
f_charbig VARCHAR(1000)
17304
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
17305
)
17306
PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
17307
(PARTITION parta VALUES LESS THAN (0),
17308
PARTITION partb VALUES LESS THAN (5),
17309
PARTITION partc VALUES LESS THAN (10),
17310
PARTITION partd VALUES LESS THAN (2147483646));
17311
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
17312
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
17313
# Start usability test (inc/partition_check.inc)
17314
create_command
17315
SHOW CREATE TABLE t1;
17316
Table	Create Table
17317
t1	CREATE TABLE `t1` (
17318
  `f_int1` int(11) DEFAULT NULL,
17319
  `f_int2` int(11) DEFAULT NULL,
17320
  `f_char1` char(20) DEFAULT NULL,
17321
  `f_char2` char(20) DEFAULT NULL,
17322
  `f_charbig` varchar(1000) DEFAULT NULL,
17323
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
17324
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
17325
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1 DIV 2) SUBPARTITION BY HASH (f_int1) SUBPARTITIONS 2 (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
17326
17327
unified filelist
17328
$MYSQLTEST_VARDIR/master-data/test/t1.frm
17329
$MYSQLTEST_VARDIR/master-data/test/t1.par
17330
17331
# check prerequisites-1 success:    1
17332
# check COUNT(*) success:    1
17333
# check MIN/MAX(f_int1) success:    1
17334
# check MIN/MAX(f_int2) success:    1
17335
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17336
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
17337
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
17338
WHERE f_int1 IN (2,3);
17339
ERROR 23000: Can't write; duplicate key in table 't1'
17340
# check prerequisites-3 success:    1
17341
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
17342
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17343
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
17344
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
17345
WHERE f_int1 IN (2,3);
17346
DELETE FROM t1 WHERE f_charbig = 'delete me';
17347
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17348
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
17349
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
17350
WHERE f_int1 IN (2,3);
17351
DELETE FROM t1 WHERE f_charbig = 'delete me';
17352
# check read via f_int1 success: 1
17353
# check read via f_int2 success: 1
17354
	
17355
# check multiple-1 success: 	1
17356
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
17357
	
17358
# check multiple-2 success: 	1
17359
INSERT INTO t1 SELECT * FROM t0_template
17360
WHERE MOD(f_int1,3) = 0;
17361
	
17362
# check multiple-3 success: 	1
17363
UPDATE t1 SET f_int1 = f_int1 + @max_row
17364
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
17365
AND @max_row_div2 + @max_row_div4;
17366
	
17367
# check multiple-4 success: 	1
17368
DELETE FROM t1
17369
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
17370
AND @max_row_div2 + @max_row_div4 + @max_row;
17371
	
17372
# check multiple-5 success: 	1
17373
SELECT COUNT(*) INTO @try_count FROM t0_template
17374
WHERE MOD(f_int1,3) = 0
17375
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
17376
SELECT COUNT(*) INTO @clash_count
17377
FROM t1 INNER JOIN t0_template USING(f_int1)
17378
WHERE MOD(f_int1,3) = 0
17379
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
17380
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
17381
INSERT INTO t1
17382
SET f_int1 = @cur_value , f_int2 = @cur_value,
17383
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
17384
f_charbig = '#SINGLE#';
17385
	
17386
# check single-1 success: 	1
17387
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
17388
INSERT INTO t1
17389
SET f_int1 = @cur_value , f_int2 = @cur_value,
17390
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
17391
f_charbig = '#SINGLE#';
17392
	
17393
# check single-2 success: 	1
17394
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
17395
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
17396
UPDATE t1 SET f_int1 = @cur_value2
17397
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
17398
	
17399
# check single-3 success: 	1
17400
SET @cur_value1= -1;
17401
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
17402
UPDATE t1 SET f_int1 = @cur_value1
17403
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
17404
	
17405
# check single-4 success: 	1
17406
SELECT MAX(f_int1) INTO @cur_value FROM t1;
17407
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
17408
	
17409
# check single-5 success: 	1
17410
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
17411
	
17412
# check single-6 success: 	1
17413
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
17414
	
17415
# check single-7 success: 	1
17416
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
17417
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
17418
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
17419
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
17420
f_charbig = '#NULL#';
17421
INSERT INTO t1
17422
SET f_int1 = NULL , f_int2 = -@max_row,
17423
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
17424
f_charbig = '#NULL#';
17425
# check null success:    1
17426
	
17427
# check null-1 success: 	1
17428
UPDATE t1 SET f_int1 = -@max_row
17429
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
17430
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
17431
	
17432
# check null-2 success: 	1
17433
UPDATE t1 SET f_int1 = NULL
17434
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
17435
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
17436
	
17437
# check null-3 success: 	1
17438
DELETE FROM t1
17439
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
17440
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
17441
	
17442
# check null-4 success: 	1
17443
DELETE FROM t1
17444
WHERE f_int1 = 0 AND f_int2 = 0
17445
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
17446
AND f_charbig = '#NULL#';
17447
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17448
SELECT f_int1, f_int1, '', '', 'was inserted'
17449
   FROM t0_template source_tab
17450
WHERE MOD(f_int1,3) = 0
17451
AND f_int1 BETWEEN @max_row_div2 AND @max_row
17452
ON DUPLICATE KEY
17453
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
17454
f_int2 = 2 * @max_row + source_tab.f_int1,
17455
f_charbig = 'was updated';
17456
	
17457
# check unique-1-a success: 	1
17458
	
17459
# check unique-1-b success: 	1
17460
DELETE FROM t1 WHERE f_charbig = 'was inserted';
17461
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17462
f_int2 = CAST(f_char1 AS SIGNED INT),
17463
f_charbig = CONCAT('===',f_char1,'===')
17464
WHERE f_charbig = 'was updated';
17465
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17466
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
17467
   FROM t0_template source_tab
17468
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
17469
	
17470
# check replace success: 	1
17471
DELETE FROM t1
17472
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
17473
DELETE FROM t1
17474
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
17475
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
17476
UPDATE t1 SET f_int2 = f_int1,
17477
f_char1 = CAST(f_int1 AS CHAR),
17478
f_char2 = CAST(f_int1 AS CHAR),
17479
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
17480
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
17481
SET AUTOCOMMIT= 0;
17482
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17483
SELECT f_int1, f_int1, '', '', 'was inserted'
17484
FROM t0_template source_tab
17485
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
17486
	
17487
# check transactions-1 success: 	1
17488
COMMIT WORK;
17489
	
17490
# check transactions-2 success: 	1
17491
ROLLBACK WORK;
17492
	
17493
# check transactions-3 success: 	1
17494
DELETE FROM t1 WHERE f_charbig = 'was inserted';
17495
COMMIT WORK;
17496
ROLLBACK WORK;
17497
	
17498
# check transactions-4 success: 	1
17499
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17500
SELECT f_int1, f_int1, '', '', 'was inserted'
17501
FROM t0_template source_tab
17502
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
17503
	
17504
# check transactions-5 success: 	1
17505
ROLLBACK WORK;
17506
	
17507
# check transactions-6 success: 	1
17508
# INFO: Storage engine used for t1 seems to be transactional.
17509
COMMIT;
17510
	
17511
# check transactions-7 success: 	1
17512
DELETE FROM t1 WHERE f_charbig = 'was inserted';
17513
COMMIT WORK;
17514
SET @@session.sql_mode = 'traditional';
17515
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
17516
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17517
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
17518
'', '', 'was inserted' FROM t0_template
17519
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
17520
ERROR 22012: Division by 0
17521
COMMIT;
17522
	
17523
# check transactions-8 success: 	1
17524
# INFO: Storage engine used for t1 seems to be able to revert
17525
#       changes made by the failing statement.
17526
SET @@session.sql_mode = '';
17527
SET AUTOCOMMIT= 1;
17528
DELETE FROM t1 WHERE f_charbig = 'was inserted';
17529
COMMIT WORK;
17530
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
17531
	
17532
# check special-1 success: 	1
17533
UPDATE t1 SET f_charbig = '';
17534
	
17535
# check special-2 success: 	1
17536
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
17537
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
17538
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
17539
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17540
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17541
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17542
'just inserted' FROM t0_template
17543
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17544
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
17545
BEGIN
17546
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17547
f_charbig = 'updated by trigger'
17548
      WHERE f_int1 = new.f_int1;
17549
END|
17550
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17551
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
17552
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17553
	
17554
# check trigger-1 success: 	1
17555
DROP TRIGGER trg_1;
17556
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17557
f_int2 = CAST(f_char1 AS SIGNED INT),
17558
f_charbig = 'just inserted'
17559
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17560
DELETE FROM t0_aux
17561
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17562
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17563
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17564
'just inserted' FROM t0_template
17565
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17566
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
17567
BEGIN
17568
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17569
f_charbig = 'updated by trigger'
17570
      WHERE f_int1 = new.f_int1;
17571
END|
17572
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17573
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
17574
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17575
	
17576
# check trigger-2 success: 	1
17577
DROP TRIGGER trg_1;
17578
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17579
f_int2 = CAST(f_char1 AS SIGNED INT),
17580
f_charbig = 'just inserted'
17581
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17582
DELETE FROM t0_aux
17583
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17584
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17585
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17586
'just inserted' FROM t0_template
17587
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17588
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
17589
BEGIN
17590
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17591
f_charbig = 'updated by trigger'
17592
      WHERE f_int1 = new.f_int1;
17593
END|
17594
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
17595
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
17596
	
17597
# check trigger-3 success: 	1
17598
DROP TRIGGER trg_1;
17599
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17600
f_int2 = CAST(f_char1 AS SIGNED INT),
17601
f_charbig = 'just inserted'
17602
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17603
DELETE FROM t0_aux
17604
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17605
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17606
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17607
'just inserted' FROM t0_template
17608
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17609
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
17610
BEGIN
17611
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17612
f_charbig = 'updated by trigger'
17613
      WHERE f_int1 = - old.f_int1;
17614
END|
17615
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
17616
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
17617
	
17618
# check trigger-4 success: 	1
17619
DROP TRIGGER trg_1;
17620
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17621
f_int2 = CAST(f_char1 AS SIGNED INT),
17622
f_charbig = 'just inserted'
17623
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17624
DELETE FROM t0_aux
17625
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17626
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17627
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17628
'just inserted' FROM t0_template
17629
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17630
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
17631
BEGIN
17632
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17633
f_charbig = 'updated by trigger'
17634
      WHERE f_int1 = new.f_int1;
17635
END|
17636
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
17637
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
17638
	
17639
# check trigger-5 success: 	1
17640
DROP TRIGGER trg_1;
17641
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17642
f_int2 = CAST(f_char1 AS SIGNED INT),
17643
f_charbig = 'just inserted'
17644
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17645
DELETE FROM t0_aux
17646
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17647
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17648
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17649
'just inserted' FROM t0_template
17650
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17651
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
17652
BEGIN
17653
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17654
f_charbig = 'updated by trigger'
17655
      WHERE f_int1 = - old.f_int1;
17656
END|
17657
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
17658
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
17659
	
17660
# check trigger-6 success: 	1
17661
DROP TRIGGER trg_1;
17662
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17663
f_int2 = CAST(f_char1 AS SIGNED INT),
17664
f_charbig = 'just inserted'
17665
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17666
DELETE FROM t0_aux
17667
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17668
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17669
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17670
'just inserted' FROM t0_template
17671
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17672
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
17673
BEGIN
17674
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17675
f_charbig = 'updated by trigger'
17676
      WHERE f_int1 = - old.f_int1;
17677
END|
17678
DELETE FROM t0_aux
17679
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
17680
	
17681
# check trigger-7 success: 	1
17682
DROP TRIGGER trg_1;
17683
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17684
f_int2 = CAST(f_char1 AS SIGNED INT),
17685
f_charbig = 'just inserted'
17686
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17687
DELETE FROM t0_aux
17688
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17689
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
17690
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
17691
'just inserted' FROM t0_template
17692
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17693
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
17694
BEGIN
17695
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
17696
f_charbig = 'updated by trigger'
17697
      WHERE f_int1 = - old.f_int1;
17698
END|
17699
DELETE FROM t0_aux
17700
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
17701
	
17702
# check trigger-8 success: 	1
17703
DROP TRIGGER trg_1;
17704
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17705
f_int2 = CAST(f_char1 AS SIGNED INT),
17706
f_charbig = 'just inserted'
17707
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
17708
DELETE FROM t0_aux
17709
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17710
DELETE FROM t1
17711
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
17712
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
17713
BEGIN
17714
SET new.f_int1 = old.f_int1 + @max_row,
17715
new.f_int2 = old.f_int2 - @max_row,
17716
new.f_charbig = '####updated per update trigger####';
17717
END|
17718
UPDATE t1
17719
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
17720
f_charbig = '####updated per update statement itself####';
17721
	
17722
# check trigger-9 success: 	1
17723
DROP TRIGGER trg_2;
17724
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17725
f_int2 = CAST(f_char1 AS SIGNED INT),
17726
f_charbig = CONCAT('===',f_char1,'===');
17727
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
17728
BEGIN
17729
SET new.f_int1 = new.f_int1 + @max_row,
17730
new.f_int2 = new.f_int2 - @max_row,
17731
new.f_charbig = '####updated per update trigger####';
17732
END|
17733
UPDATE t1
17734
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
17735
f_charbig = '####updated per update statement itself####';
17736
	
17737
# check trigger-10 success: 	1
17738
DROP TRIGGER trg_2;
17739
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17740
f_int2 = CAST(f_char1 AS SIGNED INT),
17741
f_charbig = CONCAT('===',f_char1,'===');
17742
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
17743
BEGIN
17744
SET new.f_int1 = @my_max1 + @counter,
17745
new.f_int2 = @my_min2 - @counter,
17746
new.f_charbig = '####updated per insert trigger####';
17747
SET @counter = @counter + 1;
17748
END|
17749
SET @counter = 1;
17750
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
17751
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17752
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
17753
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
17754
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
17755
ORDER BY f_int1;
17756
DROP TRIGGER trg_3;
17757
	
17758
# check trigger-11 success: 	1
17759
DELETE FROM t1
17760
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
17761
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
17762
AND f_charbig = '####updated per insert trigger####';
17763
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
17764
BEGIN
17765
SET new.f_int1 = @my_max1 + @counter,
17766
new.f_int2 = @my_min2 - @counter,
17767
new.f_charbig = '####updated per insert trigger####';
17768
SET @counter = @counter + 1;
17769
END|
17770
SET @counter = 1;
17771
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
17772
INSERT INTO t1 (f_char1, f_char2, f_charbig)
17773
SELECT CAST(f_int1 AS CHAR),
17774
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
17775
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
17776
ORDER BY f_int1;
17777
DROP TRIGGER trg_3;
17778
	
17779
# check trigger-12 success: 	1
17780
DELETE FROM t1
17781
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
17782
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
17783
AND f_charbig = '####updated per insert trigger####';
17784
ANALYZE  TABLE t1;
17785
Table	Op	Msg_type	Msg_text
17786
test.t1	analyze	note	The storage engine for the table doesn't support analyze
17787
CHECK    TABLE t1 EXTENDED;
17788
Table	Op	Msg_type	Msg_text
17789
test.t1	check	note	The storage engine for the table doesn't support check
17790
CHECKSUM TABLE t1 EXTENDED;
17791
Table	Checksum
17792
test.t1	<some_value>
17793
OPTIMIZE TABLE t1;
17794
Table	Op	Msg_type	Msg_text
17795
test.t1	optimize	note	The storage engine for the table doesn't support optimize
17796
# check layout success:    1
17797
REPAIR   TABLE t1 EXTENDED;
17798
Table	Op	Msg_type	Msg_text
17799
test.t1	repair	note	The storage engine for the table doesn't support repair
17800
# check layout success:    1
17801
TRUNCATE t1;
17802
	
17803
# check TRUNCATE success: 	1
17804
# check layout success:    1
17805
# End usability test (inc/partition_check.inc)
17806
DROP TABLE t1;
17807
CREATE TABLE t1 (
17808
f_int1 INTEGER,
17809
f_int2 INTEGER,
17810
f_char1 CHAR(20),
17811
f_char2 CHAR(20),
17812
f_charbig VARCHAR(1000)
17813
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
17814
)
17815
PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1)
17816
(PARTITION part1 VALUES LESS THAN (0)
17817
(SUBPARTITION subpart11, SUBPARTITION subpart12),
17818
PARTITION part2 VALUES LESS THAN (5)
17819
(SUBPARTITION subpart21, SUBPARTITION subpart22),
17820
PARTITION part3 VALUES LESS THAN (10)
17821
(SUBPARTITION subpart31, SUBPARTITION subpart32),
17822
PARTITION part4 VALUES LESS THAN (2147483646)
17823
(SUBPARTITION subpart41, SUBPARTITION subpart42));
17824
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
17825
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
17826
# Start usability test (inc/partition_check.inc)
17827
create_command
17828
SHOW CREATE TABLE t1;
17829
Table	Create Table
17830
t1	CREATE TABLE `t1` (
17831
  `f_int1` int(11) DEFAULT NULL,
17832
  `f_int2` int(11) DEFAULT NULL,
17833
  `f_char1` char(20) DEFAULT NULL,
17834
  `f_char2` char(20) DEFAULT NULL,
17835
  `f_charbig` varchar(1000) DEFAULT NULL,
17836
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
17837
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
17838
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) SUBPARTITION BY KEY (f_int1) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), PARTITION part2 VALUES LESS THAN (5) (SUBPARTITION subpart21 ENGINE = InnoDB, SUBPARTITION subpart22 ENGINE = InnoDB), PARTITION part3 VALUES LESS THAN (10) (SUBPARTITION subpart31 ENGINE = InnoDB, SUBPARTITION subpart32 ENGINE = InnoDB), PARTITION part4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41 ENGINE = InnoDB, SUBPARTITION subpart42 ENGINE = InnoDB)) */
17839
17840
unified filelist
17841
$MYSQLTEST_VARDIR/master-data/test/t1.frm
17842
$MYSQLTEST_VARDIR/master-data/test/t1.par
17843
17844
# check prerequisites-1 success:    1
17845
# check COUNT(*) success:    1
17846
# check MIN/MAX(f_int1) success:    1
17847
# check MIN/MAX(f_int2) success:    1
17848
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17849
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
17850
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
17851
WHERE f_int1 IN (2,3);
17852
ERROR 23000: Can't write; duplicate key in table 't1'
17853
# check prerequisites-3 success:    1
17854
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
17855
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17856
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
17857
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
17858
WHERE f_int1 IN (2,3);
17859
DELETE FROM t1 WHERE f_charbig = 'delete me';
17860
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17861
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
17862
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
17863
WHERE f_int1 IN (2,3);
17864
DELETE FROM t1 WHERE f_charbig = 'delete me';
17865
# check read via f_int1 success: 1
17866
# check read via f_int2 success: 1
17867
	
17868
# check multiple-1 success: 	1
17869
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
17870
	
17871
# check multiple-2 success: 	1
17872
INSERT INTO t1 SELECT * FROM t0_template
17873
WHERE MOD(f_int1,3) = 0;
17874
	
17875
# check multiple-3 success: 	1
17876
UPDATE t1 SET f_int1 = f_int1 + @max_row
17877
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
17878
AND @max_row_div2 + @max_row_div4;
17879
	
17880
# check multiple-4 success: 	1
17881
DELETE FROM t1
17882
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
17883
AND @max_row_div2 + @max_row_div4 + @max_row;
17884
	
17885
# check multiple-5 success: 	1
17886
SELECT COUNT(*) INTO @try_count FROM t0_template
17887
WHERE MOD(f_int1,3) = 0
17888
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
17889
SELECT COUNT(*) INTO @clash_count
17890
FROM t1 INNER JOIN t0_template USING(f_int1)
17891
WHERE MOD(f_int1,3) = 0
17892
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
17893
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
17894
INSERT INTO t1
17895
SET f_int1 = @cur_value , f_int2 = @cur_value,
17896
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
17897
f_charbig = '#SINGLE#';
17898
	
17899
# check single-1 success: 	1
17900
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
17901
INSERT INTO t1
17902
SET f_int1 = @cur_value , f_int2 = @cur_value,
17903
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
17904
f_charbig = '#SINGLE#';
17905
	
17906
# check single-2 success: 	1
17907
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
17908
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
17909
UPDATE t1 SET f_int1 = @cur_value2
17910
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
17911
	
17912
# check single-3 success: 	1
17913
SET @cur_value1= -1;
17914
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
17915
UPDATE t1 SET f_int1 = @cur_value1
17916
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
17917
	
17918
# check single-4 success: 	1
17919
SELECT MAX(f_int1) INTO @cur_value FROM t1;
17920
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
17921
	
17922
# check single-5 success: 	1
17923
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
17924
	
17925
# check single-6 success: 	1
17926
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
17927
ERROR HY000: Table has no partition for value 2147483647
17928
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
17929
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
17930
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
17931
f_charbig = '#NULL#';
17932
INSERT INTO t1
17933
SET f_int1 = NULL , f_int2 = -@max_row,
17934
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
17935
f_charbig = '#NULL#';
17936
# check null success:    1
17937
	
17938
# check null-1 success: 	1
17939
UPDATE t1 SET f_int1 = -@max_row
17940
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
17941
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
17942
	
17943
# check null-2 success: 	1
17944
UPDATE t1 SET f_int1 = NULL
17945
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
17946
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
17947
	
17948
# check null-3 success: 	1
17949
DELETE FROM t1
17950
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
17951
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
17952
	
17953
# check null-4 success: 	1
17954
DELETE FROM t1
17955
WHERE f_int1 = 0 AND f_int2 = 0
17956
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
17957
AND f_charbig = '#NULL#';
17958
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17959
SELECT f_int1, f_int1, '', '', 'was inserted'
17960
   FROM t0_template source_tab
17961
WHERE MOD(f_int1,3) = 0
17962
AND f_int1 BETWEEN @max_row_div2 AND @max_row
17963
ON DUPLICATE KEY
17964
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
17965
f_int2 = 2 * @max_row + source_tab.f_int1,
17966
f_charbig = 'was updated';
17967
	
17968
# check unique-1-a success: 	1
17969
	
17970
# check unique-1-b success: 	1
17971
DELETE FROM t1 WHERE f_charbig = 'was inserted';
17972
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
17973
f_int2 = CAST(f_char1 AS SIGNED INT),
17974
f_charbig = CONCAT('===',f_char1,'===')
17975
WHERE f_charbig = 'was updated';
17976
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17977
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
17978
   FROM t0_template source_tab
17979
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
17980
	
17981
# check replace success: 	1
17982
DELETE FROM t1
17983
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
17984
DELETE FROM t1
17985
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
17986
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
17987
UPDATE t1 SET f_int2 = f_int1,
17988
f_char1 = CAST(f_int1 AS CHAR),
17989
f_char2 = CAST(f_int1 AS CHAR),
17990
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
17991
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
17992
SET AUTOCOMMIT= 0;
17993
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
17994
SELECT f_int1, f_int1, '', '', 'was inserted'
17995
FROM t0_template source_tab
17996
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
17997
	
17998
# check transactions-1 success: 	1
17999
COMMIT WORK;
18000
	
18001
# check transactions-2 success: 	1
18002
ROLLBACK WORK;
18003
	
18004
# check transactions-3 success: 	1
18005
DELETE FROM t1 WHERE f_charbig = 'was inserted';
18006
COMMIT WORK;
18007
ROLLBACK WORK;
18008
	
18009
# check transactions-4 success: 	1
18010
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18011
SELECT f_int1, f_int1, '', '', 'was inserted'
18012
FROM t0_template source_tab
18013
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
18014
	
18015
# check transactions-5 success: 	1
18016
ROLLBACK WORK;
18017
	
18018
# check transactions-6 success: 	1
18019
# INFO: Storage engine used for t1 seems to be transactional.
18020
COMMIT;
18021
	
18022
# check transactions-7 success: 	1
18023
DELETE FROM t1 WHERE f_charbig = 'was inserted';
18024
COMMIT WORK;
18025
SET @@session.sql_mode = 'traditional';
18026
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
18027
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18028
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
18029
'', '', 'was inserted' FROM t0_template
18030
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
18031
ERROR 22012: Division by 0
18032
COMMIT;
18033
	
18034
# check transactions-8 success: 	1
18035
# INFO: Storage engine used for t1 seems to be able to revert
18036
#       changes made by the failing statement.
18037
SET @@session.sql_mode = '';
18038
SET AUTOCOMMIT= 1;
18039
DELETE FROM t1 WHERE f_charbig = 'was inserted';
18040
COMMIT WORK;
18041
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
18042
	
18043
# check special-1 success: 	1
18044
UPDATE t1 SET f_charbig = '';
18045
	
18046
# check special-2 success: 	1
18047
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
18048
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
18049
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
18050
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18051
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18052
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18053
'just inserted' FROM t0_template
18054
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18055
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
18056
BEGIN
18057
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18058
f_charbig = 'updated by trigger'
18059
      WHERE f_int1 = new.f_int1;
18060
END|
18061
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18062
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
18063
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18064
	
18065
# check trigger-1 success: 	1
18066
DROP TRIGGER trg_1;
18067
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18068
f_int2 = CAST(f_char1 AS SIGNED INT),
18069
f_charbig = 'just inserted'
18070
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18071
DELETE FROM t0_aux
18072
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18073
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18074
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18075
'just inserted' FROM t0_template
18076
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18077
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
18078
BEGIN
18079
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18080
f_charbig = 'updated by trigger'
18081
      WHERE f_int1 = new.f_int1;
18082
END|
18083
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18084
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
18085
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18086
	
18087
# check trigger-2 success: 	1
18088
DROP TRIGGER trg_1;
18089
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18090
f_int2 = CAST(f_char1 AS SIGNED INT),
18091
f_charbig = 'just inserted'
18092
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18093
DELETE FROM t0_aux
18094
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18095
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18096
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18097
'just inserted' FROM t0_template
18098
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18099
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
18100
BEGIN
18101
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18102
f_charbig = 'updated by trigger'
18103
      WHERE f_int1 = new.f_int1;
18104
END|
18105
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
18106
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
18107
	
18108
# check trigger-3 success: 	1
18109
DROP TRIGGER trg_1;
18110
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18111
f_int2 = CAST(f_char1 AS SIGNED INT),
18112
f_charbig = 'just inserted'
18113
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18114
DELETE FROM t0_aux
18115
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18116
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18117
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18118
'just inserted' FROM t0_template
18119
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18120
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
18121
BEGIN
18122
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18123
f_charbig = 'updated by trigger'
18124
      WHERE f_int1 = - old.f_int1;
18125
END|
18126
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
18127
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
18128
	
18129
# check trigger-4 success: 	1
18130
DROP TRIGGER trg_1;
18131
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18132
f_int2 = CAST(f_char1 AS SIGNED INT),
18133
f_charbig = 'just inserted'
18134
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18135
DELETE FROM t0_aux
18136
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18137
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18138
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18139
'just inserted' FROM t0_template
18140
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18141
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
18142
BEGIN
18143
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18144
f_charbig = 'updated by trigger'
18145
      WHERE f_int1 = new.f_int1;
18146
END|
18147
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
18148
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
18149
	
18150
# check trigger-5 success: 	1
18151
DROP TRIGGER trg_1;
18152
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18153
f_int2 = CAST(f_char1 AS SIGNED INT),
18154
f_charbig = 'just inserted'
18155
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18156
DELETE FROM t0_aux
18157
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18158
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18159
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18160
'just inserted' FROM t0_template
18161
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18162
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
18163
BEGIN
18164
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18165
f_charbig = 'updated by trigger'
18166
      WHERE f_int1 = - old.f_int1;
18167
END|
18168
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
18169
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
18170
	
18171
# check trigger-6 success: 	1
18172
DROP TRIGGER trg_1;
18173
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18174
f_int2 = CAST(f_char1 AS SIGNED INT),
18175
f_charbig = 'just inserted'
18176
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18177
DELETE FROM t0_aux
18178
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18179
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18180
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18181
'just inserted' FROM t0_template
18182
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18183
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
18184
BEGIN
18185
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18186
f_charbig = 'updated by trigger'
18187
      WHERE f_int1 = - old.f_int1;
18188
END|
18189
DELETE FROM t0_aux
18190
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
18191
	
18192
# check trigger-7 success: 	1
18193
DROP TRIGGER trg_1;
18194
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18195
f_int2 = CAST(f_char1 AS SIGNED INT),
18196
f_charbig = 'just inserted'
18197
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18198
DELETE FROM t0_aux
18199
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18200
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18201
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18202
'just inserted' FROM t0_template
18203
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18204
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
18205
BEGIN
18206
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18207
f_charbig = 'updated by trigger'
18208
      WHERE f_int1 = - old.f_int1;
18209
END|
18210
DELETE FROM t0_aux
18211
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
18212
	
18213
# check trigger-8 success: 	1
18214
DROP TRIGGER trg_1;
18215
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18216
f_int2 = CAST(f_char1 AS SIGNED INT),
18217
f_charbig = 'just inserted'
18218
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18219
DELETE FROM t0_aux
18220
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18221
DELETE FROM t1
18222
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18223
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
18224
BEGIN
18225
SET new.f_int1 = old.f_int1 + @max_row,
18226
new.f_int2 = old.f_int2 - @max_row,
18227
new.f_charbig = '####updated per update trigger####';
18228
END|
18229
UPDATE t1
18230
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
18231
f_charbig = '####updated per update statement itself####';
18232
	
18233
# check trigger-9 success: 	1
18234
DROP TRIGGER trg_2;
18235
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18236
f_int2 = CAST(f_char1 AS SIGNED INT),
18237
f_charbig = CONCAT('===',f_char1,'===');
18238
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
18239
BEGIN
18240
SET new.f_int1 = new.f_int1 + @max_row,
18241
new.f_int2 = new.f_int2 - @max_row,
18242
new.f_charbig = '####updated per update trigger####';
18243
END|
18244
UPDATE t1
18245
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
18246
f_charbig = '####updated per update statement itself####';
18247
	
18248
# check trigger-10 success: 	1
18249
DROP TRIGGER trg_2;
18250
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18251
f_int2 = CAST(f_char1 AS SIGNED INT),
18252
f_charbig = CONCAT('===',f_char1,'===');
18253
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
18254
BEGIN
18255
SET new.f_int1 = @my_max1 + @counter,
18256
new.f_int2 = @my_min2 - @counter,
18257
new.f_charbig = '####updated per insert trigger####';
18258
SET @counter = @counter + 1;
18259
END|
18260
SET @counter = 1;
18261
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
18262
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18263
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
18264
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
18265
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
18266
ORDER BY f_int1;
18267
DROP TRIGGER trg_3;
18268
	
18269
# check trigger-11 success: 	1
18270
DELETE FROM t1
18271
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
18272
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
18273
AND f_charbig = '####updated per insert trigger####';
18274
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
18275
BEGIN
18276
SET new.f_int1 = @my_max1 + @counter,
18277
new.f_int2 = @my_min2 - @counter,
18278
new.f_charbig = '####updated per insert trigger####';
18279
SET @counter = @counter + 1;
18280
END|
18281
SET @counter = 1;
18282
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
18283
INSERT INTO t1 (f_char1, f_char2, f_charbig)
18284
SELECT CAST(f_int1 AS CHAR),
18285
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
18286
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
18287
ORDER BY f_int1;
18288
DROP TRIGGER trg_3;
18289
	
18290
# check trigger-12 success: 	1
18291
DELETE FROM t1
18292
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
18293
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
18294
AND f_charbig = '####updated per insert trigger####';
18295
ANALYZE  TABLE t1;
18296
Table	Op	Msg_type	Msg_text
18297
test.t1	analyze	note	The storage engine for the table doesn't support analyze
18298
CHECK    TABLE t1 EXTENDED;
18299
Table	Op	Msg_type	Msg_text
18300
test.t1	check	note	The storage engine for the table doesn't support check
18301
CHECKSUM TABLE t1 EXTENDED;
18302
Table	Checksum
18303
test.t1	<some_value>
18304
OPTIMIZE TABLE t1;
18305
Table	Op	Msg_type	Msg_text
18306
test.t1	optimize	note	The storage engine for the table doesn't support optimize
18307
# check layout success:    1
18308
REPAIR   TABLE t1 EXTENDED;
18309
Table	Op	Msg_type	Msg_text
18310
test.t1	repair	note	The storage engine for the table doesn't support repair
18311
# check layout success:    1
18312
TRUNCATE t1;
18313
	
18314
# check TRUNCATE success: 	1
18315
# check layout success:    1
18316
# End usability test (inc/partition_check.inc)
18317
DROP TABLE t1;
18318
CREATE TABLE t1 (
18319
f_int1 INTEGER,
18320
f_int2 INTEGER,
18321
f_char1 CHAR(20),
18322
f_char2 CHAR(20),
18323
f_charbig VARCHAR(1000)
18324
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
18325
)
18326
PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1)
18327
(PARTITION part1 VALUES IN (0)
18328
(SUBPARTITION sp11,
18329
SUBPARTITION sp12),
18330
PARTITION part2 VALUES IN (1)
18331
(SUBPARTITION sp21,
18332
SUBPARTITION sp22),
18333
PARTITION part3 VALUES IN (2)
18334
(SUBPARTITION sp31, 
18335
SUBPARTITION sp32),
18336
PARTITION part4 VALUES IN (NULL)
18337
(SUBPARTITION sp41,
18338
SUBPARTITION sp42));
18339
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
18340
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
18341
# Start usability test (inc/partition_check.inc)
18342
create_command
18343
SHOW CREATE TABLE t1;
18344
Table	Create Table
18345
t1	CREATE TABLE `t1` (
18346
  `f_int1` int(11) DEFAULT NULL,
18347
  `f_int2` int(11) DEFAULT NULL,
18348
  `f_char1` char(20) DEFAULT NULL,
18349
  `f_char2` char(20) DEFAULT NULL,
18350
  `f_charbig` varchar(1000) DEFAULT NULL,
18351
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
18352
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
18353
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,3))) SUBPARTITION BY HASH (f_int1 + 1) (PARTITION part1 VALUES IN (0) (SUBPARTITION sp11 ENGINE = InnoDB, SUBPARTITION sp12 ENGINE = InnoDB), PARTITION part2 VALUES IN (1) (SUBPARTITION sp21 ENGINE = InnoDB, SUBPARTITION sp22 ENGINE = InnoDB), PARTITION part3 VALUES IN (2) (SUBPARTITION sp31 ENGINE = InnoDB, SUBPARTITION sp32 ENGINE = InnoDB), PARTITION part4 VALUES IN (NULL) (SUBPARTITION sp41 ENGINE = InnoDB, SUBPARTITION sp42 ENGINE = InnoDB)) */
18354
18355
unified filelist
18356
$MYSQLTEST_VARDIR/master-data/test/t1.frm
18357
$MYSQLTEST_VARDIR/master-data/test/t1.par
18358
18359
# check prerequisites-1 success:    1
18360
# check COUNT(*) success:    1
18361
# check MIN/MAX(f_int1) success:    1
18362
# check MIN/MAX(f_int2) success:    1
18363
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18364
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
18365
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
18366
WHERE f_int1 IN (2,3);
18367
ERROR 23000: Can't write; duplicate key in table 't1'
18368
# check prerequisites-3 success:    1
18369
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
18370
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18371
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
18372
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
18373
WHERE f_int1 IN (2,3);
18374
DELETE FROM t1 WHERE f_charbig = 'delete me';
18375
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18376
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
18377
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
18378
WHERE f_int1 IN (2,3);
18379
DELETE FROM t1 WHERE f_charbig = 'delete me';
18380
# check read via f_int1 success: 1
18381
# check read via f_int2 success: 1
18382
	
18383
# check multiple-1 success: 	1
18384
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
18385
	
18386
# check multiple-2 success: 	1
18387
INSERT INTO t1 SELECT * FROM t0_template
18388
WHERE MOD(f_int1,3) = 0;
18389
	
18390
# check multiple-3 success: 	1
18391
UPDATE t1 SET f_int1 = f_int1 + @max_row
18392
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
18393
AND @max_row_div2 + @max_row_div4;
18394
	
18395
# check multiple-4 success: 	1
18396
DELETE FROM t1
18397
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
18398
AND @max_row_div2 + @max_row_div4 + @max_row;
18399
	
18400
# check multiple-5 success: 	1
18401
SELECT COUNT(*) INTO @try_count FROM t0_template
18402
WHERE MOD(f_int1,3) = 0
18403
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
18404
SELECT COUNT(*) INTO @clash_count
18405
FROM t1 INNER JOIN t0_template USING(f_int1)
18406
WHERE MOD(f_int1,3) = 0
18407
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
18408
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
18409
INSERT INTO t1
18410
SET f_int1 = @cur_value , f_int2 = @cur_value,
18411
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
18412
f_charbig = '#SINGLE#';
18413
	
18414
# check single-1 success: 	1
18415
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
18416
INSERT INTO t1
18417
SET f_int1 = @cur_value , f_int2 = @cur_value,
18418
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
18419
f_charbig = '#SINGLE#';
18420
	
18421
# check single-2 success: 	1
18422
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
18423
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
18424
UPDATE t1 SET f_int1 = @cur_value2
18425
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
18426
	
18427
# check single-3 success: 	1
18428
SET @cur_value1= -1;
18429
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
18430
UPDATE t1 SET f_int1 = @cur_value1
18431
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
18432
	
18433
# check single-4 success: 	1
18434
SELECT MAX(f_int1) INTO @cur_value FROM t1;
18435
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
18436
	
18437
# check single-5 success: 	1
18438
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
18439
	
18440
# check single-6 success: 	1
18441
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
18442
	
18443
# check single-7 success: 	1
18444
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
18445
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
18446
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
18447
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
18448
f_charbig = '#NULL#';
18449
INSERT INTO t1
18450
SET f_int1 = NULL , f_int2 = -@max_row,
18451
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
18452
f_charbig = '#NULL#';
18453
# check null success:    1
18454
	
18455
# check null-1 success: 	1
18456
UPDATE t1 SET f_int1 = -@max_row
18457
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
18458
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
18459
	
18460
# check null-2 success: 	1
18461
UPDATE t1 SET f_int1 = NULL
18462
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
18463
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
18464
	
18465
# check null-3 success: 	1
18466
DELETE FROM t1
18467
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
18468
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
18469
	
18470
# check null-4 success: 	1
18471
DELETE FROM t1
18472
WHERE f_int1 = 0 AND f_int2 = 0
18473
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
18474
AND f_charbig = '#NULL#';
18475
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18476
SELECT f_int1, f_int1, '', '', 'was inserted'
18477
   FROM t0_template source_tab
18478
WHERE MOD(f_int1,3) = 0
18479
AND f_int1 BETWEEN @max_row_div2 AND @max_row
18480
ON DUPLICATE KEY
18481
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
18482
f_int2 = 2 * @max_row + source_tab.f_int1,
18483
f_charbig = 'was updated';
18484
	
18485
# check unique-1-a success: 	1
18486
	
18487
# check unique-1-b success: 	1
18488
DELETE FROM t1 WHERE f_charbig = 'was inserted';
18489
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18490
f_int2 = CAST(f_char1 AS SIGNED INT),
18491
f_charbig = CONCAT('===',f_char1,'===')
18492
WHERE f_charbig = 'was updated';
18493
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18494
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
18495
   FROM t0_template source_tab
18496
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
18497
	
18498
# check replace success: 	1
18499
DELETE FROM t1
18500
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
18501
DELETE FROM t1
18502
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
18503
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
18504
UPDATE t1 SET f_int2 = f_int1,
18505
f_char1 = CAST(f_int1 AS CHAR),
18506
f_char2 = CAST(f_int1 AS CHAR),
18507
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
18508
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
18509
SET AUTOCOMMIT= 0;
18510
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18511
SELECT f_int1, f_int1, '', '', 'was inserted'
18512
FROM t0_template source_tab
18513
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
18514
	
18515
# check transactions-1 success: 	1
18516
COMMIT WORK;
18517
	
18518
# check transactions-2 success: 	1
18519
ROLLBACK WORK;
18520
	
18521
# check transactions-3 success: 	1
18522
DELETE FROM t1 WHERE f_charbig = 'was inserted';
18523
COMMIT WORK;
18524
ROLLBACK WORK;
18525
	
18526
# check transactions-4 success: 	1
18527
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18528
SELECT f_int1, f_int1, '', '', 'was inserted'
18529
FROM t0_template source_tab
18530
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
18531
	
18532
# check transactions-5 success: 	1
18533
ROLLBACK WORK;
18534
	
18535
# check transactions-6 success: 	1
18536
# INFO: Storage engine used for t1 seems to be transactional.
18537
COMMIT;
18538
	
18539
# check transactions-7 success: 	1
18540
DELETE FROM t1 WHERE f_charbig = 'was inserted';
18541
COMMIT WORK;
18542
SET @@session.sql_mode = 'traditional';
18543
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
18544
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18545
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
18546
'', '', 'was inserted' FROM t0_template
18547
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
18548
ERROR 22012: Division by 0
18549
COMMIT;
18550
	
18551
# check transactions-8 success: 	1
18552
# INFO: Storage engine used for t1 seems to be able to revert
18553
#       changes made by the failing statement.
18554
SET @@session.sql_mode = '';
18555
SET AUTOCOMMIT= 1;
18556
DELETE FROM t1 WHERE f_charbig = 'was inserted';
18557
COMMIT WORK;
18558
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
18559
	
18560
# check special-1 success: 	1
18561
UPDATE t1 SET f_charbig = '';
18562
	
18563
# check special-2 success: 	1
18564
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
18565
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
18566
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
18567
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18568
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18569
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18570
'just inserted' FROM t0_template
18571
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18572
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
18573
BEGIN
18574
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18575
f_charbig = 'updated by trigger'
18576
      WHERE f_int1 = new.f_int1;
18577
END|
18578
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18579
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
18580
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18581
	
18582
# check trigger-1 success: 	1
18583
DROP TRIGGER trg_1;
18584
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18585
f_int2 = CAST(f_char1 AS SIGNED INT),
18586
f_charbig = 'just inserted'
18587
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18588
DELETE FROM t0_aux
18589
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18590
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18591
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18592
'just inserted' FROM t0_template
18593
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18594
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
18595
BEGIN
18596
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18597
f_charbig = 'updated by trigger'
18598
      WHERE f_int1 = new.f_int1;
18599
END|
18600
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18601
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
18602
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18603
	
18604
# check trigger-2 success: 	1
18605
DROP TRIGGER trg_1;
18606
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18607
f_int2 = CAST(f_char1 AS SIGNED INT),
18608
f_charbig = 'just inserted'
18609
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18610
DELETE FROM t0_aux
18611
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18612
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18613
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18614
'just inserted' FROM t0_template
18615
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18616
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
18617
BEGIN
18618
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18619
f_charbig = 'updated by trigger'
18620
      WHERE f_int1 = new.f_int1;
18621
END|
18622
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
18623
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
18624
	
18625
# check trigger-3 success: 	1
18626
DROP TRIGGER trg_1;
18627
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18628
f_int2 = CAST(f_char1 AS SIGNED INT),
18629
f_charbig = 'just inserted'
18630
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18631
DELETE FROM t0_aux
18632
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18633
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18634
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18635
'just inserted' FROM t0_template
18636
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18637
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
18638
BEGIN
18639
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18640
f_charbig = 'updated by trigger'
18641
      WHERE f_int1 = - old.f_int1;
18642
END|
18643
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
18644
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
18645
	
18646
# check trigger-4 success: 	1
18647
DROP TRIGGER trg_1;
18648
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18649
f_int2 = CAST(f_char1 AS SIGNED INT),
18650
f_charbig = 'just inserted'
18651
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18652
DELETE FROM t0_aux
18653
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18654
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18655
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18656
'just inserted' FROM t0_template
18657
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18658
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
18659
BEGIN
18660
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18661
f_charbig = 'updated by trigger'
18662
      WHERE f_int1 = new.f_int1;
18663
END|
18664
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
18665
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
18666
	
18667
# check trigger-5 success: 	1
18668
DROP TRIGGER trg_1;
18669
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18670
f_int2 = CAST(f_char1 AS SIGNED INT),
18671
f_charbig = 'just inserted'
18672
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18673
DELETE FROM t0_aux
18674
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18675
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18676
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18677
'just inserted' FROM t0_template
18678
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18679
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
18680
BEGIN
18681
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18682
f_charbig = 'updated by trigger'
18683
      WHERE f_int1 = - old.f_int1;
18684
END|
18685
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
18686
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
18687
	
18688
# check trigger-6 success: 	1
18689
DROP TRIGGER trg_1;
18690
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18691
f_int2 = CAST(f_char1 AS SIGNED INT),
18692
f_charbig = 'just inserted'
18693
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18694
DELETE FROM t0_aux
18695
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18696
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18697
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18698
'just inserted' FROM t0_template
18699
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18700
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
18701
BEGIN
18702
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18703
f_charbig = 'updated by trigger'
18704
      WHERE f_int1 = - old.f_int1;
18705
END|
18706
DELETE FROM t0_aux
18707
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
18708
	
18709
# check trigger-7 success: 	1
18710
DROP TRIGGER trg_1;
18711
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18712
f_int2 = CAST(f_char1 AS SIGNED INT),
18713
f_charbig = 'just inserted'
18714
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18715
DELETE FROM t0_aux
18716
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18717
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
18718
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
18719
'just inserted' FROM t0_template
18720
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18721
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
18722
BEGIN
18723
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
18724
f_charbig = 'updated by trigger'
18725
      WHERE f_int1 = - old.f_int1;
18726
END|
18727
DELETE FROM t0_aux
18728
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
18729
	
18730
# check trigger-8 success: 	1
18731
DROP TRIGGER trg_1;
18732
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18733
f_int2 = CAST(f_char1 AS SIGNED INT),
18734
f_charbig = 'just inserted'
18735
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
18736
DELETE FROM t0_aux
18737
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18738
DELETE FROM t1
18739
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
18740
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
18741
BEGIN
18742
SET new.f_int1 = old.f_int1 + @max_row,
18743
new.f_int2 = old.f_int2 - @max_row,
18744
new.f_charbig = '####updated per update trigger####';
18745
END|
18746
UPDATE t1
18747
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
18748
f_charbig = '####updated per update statement itself####';
18749
	
18750
# check trigger-9 success: 	1
18751
DROP TRIGGER trg_2;
18752
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18753
f_int2 = CAST(f_char1 AS SIGNED INT),
18754
f_charbig = CONCAT('===',f_char1,'===');
18755
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
18756
BEGIN
18757
SET new.f_int1 = new.f_int1 + @max_row,
18758
new.f_int2 = new.f_int2 - @max_row,
18759
new.f_charbig = '####updated per update trigger####';
18760
END|
18761
UPDATE t1
18762
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
18763
f_charbig = '####updated per update statement itself####';
18764
	
18765
# check trigger-10 success: 	1
18766
DROP TRIGGER trg_2;
18767
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18768
f_int2 = CAST(f_char1 AS SIGNED INT),
18769
f_charbig = CONCAT('===',f_char1,'===');
18770
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
18771
BEGIN
18772
SET new.f_int1 = @my_max1 + @counter,
18773
new.f_int2 = @my_min2 - @counter,
18774
new.f_charbig = '####updated per insert trigger####';
18775
SET @counter = @counter + 1;
18776
END|
18777
SET @counter = 1;
18778
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
18779
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18780
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
18781
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
18782
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
18783
ORDER BY f_int1;
18784
DROP TRIGGER trg_3;
18785
	
18786
# check trigger-11 success: 	1
18787
DELETE FROM t1
18788
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
18789
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
18790
AND f_charbig = '####updated per insert trigger####';
18791
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
18792
BEGIN
18793
SET new.f_int1 = @my_max1 + @counter,
18794
new.f_int2 = @my_min2 - @counter,
18795
new.f_charbig = '####updated per insert trigger####';
18796
SET @counter = @counter + 1;
18797
END|
18798
SET @counter = 1;
18799
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
18800
INSERT INTO t1 (f_char1, f_char2, f_charbig)
18801
SELECT CAST(f_int1 AS CHAR),
18802
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
18803
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
18804
ORDER BY f_int1;
18805
DROP TRIGGER trg_3;
18806
	
18807
# check trigger-12 success: 	1
18808
DELETE FROM t1
18809
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
18810
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
18811
AND f_charbig = '####updated per insert trigger####';
18812
ANALYZE  TABLE t1;
18813
Table	Op	Msg_type	Msg_text
18814
test.t1	analyze	note	The storage engine for the table doesn't support analyze
18815
CHECK    TABLE t1 EXTENDED;
18816
Table	Op	Msg_type	Msg_text
18817
test.t1	check	note	The storage engine for the table doesn't support check
18818
CHECKSUM TABLE t1 EXTENDED;
18819
Table	Checksum
18820
test.t1	<some_value>
18821
OPTIMIZE TABLE t1;
18822
Table	Op	Msg_type	Msg_text
18823
test.t1	optimize	note	The storage engine for the table doesn't support optimize
18824
# check layout success:    1
18825
REPAIR   TABLE t1 EXTENDED;
18826
Table	Op	Msg_type	Msg_text
18827
test.t1	repair	note	The storage engine for the table doesn't support repair
18828
# check layout success:    1
18829
TRUNCATE t1;
18830
	
18831
# check TRUNCATE success: 	1
18832
# check layout success:    1
18833
# End usability test (inc/partition_check.inc)
18834
DROP TABLE t1;
18835
CREATE TABLE t1 (
18836
f_int1 INTEGER,
18837
f_int2 INTEGER,
18838
f_char1 CHAR(20),
18839
f_char2 CHAR(20),
18840
f_charbig VARCHAR(1000)
18841
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
18842
)
18843
PARTITION BY LIST(ABS(MOD(f_int1,2)))
18844
SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3
18845
(PARTITION part1 VALUES IN (0),
18846
PARTITION part2 VALUES IN (1),
18847
PARTITION part3 VALUES IN (NULL));
18848
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
18849
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
18850
# Start usability test (inc/partition_check.inc)
18851
create_command
18852
SHOW CREATE TABLE t1;
18853
Table	Create Table
18854
t1	CREATE TABLE `t1` (
18855
  `f_int1` int(11) DEFAULT NULL,
18856
  `f_int2` int(11) DEFAULT NULL,
18857
  `f_char1` char(20) DEFAULT NULL,
18858
  `f_char2` char(20) DEFAULT NULL,
18859
  `f_charbig` varchar(1000) DEFAULT NULL,
18860
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
18861
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
18862
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) SUBPARTITION BY KEY (f_int1) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
18863
18864
unified filelist
18865
$MYSQLTEST_VARDIR/master-data/test/t1.frm
18866
$MYSQLTEST_VARDIR/master-data/test/t1.par
18867
18868
# check prerequisites-1 success:    1
18869
# check COUNT(*) success:    1
18870
# check MIN/MAX(f_int1) success:    1
18871
# check MIN/MAX(f_int2) success:    1
18872
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18873
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
18874
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
18875
WHERE f_int1 IN (2,3);
18876
ERROR 23000: Can't write; duplicate key in table 't1'
18877
# check prerequisites-3 success:    1
18878
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
18879
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18880
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
18881
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
18882
WHERE f_int1 IN (2,3);
18883
DELETE FROM t1 WHERE f_charbig = 'delete me';
18884
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18885
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
18886
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
18887
WHERE f_int1 IN (2,3);
18888
DELETE FROM t1 WHERE f_charbig = 'delete me';
18889
# check read via f_int1 success: 1
18890
# check read via f_int2 success: 1
18891
	
18892
# check multiple-1 success: 	1
18893
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
18894
	
18895
# check multiple-2 success: 	1
18896
INSERT INTO t1 SELECT * FROM t0_template
18897
WHERE MOD(f_int1,3) = 0;
18898
	
18899
# check multiple-3 success: 	1
18900
UPDATE t1 SET f_int1 = f_int1 + @max_row
18901
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
18902
AND @max_row_div2 + @max_row_div4;
18903
	
18904
# check multiple-4 success: 	1
18905
DELETE FROM t1
18906
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
18907
AND @max_row_div2 + @max_row_div4 + @max_row;
18908
	
18909
# check multiple-5 success: 	1
18910
SELECT COUNT(*) INTO @try_count FROM t0_template
18911
WHERE MOD(f_int1,3) = 0
18912
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
18913
SELECT COUNT(*) INTO @clash_count
18914
FROM t1 INNER JOIN t0_template USING(f_int1)
18915
WHERE MOD(f_int1,3) = 0
18916
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
18917
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
18918
INSERT INTO t1
18919
SET f_int1 = @cur_value , f_int2 = @cur_value,
18920
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
18921
f_charbig = '#SINGLE#';
18922
	
18923
# check single-1 success: 	1
18924
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
18925
INSERT INTO t1
18926
SET f_int1 = @cur_value , f_int2 = @cur_value,
18927
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
18928
f_charbig = '#SINGLE#';
18929
	
18930
# check single-2 success: 	1
18931
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
18932
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
18933
UPDATE t1 SET f_int1 = @cur_value2
18934
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
18935
	
18936
# check single-3 success: 	1
18937
SET @cur_value1= -1;
18938
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
18939
UPDATE t1 SET f_int1 = @cur_value1
18940
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
18941
	
18942
# check single-4 success: 	1
18943
SELECT MAX(f_int1) INTO @cur_value FROM t1;
18944
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
18945
	
18946
# check single-5 success: 	1
18947
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
18948
	
18949
# check single-6 success: 	1
18950
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
18951
	
18952
# check single-7 success: 	1
18953
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
18954
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
18955
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
18956
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
18957
f_charbig = '#NULL#';
18958
INSERT INTO t1
18959
SET f_int1 = NULL , f_int2 = -@max_row,
18960
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
18961
f_charbig = '#NULL#';
18962
# check null success:    1
18963
	
18964
# check null-1 success: 	1
18965
UPDATE t1 SET f_int1 = -@max_row
18966
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
18967
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
18968
	
18969
# check null-2 success: 	1
18970
UPDATE t1 SET f_int1 = NULL
18971
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
18972
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
18973
	
18974
# check null-3 success: 	1
18975
DELETE FROM t1
18976
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
18977
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
18978
	
18979
# check null-4 success: 	1
18980
DELETE FROM t1
18981
WHERE f_int1 = 0 AND f_int2 = 0
18982
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
18983
AND f_charbig = '#NULL#';
18984
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
18985
SELECT f_int1, f_int1, '', '', 'was inserted'
18986
   FROM t0_template source_tab
18987
WHERE MOD(f_int1,3) = 0
18988
AND f_int1 BETWEEN @max_row_div2 AND @max_row
18989
ON DUPLICATE KEY
18990
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
18991
f_int2 = 2 * @max_row + source_tab.f_int1,
18992
f_charbig = 'was updated';
18993
	
18994
# check unique-1-a success: 	1
18995
	
18996
# check unique-1-b success: 	1
18997
DELETE FROM t1 WHERE f_charbig = 'was inserted';
18998
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
18999
f_int2 = CAST(f_char1 AS SIGNED INT),
19000
f_charbig = CONCAT('===',f_char1,'===')
19001
WHERE f_charbig = 'was updated';
19002
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19003
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
19004
   FROM t0_template source_tab
19005
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
19006
	
19007
# check replace success: 	1
19008
DELETE FROM t1
19009
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
19010
DELETE FROM t1
19011
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
19012
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
19013
UPDATE t1 SET f_int2 = f_int1,
19014
f_char1 = CAST(f_int1 AS CHAR),
19015
f_char2 = CAST(f_int1 AS CHAR),
19016
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
19017
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
19018
SET AUTOCOMMIT= 0;
19019
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19020
SELECT f_int1, f_int1, '', '', 'was inserted'
19021
FROM t0_template source_tab
19022
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
19023
	
19024
# check transactions-1 success: 	1
19025
COMMIT WORK;
19026
	
19027
# check transactions-2 success: 	1
19028
ROLLBACK WORK;
19029
	
19030
# check transactions-3 success: 	1
19031
DELETE FROM t1 WHERE f_charbig = 'was inserted';
19032
COMMIT WORK;
19033
ROLLBACK WORK;
19034
	
19035
# check transactions-4 success: 	1
19036
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19037
SELECT f_int1, f_int1, '', '', 'was inserted'
19038
FROM t0_template source_tab
19039
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
19040
	
19041
# check transactions-5 success: 	1
19042
ROLLBACK WORK;
19043
	
19044
# check transactions-6 success: 	1
19045
# INFO: Storage engine used for t1 seems to be transactional.
19046
COMMIT;
19047
	
19048
# check transactions-7 success: 	1
19049
DELETE FROM t1 WHERE f_charbig = 'was inserted';
19050
COMMIT WORK;
19051
SET @@session.sql_mode = 'traditional';
19052
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
19053
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19054
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
19055
'', '', 'was inserted' FROM t0_template
19056
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
19057
ERROR 22012: Division by 0
19058
COMMIT;
19059
	
19060
# check transactions-8 success: 	1
19061
# INFO: Storage engine used for t1 seems to be able to revert
19062
#       changes made by the failing statement.
19063
SET @@session.sql_mode = '';
19064
SET AUTOCOMMIT= 1;
19065
DELETE FROM t1 WHERE f_charbig = 'was inserted';
19066
COMMIT WORK;
19067
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
19068
	
19069
# check special-1 success: 	1
19070
UPDATE t1 SET f_charbig = '';
19071
	
19072
# check special-2 success: 	1
19073
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
19074
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
19075
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
19076
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19077
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19078
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19079
'just inserted' FROM t0_template
19080
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19081
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
19082
BEGIN
19083
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19084
f_charbig = 'updated by trigger'
19085
      WHERE f_int1 = new.f_int1;
19086
END|
19087
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19088
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
19089
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19090
	
19091
# check trigger-1 success: 	1
19092
DROP TRIGGER trg_1;
19093
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19094
f_int2 = CAST(f_char1 AS SIGNED INT),
19095
f_charbig = 'just inserted'
19096
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19097
DELETE FROM t0_aux
19098
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19099
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19100
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19101
'just inserted' FROM t0_template
19102
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19103
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
19104
BEGIN
19105
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19106
f_charbig = 'updated by trigger'
19107
      WHERE f_int1 = new.f_int1;
19108
END|
19109
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19110
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
19111
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19112
	
19113
# check trigger-2 success: 	1
19114
DROP TRIGGER trg_1;
19115
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19116
f_int2 = CAST(f_char1 AS SIGNED INT),
19117
f_charbig = 'just inserted'
19118
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19119
DELETE FROM t0_aux
19120
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19121
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19122
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19123
'just inserted' FROM t0_template
19124
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19125
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
19126
BEGIN
19127
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19128
f_charbig = 'updated by trigger'
19129
      WHERE f_int1 = new.f_int1;
19130
END|
19131
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
19132
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
19133
	
19134
# check trigger-3 success: 	1
19135
DROP TRIGGER trg_1;
19136
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19137
f_int2 = CAST(f_char1 AS SIGNED INT),
19138
f_charbig = 'just inserted'
19139
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19140
DELETE FROM t0_aux
19141
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19142
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19143
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19144
'just inserted' FROM t0_template
19145
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19146
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
19147
BEGIN
19148
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19149
f_charbig = 'updated by trigger'
19150
      WHERE f_int1 = - old.f_int1;
19151
END|
19152
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
19153
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
19154
	
19155
# check trigger-4 success: 	1
19156
DROP TRIGGER trg_1;
19157
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19158
f_int2 = CAST(f_char1 AS SIGNED INT),
19159
f_charbig = 'just inserted'
19160
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19161
DELETE FROM t0_aux
19162
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19163
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19164
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19165
'just inserted' FROM t0_template
19166
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19167
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
19168
BEGIN
19169
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19170
f_charbig = 'updated by trigger'
19171
      WHERE f_int1 = new.f_int1;
19172
END|
19173
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
19174
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
19175
	
19176
# check trigger-5 success: 	1
19177
DROP TRIGGER trg_1;
19178
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19179
f_int2 = CAST(f_char1 AS SIGNED INT),
19180
f_charbig = 'just inserted'
19181
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19182
DELETE FROM t0_aux
19183
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19184
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19185
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19186
'just inserted' FROM t0_template
19187
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19188
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
19189
BEGIN
19190
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19191
f_charbig = 'updated by trigger'
19192
      WHERE f_int1 = - old.f_int1;
19193
END|
19194
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
19195
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
19196
	
19197
# check trigger-6 success: 	1
19198
DROP TRIGGER trg_1;
19199
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19200
f_int2 = CAST(f_char1 AS SIGNED INT),
19201
f_charbig = 'just inserted'
19202
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19203
DELETE FROM t0_aux
19204
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19205
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19206
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19207
'just inserted' FROM t0_template
19208
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19209
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
19210
BEGIN
19211
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19212
f_charbig = 'updated by trigger'
19213
      WHERE f_int1 = - old.f_int1;
19214
END|
19215
DELETE FROM t0_aux
19216
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
19217
	
19218
# check trigger-7 success: 	1
19219
DROP TRIGGER trg_1;
19220
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19221
f_int2 = CAST(f_char1 AS SIGNED INT),
19222
f_charbig = 'just inserted'
19223
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19224
DELETE FROM t0_aux
19225
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19226
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19227
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19228
'just inserted' FROM t0_template
19229
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19230
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
19231
BEGIN
19232
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19233
f_charbig = 'updated by trigger'
19234
      WHERE f_int1 = - old.f_int1;
19235
END|
19236
DELETE FROM t0_aux
19237
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
19238
	
19239
# check trigger-8 success: 	1
19240
DROP TRIGGER trg_1;
19241
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19242
f_int2 = CAST(f_char1 AS SIGNED INT),
19243
f_charbig = 'just inserted'
19244
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19245
DELETE FROM t0_aux
19246
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19247
DELETE FROM t1
19248
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19249
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
19250
BEGIN
19251
SET new.f_int1 = old.f_int1 + @max_row,
19252
new.f_int2 = old.f_int2 - @max_row,
19253
new.f_charbig = '####updated per update trigger####';
19254
END|
19255
UPDATE t1
19256
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
19257
f_charbig = '####updated per update statement itself####';
19258
	
19259
# check trigger-9 success: 	1
19260
DROP TRIGGER trg_2;
19261
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19262
f_int2 = CAST(f_char1 AS SIGNED INT),
19263
f_charbig = CONCAT('===',f_char1,'===');
19264
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
19265
BEGIN
19266
SET new.f_int1 = new.f_int1 + @max_row,
19267
new.f_int2 = new.f_int2 - @max_row,
19268
new.f_charbig = '####updated per update trigger####';
19269
END|
19270
UPDATE t1
19271
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
19272
f_charbig = '####updated per update statement itself####';
19273
	
19274
# check trigger-10 success: 	1
19275
DROP TRIGGER trg_2;
19276
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19277
f_int2 = CAST(f_char1 AS SIGNED INT),
19278
f_charbig = CONCAT('===',f_char1,'===');
19279
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
19280
BEGIN
19281
SET new.f_int1 = @my_max1 + @counter,
19282
new.f_int2 = @my_min2 - @counter,
19283
new.f_charbig = '####updated per insert trigger####';
19284
SET @counter = @counter + 1;
19285
END|
19286
SET @counter = 1;
19287
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
19288
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19289
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
19290
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
19291
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
19292
ORDER BY f_int1;
19293
DROP TRIGGER trg_3;
19294
	
19295
# check trigger-11 success: 	1
19296
DELETE FROM t1
19297
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
19298
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
19299
AND f_charbig = '####updated per insert trigger####';
19300
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
19301
BEGIN
19302
SET new.f_int1 = @my_max1 + @counter,
19303
new.f_int2 = @my_min2 - @counter,
19304
new.f_charbig = '####updated per insert trigger####';
19305
SET @counter = @counter + 1;
19306
END|
19307
SET @counter = 1;
19308
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
19309
INSERT INTO t1 (f_char1, f_char2, f_charbig)
19310
SELECT CAST(f_int1 AS CHAR),
19311
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
19312
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
19313
ORDER BY f_int1;
19314
DROP TRIGGER trg_3;
19315
	
19316
# check trigger-12 success: 	1
19317
DELETE FROM t1
19318
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
19319
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
19320
AND f_charbig = '####updated per insert trigger####';
19321
ANALYZE  TABLE t1;
19322
Table	Op	Msg_type	Msg_text
19323
test.t1	analyze	note	The storage engine for the table doesn't support analyze
19324
CHECK    TABLE t1 EXTENDED;
19325
Table	Op	Msg_type	Msg_text
19326
test.t1	check	note	The storage engine for the table doesn't support check
19327
CHECKSUM TABLE t1 EXTENDED;
19328
Table	Checksum
19329
test.t1	<some_value>
19330
OPTIMIZE TABLE t1;
19331
Table	Op	Msg_type	Msg_text
19332
test.t1	optimize	note	The storage engine for the table doesn't support optimize
19333
# check layout success:    1
19334
REPAIR   TABLE t1 EXTENDED;
19335
Table	Op	Msg_type	Msg_text
19336
test.t1	repair	note	The storage engine for the table doesn't support repair
19337
# check layout success:    1
19338
TRUNCATE t1;
19339
	
19340
# check TRUNCATE success: 	1
19341
# check layout success:    1
19342
# End usability test (inc/partition_check.inc)
19343
DROP TABLE t1;
19344
#------------------------------------------------------------------------
19345
#  3   Tables with PRIMARY KEY and/or UNIQUE INDEXes
19346
#        The partitioning function contains two columns.
19347
#------------------------------------------------------------------------
19348
#  3.3 PRIMARY KEY and UNIQUE INDEX consisting of two columns
19349
DROP TABLE IF EXISTS t1;
19350
CREATE TABLE t1 (
19351
f_int1 INTEGER,
19352
f_int2 INTEGER,
19353
f_char1 CHAR(20),
19354
f_char2 CHAR(20),
19355
f_charbig VARCHAR(1000)
19356
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
19357
)
19358
PARTITION BY HASH(f_int1 + f_int2) PARTITIONS 2;
19359
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
19360
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
19361
# Start usability test (inc/partition_check.inc)
19362
create_command
19363
SHOW CREATE TABLE t1;
19364
Table	Create Table
19365
t1	CREATE TABLE `t1` (
19366
  `f_int1` int(11) NOT NULL DEFAULT '0',
19367
  `f_int2` int(11) NOT NULL DEFAULT '0',
19368
  `f_char1` char(20) DEFAULT NULL,
19369
  `f_char2` char(20) DEFAULT NULL,
19370
  `f_charbig` varchar(1000) DEFAULT NULL,
19371
  PRIMARY KEY (`f_int2`,`f_int1`),
19372
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
19373
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (f_int1 + f_int2) PARTITIONS 2  */
19374
19375
unified filelist
19376
$MYSQLTEST_VARDIR/master-data/test/t1.frm
19377
$MYSQLTEST_VARDIR/master-data/test/t1.par
19378
19379
# check prerequisites-1 success:    1
19380
# check COUNT(*) success:    1
19381
# check MIN/MAX(f_int1) success:    1
19382
# check MIN/MAX(f_int2) success:    1
19383
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19384
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
19385
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
19386
WHERE f_int1 IN (2,3);
19387
ERROR 23000: Can't write; duplicate key in table 't1'
19388
# check prerequisites-3 success:    1
19389
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
19390
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19391
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
19392
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
19393
WHERE f_int1 IN (2,3);
19394
DELETE FROM t1 WHERE f_charbig = 'delete me';
19395
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19396
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
19397
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
19398
WHERE f_int1 IN (2,3);
19399
DELETE FROM t1 WHERE f_charbig = 'delete me';
19400
# check read via f_int1 success: 1
19401
# check read via f_int2 success: 1
19402
	
19403
# check multiple-1 success: 	1
19404
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
19405
	
19406
# check multiple-2 success: 	1
19407
INSERT INTO t1 SELECT * FROM t0_template
19408
WHERE MOD(f_int1,3) = 0;
19409
	
19410
# check multiple-3 success: 	1
19411
UPDATE t1 SET f_int1 = f_int1 + @max_row
19412
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
19413
AND @max_row_div2 + @max_row_div4;
19414
	
19415
# check multiple-4 success: 	1
19416
DELETE FROM t1
19417
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
19418
AND @max_row_div2 + @max_row_div4 + @max_row;
19419
	
19420
# check multiple-5 success: 	1
19421
SELECT COUNT(*) INTO @try_count FROM t0_template
19422
WHERE MOD(f_int1,3) = 0
19423
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
19424
SELECT COUNT(*) INTO @clash_count
19425
FROM t1 INNER JOIN t0_template USING(f_int1)
19426
WHERE MOD(f_int1,3) = 0
19427
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
19428
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
19429
INSERT INTO t1
19430
SET f_int1 = @cur_value , f_int2 = @cur_value,
19431
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
19432
f_charbig = '#SINGLE#';
19433
	
19434
# check single-1 success: 	1
19435
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
19436
INSERT INTO t1
19437
SET f_int1 = @cur_value , f_int2 = @cur_value,
19438
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
19439
f_charbig = '#SINGLE#';
19440
	
19441
# check single-2 success: 	1
19442
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
19443
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
19444
UPDATE t1 SET f_int1 = @cur_value2
19445
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
19446
	
19447
# check single-3 success: 	1
19448
SET @cur_value1= -1;
19449
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
19450
UPDATE t1 SET f_int1 = @cur_value1
19451
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
19452
	
19453
# check single-4 success: 	1
19454
SELECT MAX(f_int1) INTO @cur_value FROM t1;
19455
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
19456
	
19457
# check single-5 success: 	1
19458
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
19459
	
19460
# check single-6 success: 	1
19461
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
19462
	
19463
# check single-7 success: 	1
19464
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
19465
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
19466
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
19467
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
19468
f_charbig = '#NULL#';
19469
INSERT INTO t1
19470
SET f_int1 = NULL , f_int2 = -@max_row,
19471
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
19472
f_charbig = '#NULL#';
19473
ERROR 23000: Column 'f_int1' cannot be null
19474
# check null success:    1
19475
DELETE FROM t1
19476
WHERE f_int1 = 0 AND f_int2 = 0
19477
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
19478
AND f_charbig = '#NULL#';
19479
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19480
SELECT f_int1, f_int1, '', '', 'was inserted'
19481
   FROM t0_template source_tab
19482
WHERE MOD(f_int1,3) = 0
19483
AND f_int1 BETWEEN @max_row_div2 AND @max_row
19484
ON DUPLICATE KEY
19485
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
19486
f_int2 = 2 * @max_row + source_tab.f_int1,
19487
f_charbig = 'was updated';
19488
	
19489
# check unique-1-a success: 	1
19490
	
19491
# check unique-1-b success: 	1
19492
DELETE FROM t1 WHERE f_charbig = 'was inserted';
19493
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19494
f_int2 = CAST(f_char1 AS SIGNED INT),
19495
f_charbig = CONCAT('===',f_char1,'===')
19496
WHERE f_charbig = 'was updated';
19497
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19498
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
19499
   FROM t0_template source_tab
19500
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
19501
	
19502
# check replace success: 	1
19503
DELETE FROM t1
19504
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
19505
DELETE FROM t1
19506
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
19507
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
19508
UPDATE t1 SET f_int2 = f_int1,
19509
f_char1 = CAST(f_int1 AS CHAR),
19510
f_char2 = CAST(f_int1 AS CHAR),
19511
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
19512
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
19513
SET AUTOCOMMIT= 0;
19514
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19515
SELECT f_int1, f_int1, '', '', 'was inserted'
19516
FROM t0_template source_tab
19517
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
19518
	
19519
# check transactions-1 success: 	1
19520
COMMIT WORK;
19521
	
19522
# check transactions-2 success: 	1
19523
ROLLBACK WORK;
19524
	
19525
# check transactions-3 success: 	1
19526
DELETE FROM t1 WHERE f_charbig = 'was inserted';
19527
COMMIT WORK;
19528
ROLLBACK WORK;
19529
	
19530
# check transactions-4 success: 	1
19531
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19532
SELECT f_int1, f_int1, '', '', 'was inserted'
19533
FROM t0_template source_tab
19534
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
19535
	
19536
# check transactions-5 success: 	1
19537
ROLLBACK WORK;
19538
	
19539
# check transactions-6 success: 	1
19540
# INFO: Storage engine used for t1 seems to be transactional.
19541
COMMIT;
19542
	
19543
# check transactions-7 success: 	1
19544
DELETE FROM t1 WHERE f_charbig = 'was inserted';
19545
COMMIT WORK;
19546
SET @@session.sql_mode = 'traditional';
19547
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
19548
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19549
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
19550
'', '', 'was inserted' FROM t0_template
19551
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
19552
ERROR 22012: Division by 0
19553
COMMIT;
19554
	
19555
# check transactions-8 success: 	1
19556
# INFO: Storage engine used for t1 seems to be able to revert
19557
#       changes made by the failing statement.
19558
SET @@session.sql_mode = '';
19559
SET AUTOCOMMIT= 1;
19560
DELETE FROM t1 WHERE f_charbig = 'was inserted';
19561
COMMIT WORK;
19562
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
19563
	
19564
# check special-1 success: 	1
19565
UPDATE t1 SET f_charbig = '';
19566
	
19567
# check special-2 success: 	1
19568
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
19569
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
19570
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
19571
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19572
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19573
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19574
'just inserted' FROM t0_template
19575
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19576
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
19577
BEGIN
19578
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19579
f_charbig = 'updated by trigger'
19580
      WHERE f_int1 = new.f_int1;
19581
END|
19582
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19583
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
19584
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19585
	
19586
# check trigger-1 success: 	1
19587
DROP TRIGGER trg_1;
19588
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19589
f_int2 = CAST(f_char1 AS SIGNED INT),
19590
f_charbig = 'just inserted'
19591
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19592
DELETE FROM t0_aux
19593
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19594
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19595
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19596
'just inserted' FROM t0_template
19597
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19598
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
19599
BEGIN
19600
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19601
f_charbig = 'updated by trigger'
19602
      WHERE f_int1 = new.f_int1;
19603
END|
19604
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19605
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
19606
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19607
	
19608
# check trigger-2 success: 	1
19609
DROP TRIGGER trg_1;
19610
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19611
f_int2 = CAST(f_char1 AS SIGNED INT),
19612
f_charbig = 'just inserted'
19613
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19614
DELETE FROM t0_aux
19615
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19616
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19617
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19618
'just inserted' FROM t0_template
19619
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19620
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
19621
BEGIN
19622
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19623
f_charbig = 'updated by trigger'
19624
      WHERE f_int1 = new.f_int1;
19625
END|
19626
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
19627
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
19628
	
19629
# check trigger-3 success: 	1
19630
DROP TRIGGER trg_1;
19631
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19632
f_int2 = CAST(f_char1 AS SIGNED INT),
19633
f_charbig = 'just inserted'
19634
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19635
DELETE FROM t0_aux
19636
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19637
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19638
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19639
'just inserted' FROM t0_template
19640
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19641
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
19642
BEGIN
19643
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19644
f_charbig = 'updated by trigger'
19645
      WHERE f_int1 = - old.f_int1;
19646
END|
19647
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
19648
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
19649
	
19650
# check trigger-4 success: 	1
19651
DROP TRIGGER trg_1;
19652
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19653
f_int2 = CAST(f_char1 AS SIGNED INT),
19654
f_charbig = 'just inserted'
19655
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19656
DELETE FROM t0_aux
19657
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19658
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19659
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19660
'just inserted' FROM t0_template
19661
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19662
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
19663
BEGIN
19664
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19665
f_charbig = 'updated by trigger'
19666
      WHERE f_int1 = new.f_int1;
19667
END|
19668
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
19669
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
19670
	
19671
# check trigger-5 success: 	1
19672
DROP TRIGGER trg_1;
19673
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19674
f_int2 = CAST(f_char1 AS SIGNED INT),
19675
f_charbig = 'just inserted'
19676
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19677
DELETE FROM t0_aux
19678
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19679
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19680
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19681
'just inserted' FROM t0_template
19682
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19683
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
19684
BEGIN
19685
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19686
f_charbig = 'updated by trigger'
19687
      WHERE f_int1 = - old.f_int1;
19688
END|
19689
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
19690
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
19691
	
19692
# check trigger-6 success: 	1
19693
DROP TRIGGER trg_1;
19694
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19695
f_int2 = CAST(f_char1 AS SIGNED INT),
19696
f_charbig = 'just inserted'
19697
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19698
DELETE FROM t0_aux
19699
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19700
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19701
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19702
'just inserted' FROM t0_template
19703
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19704
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
19705
BEGIN
19706
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19707
f_charbig = 'updated by trigger'
19708
      WHERE f_int1 = - old.f_int1;
19709
END|
19710
DELETE FROM t0_aux
19711
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
19712
	
19713
# check trigger-7 success: 	1
19714
DROP TRIGGER trg_1;
19715
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19716
f_int2 = CAST(f_char1 AS SIGNED INT),
19717
f_charbig = 'just inserted'
19718
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19719
DELETE FROM t0_aux
19720
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19721
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
19722
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
19723
'just inserted' FROM t0_template
19724
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19725
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
19726
BEGIN
19727
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
19728
f_charbig = 'updated by trigger'
19729
      WHERE f_int1 = - old.f_int1;
19730
END|
19731
DELETE FROM t0_aux
19732
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
19733
	
19734
# check trigger-8 success: 	1
19735
DROP TRIGGER trg_1;
19736
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19737
f_int2 = CAST(f_char1 AS SIGNED INT),
19738
f_charbig = 'just inserted'
19739
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
19740
DELETE FROM t0_aux
19741
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19742
DELETE FROM t1
19743
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
19744
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
19745
BEGIN
19746
SET new.f_int1 = old.f_int1 + @max_row,
19747
new.f_int2 = old.f_int2 - @max_row,
19748
new.f_charbig = '####updated per update trigger####';
19749
END|
19750
UPDATE t1
19751
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
19752
f_charbig = '####updated per update statement itself####';
19753
	
19754
# check trigger-9 success: 	1
19755
DROP TRIGGER trg_2;
19756
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19757
f_int2 = CAST(f_char1 AS SIGNED INT),
19758
f_charbig = CONCAT('===',f_char1,'===');
19759
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
19760
BEGIN
19761
SET new.f_int1 = new.f_int1 + @max_row,
19762
new.f_int2 = new.f_int2 - @max_row,
19763
new.f_charbig = '####updated per update trigger####';
19764
END|
19765
UPDATE t1
19766
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
19767
f_charbig = '####updated per update statement itself####';
19768
	
19769
# check trigger-10 success: 	1
19770
DROP TRIGGER trg_2;
19771
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19772
f_int2 = CAST(f_char1 AS SIGNED INT),
19773
f_charbig = CONCAT('===',f_char1,'===');
19774
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
19775
BEGIN
19776
SET new.f_int1 = @my_max1 + @counter,
19777
new.f_int2 = @my_min2 - @counter,
19778
new.f_charbig = '####updated per insert trigger####';
19779
SET @counter = @counter + 1;
19780
END|
19781
SET @counter = 1;
19782
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
19783
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19784
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
19785
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
19786
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
19787
ORDER BY f_int1;
19788
DROP TRIGGER trg_3;
19789
	
19790
# check trigger-11 success: 	1
19791
DELETE FROM t1
19792
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
19793
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
19794
AND f_charbig = '####updated per insert trigger####';
19795
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
19796
BEGIN
19797
SET new.f_int1 = @my_max1 + @counter,
19798
new.f_int2 = @my_min2 - @counter,
19799
new.f_charbig = '####updated per insert trigger####';
19800
SET @counter = @counter + 1;
19801
END|
19802
SET @counter = 1;
19803
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
19804
INSERT INTO t1 (f_char1, f_char2, f_charbig)
19805
SELECT CAST(f_int1 AS CHAR),
19806
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
19807
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
19808
ORDER BY f_int1;
19809
DROP TRIGGER trg_3;
19810
	
19811
# check trigger-12 success: 	1
19812
DELETE FROM t1
19813
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
19814
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
19815
AND f_charbig = '####updated per insert trigger####';
19816
ANALYZE  TABLE t1;
19817
Table	Op	Msg_type	Msg_text
19818
test.t1	analyze	note	The storage engine for the table doesn't support analyze
19819
CHECK    TABLE t1 EXTENDED;
19820
Table	Op	Msg_type	Msg_text
19821
test.t1	check	note	The storage engine for the table doesn't support check
19822
CHECKSUM TABLE t1 EXTENDED;
19823
Table	Checksum
19824
test.t1	<some_value>
19825
OPTIMIZE TABLE t1;
19826
Table	Op	Msg_type	Msg_text
19827
test.t1	optimize	note	The storage engine for the table doesn't support optimize
19828
# check layout success:    1
19829
REPAIR   TABLE t1 EXTENDED;
19830
Table	Op	Msg_type	Msg_text
19831
test.t1	repair	note	The storage engine for the table doesn't support repair
19832
# check layout success:    1
19833
TRUNCATE t1;
19834
	
19835
# check TRUNCATE success: 	1
19836
# check layout success:    1
19837
# End usability test (inc/partition_check.inc)
19838
DROP TABLE t1;
19839
CREATE TABLE t1 (
19840
f_int1 INTEGER,
19841
f_int2 INTEGER,
19842
f_char1 CHAR(20),
19843
f_char2 CHAR(20),
19844
f_charbig VARCHAR(1000)
19845
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
19846
)
19847
PARTITION BY KEY(f_int1,f_int2) PARTITIONS 5;
19848
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
19849
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
19850
# Start usability test (inc/partition_check.inc)
19851
create_command
19852
SHOW CREATE TABLE t1;
19853
Table	Create Table
19854
t1	CREATE TABLE `t1` (
19855
  `f_int1` int(11) NOT NULL DEFAULT '0',
19856
  `f_int2` int(11) NOT NULL DEFAULT '0',
19857
  `f_char1` char(20) DEFAULT NULL,
19858
  `f_char2` char(20) DEFAULT NULL,
19859
  `f_charbig` varchar(1000) DEFAULT NULL,
19860
  PRIMARY KEY (`f_int2`,`f_int1`),
19861
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
19862
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5  */
19863
19864
unified filelist
19865
$MYSQLTEST_VARDIR/master-data/test/t1.frm
19866
$MYSQLTEST_VARDIR/master-data/test/t1.par
19867
19868
# check prerequisites-1 success:    1
19869
# check COUNT(*) success:    1
19870
# check MIN/MAX(f_int1) success:    1
19871
# check MIN/MAX(f_int2) success:    1
19872
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19873
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
19874
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
19875
WHERE f_int1 IN (2,3);
19876
ERROR 23000: Can't write; duplicate key in table 't1'
19877
# check prerequisites-3 success:    1
19878
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
19879
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19880
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
19881
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
19882
WHERE f_int1 IN (2,3);
19883
DELETE FROM t1 WHERE f_charbig = 'delete me';
19884
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19885
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
19886
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
19887
WHERE f_int1 IN (2,3);
19888
DELETE FROM t1 WHERE f_charbig = 'delete me';
19889
# check read via f_int1 success: 1
19890
# check read via f_int2 success: 1
19891
	
19892
# check multiple-1 success: 	1
19893
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
19894
	
19895
# check multiple-2 success: 	1
19896
INSERT INTO t1 SELECT * FROM t0_template
19897
WHERE MOD(f_int1,3) = 0;
19898
	
19899
# check multiple-3 success: 	1
19900
UPDATE t1 SET f_int1 = f_int1 + @max_row
19901
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
19902
AND @max_row_div2 + @max_row_div4;
19903
	
19904
# check multiple-4 success: 	1
19905
DELETE FROM t1
19906
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
19907
AND @max_row_div2 + @max_row_div4 + @max_row;
19908
	
19909
# check multiple-5 success: 	1
19910
SELECT COUNT(*) INTO @try_count FROM t0_template
19911
WHERE MOD(f_int1,3) = 0
19912
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
19913
SELECT COUNT(*) INTO @clash_count
19914
FROM t1 INNER JOIN t0_template USING(f_int1)
19915
WHERE MOD(f_int1,3) = 0
19916
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
19917
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
19918
INSERT INTO t1
19919
SET f_int1 = @cur_value , f_int2 = @cur_value,
19920
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
19921
f_charbig = '#SINGLE#';
19922
	
19923
# check single-1 success: 	1
19924
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
19925
INSERT INTO t1
19926
SET f_int1 = @cur_value , f_int2 = @cur_value,
19927
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
19928
f_charbig = '#SINGLE#';
19929
	
19930
# check single-2 success: 	1
19931
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
19932
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
19933
UPDATE t1 SET f_int1 = @cur_value2
19934
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
19935
	
19936
# check single-3 success: 	1
19937
SET @cur_value1= -1;
19938
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
19939
UPDATE t1 SET f_int1 = @cur_value1
19940
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
19941
	
19942
# check single-4 success: 	1
19943
SELECT MAX(f_int1) INTO @cur_value FROM t1;
19944
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
19945
	
19946
# check single-5 success: 	1
19947
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
19948
	
19949
# check single-6 success: 	1
19950
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
19951
	
19952
# check single-7 success: 	1
19953
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
19954
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
19955
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
19956
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
19957
f_charbig = '#NULL#';
19958
INSERT INTO t1
19959
SET f_int1 = NULL , f_int2 = -@max_row,
19960
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
19961
f_charbig = '#NULL#';
19962
ERROR 23000: Column 'f_int1' cannot be null
19963
# check null success:    1
19964
DELETE FROM t1
19965
WHERE f_int1 = 0 AND f_int2 = 0
19966
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
19967
AND f_charbig = '#NULL#';
19968
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19969
SELECT f_int1, f_int1, '', '', 'was inserted'
19970
   FROM t0_template source_tab
19971
WHERE MOD(f_int1,3) = 0
19972
AND f_int1 BETWEEN @max_row_div2 AND @max_row
19973
ON DUPLICATE KEY
19974
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
19975
f_int2 = 2 * @max_row + source_tab.f_int1,
19976
f_charbig = 'was updated';
19977
	
19978
# check unique-1-a success: 	1
19979
	
19980
# check unique-1-b success: 	1
19981
DELETE FROM t1 WHERE f_charbig = 'was inserted';
19982
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
19983
f_int2 = CAST(f_char1 AS SIGNED INT),
19984
f_charbig = CONCAT('===',f_char1,'===')
19985
WHERE f_charbig = 'was updated';
19986
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
19987
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
19988
   FROM t0_template source_tab
19989
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
19990
	
19991
# check replace success: 	1
19992
DELETE FROM t1
19993
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
19994
DELETE FROM t1
19995
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
19996
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
19997
UPDATE t1 SET f_int2 = f_int1,
19998
f_char1 = CAST(f_int1 AS CHAR),
19999
f_char2 = CAST(f_int1 AS CHAR),
20000
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
20001
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
20002
SET AUTOCOMMIT= 0;
20003
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20004
SELECT f_int1, f_int1, '', '', 'was inserted'
20005
FROM t0_template source_tab
20006
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
20007
	
20008
# check transactions-1 success: 	1
20009
COMMIT WORK;
20010
	
20011
# check transactions-2 success: 	1
20012
ROLLBACK WORK;
20013
	
20014
# check transactions-3 success: 	1
20015
DELETE FROM t1 WHERE f_charbig = 'was inserted';
20016
COMMIT WORK;
20017
ROLLBACK WORK;
20018
	
20019
# check transactions-4 success: 	1
20020
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20021
SELECT f_int1, f_int1, '', '', 'was inserted'
20022
FROM t0_template source_tab
20023
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
20024
	
20025
# check transactions-5 success: 	1
20026
ROLLBACK WORK;
20027
	
20028
# check transactions-6 success: 	1
20029
# INFO: Storage engine used for t1 seems to be transactional.
20030
COMMIT;
20031
	
20032
# check transactions-7 success: 	1
20033
DELETE FROM t1 WHERE f_charbig = 'was inserted';
20034
COMMIT WORK;
20035
SET @@session.sql_mode = 'traditional';
20036
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
20037
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20038
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
20039
'', '', 'was inserted' FROM t0_template
20040
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
20041
ERROR 22012: Division by 0
20042
COMMIT;
20043
	
20044
# check transactions-8 success: 	1
20045
# INFO: Storage engine used for t1 seems to be able to revert
20046
#       changes made by the failing statement.
20047
SET @@session.sql_mode = '';
20048
SET AUTOCOMMIT= 1;
20049
DELETE FROM t1 WHERE f_charbig = 'was inserted';
20050
COMMIT WORK;
20051
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
20052
	
20053
# check special-1 success: 	1
20054
UPDATE t1 SET f_charbig = '';
20055
	
20056
# check special-2 success: 	1
20057
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
20058
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
20059
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
20060
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20061
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20062
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20063
'just inserted' FROM t0_template
20064
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20065
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
20066
BEGIN
20067
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20068
f_charbig = 'updated by trigger'
20069
      WHERE f_int1 = new.f_int1;
20070
END|
20071
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20072
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
20073
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20074
	
20075
# check trigger-1 success: 	1
20076
DROP TRIGGER trg_1;
20077
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20078
f_int2 = CAST(f_char1 AS SIGNED INT),
20079
f_charbig = 'just inserted'
20080
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20081
DELETE FROM t0_aux
20082
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20083
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20084
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20085
'just inserted' FROM t0_template
20086
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20087
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
20088
BEGIN
20089
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20090
f_charbig = 'updated by trigger'
20091
      WHERE f_int1 = new.f_int1;
20092
END|
20093
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20094
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
20095
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20096
	
20097
# check trigger-2 success: 	1
20098
DROP TRIGGER trg_1;
20099
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20100
f_int2 = CAST(f_char1 AS SIGNED INT),
20101
f_charbig = 'just inserted'
20102
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20103
DELETE FROM t0_aux
20104
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20105
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20106
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20107
'just inserted' FROM t0_template
20108
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20109
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
20110
BEGIN
20111
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20112
f_charbig = 'updated by trigger'
20113
      WHERE f_int1 = new.f_int1;
20114
END|
20115
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
20116
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
20117
	
20118
# check trigger-3 success: 	1
20119
DROP TRIGGER trg_1;
20120
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20121
f_int2 = CAST(f_char1 AS SIGNED INT),
20122
f_charbig = 'just inserted'
20123
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20124
DELETE FROM t0_aux
20125
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20126
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20127
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20128
'just inserted' FROM t0_template
20129
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20130
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
20131
BEGIN
20132
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20133
f_charbig = 'updated by trigger'
20134
      WHERE f_int1 = - old.f_int1;
20135
END|
20136
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
20137
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
20138
	
20139
# check trigger-4 success: 	1
20140
DROP TRIGGER trg_1;
20141
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20142
f_int2 = CAST(f_char1 AS SIGNED INT),
20143
f_charbig = 'just inserted'
20144
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20145
DELETE FROM t0_aux
20146
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20147
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20148
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20149
'just inserted' FROM t0_template
20150
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20151
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
20152
BEGIN
20153
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20154
f_charbig = 'updated by trigger'
20155
      WHERE f_int1 = new.f_int1;
20156
END|
20157
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
20158
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
20159
	
20160
# check trigger-5 success: 	1
20161
DROP TRIGGER trg_1;
20162
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20163
f_int2 = CAST(f_char1 AS SIGNED INT),
20164
f_charbig = 'just inserted'
20165
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20166
DELETE FROM t0_aux
20167
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20168
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20169
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20170
'just inserted' FROM t0_template
20171
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20172
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
20173
BEGIN
20174
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20175
f_charbig = 'updated by trigger'
20176
      WHERE f_int1 = - old.f_int1;
20177
END|
20178
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
20179
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
20180
	
20181
# check trigger-6 success: 	1
20182
DROP TRIGGER trg_1;
20183
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20184
f_int2 = CAST(f_char1 AS SIGNED INT),
20185
f_charbig = 'just inserted'
20186
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20187
DELETE FROM t0_aux
20188
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20189
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20190
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20191
'just inserted' FROM t0_template
20192
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20193
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
20194
BEGIN
20195
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20196
f_charbig = 'updated by trigger'
20197
      WHERE f_int1 = - old.f_int1;
20198
END|
20199
DELETE FROM t0_aux
20200
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
20201
	
20202
# check trigger-7 success: 	1
20203
DROP TRIGGER trg_1;
20204
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20205
f_int2 = CAST(f_char1 AS SIGNED INT),
20206
f_charbig = 'just inserted'
20207
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20208
DELETE FROM t0_aux
20209
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20210
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20211
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20212
'just inserted' FROM t0_template
20213
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20214
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
20215
BEGIN
20216
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20217
f_charbig = 'updated by trigger'
20218
      WHERE f_int1 = - old.f_int1;
20219
END|
20220
DELETE FROM t0_aux
20221
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
20222
	
20223
# check trigger-8 success: 	1
20224
DROP TRIGGER trg_1;
20225
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20226
f_int2 = CAST(f_char1 AS SIGNED INT),
20227
f_charbig = 'just inserted'
20228
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20229
DELETE FROM t0_aux
20230
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20231
DELETE FROM t1
20232
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20233
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
20234
BEGIN
20235
SET new.f_int1 = old.f_int1 + @max_row,
20236
new.f_int2 = old.f_int2 - @max_row,
20237
new.f_charbig = '####updated per update trigger####';
20238
END|
20239
UPDATE t1
20240
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
20241
f_charbig = '####updated per update statement itself####';
20242
	
20243
# check trigger-9 success: 	1
20244
DROP TRIGGER trg_2;
20245
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20246
f_int2 = CAST(f_char1 AS SIGNED INT),
20247
f_charbig = CONCAT('===',f_char1,'===');
20248
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
20249
BEGIN
20250
SET new.f_int1 = new.f_int1 + @max_row,
20251
new.f_int2 = new.f_int2 - @max_row,
20252
new.f_charbig = '####updated per update trigger####';
20253
END|
20254
UPDATE t1
20255
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
20256
f_charbig = '####updated per update statement itself####';
20257
	
20258
# check trigger-10 success: 	1
20259
DROP TRIGGER trg_2;
20260
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20261
f_int2 = CAST(f_char1 AS SIGNED INT),
20262
f_charbig = CONCAT('===',f_char1,'===');
20263
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
20264
BEGIN
20265
SET new.f_int1 = @my_max1 + @counter,
20266
new.f_int2 = @my_min2 - @counter,
20267
new.f_charbig = '####updated per insert trigger####';
20268
SET @counter = @counter + 1;
20269
END|
20270
SET @counter = 1;
20271
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
20272
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20273
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
20274
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
20275
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
20276
ORDER BY f_int1;
20277
DROP TRIGGER trg_3;
20278
	
20279
# check trigger-11 success: 	1
20280
DELETE FROM t1
20281
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
20282
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
20283
AND f_charbig = '####updated per insert trigger####';
20284
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
20285
BEGIN
20286
SET new.f_int1 = @my_max1 + @counter,
20287
new.f_int2 = @my_min2 - @counter,
20288
new.f_charbig = '####updated per insert trigger####';
20289
SET @counter = @counter + 1;
20290
END|
20291
SET @counter = 1;
20292
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
20293
INSERT INTO t1 (f_char1, f_char2, f_charbig)
20294
SELECT CAST(f_int1 AS CHAR),
20295
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
20296
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
20297
ORDER BY f_int1;
20298
DROP TRIGGER trg_3;
20299
	
20300
# check trigger-12 success: 	1
20301
DELETE FROM t1
20302
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
20303
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
20304
AND f_charbig = '####updated per insert trigger####';
20305
ANALYZE  TABLE t1;
20306
Table	Op	Msg_type	Msg_text
20307
test.t1	analyze	note	The storage engine for the table doesn't support analyze
20308
CHECK    TABLE t1 EXTENDED;
20309
Table	Op	Msg_type	Msg_text
20310
test.t1	check	note	The storage engine for the table doesn't support check
20311
CHECKSUM TABLE t1 EXTENDED;
20312
Table	Checksum
20313
test.t1	<some_value>
20314
OPTIMIZE TABLE t1;
20315
Table	Op	Msg_type	Msg_text
20316
test.t1	optimize	note	The storage engine for the table doesn't support optimize
20317
# check layout success:    1
20318
REPAIR   TABLE t1 EXTENDED;
20319
Table	Op	Msg_type	Msg_text
20320
test.t1	repair	note	The storage engine for the table doesn't support repair
20321
# check layout success:    1
20322
TRUNCATE t1;
20323
	
20324
# check TRUNCATE success: 	1
20325
# check layout success:    1
20326
# End usability test (inc/partition_check.inc)
20327
DROP TABLE t1;
20328
CREATE TABLE t1 (
20329
f_int1 INTEGER,
20330
f_int2 INTEGER,
20331
f_char1 CHAR(20),
20332
f_char2 CHAR(20),
20333
f_charbig VARCHAR(1000)
20334
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
20335
)
20336
PARTITION BY LIST(MOD(f_int1 + f_int2,4))
20337
(PARTITION part_3 VALUES IN (-3),
20338
PARTITION part_2 VALUES IN (-2),
20339
PARTITION part_1 VALUES IN (-1),
20340
PARTITION part_N VALUES IN (NULL),
20341
PARTITION part0 VALUES IN (0),
20342
PARTITION part1 VALUES IN (1),
20343
PARTITION part2 VALUES IN (2),
20344
PARTITION part3 VALUES IN (3));
20345
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
20346
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
20347
# Start usability test (inc/partition_check.inc)
20348
create_command
20349
SHOW CREATE TABLE t1;
20350
Table	Create Table
20351
t1	CREATE TABLE `t1` (
20352
  `f_int1` int(11) NOT NULL DEFAULT '0',
20353
  `f_int2` int(11) NOT NULL DEFAULT '0',
20354
  `f_char1` char(20) DEFAULT NULL,
20355
  `f_char2` char(20) DEFAULT NULL,
20356
  `f_charbig` varchar(1000) DEFAULT NULL,
20357
  PRIMARY KEY (`f_int2`,`f_int1`),
20358
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
20359
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (MOD(f_int1 + f_int2,4)) (PARTITION part_3 VALUES IN (-3) ENGINE = InnoDB, PARTITION part_2 VALUES IN (-2) ENGINE = InnoDB, PARTITION part_1 VALUES IN (-1) ENGINE = InnoDB, PARTITION part_N VALUES IN (NULL) ENGINE = InnoDB, PARTITION part0 VALUES IN (0) ENGINE = InnoDB, PARTITION part1 VALUES IN (1) ENGINE = InnoDB, PARTITION part2 VALUES IN (2) ENGINE = InnoDB, PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
20360
20361
unified filelist
20362
$MYSQLTEST_VARDIR/master-data/test/t1.frm
20363
$MYSQLTEST_VARDIR/master-data/test/t1.par
20364
20365
# check prerequisites-1 success:    1
20366
# check COUNT(*) success:    1
20367
# check MIN/MAX(f_int1) success:    1
20368
# check MIN/MAX(f_int2) success:    1
20369
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20370
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
20371
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
20372
WHERE f_int1 IN (2,3);
20373
ERROR 23000: Can't write; duplicate key in table 't1'
20374
# check prerequisites-3 success:    1
20375
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
20376
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20377
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
20378
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
20379
WHERE f_int1 IN (2,3);
20380
DELETE FROM t1 WHERE f_charbig = 'delete me';
20381
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20382
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
20383
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
20384
WHERE f_int1 IN (2,3);
20385
DELETE FROM t1 WHERE f_charbig = 'delete me';
20386
# check read via f_int1 success: 1
20387
# check read via f_int2 success: 1
20388
	
20389
# check multiple-1 success: 	1
20390
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
20391
	
20392
# check multiple-2 success: 	1
20393
INSERT INTO t1 SELECT * FROM t0_template
20394
WHERE MOD(f_int1,3) = 0;
20395
	
20396
# check multiple-3 success: 	1
20397
UPDATE t1 SET f_int1 = f_int1 + @max_row
20398
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
20399
AND @max_row_div2 + @max_row_div4;
20400
	
20401
# check multiple-4 success: 	1
20402
DELETE FROM t1
20403
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
20404
AND @max_row_div2 + @max_row_div4 + @max_row;
20405
	
20406
# check multiple-5 success: 	1
20407
SELECT COUNT(*) INTO @try_count FROM t0_template
20408
WHERE MOD(f_int1,3) = 0
20409
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
20410
SELECT COUNT(*) INTO @clash_count
20411
FROM t1 INNER JOIN t0_template USING(f_int1)
20412
WHERE MOD(f_int1,3) = 0
20413
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
20414
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
20415
INSERT INTO t1
20416
SET f_int1 = @cur_value , f_int2 = @cur_value,
20417
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
20418
f_charbig = '#SINGLE#';
20419
	
20420
# check single-1 success: 	1
20421
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
20422
INSERT INTO t1
20423
SET f_int1 = @cur_value , f_int2 = @cur_value,
20424
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
20425
f_charbig = '#SINGLE#';
20426
	
20427
# check single-2 success: 	1
20428
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
20429
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
20430
UPDATE t1 SET f_int1 = @cur_value2
20431
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
20432
	
20433
# check single-3 success: 	1
20434
SET @cur_value1= -1;
20435
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
20436
UPDATE t1 SET f_int1 = @cur_value1
20437
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
20438
	
20439
# check single-4 success: 	1
20440
SELECT MAX(f_int1) INTO @cur_value FROM t1;
20441
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
20442
	
20443
# check single-5 success: 	1
20444
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
20445
	
20446
# check single-6 success: 	1
20447
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
20448
	
20449
# check single-7 success: 	1
20450
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
20451
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
20452
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
20453
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
20454
f_charbig = '#NULL#';
20455
INSERT INTO t1
20456
SET f_int1 = NULL , f_int2 = -@max_row,
20457
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
20458
f_charbig = '#NULL#';
20459
ERROR 23000: Column 'f_int1' cannot be null
20460
# check null success:    1
20461
DELETE FROM t1
20462
WHERE f_int1 = 0 AND f_int2 = 0
20463
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
20464
AND f_charbig = '#NULL#';
20465
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20466
SELECT f_int1, f_int1, '', '', 'was inserted'
20467
   FROM t0_template source_tab
20468
WHERE MOD(f_int1,3) = 0
20469
AND f_int1 BETWEEN @max_row_div2 AND @max_row
20470
ON DUPLICATE KEY
20471
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
20472
f_int2 = 2 * @max_row + source_tab.f_int1,
20473
f_charbig = 'was updated';
20474
	
20475
# check unique-1-a success: 	1
20476
	
20477
# check unique-1-b success: 	1
20478
DELETE FROM t1 WHERE f_charbig = 'was inserted';
20479
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20480
f_int2 = CAST(f_char1 AS SIGNED INT),
20481
f_charbig = CONCAT('===',f_char1,'===')
20482
WHERE f_charbig = 'was updated';
20483
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20484
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
20485
   FROM t0_template source_tab
20486
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
20487
	
20488
# check replace success: 	1
20489
DELETE FROM t1
20490
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
20491
DELETE FROM t1
20492
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
20493
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
20494
UPDATE t1 SET f_int2 = f_int1,
20495
f_char1 = CAST(f_int1 AS CHAR),
20496
f_char2 = CAST(f_int1 AS CHAR),
20497
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
20498
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
20499
SET AUTOCOMMIT= 0;
20500
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20501
SELECT f_int1, f_int1, '', '', 'was inserted'
20502
FROM t0_template source_tab
20503
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
20504
	
20505
# check transactions-1 success: 	1
20506
COMMIT WORK;
20507
	
20508
# check transactions-2 success: 	1
20509
ROLLBACK WORK;
20510
	
20511
# check transactions-3 success: 	1
20512
DELETE FROM t1 WHERE f_charbig = 'was inserted';
20513
COMMIT WORK;
20514
ROLLBACK WORK;
20515
	
20516
# check transactions-4 success: 	1
20517
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20518
SELECT f_int1, f_int1, '', '', 'was inserted'
20519
FROM t0_template source_tab
20520
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
20521
	
20522
# check transactions-5 success: 	1
20523
ROLLBACK WORK;
20524
	
20525
# check transactions-6 success: 	1
20526
# INFO: Storage engine used for t1 seems to be transactional.
20527
COMMIT;
20528
	
20529
# check transactions-7 success: 	1
20530
DELETE FROM t1 WHERE f_charbig = 'was inserted';
20531
COMMIT WORK;
20532
SET @@session.sql_mode = 'traditional';
20533
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
20534
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20535
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
20536
'', '', 'was inserted' FROM t0_template
20537
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
20538
ERROR 22012: Division by 0
20539
COMMIT;
20540
	
20541
# check transactions-8 success: 	1
20542
# INFO: Storage engine used for t1 seems to be able to revert
20543
#       changes made by the failing statement.
20544
SET @@session.sql_mode = '';
20545
SET AUTOCOMMIT= 1;
20546
DELETE FROM t1 WHERE f_charbig = 'was inserted';
20547
COMMIT WORK;
20548
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
20549
	
20550
# check special-1 success: 	1
20551
UPDATE t1 SET f_charbig = '';
20552
	
20553
# check special-2 success: 	1
20554
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
20555
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
20556
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
20557
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20558
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20559
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20560
'just inserted' FROM t0_template
20561
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20562
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
20563
BEGIN
20564
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20565
f_charbig = 'updated by trigger'
20566
      WHERE f_int1 = new.f_int1;
20567
END|
20568
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20569
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
20570
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20571
	
20572
# check trigger-1 success: 	1
20573
DROP TRIGGER trg_1;
20574
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20575
f_int2 = CAST(f_char1 AS SIGNED INT),
20576
f_charbig = 'just inserted'
20577
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20578
DELETE FROM t0_aux
20579
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20580
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20581
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20582
'just inserted' FROM t0_template
20583
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20584
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
20585
BEGIN
20586
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20587
f_charbig = 'updated by trigger'
20588
      WHERE f_int1 = new.f_int1;
20589
END|
20590
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20591
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
20592
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20593
	
20594
# check trigger-2 success: 	1
20595
DROP TRIGGER trg_1;
20596
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20597
f_int2 = CAST(f_char1 AS SIGNED INT),
20598
f_charbig = 'just inserted'
20599
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20600
DELETE FROM t0_aux
20601
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20602
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20603
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20604
'just inserted' FROM t0_template
20605
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20606
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
20607
BEGIN
20608
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20609
f_charbig = 'updated by trigger'
20610
      WHERE f_int1 = new.f_int1;
20611
END|
20612
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
20613
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
20614
	
20615
# check trigger-3 success: 	1
20616
DROP TRIGGER trg_1;
20617
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20618
f_int2 = CAST(f_char1 AS SIGNED INT),
20619
f_charbig = 'just inserted'
20620
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20621
DELETE FROM t0_aux
20622
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20623
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20624
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20625
'just inserted' FROM t0_template
20626
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20627
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
20628
BEGIN
20629
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20630
f_charbig = 'updated by trigger'
20631
      WHERE f_int1 = - old.f_int1;
20632
END|
20633
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
20634
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
20635
	
20636
# check trigger-4 success: 	1
20637
DROP TRIGGER trg_1;
20638
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20639
f_int2 = CAST(f_char1 AS SIGNED INT),
20640
f_charbig = 'just inserted'
20641
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20642
DELETE FROM t0_aux
20643
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20644
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20645
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20646
'just inserted' FROM t0_template
20647
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20648
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
20649
BEGIN
20650
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20651
f_charbig = 'updated by trigger'
20652
      WHERE f_int1 = new.f_int1;
20653
END|
20654
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
20655
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
20656
	
20657
# check trigger-5 success: 	1
20658
DROP TRIGGER trg_1;
20659
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20660
f_int2 = CAST(f_char1 AS SIGNED INT),
20661
f_charbig = 'just inserted'
20662
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20663
DELETE FROM t0_aux
20664
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20665
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20666
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20667
'just inserted' FROM t0_template
20668
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20669
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
20670
BEGIN
20671
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20672
f_charbig = 'updated by trigger'
20673
      WHERE f_int1 = - old.f_int1;
20674
END|
20675
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
20676
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
20677
	
20678
# check trigger-6 success: 	1
20679
DROP TRIGGER trg_1;
20680
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20681
f_int2 = CAST(f_char1 AS SIGNED INT),
20682
f_charbig = 'just inserted'
20683
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20684
DELETE FROM t0_aux
20685
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20686
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20687
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20688
'just inserted' FROM t0_template
20689
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20690
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
20691
BEGIN
20692
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20693
f_charbig = 'updated by trigger'
20694
      WHERE f_int1 = - old.f_int1;
20695
END|
20696
DELETE FROM t0_aux
20697
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
20698
	
20699
# check trigger-7 success: 	1
20700
DROP TRIGGER trg_1;
20701
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20702
f_int2 = CAST(f_char1 AS SIGNED INT),
20703
f_charbig = 'just inserted'
20704
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20705
DELETE FROM t0_aux
20706
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20707
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
20708
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
20709
'just inserted' FROM t0_template
20710
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20711
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
20712
BEGIN
20713
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
20714
f_charbig = 'updated by trigger'
20715
      WHERE f_int1 = - old.f_int1;
20716
END|
20717
DELETE FROM t0_aux
20718
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
20719
	
20720
# check trigger-8 success: 	1
20721
DROP TRIGGER trg_1;
20722
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20723
f_int2 = CAST(f_char1 AS SIGNED INT),
20724
f_charbig = 'just inserted'
20725
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
20726
DELETE FROM t0_aux
20727
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20728
DELETE FROM t1
20729
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
20730
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
20731
BEGIN
20732
SET new.f_int1 = old.f_int1 + @max_row,
20733
new.f_int2 = old.f_int2 - @max_row,
20734
new.f_charbig = '####updated per update trigger####';
20735
END|
20736
UPDATE t1
20737
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
20738
f_charbig = '####updated per update statement itself####';
20739
	
20740
# check trigger-9 success: 	1
20741
DROP TRIGGER trg_2;
20742
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20743
f_int2 = CAST(f_char1 AS SIGNED INT),
20744
f_charbig = CONCAT('===',f_char1,'===');
20745
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
20746
BEGIN
20747
SET new.f_int1 = new.f_int1 + @max_row,
20748
new.f_int2 = new.f_int2 - @max_row,
20749
new.f_charbig = '####updated per update trigger####';
20750
END|
20751
UPDATE t1
20752
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
20753
f_charbig = '####updated per update statement itself####';
20754
	
20755
# check trigger-10 success: 	1
20756
DROP TRIGGER trg_2;
20757
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20758
f_int2 = CAST(f_char1 AS SIGNED INT),
20759
f_charbig = CONCAT('===',f_char1,'===');
20760
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
20761
BEGIN
20762
SET new.f_int1 = @my_max1 + @counter,
20763
new.f_int2 = @my_min2 - @counter,
20764
new.f_charbig = '####updated per insert trigger####';
20765
SET @counter = @counter + 1;
20766
END|
20767
SET @counter = 1;
20768
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
20769
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20770
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
20771
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
20772
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
20773
ORDER BY f_int1;
20774
DROP TRIGGER trg_3;
20775
	
20776
# check trigger-11 success: 	1
20777
DELETE FROM t1
20778
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
20779
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
20780
AND f_charbig = '####updated per insert trigger####';
20781
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
20782
BEGIN
20783
SET new.f_int1 = @my_max1 + @counter,
20784
new.f_int2 = @my_min2 - @counter,
20785
new.f_charbig = '####updated per insert trigger####';
20786
SET @counter = @counter + 1;
20787
END|
20788
SET @counter = 1;
20789
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
20790
INSERT INTO t1 (f_char1, f_char2, f_charbig)
20791
SELECT CAST(f_int1 AS CHAR),
20792
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
20793
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
20794
ORDER BY f_int1;
20795
DROP TRIGGER trg_3;
20796
	
20797
# check trigger-12 success: 	1
20798
DELETE FROM t1
20799
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
20800
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
20801
AND f_charbig = '####updated per insert trigger####';
20802
ANALYZE  TABLE t1;
20803
Table	Op	Msg_type	Msg_text
20804
test.t1	analyze	note	The storage engine for the table doesn't support analyze
20805
CHECK    TABLE t1 EXTENDED;
20806
Table	Op	Msg_type	Msg_text
20807
test.t1	check	note	The storage engine for the table doesn't support check
20808
CHECKSUM TABLE t1 EXTENDED;
20809
Table	Checksum
20810
test.t1	<some_value>
20811
OPTIMIZE TABLE t1;
20812
Table	Op	Msg_type	Msg_text
20813
test.t1	optimize	note	The storage engine for the table doesn't support optimize
20814
# check layout success:    1
20815
REPAIR   TABLE t1 EXTENDED;
20816
Table	Op	Msg_type	Msg_text
20817
test.t1	repair	note	The storage engine for the table doesn't support repair
20818
# check layout success:    1
20819
TRUNCATE t1;
20820
	
20821
# check TRUNCATE success: 	1
20822
# check layout success:    1
20823
# End usability test (inc/partition_check.inc)
20824
DROP TABLE t1;
20825
CREATE TABLE t1 (
20826
f_int1 INTEGER,
20827
f_int2 INTEGER,
20828
f_char1 CHAR(20),
20829
f_char2 CHAR(20),
20830
f_charbig VARCHAR(1000)
20831
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
20832
)
20833
PARTITION BY RANGE((f_int1 + f_int2) DIV 2)
20834
(PARTITION parta VALUES LESS THAN (0),
20835
PARTITION partb VALUES LESS THAN (5),
20836
PARTITION partc VALUES LESS THAN (10),
20837
PARTITION partd VALUES LESS THAN (10 + 5),
20838
PARTITION parte VALUES LESS THAN (20),
20839
PARTITION partf VALUES LESS THAN (2147483646));
20840
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
20841
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
20842
# Start usability test (inc/partition_check.inc)
20843
create_command
20844
SHOW CREATE TABLE t1;
20845
Table	Create Table
20846
t1	CREATE TABLE `t1` (
20847
  `f_int1` int(11) NOT NULL DEFAULT '0',
20848
  `f_int2` int(11) NOT NULL DEFAULT '0',
20849
  `f_char1` char(20) DEFAULT NULL,
20850
  `f_char2` char(20) DEFAULT NULL,
20851
  `f_charbig` varchar(1000) DEFAULT NULL,
20852
  PRIMARY KEY (`f_int2`,`f_int1`),
20853
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
20854
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE ((f_int1 + f_int2) DIV 2) (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION parte VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
20855
20856
unified filelist
20857
$MYSQLTEST_VARDIR/master-data/test/t1.frm
20858
$MYSQLTEST_VARDIR/master-data/test/t1.par
20859
20860
# check prerequisites-1 success:    1
20861
# check COUNT(*) success:    1
20862
# check MIN/MAX(f_int1) success:    1
20863
# check MIN/MAX(f_int2) success:    1
20864
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20865
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
20866
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
20867
WHERE f_int1 IN (2,3);
20868
ERROR 23000: Can't write; duplicate key in table 't1'
20869
# check prerequisites-3 success:    1
20870
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
20871
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20872
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
20873
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
20874
WHERE f_int1 IN (2,3);
20875
DELETE FROM t1 WHERE f_charbig = 'delete me';
20876
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20877
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
20878
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
20879
WHERE f_int1 IN (2,3);
20880
DELETE FROM t1 WHERE f_charbig = 'delete me';
20881
# check read via f_int1 success: 1
20882
# check read via f_int2 success: 1
20883
	
20884
# check multiple-1 success: 	1
20885
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
20886
	
20887
# check multiple-2 success: 	1
20888
INSERT INTO t1 SELECT * FROM t0_template
20889
WHERE MOD(f_int1,3) = 0;
20890
	
20891
# check multiple-3 success: 	1
20892
UPDATE t1 SET f_int1 = f_int1 + @max_row
20893
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
20894
AND @max_row_div2 + @max_row_div4;
20895
	
20896
# check multiple-4 success: 	1
20897
DELETE FROM t1
20898
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
20899
AND @max_row_div2 + @max_row_div4 + @max_row;
20900
	
20901
# check multiple-5 success: 	1
20902
SELECT COUNT(*) INTO @try_count FROM t0_template
20903
WHERE MOD(f_int1,3) = 0
20904
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
20905
SELECT COUNT(*) INTO @clash_count
20906
FROM t1 INNER JOIN t0_template USING(f_int1)
20907
WHERE MOD(f_int1,3) = 0
20908
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
20909
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
20910
INSERT INTO t1
20911
SET f_int1 = @cur_value , f_int2 = @cur_value,
20912
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
20913
f_charbig = '#SINGLE#';
20914
	
20915
# check single-1 success: 	1
20916
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
20917
INSERT INTO t1
20918
SET f_int1 = @cur_value , f_int2 = @cur_value,
20919
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
20920
f_charbig = '#SINGLE#';
20921
	
20922
# check single-2 success: 	1
20923
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
20924
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
20925
UPDATE t1 SET f_int1 = @cur_value2
20926
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
20927
	
20928
# check single-3 success: 	1
20929
SET @cur_value1= -1;
20930
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
20931
UPDATE t1 SET f_int1 = @cur_value1
20932
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
20933
	
20934
# check single-4 success: 	1
20935
SELECT MAX(f_int1) INTO @cur_value FROM t1;
20936
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
20937
	
20938
# check single-5 success: 	1
20939
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
20940
	
20941
# check single-6 success: 	1
20942
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
20943
ERROR HY000: Table has no partition for value 2147483647
20944
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
20945
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
20946
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
20947
f_charbig = '#NULL#';
20948
INSERT INTO t1
20949
SET f_int1 = NULL , f_int2 = -@max_row,
20950
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
20951
f_charbig = '#NULL#';
20952
ERROR 23000: Column 'f_int1' cannot be null
20953
# check null success:    1
20954
DELETE FROM t1
20955
WHERE f_int1 = 0 AND f_int2 = 0
20956
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
20957
AND f_charbig = '#NULL#';
20958
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20959
SELECT f_int1, f_int1, '', '', 'was inserted'
20960
   FROM t0_template source_tab
20961
WHERE MOD(f_int1,3) = 0
20962
AND f_int1 BETWEEN @max_row_div2 AND @max_row
20963
ON DUPLICATE KEY
20964
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
20965
f_int2 = 2 * @max_row + source_tab.f_int1,
20966
f_charbig = 'was updated';
20967
	
20968
# check unique-1-a success: 	1
20969
	
20970
# check unique-1-b success: 	1
20971
DELETE FROM t1 WHERE f_charbig = 'was inserted';
20972
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
20973
f_int2 = CAST(f_char1 AS SIGNED INT),
20974
f_charbig = CONCAT('===',f_char1,'===')
20975
WHERE f_charbig = 'was updated';
20976
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20977
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
20978
   FROM t0_template source_tab
20979
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
20980
	
20981
# check replace success: 	1
20982
DELETE FROM t1
20983
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
20984
DELETE FROM t1
20985
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
20986
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
20987
UPDATE t1 SET f_int2 = f_int1,
20988
f_char1 = CAST(f_int1 AS CHAR),
20989
f_char2 = CAST(f_int1 AS CHAR),
20990
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
20991
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
20992
SET AUTOCOMMIT= 0;
20993
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
20994
SELECT f_int1, f_int1, '', '', 'was inserted'
20995
FROM t0_template source_tab
20996
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
20997
	
20998
# check transactions-1 success: 	1
20999
COMMIT WORK;
21000
	
21001
# check transactions-2 success: 	1
21002
ROLLBACK WORK;
21003
	
21004
# check transactions-3 success: 	1
21005
DELETE FROM t1 WHERE f_charbig = 'was inserted';
21006
COMMIT WORK;
21007
ROLLBACK WORK;
21008
	
21009
# check transactions-4 success: 	1
21010
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21011
SELECT f_int1, f_int1, '', '', 'was inserted'
21012
FROM t0_template source_tab
21013
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
21014
	
21015
# check transactions-5 success: 	1
21016
ROLLBACK WORK;
21017
	
21018
# check transactions-6 success: 	1
21019
# INFO: Storage engine used for t1 seems to be transactional.
21020
COMMIT;
21021
	
21022
# check transactions-7 success: 	1
21023
DELETE FROM t1 WHERE f_charbig = 'was inserted';
21024
COMMIT WORK;
21025
SET @@session.sql_mode = 'traditional';
21026
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
21027
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21028
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
21029
'', '', 'was inserted' FROM t0_template
21030
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
21031
ERROR 22012: Division by 0
21032
COMMIT;
21033
	
21034
# check transactions-8 success: 	1
21035
# INFO: Storage engine used for t1 seems to be able to revert
21036
#       changes made by the failing statement.
21037
SET @@session.sql_mode = '';
21038
SET AUTOCOMMIT= 1;
21039
DELETE FROM t1 WHERE f_charbig = 'was inserted';
21040
COMMIT WORK;
21041
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
21042
	
21043
# check special-1 success: 	1
21044
UPDATE t1 SET f_charbig = '';
21045
	
21046
# check special-2 success: 	1
21047
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
21048
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
21049
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
21050
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21051
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21052
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21053
'just inserted' FROM t0_template
21054
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21055
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
21056
BEGIN
21057
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21058
f_charbig = 'updated by trigger'
21059
      WHERE f_int1 = new.f_int1;
21060
END|
21061
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21062
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
21063
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21064
	
21065
# check trigger-1 success: 	1
21066
DROP TRIGGER trg_1;
21067
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21068
f_int2 = CAST(f_char1 AS SIGNED INT),
21069
f_charbig = 'just inserted'
21070
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21071
DELETE FROM t0_aux
21072
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21073
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21074
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21075
'just inserted' FROM t0_template
21076
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21077
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
21078
BEGIN
21079
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21080
f_charbig = 'updated by trigger'
21081
      WHERE f_int1 = new.f_int1;
21082
END|
21083
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21084
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
21085
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21086
	
21087
# check trigger-2 success: 	1
21088
DROP TRIGGER trg_1;
21089
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21090
f_int2 = CAST(f_char1 AS SIGNED INT),
21091
f_charbig = 'just inserted'
21092
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21093
DELETE FROM t0_aux
21094
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21095
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21096
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21097
'just inserted' FROM t0_template
21098
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21099
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
21100
BEGIN
21101
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21102
f_charbig = 'updated by trigger'
21103
      WHERE f_int1 = new.f_int1;
21104
END|
21105
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
21106
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
21107
	
21108
# check trigger-3 success: 	1
21109
DROP TRIGGER trg_1;
21110
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21111
f_int2 = CAST(f_char1 AS SIGNED INT),
21112
f_charbig = 'just inserted'
21113
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21114
DELETE FROM t0_aux
21115
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21116
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21117
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21118
'just inserted' FROM t0_template
21119
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21120
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
21121
BEGIN
21122
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21123
f_charbig = 'updated by trigger'
21124
      WHERE f_int1 = - old.f_int1;
21125
END|
21126
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
21127
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
21128
	
21129
# check trigger-4 success: 	1
21130
DROP TRIGGER trg_1;
21131
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21132
f_int2 = CAST(f_char1 AS SIGNED INT),
21133
f_charbig = 'just inserted'
21134
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21135
DELETE FROM t0_aux
21136
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21137
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21138
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21139
'just inserted' FROM t0_template
21140
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21141
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
21142
BEGIN
21143
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21144
f_charbig = 'updated by trigger'
21145
      WHERE f_int1 = new.f_int1;
21146
END|
21147
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
21148
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
21149
	
21150
# check trigger-5 success: 	1
21151
DROP TRIGGER trg_1;
21152
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21153
f_int2 = CAST(f_char1 AS SIGNED INT),
21154
f_charbig = 'just inserted'
21155
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21156
DELETE FROM t0_aux
21157
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21158
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21159
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21160
'just inserted' FROM t0_template
21161
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21162
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
21163
BEGIN
21164
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21165
f_charbig = 'updated by trigger'
21166
      WHERE f_int1 = - old.f_int1;
21167
END|
21168
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
21169
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
21170
	
21171
# check trigger-6 success: 	1
21172
DROP TRIGGER trg_1;
21173
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21174
f_int2 = CAST(f_char1 AS SIGNED INT),
21175
f_charbig = 'just inserted'
21176
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21177
DELETE FROM t0_aux
21178
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21179
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21180
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21181
'just inserted' FROM t0_template
21182
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21183
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
21184
BEGIN
21185
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21186
f_charbig = 'updated by trigger'
21187
      WHERE f_int1 = - old.f_int1;
21188
END|
21189
DELETE FROM t0_aux
21190
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
21191
	
21192
# check trigger-7 success: 	1
21193
DROP TRIGGER trg_1;
21194
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21195
f_int2 = CAST(f_char1 AS SIGNED INT),
21196
f_charbig = 'just inserted'
21197
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21198
DELETE FROM t0_aux
21199
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21200
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21201
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21202
'just inserted' FROM t0_template
21203
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21204
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
21205
BEGIN
21206
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21207
f_charbig = 'updated by trigger'
21208
      WHERE f_int1 = - old.f_int1;
21209
END|
21210
DELETE FROM t0_aux
21211
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
21212
	
21213
# check trigger-8 success: 	1
21214
DROP TRIGGER trg_1;
21215
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21216
f_int2 = CAST(f_char1 AS SIGNED INT),
21217
f_charbig = 'just inserted'
21218
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21219
DELETE FROM t0_aux
21220
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21221
DELETE FROM t1
21222
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21223
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
21224
BEGIN
21225
SET new.f_int1 = old.f_int1 + @max_row,
21226
new.f_int2 = old.f_int2 - @max_row,
21227
new.f_charbig = '####updated per update trigger####';
21228
END|
21229
UPDATE t1
21230
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
21231
f_charbig = '####updated per update statement itself####';
21232
	
21233
# check trigger-9 success: 	1
21234
DROP TRIGGER trg_2;
21235
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21236
f_int2 = CAST(f_char1 AS SIGNED INT),
21237
f_charbig = CONCAT('===',f_char1,'===');
21238
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
21239
BEGIN
21240
SET new.f_int1 = new.f_int1 + @max_row,
21241
new.f_int2 = new.f_int2 - @max_row,
21242
new.f_charbig = '####updated per update trigger####';
21243
END|
21244
UPDATE t1
21245
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
21246
f_charbig = '####updated per update statement itself####';
21247
	
21248
# check trigger-10 success: 	1
21249
DROP TRIGGER trg_2;
21250
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21251
f_int2 = CAST(f_char1 AS SIGNED INT),
21252
f_charbig = CONCAT('===',f_char1,'===');
21253
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
21254
BEGIN
21255
SET new.f_int1 = @my_max1 + @counter,
21256
new.f_int2 = @my_min2 - @counter,
21257
new.f_charbig = '####updated per insert trigger####';
21258
SET @counter = @counter + 1;
21259
END|
21260
SET @counter = 1;
21261
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
21262
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21263
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
21264
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
21265
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
21266
ORDER BY f_int1;
21267
DROP TRIGGER trg_3;
21268
	
21269
# check trigger-11 success: 	1
21270
DELETE FROM t1
21271
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
21272
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
21273
AND f_charbig = '####updated per insert trigger####';
21274
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
21275
BEGIN
21276
SET new.f_int1 = @my_max1 + @counter,
21277
new.f_int2 = @my_min2 - @counter,
21278
new.f_charbig = '####updated per insert trigger####';
21279
SET @counter = @counter + 1;
21280
END|
21281
SET @counter = 1;
21282
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
21283
INSERT INTO t1 (f_char1, f_char2, f_charbig)
21284
SELECT CAST(f_int1 AS CHAR),
21285
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
21286
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
21287
ORDER BY f_int1;
21288
DROP TRIGGER trg_3;
21289
	
21290
# check trigger-12 success: 	1
21291
DELETE FROM t1
21292
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
21293
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
21294
AND f_charbig = '####updated per insert trigger####';
21295
ANALYZE  TABLE t1;
21296
Table	Op	Msg_type	Msg_text
21297
test.t1	analyze	note	The storage engine for the table doesn't support analyze
21298
CHECK    TABLE t1 EXTENDED;
21299
Table	Op	Msg_type	Msg_text
21300
test.t1	check	note	The storage engine for the table doesn't support check
21301
CHECKSUM TABLE t1 EXTENDED;
21302
Table	Checksum
21303
test.t1	<some_value>
21304
OPTIMIZE TABLE t1;
21305
Table	Op	Msg_type	Msg_text
21306
test.t1	optimize	note	The storage engine for the table doesn't support optimize
21307
# check layout success:    1
21308
REPAIR   TABLE t1 EXTENDED;
21309
Table	Op	Msg_type	Msg_text
21310
test.t1	repair	note	The storage engine for the table doesn't support repair
21311
# check layout success:    1
21312
TRUNCATE t1;
21313
	
21314
# check TRUNCATE success: 	1
21315
# check layout success:    1
21316
# End usability test (inc/partition_check.inc)
21317
DROP TABLE t1;
21318
CREATE TABLE t1 (
21319
f_int1 INTEGER,
21320
f_int2 INTEGER,
21321
f_char1 CHAR(20),
21322
f_char2 CHAR(20),
21323
f_charbig VARCHAR(1000)
21324
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
21325
)
21326
PARTITION BY RANGE(f_int1) SUBPARTITION BY HASH(f_int2) SUBPARTITIONS 2
21327
(PARTITION parta VALUES LESS THAN (0),
21328
PARTITION partb VALUES LESS THAN (5),
21329
PARTITION partc VALUES LESS THAN (10),
21330
PARTITION partd VALUES LESS THAN (2147483646));
21331
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
21332
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
21333
# Start usability test (inc/partition_check.inc)
21334
create_command
21335
SHOW CREATE TABLE t1;
21336
Table	Create Table
21337
t1	CREATE TABLE `t1` (
21338
  `f_int1` int(11) NOT NULL DEFAULT '0',
21339
  `f_int2` int(11) NOT NULL DEFAULT '0',
21340
  `f_char1` char(20) DEFAULT NULL,
21341
  `f_char2` char(20) DEFAULT NULL,
21342
  `f_charbig` varchar(1000) DEFAULT NULL,
21343
  PRIMARY KEY (`f_int2`,`f_int1`),
21344
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
21345
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) SUBPARTITION BY HASH (f_int2) SUBPARTITIONS 2 (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
21346
21347
unified filelist
21348
$MYSQLTEST_VARDIR/master-data/test/t1.frm
21349
$MYSQLTEST_VARDIR/master-data/test/t1.par
21350
21351
# check prerequisites-1 success:    1
21352
# check COUNT(*) success:    1
21353
# check MIN/MAX(f_int1) success:    1
21354
# check MIN/MAX(f_int2) success:    1
21355
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21356
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
21357
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
21358
WHERE f_int1 IN (2,3);
21359
ERROR 23000: Can't write; duplicate key in table 't1'
21360
# check prerequisites-3 success:    1
21361
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
21362
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21363
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
21364
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
21365
WHERE f_int1 IN (2,3);
21366
DELETE FROM t1 WHERE f_charbig = 'delete me';
21367
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21368
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
21369
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
21370
WHERE f_int1 IN (2,3);
21371
DELETE FROM t1 WHERE f_charbig = 'delete me';
21372
# check read via f_int1 success: 1
21373
# check read via f_int2 success: 1
21374
	
21375
# check multiple-1 success: 	1
21376
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
21377
	
21378
# check multiple-2 success: 	1
21379
INSERT INTO t1 SELECT * FROM t0_template
21380
WHERE MOD(f_int1,3) = 0;
21381
	
21382
# check multiple-3 success: 	1
21383
UPDATE t1 SET f_int1 = f_int1 + @max_row
21384
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
21385
AND @max_row_div2 + @max_row_div4;
21386
	
21387
# check multiple-4 success: 	1
21388
DELETE FROM t1
21389
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
21390
AND @max_row_div2 + @max_row_div4 + @max_row;
21391
	
21392
# check multiple-5 success: 	1
21393
SELECT COUNT(*) INTO @try_count FROM t0_template
21394
WHERE MOD(f_int1,3) = 0
21395
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
21396
SELECT COUNT(*) INTO @clash_count
21397
FROM t1 INNER JOIN t0_template USING(f_int1)
21398
WHERE MOD(f_int1,3) = 0
21399
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
21400
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
21401
INSERT INTO t1
21402
SET f_int1 = @cur_value , f_int2 = @cur_value,
21403
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
21404
f_charbig = '#SINGLE#';
21405
	
21406
# check single-1 success: 	1
21407
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
21408
INSERT INTO t1
21409
SET f_int1 = @cur_value , f_int2 = @cur_value,
21410
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
21411
f_charbig = '#SINGLE#';
21412
	
21413
# check single-2 success: 	1
21414
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
21415
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
21416
UPDATE t1 SET f_int1 = @cur_value2
21417
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
21418
	
21419
# check single-3 success: 	1
21420
SET @cur_value1= -1;
21421
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
21422
UPDATE t1 SET f_int1 = @cur_value1
21423
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
21424
	
21425
# check single-4 success: 	1
21426
SELECT MAX(f_int1) INTO @cur_value FROM t1;
21427
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
21428
	
21429
# check single-5 success: 	1
21430
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
21431
	
21432
# check single-6 success: 	1
21433
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
21434
ERROR HY000: Table has no partition for value 2147483647
21435
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
21436
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
21437
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
21438
f_charbig = '#NULL#';
21439
INSERT INTO t1
21440
SET f_int1 = NULL , f_int2 = -@max_row,
21441
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
21442
f_charbig = '#NULL#';
21443
ERROR 23000: Column 'f_int1' cannot be null
21444
# check null success:    1
21445
DELETE FROM t1
21446
WHERE f_int1 = 0 AND f_int2 = 0
21447
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
21448
AND f_charbig = '#NULL#';
21449
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21450
SELECT f_int1, f_int1, '', '', 'was inserted'
21451
   FROM t0_template source_tab
21452
WHERE MOD(f_int1,3) = 0
21453
AND f_int1 BETWEEN @max_row_div2 AND @max_row
21454
ON DUPLICATE KEY
21455
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
21456
f_int2 = 2 * @max_row + source_tab.f_int1,
21457
f_charbig = 'was updated';
21458
	
21459
# check unique-1-a success: 	1
21460
	
21461
# check unique-1-b success: 	1
21462
DELETE FROM t1 WHERE f_charbig = 'was inserted';
21463
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21464
f_int2 = CAST(f_char1 AS SIGNED INT),
21465
f_charbig = CONCAT('===',f_char1,'===')
21466
WHERE f_charbig = 'was updated';
21467
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21468
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
21469
   FROM t0_template source_tab
21470
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
21471
	
21472
# check replace success: 	1
21473
DELETE FROM t1
21474
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
21475
DELETE FROM t1
21476
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
21477
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
21478
UPDATE t1 SET f_int2 = f_int1,
21479
f_char1 = CAST(f_int1 AS CHAR),
21480
f_char2 = CAST(f_int1 AS CHAR),
21481
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
21482
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
21483
SET AUTOCOMMIT= 0;
21484
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21485
SELECT f_int1, f_int1, '', '', 'was inserted'
21486
FROM t0_template source_tab
21487
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
21488
	
21489
# check transactions-1 success: 	1
21490
COMMIT WORK;
21491
	
21492
# check transactions-2 success: 	1
21493
ROLLBACK WORK;
21494
	
21495
# check transactions-3 success: 	1
21496
DELETE FROM t1 WHERE f_charbig = 'was inserted';
21497
COMMIT WORK;
21498
ROLLBACK WORK;
21499
	
21500
# check transactions-4 success: 	1
21501
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21502
SELECT f_int1, f_int1, '', '', 'was inserted'
21503
FROM t0_template source_tab
21504
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
21505
	
21506
# check transactions-5 success: 	1
21507
ROLLBACK WORK;
21508
	
21509
# check transactions-6 success: 	1
21510
# INFO: Storage engine used for t1 seems to be transactional.
21511
COMMIT;
21512
	
21513
# check transactions-7 success: 	1
21514
DELETE FROM t1 WHERE f_charbig = 'was inserted';
21515
COMMIT WORK;
21516
SET @@session.sql_mode = 'traditional';
21517
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
21518
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21519
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
21520
'', '', 'was inserted' FROM t0_template
21521
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
21522
ERROR 22012: Division by 0
21523
COMMIT;
21524
	
21525
# check transactions-8 success: 	1
21526
# INFO: Storage engine used for t1 seems to be able to revert
21527
#       changes made by the failing statement.
21528
SET @@session.sql_mode = '';
21529
SET AUTOCOMMIT= 1;
21530
DELETE FROM t1 WHERE f_charbig = 'was inserted';
21531
COMMIT WORK;
21532
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
21533
	
21534
# check special-1 success: 	1
21535
UPDATE t1 SET f_charbig = '';
21536
	
21537
# check special-2 success: 	1
21538
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
21539
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
21540
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
21541
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21542
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21543
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21544
'just inserted' FROM t0_template
21545
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21546
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
21547
BEGIN
21548
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21549
f_charbig = 'updated by trigger'
21550
      WHERE f_int1 = new.f_int1;
21551
END|
21552
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21553
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
21554
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21555
	
21556
# check trigger-1 success: 	1
21557
DROP TRIGGER trg_1;
21558
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21559
f_int2 = CAST(f_char1 AS SIGNED INT),
21560
f_charbig = 'just inserted'
21561
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21562
DELETE FROM t0_aux
21563
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21564
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21565
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21566
'just inserted' FROM t0_template
21567
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21568
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
21569
BEGIN
21570
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21571
f_charbig = 'updated by trigger'
21572
      WHERE f_int1 = new.f_int1;
21573
END|
21574
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21575
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
21576
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21577
	
21578
# check trigger-2 success: 	1
21579
DROP TRIGGER trg_1;
21580
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21581
f_int2 = CAST(f_char1 AS SIGNED INT),
21582
f_charbig = 'just inserted'
21583
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21584
DELETE FROM t0_aux
21585
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21586
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21587
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21588
'just inserted' FROM t0_template
21589
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21590
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
21591
BEGIN
21592
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21593
f_charbig = 'updated by trigger'
21594
      WHERE f_int1 = new.f_int1;
21595
END|
21596
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
21597
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
21598
	
21599
# check trigger-3 success: 	1
21600
DROP TRIGGER trg_1;
21601
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21602
f_int2 = CAST(f_char1 AS SIGNED INT),
21603
f_charbig = 'just inserted'
21604
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21605
DELETE FROM t0_aux
21606
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21607
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21608
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21609
'just inserted' FROM t0_template
21610
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21611
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
21612
BEGIN
21613
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21614
f_charbig = 'updated by trigger'
21615
      WHERE f_int1 = - old.f_int1;
21616
END|
21617
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
21618
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
21619
	
21620
# check trigger-4 success: 	1
21621
DROP TRIGGER trg_1;
21622
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21623
f_int2 = CAST(f_char1 AS SIGNED INT),
21624
f_charbig = 'just inserted'
21625
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21626
DELETE FROM t0_aux
21627
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21628
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21629
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21630
'just inserted' FROM t0_template
21631
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21632
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
21633
BEGIN
21634
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21635
f_charbig = 'updated by trigger'
21636
      WHERE f_int1 = new.f_int1;
21637
END|
21638
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
21639
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
21640
	
21641
# check trigger-5 success: 	1
21642
DROP TRIGGER trg_1;
21643
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21644
f_int2 = CAST(f_char1 AS SIGNED INT),
21645
f_charbig = 'just inserted'
21646
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21647
DELETE FROM t0_aux
21648
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21649
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21650
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21651
'just inserted' FROM t0_template
21652
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21653
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
21654
BEGIN
21655
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21656
f_charbig = 'updated by trigger'
21657
      WHERE f_int1 = - old.f_int1;
21658
END|
21659
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
21660
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
21661
	
21662
# check trigger-6 success: 	1
21663
DROP TRIGGER trg_1;
21664
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21665
f_int2 = CAST(f_char1 AS SIGNED INT),
21666
f_charbig = 'just inserted'
21667
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21668
DELETE FROM t0_aux
21669
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21670
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21671
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21672
'just inserted' FROM t0_template
21673
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21674
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
21675
BEGIN
21676
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21677
f_charbig = 'updated by trigger'
21678
      WHERE f_int1 = - old.f_int1;
21679
END|
21680
DELETE FROM t0_aux
21681
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
21682
	
21683
# check trigger-7 success: 	1
21684
DROP TRIGGER trg_1;
21685
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21686
f_int2 = CAST(f_char1 AS SIGNED INT),
21687
f_charbig = 'just inserted'
21688
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21689
DELETE FROM t0_aux
21690
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21691
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
21692
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
21693
'just inserted' FROM t0_template
21694
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21695
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
21696
BEGIN
21697
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
21698
f_charbig = 'updated by trigger'
21699
      WHERE f_int1 = - old.f_int1;
21700
END|
21701
DELETE FROM t0_aux
21702
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
21703
	
21704
# check trigger-8 success: 	1
21705
DROP TRIGGER trg_1;
21706
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21707
f_int2 = CAST(f_char1 AS SIGNED INT),
21708
f_charbig = 'just inserted'
21709
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
21710
DELETE FROM t0_aux
21711
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21712
DELETE FROM t1
21713
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
21714
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
21715
BEGIN
21716
SET new.f_int1 = old.f_int1 + @max_row,
21717
new.f_int2 = old.f_int2 - @max_row,
21718
new.f_charbig = '####updated per update trigger####';
21719
END|
21720
UPDATE t1
21721
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
21722
f_charbig = '####updated per update statement itself####';
21723
	
21724
# check trigger-9 success: 	1
21725
DROP TRIGGER trg_2;
21726
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21727
f_int2 = CAST(f_char1 AS SIGNED INT),
21728
f_charbig = CONCAT('===',f_char1,'===');
21729
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
21730
BEGIN
21731
SET new.f_int1 = new.f_int1 + @max_row,
21732
new.f_int2 = new.f_int2 - @max_row,
21733
new.f_charbig = '####updated per update trigger####';
21734
END|
21735
UPDATE t1
21736
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
21737
f_charbig = '####updated per update statement itself####';
21738
	
21739
# check trigger-10 success: 	1
21740
DROP TRIGGER trg_2;
21741
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21742
f_int2 = CAST(f_char1 AS SIGNED INT),
21743
f_charbig = CONCAT('===',f_char1,'===');
21744
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
21745
BEGIN
21746
SET new.f_int1 = @my_max1 + @counter,
21747
new.f_int2 = @my_min2 - @counter,
21748
new.f_charbig = '####updated per insert trigger####';
21749
SET @counter = @counter + 1;
21750
END|
21751
SET @counter = 1;
21752
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
21753
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21754
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
21755
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
21756
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
21757
ORDER BY f_int1;
21758
DROP TRIGGER trg_3;
21759
	
21760
# check trigger-11 success: 	1
21761
DELETE FROM t1
21762
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
21763
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
21764
AND f_charbig = '####updated per insert trigger####';
21765
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
21766
BEGIN
21767
SET new.f_int1 = @my_max1 + @counter,
21768
new.f_int2 = @my_min2 - @counter,
21769
new.f_charbig = '####updated per insert trigger####';
21770
SET @counter = @counter + 1;
21771
END|
21772
SET @counter = 1;
21773
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
21774
INSERT INTO t1 (f_char1, f_char2, f_charbig)
21775
SELECT CAST(f_int1 AS CHAR),
21776
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
21777
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
21778
ORDER BY f_int1;
21779
DROP TRIGGER trg_3;
21780
	
21781
# check trigger-12 success: 	1
21782
DELETE FROM t1
21783
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
21784
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
21785
AND f_charbig = '####updated per insert trigger####';
21786
ANALYZE  TABLE t1;
21787
Table	Op	Msg_type	Msg_text
21788
test.t1	analyze	note	The storage engine for the table doesn't support analyze
21789
CHECK    TABLE t1 EXTENDED;
21790
Table	Op	Msg_type	Msg_text
21791
test.t1	check	note	The storage engine for the table doesn't support check
21792
CHECKSUM TABLE t1 EXTENDED;
21793
Table	Checksum
21794
test.t1	<some_value>
21795
OPTIMIZE TABLE t1;
21796
Table	Op	Msg_type	Msg_text
21797
test.t1	optimize	note	The storage engine for the table doesn't support optimize
21798
# check layout success:    1
21799
REPAIR   TABLE t1 EXTENDED;
21800
Table	Op	Msg_type	Msg_text
21801
test.t1	repair	note	The storage engine for the table doesn't support repair
21802
# check layout success:    1
21803
TRUNCATE t1;
21804
	
21805
# check TRUNCATE success: 	1
21806
# check layout success:    1
21807
# End usability test (inc/partition_check.inc)
21808
DROP TABLE t1;
21809
CREATE TABLE t1 (
21810
f_int1 INTEGER,
21811
f_int2 INTEGER,
21812
f_char1 CHAR(20),
21813
f_char2 CHAR(20),
21814
f_charbig VARCHAR(1000)
21815
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
21816
)
21817
PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int2)
21818
(PARTITION part1 VALUES LESS THAN (0)
21819
(SUBPARTITION subpart11, SUBPARTITION subpart12),
21820
PARTITION part2 VALUES LESS THAN (5)
21821
(SUBPARTITION subpart21, SUBPARTITION subpart22),
21822
PARTITION part3 VALUES LESS THAN (10)
21823
(SUBPARTITION subpart31, SUBPARTITION subpart32),
21824
PARTITION part4 VALUES LESS THAN (2147483646)
21825
(SUBPARTITION subpart41, SUBPARTITION subpart42));
21826
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
21827
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
21828
# Start usability test (inc/partition_check.inc)
21829
create_command
21830
SHOW CREATE TABLE t1;
21831
Table	Create Table
21832
t1	CREATE TABLE `t1` (
21833
  `f_int1` int(11) NOT NULL DEFAULT '0',
21834
  `f_int2` int(11) NOT NULL DEFAULT '0',
21835
  `f_char1` char(20) DEFAULT NULL,
21836
  `f_char2` char(20) DEFAULT NULL,
21837
  `f_charbig` varchar(1000) DEFAULT NULL,
21838
  PRIMARY KEY (`f_int2`,`f_int1`),
21839
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
21840
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), PARTITION part2 VALUES LESS THAN (5) (SUBPARTITION subpart21 ENGINE = InnoDB, SUBPARTITION subpart22 ENGINE = InnoDB), PARTITION part3 VALUES LESS THAN (10) (SUBPARTITION subpart31 ENGINE = InnoDB, SUBPARTITION subpart32 ENGINE = InnoDB), PARTITION part4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41 ENGINE = InnoDB, SUBPARTITION subpart42 ENGINE = InnoDB)) */
21841
21842
unified filelist
21843
$MYSQLTEST_VARDIR/master-data/test/t1.frm
21844
$MYSQLTEST_VARDIR/master-data/test/t1.par
21845
21846
# check prerequisites-1 success:    1
21847
# check COUNT(*) success:    1
21848
# check MIN/MAX(f_int1) success:    1
21849
# check MIN/MAX(f_int2) success:    1
21850
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21851
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
21852
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
21853
WHERE f_int1 IN (2,3);
21854
ERROR 23000: Can't write; duplicate key in table 't1'
21855
# check prerequisites-3 success:    1
21856
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
21857
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21858
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
21859
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
21860
WHERE f_int1 IN (2,3);
21861
DELETE FROM t1 WHERE f_charbig = 'delete me';
21862
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21863
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
21864
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
21865
WHERE f_int1 IN (2,3);
21866
DELETE FROM t1 WHERE f_charbig = 'delete me';
21867
# check read via f_int1 success: 1
21868
# check read via f_int2 success: 1
21869
	
21870
# check multiple-1 success: 	1
21871
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
21872
	
21873
# check multiple-2 success: 	1
21874
INSERT INTO t1 SELECT * FROM t0_template
21875
WHERE MOD(f_int1,3) = 0;
21876
	
21877
# check multiple-3 success: 	1
21878
UPDATE t1 SET f_int1 = f_int1 + @max_row
21879
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
21880
AND @max_row_div2 + @max_row_div4;
21881
	
21882
# check multiple-4 success: 	1
21883
DELETE FROM t1
21884
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
21885
AND @max_row_div2 + @max_row_div4 + @max_row;
21886
	
21887
# check multiple-5 success: 	1
21888
SELECT COUNT(*) INTO @try_count FROM t0_template
21889
WHERE MOD(f_int1,3) = 0
21890
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
21891
SELECT COUNT(*) INTO @clash_count
21892
FROM t1 INNER JOIN t0_template USING(f_int1)
21893
WHERE MOD(f_int1,3) = 0
21894
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
21895
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
21896
INSERT INTO t1
21897
SET f_int1 = @cur_value , f_int2 = @cur_value,
21898
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
21899
f_charbig = '#SINGLE#';
21900
	
21901
# check single-1 success: 	1
21902
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
21903
INSERT INTO t1
21904
SET f_int1 = @cur_value , f_int2 = @cur_value,
21905
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
21906
f_charbig = '#SINGLE#';
21907
	
21908
# check single-2 success: 	1
21909
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
21910
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
21911
UPDATE t1 SET f_int1 = @cur_value2
21912
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
21913
	
21914
# check single-3 success: 	1
21915
SET @cur_value1= -1;
21916
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
21917
UPDATE t1 SET f_int1 = @cur_value1
21918
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
21919
	
21920
# check single-4 success: 	1
21921
SELECT MAX(f_int1) INTO @cur_value FROM t1;
21922
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
21923
	
21924
# check single-5 success: 	1
21925
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
21926
	
21927
# check single-6 success: 	1
21928
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
21929
ERROR HY000: Table has no partition for value 2147483647
21930
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
21931
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
21932
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
21933
f_charbig = '#NULL#';
21934
INSERT INTO t1
21935
SET f_int1 = NULL , f_int2 = -@max_row,
21936
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
21937
f_charbig = '#NULL#';
21938
ERROR 23000: Column 'f_int1' cannot be null
21939
# check null success:    1
21940
DELETE FROM t1
21941
WHERE f_int1 = 0 AND f_int2 = 0
21942
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
21943
AND f_charbig = '#NULL#';
21944
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21945
SELECT f_int1, f_int1, '', '', 'was inserted'
21946
   FROM t0_template source_tab
21947
WHERE MOD(f_int1,3) = 0
21948
AND f_int1 BETWEEN @max_row_div2 AND @max_row
21949
ON DUPLICATE KEY
21950
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
21951
f_int2 = 2 * @max_row + source_tab.f_int1,
21952
f_charbig = 'was updated';
21953
	
21954
# check unique-1-a success: 	1
21955
	
21956
# check unique-1-b success: 	1
21957
DELETE FROM t1 WHERE f_charbig = 'was inserted';
21958
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
21959
f_int2 = CAST(f_char1 AS SIGNED INT),
21960
f_charbig = CONCAT('===',f_char1,'===')
21961
WHERE f_charbig = 'was updated';
21962
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21963
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
21964
   FROM t0_template source_tab
21965
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
21966
	
21967
# check replace success: 	1
21968
DELETE FROM t1
21969
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
21970
DELETE FROM t1
21971
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
21972
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
21973
UPDATE t1 SET f_int2 = f_int1,
21974
f_char1 = CAST(f_int1 AS CHAR),
21975
f_char2 = CAST(f_int1 AS CHAR),
21976
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
21977
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
21978
SET AUTOCOMMIT= 0;
21979
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21980
SELECT f_int1, f_int1, '', '', 'was inserted'
21981
FROM t0_template source_tab
21982
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
21983
	
21984
# check transactions-1 success: 	1
21985
COMMIT WORK;
21986
	
21987
# check transactions-2 success: 	1
21988
ROLLBACK WORK;
21989
	
21990
# check transactions-3 success: 	1
21991
DELETE FROM t1 WHERE f_charbig = 'was inserted';
21992
COMMIT WORK;
21993
ROLLBACK WORK;
21994
	
21995
# check transactions-4 success: 	1
21996
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
21997
SELECT f_int1, f_int1, '', '', 'was inserted'
21998
FROM t0_template source_tab
21999
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
22000
	
22001
# check transactions-5 success: 	1
22002
ROLLBACK WORK;
22003
	
22004
# check transactions-6 success: 	1
22005
# INFO: Storage engine used for t1 seems to be transactional.
22006
COMMIT;
22007
	
22008
# check transactions-7 success: 	1
22009
DELETE FROM t1 WHERE f_charbig = 'was inserted';
22010
COMMIT WORK;
22011
SET @@session.sql_mode = 'traditional';
22012
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
22013
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22014
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
22015
'', '', 'was inserted' FROM t0_template
22016
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
22017
ERROR 22012: Division by 0
22018
COMMIT;
22019
	
22020
# check transactions-8 success: 	1
22021
# INFO: Storage engine used for t1 seems to be able to revert
22022
#       changes made by the failing statement.
22023
SET @@session.sql_mode = '';
22024
SET AUTOCOMMIT= 1;
22025
DELETE FROM t1 WHERE f_charbig = 'was inserted';
22026
COMMIT WORK;
22027
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
22028
	
22029
# check special-1 success: 	1
22030
UPDATE t1 SET f_charbig = '';
22031
	
22032
# check special-2 success: 	1
22033
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
22034
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
22035
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
22036
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22037
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22038
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22039
'just inserted' FROM t0_template
22040
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22041
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
22042
BEGIN
22043
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22044
f_charbig = 'updated by trigger'
22045
      WHERE f_int1 = new.f_int1;
22046
END|
22047
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22048
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
22049
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22050
	
22051
# check trigger-1 success: 	1
22052
DROP TRIGGER trg_1;
22053
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22054
f_int2 = CAST(f_char1 AS SIGNED INT),
22055
f_charbig = 'just inserted'
22056
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22057
DELETE FROM t0_aux
22058
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22059
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22060
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22061
'just inserted' FROM t0_template
22062
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22063
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
22064
BEGIN
22065
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22066
f_charbig = 'updated by trigger'
22067
      WHERE f_int1 = new.f_int1;
22068
END|
22069
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22070
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
22071
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22072
	
22073
# check trigger-2 success: 	1
22074
DROP TRIGGER trg_1;
22075
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22076
f_int2 = CAST(f_char1 AS SIGNED INT),
22077
f_charbig = 'just inserted'
22078
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22079
DELETE FROM t0_aux
22080
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22081
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22082
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22083
'just inserted' FROM t0_template
22084
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22085
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
22086
BEGIN
22087
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22088
f_charbig = 'updated by trigger'
22089
      WHERE f_int1 = new.f_int1;
22090
END|
22091
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
22092
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
22093
	
22094
# check trigger-3 success: 	1
22095
DROP TRIGGER trg_1;
22096
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22097
f_int2 = CAST(f_char1 AS SIGNED INT),
22098
f_charbig = 'just inserted'
22099
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22100
DELETE FROM t0_aux
22101
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22102
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22103
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22104
'just inserted' FROM t0_template
22105
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22106
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
22107
BEGIN
22108
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22109
f_charbig = 'updated by trigger'
22110
      WHERE f_int1 = - old.f_int1;
22111
END|
22112
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
22113
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
22114
	
22115
# check trigger-4 success: 	1
22116
DROP TRIGGER trg_1;
22117
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22118
f_int2 = CAST(f_char1 AS SIGNED INT),
22119
f_charbig = 'just inserted'
22120
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22121
DELETE FROM t0_aux
22122
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22123
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22124
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22125
'just inserted' FROM t0_template
22126
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22127
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
22128
BEGIN
22129
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22130
f_charbig = 'updated by trigger'
22131
      WHERE f_int1 = new.f_int1;
22132
END|
22133
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
22134
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
22135
	
22136
# check trigger-5 success: 	1
22137
DROP TRIGGER trg_1;
22138
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22139
f_int2 = CAST(f_char1 AS SIGNED INT),
22140
f_charbig = 'just inserted'
22141
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22142
DELETE FROM t0_aux
22143
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22144
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22145
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22146
'just inserted' FROM t0_template
22147
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22148
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
22149
BEGIN
22150
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22151
f_charbig = 'updated by trigger'
22152
      WHERE f_int1 = - old.f_int1;
22153
END|
22154
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
22155
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
22156
	
22157
# check trigger-6 success: 	1
22158
DROP TRIGGER trg_1;
22159
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22160
f_int2 = CAST(f_char1 AS SIGNED INT),
22161
f_charbig = 'just inserted'
22162
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22163
DELETE FROM t0_aux
22164
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22165
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22166
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22167
'just inserted' FROM t0_template
22168
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22169
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
22170
BEGIN
22171
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22172
f_charbig = 'updated by trigger'
22173
      WHERE f_int1 = - old.f_int1;
22174
END|
22175
DELETE FROM t0_aux
22176
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
22177
	
22178
# check trigger-7 success: 	1
22179
DROP TRIGGER trg_1;
22180
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22181
f_int2 = CAST(f_char1 AS SIGNED INT),
22182
f_charbig = 'just inserted'
22183
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22184
DELETE FROM t0_aux
22185
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22186
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22187
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22188
'just inserted' FROM t0_template
22189
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22190
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
22191
BEGIN
22192
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22193
f_charbig = 'updated by trigger'
22194
      WHERE f_int1 = - old.f_int1;
22195
END|
22196
DELETE FROM t0_aux
22197
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
22198
	
22199
# check trigger-8 success: 	1
22200
DROP TRIGGER trg_1;
22201
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22202
f_int2 = CAST(f_char1 AS SIGNED INT),
22203
f_charbig = 'just inserted'
22204
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22205
DELETE FROM t0_aux
22206
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22207
DELETE FROM t1
22208
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22209
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
22210
BEGIN
22211
SET new.f_int1 = old.f_int1 + @max_row,
22212
new.f_int2 = old.f_int2 - @max_row,
22213
new.f_charbig = '####updated per update trigger####';
22214
END|
22215
UPDATE t1
22216
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
22217
f_charbig = '####updated per update statement itself####';
22218
	
22219
# check trigger-9 success: 	1
22220
DROP TRIGGER trg_2;
22221
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22222
f_int2 = CAST(f_char1 AS SIGNED INT),
22223
f_charbig = CONCAT('===',f_char1,'===');
22224
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
22225
BEGIN
22226
SET new.f_int1 = new.f_int1 + @max_row,
22227
new.f_int2 = new.f_int2 - @max_row,
22228
new.f_charbig = '####updated per update trigger####';
22229
END|
22230
UPDATE t1
22231
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
22232
f_charbig = '####updated per update statement itself####';
22233
	
22234
# check trigger-10 success: 	1
22235
DROP TRIGGER trg_2;
22236
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22237
f_int2 = CAST(f_char1 AS SIGNED INT),
22238
f_charbig = CONCAT('===',f_char1,'===');
22239
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
22240
BEGIN
22241
SET new.f_int1 = @my_max1 + @counter,
22242
new.f_int2 = @my_min2 - @counter,
22243
new.f_charbig = '####updated per insert trigger####';
22244
SET @counter = @counter + 1;
22245
END|
22246
SET @counter = 1;
22247
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
22248
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22249
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
22250
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
22251
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
22252
ORDER BY f_int1;
22253
DROP TRIGGER trg_3;
22254
	
22255
# check trigger-11 success: 	1
22256
DELETE FROM t1
22257
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
22258
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
22259
AND f_charbig = '####updated per insert trigger####';
22260
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
22261
BEGIN
22262
SET new.f_int1 = @my_max1 + @counter,
22263
new.f_int2 = @my_min2 - @counter,
22264
new.f_charbig = '####updated per insert trigger####';
22265
SET @counter = @counter + 1;
22266
END|
22267
SET @counter = 1;
22268
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
22269
INSERT INTO t1 (f_char1, f_char2, f_charbig)
22270
SELECT CAST(f_int1 AS CHAR),
22271
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
22272
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
22273
ORDER BY f_int1;
22274
DROP TRIGGER trg_3;
22275
	
22276
# check trigger-12 success: 	1
22277
DELETE FROM t1
22278
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
22279
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
22280
AND f_charbig = '####updated per insert trigger####';
22281
ANALYZE  TABLE t1;
22282
Table	Op	Msg_type	Msg_text
22283
test.t1	analyze	note	The storage engine for the table doesn't support analyze
22284
CHECK    TABLE t1 EXTENDED;
22285
Table	Op	Msg_type	Msg_text
22286
test.t1	check	note	The storage engine for the table doesn't support check
22287
CHECKSUM TABLE t1 EXTENDED;
22288
Table	Checksum
22289
test.t1	<some_value>
22290
OPTIMIZE TABLE t1;
22291
Table	Op	Msg_type	Msg_text
22292
test.t1	optimize	note	The storage engine for the table doesn't support optimize
22293
# check layout success:    1
22294
REPAIR   TABLE t1 EXTENDED;
22295
Table	Op	Msg_type	Msg_text
22296
test.t1	repair	note	The storage engine for the table doesn't support repair
22297
# check layout success:    1
22298
TRUNCATE t1;
22299
	
22300
# check TRUNCATE success: 	1
22301
# check layout success:    1
22302
# End usability test (inc/partition_check.inc)
22303
DROP TABLE t1;
22304
CREATE TABLE t1 (
22305
f_int1 INTEGER,
22306
f_int2 INTEGER,
22307
f_char1 CHAR(20),
22308
f_char2 CHAR(20),
22309
f_charbig VARCHAR(1000)
22310
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
22311
)
22312
PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int2 + 1)
22313
(PARTITION part1 VALUES IN (0)
22314
(SUBPARTITION sp11, SUBPARTITION sp12),
22315
PARTITION part2 VALUES IN (1)
22316
(SUBPARTITION sp21, SUBPARTITION sp22),
22317
PARTITION part3 VALUES IN (2)
22318
(SUBPARTITION sp31, SUBPARTITION sp32),
22319
PARTITION part4 VALUES IN (NULL)
22320
(SUBPARTITION sp41, SUBPARTITION sp42));
22321
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
22322
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
22323
# Start usability test (inc/partition_check.inc)
22324
create_command
22325
SHOW CREATE TABLE t1;
22326
Table	Create Table
22327
t1	CREATE TABLE `t1` (
22328
  `f_int1` int(11) NOT NULL DEFAULT '0',
22329
  `f_int2` int(11) NOT NULL DEFAULT '0',
22330
  `f_char1` char(20) DEFAULT NULL,
22331
  `f_char2` char(20) DEFAULT NULL,
22332
  `f_charbig` varchar(1000) DEFAULT NULL,
22333
  PRIMARY KEY (`f_int2`,`f_int1`),
22334
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
22335
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,3))) SUBPARTITION BY HASH (f_int2 + 1) (PARTITION part1 VALUES IN (0) (SUBPARTITION sp11 ENGINE = InnoDB, SUBPARTITION sp12 ENGINE = InnoDB), PARTITION part2 VALUES IN (1) (SUBPARTITION sp21 ENGINE = InnoDB, SUBPARTITION sp22 ENGINE = InnoDB), PARTITION part3 VALUES IN (2) (SUBPARTITION sp31 ENGINE = InnoDB, SUBPARTITION sp32 ENGINE = InnoDB), PARTITION part4 VALUES IN (NULL) (SUBPARTITION sp41 ENGINE = InnoDB, SUBPARTITION sp42 ENGINE = InnoDB)) */
22336
22337
unified filelist
22338
$MYSQLTEST_VARDIR/master-data/test/t1.frm
22339
$MYSQLTEST_VARDIR/master-data/test/t1.par
22340
22341
# check prerequisites-1 success:    1
22342
# check COUNT(*) success:    1
22343
# check MIN/MAX(f_int1) success:    1
22344
# check MIN/MAX(f_int2) success:    1
22345
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22346
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
22347
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
22348
WHERE f_int1 IN (2,3);
22349
ERROR 23000: Can't write; duplicate key in table 't1'
22350
# check prerequisites-3 success:    1
22351
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
22352
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22353
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
22354
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
22355
WHERE f_int1 IN (2,3);
22356
DELETE FROM t1 WHERE f_charbig = 'delete me';
22357
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22358
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
22359
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
22360
WHERE f_int1 IN (2,3);
22361
DELETE FROM t1 WHERE f_charbig = 'delete me';
22362
# check read via f_int1 success: 1
22363
# check read via f_int2 success: 1
22364
	
22365
# check multiple-1 success: 	1
22366
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
22367
	
22368
# check multiple-2 success: 	1
22369
INSERT INTO t1 SELECT * FROM t0_template
22370
WHERE MOD(f_int1,3) = 0;
22371
	
22372
# check multiple-3 success: 	1
22373
UPDATE t1 SET f_int1 = f_int1 + @max_row
22374
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
22375
AND @max_row_div2 + @max_row_div4;
22376
	
22377
# check multiple-4 success: 	1
22378
DELETE FROM t1
22379
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
22380
AND @max_row_div2 + @max_row_div4 + @max_row;
22381
	
22382
# check multiple-5 success: 	1
22383
SELECT COUNT(*) INTO @try_count FROM t0_template
22384
WHERE MOD(f_int1,3) = 0
22385
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
22386
SELECT COUNT(*) INTO @clash_count
22387
FROM t1 INNER JOIN t0_template USING(f_int1)
22388
WHERE MOD(f_int1,3) = 0
22389
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
22390
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
22391
INSERT INTO t1
22392
SET f_int1 = @cur_value , f_int2 = @cur_value,
22393
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
22394
f_charbig = '#SINGLE#';
22395
	
22396
# check single-1 success: 	1
22397
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
22398
INSERT INTO t1
22399
SET f_int1 = @cur_value , f_int2 = @cur_value,
22400
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
22401
f_charbig = '#SINGLE#';
22402
	
22403
# check single-2 success: 	1
22404
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
22405
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
22406
UPDATE t1 SET f_int1 = @cur_value2
22407
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
22408
	
22409
# check single-3 success: 	1
22410
SET @cur_value1= -1;
22411
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
22412
UPDATE t1 SET f_int1 = @cur_value1
22413
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
22414
	
22415
# check single-4 success: 	1
22416
SELECT MAX(f_int1) INTO @cur_value FROM t1;
22417
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
22418
	
22419
# check single-5 success: 	1
22420
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
22421
	
22422
# check single-6 success: 	1
22423
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
22424
	
22425
# check single-7 success: 	1
22426
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
22427
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
22428
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
22429
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
22430
f_charbig = '#NULL#';
22431
INSERT INTO t1
22432
SET f_int1 = NULL , f_int2 = -@max_row,
22433
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
22434
f_charbig = '#NULL#';
22435
ERROR 23000: Column 'f_int1' cannot be null
22436
# check null success:    1
22437
DELETE FROM t1
22438
WHERE f_int1 = 0 AND f_int2 = 0
22439
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
22440
AND f_charbig = '#NULL#';
22441
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22442
SELECT f_int1, f_int1, '', '', 'was inserted'
22443
   FROM t0_template source_tab
22444
WHERE MOD(f_int1,3) = 0
22445
AND f_int1 BETWEEN @max_row_div2 AND @max_row
22446
ON DUPLICATE KEY
22447
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
22448
f_int2 = 2 * @max_row + source_tab.f_int1,
22449
f_charbig = 'was updated';
22450
	
22451
# check unique-1-a success: 	1
22452
	
22453
# check unique-1-b success: 	1
22454
DELETE FROM t1 WHERE f_charbig = 'was inserted';
22455
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22456
f_int2 = CAST(f_char1 AS SIGNED INT),
22457
f_charbig = CONCAT('===',f_char1,'===')
22458
WHERE f_charbig = 'was updated';
22459
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22460
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
22461
   FROM t0_template source_tab
22462
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
22463
	
22464
# check replace success: 	1
22465
DELETE FROM t1
22466
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
22467
DELETE FROM t1
22468
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
22469
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
22470
UPDATE t1 SET f_int2 = f_int1,
22471
f_char1 = CAST(f_int1 AS CHAR),
22472
f_char2 = CAST(f_int1 AS CHAR),
22473
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
22474
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
22475
SET AUTOCOMMIT= 0;
22476
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22477
SELECT f_int1, f_int1, '', '', 'was inserted'
22478
FROM t0_template source_tab
22479
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
22480
	
22481
# check transactions-1 success: 	1
22482
COMMIT WORK;
22483
	
22484
# check transactions-2 success: 	1
22485
ROLLBACK WORK;
22486
	
22487
# check transactions-3 success: 	1
22488
DELETE FROM t1 WHERE f_charbig = 'was inserted';
22489
COMMIT WORK;
22490
ROLLBACK WORK;
22491
	
22492
# check transactions-4 success: 	1
22493
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22494
SELECT f_int1, f_int1, '', '', 'was inserted'
22495
FROM t0_template source_tab
22496
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
22497
	
22498
# check transactions-5 success: 	1
22499
ROLLBACK WORK;
22500
	
22501
# check transactions-6 success: 	1
22502
# INFO: Storage engine used for t1 seems to be transactional.
22503
COMMIT;
22504
	
22505
# check transactions-7 success: 	1
22506
DELETE FROM t1 WHERE f_charbig = 'was inserted';
22507
COMMIT WORK;
22508
SET @@session.sql_mode = 'traditional';
22509
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
22510
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22511
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
22512
'', '', 'was inserted' FROM t0_template
22513
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
22514
ERROR 22012: Division by 0
22515
COMMIT;
22516
	
22517
# check transactions-8 success: 	1
22518
# INFO: Storage engine used for t1 seems to be able to revert
22519
#       changes made by the failing statement.
22520
SET @@session.sql_mode = '';
22521
SET AUTOCOMMIT= 1;
22522
DELETE FROM t1 WHERE f_charbig = 'was inserted';
22523
COMMIT WORK;
22524
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
22525
	
22526
# check special-1 success: 	1
22527
UPDATE t1 SET f_charbig = '';
22528
	
22529
# check special-2 success: 	1
22530
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
22531
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
22532
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
22533
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22534
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22535
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22536
'just inserted' FROM t0_template
22537
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22538
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
22539
BEGIN
22540
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22541
f_charbig = 'updated by trigger'
22542
      WHERE f_int1 = new.f_int1;
22543
END|
22544
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22545
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
22546
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22547
	
22548
# check trigger-1 success: 	1
22549
DROP TRIGGER trg_1;
22550
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22551
f_int2 = CAST(f_char1 AS SIGNED INT),
22552
f_charbig = 'just inserted'
22553
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22554
DELETE FROM t0_aux
22555
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22556
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22557
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22558
'just inserted' FROM t0_template
22559
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22560
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
22561
BEGIN
22562
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22563
f_charbig = 'updated by trigger'
22564
      WHERE f_int1 = new.f_int1;
22565
END|
22566
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22567
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
22568
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22569
	
22570
# check trigger-2 success: 	1
22571
DROP TRIGGER trg_1;
22572
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22573
f_int2 = CAST(f_char1 AS SIGNED INT),
22574
f_charbig = 'just inserted'
22575
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22576
DELETE FROM t0_aux
22577
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22578
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22579
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22580
'just inserted' FROM t0_template
22581
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22582
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
22583
BEGIN
22584
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22585
f_charbig = 'updated by trigger'
22586
      WHERE f_int1 = new.f_int1;
22587
END|
22588
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
22589
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
22590
	
22591
# check trigger-3 success: 	1
22592
DROP TRIGGER trg_1;
22593
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22594
f_int2 = CAST(f_char1 AS SIGNED INT),
22595
f_charbig = 'just inserted'
22596
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22597
DELETE FROM t0_aux
22598
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22599
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22600
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22601
'just inserted' FROM t0_template
22602
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22603
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
22604
BEGIN
22605
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22606
f_charbig = 'updated by trigger'
22607
      WHERE f_int1 = - old.f_int1;
22608
END|
22609
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
22610
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
22611
	
22612
# check trigger-4 success: 	1
22613
DROP TRIGGER trg_1;
22614
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22615
f_int2 = CAST(f_char1 AS SIGNED INT),
22616
f_charbig = 'just inserted'
22617
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22618
DELETE FROM t0_aux
22619
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22620
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22621
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22622
'just inserted' FROM t0_template
22623
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22624
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
22625
BEGIN
22626
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22627
f_charbig = 'updated by trigger'
22628
      WHERE f_int1 = new.f_int1;
22629
END|
22630
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
22631
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
22632
	
22633
# check trigger-5 success: 	1
22634
DROP TRIGGER trg_1;
22635
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22636
f_int2 = CAST(f_char1 AS SIGNED INT),
22637
f_charbig = 'just inserted'
22638
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22639
DELETE FROM t0_aux
22640
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22641
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22642
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22643
'just inserted' FROM t0_template
22644
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22645
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
22646
BEGIN
22647
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22648
f_charbig = 'updated by trigger'
22649
      WHERE f_int1 = - old.f_int1;
22650
END|
22651
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
22652
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
22653
	
22654
# check trigger-6 success: 	1
22655
DROP TRIGGER trg_1;
22656
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22657
f_int2 = CAST(f_char1 AS SIGNED INT),
22658
f_charbig = 'just inserted'
22659
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22660
DELETE FROM t0_aux
22661
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22662
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22663
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22664
'just inserted' FROM t0_template
22665
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22666
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
22667
BEGIN
22668
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22669
f_charbig = 'updated by trigger'
22670
      WHERE f_int1 = - old.f_int1;
22671
END|
22672
DELETE FROM t0_aux
22673
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
22674
	
22675
# check trigger-7 success: 	1
22676
DROP TRIGGER trg_1;
22677
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22678
f_int2 = CAST(f_char1 AS SIGNED INT),
22679
f_charbig = 'just inserted'
22680
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22681
DELETE FROM t0_aux
22682
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22683
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
22684
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
22685
'just inserted' FROM t0_template
22686
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22687
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
22688
BEGIN
22689
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
22690
f_charbig = 'updated by trigger'
22691
      WHERE f_int1 = - old.f_int1;
22692
END|
22693
DELETE FROM t0_aux
22694
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
22695
	
22696
# check trigger-8 success: 	1
22697
DROP TRIGGER trg_1;
22698
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22699
f_int2 = CAST(f_char1 AS SIGNED INT),
22700
f_charbig = 'just inserted'
22701
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
22702
DELETE FROM t0_aux
22703
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22704
DELETE FROM t1
22705
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
22706
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
22707
BEGIN
22708
SET new.f_int1 = old.f_int1 + @max_row,
22709
new.f_int2 = old.f_int2 - @max_row,
22710
new.f_charbig = '####updated per update trigger####';
22711
END|
22712
UPDATE t1
22713
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
22714
f_charbig = '####updated per update statement itself####';
22715
	
22716
# check trigger-9 success: 	1
22717
DROP TRIGGER trg_2;
22718
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22719
f_int2 = CAST(f_char1 AS SIGNED INT),
22720
f_charbig = CONCAT('===',f_char1,'===');
22721
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
22722
BEGIN
22723
SET new.f_int1 = new.f_int1 + @max_row,
22724
new.f_int2 = new.f_int2 - @max_row,
22725
new.f_charbig = '####updated per update trigger####';
22726
END|
22727
UPDATE t1
22728
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
22729
f_charbig = '####updated per update statement itself####';
22730
	
22731
# check trigger-10 success: 	1
22732
DROP TRIGGER trg_2;
22733
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22734
f_int2 = CAST(f_char1 AS SIGNED INT),
22735
f_charbig = CONCAT('===',f_char1,'===');
22736
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
22737
BEGIN
22738
SET new.f_int1 = @my_max1 + @counter,
22739
new.f_int2 = @my_min2 - @counter,
22740
new.f_charbig = '####updated per insert trigger####';
22741
SET @counter = @counter + 1;
22742
END|
22743
SET @counter = 1;
22744
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
22745
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22746
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
22747
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
22748
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
22749
ORDER BY f_int1;
22750
DROP TRIGGER trg_3;
22751
	
22752
# check trigger-11 success: 	1
22753
DELETE FROM t1
22754
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
22755
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
22756
AND f_charbig = '####updated per insert trigger####';
22757
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
22758
BEGIN
22759
SET new.f_int1 = @my_max1 + @counter,
22760
new.f_int2 = @my_min2 - @counter,
22761
new.f_charbig = '####updated per insert trigger####';
22762
SET @counter = @counter + 1;
22763
END|
22764
SET @counter = 1;
22765
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
22766
INSERT INTO t1 (f_char1, f_char2, f_charbig)
22767
SELECT CAST(f_int1 AS CHAR),
22768
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
22769
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
22770
ORDER BY f_int1;
22771
DROP TRIGGER trg_3;
22772
	
22773
# check trigger-12 success: 	1
22774
DELETE FROM t1
22775
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
22776
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
22777
AND f_charbig = '####updated per insert trigger####';
22778
ANALYZE  TABLE t1;
22779
Table	Op	Msg_type	Msg_text
22780
test.t1	analyze	note	The storage engine for the table doesn't support analyze
22781
CHECK    TABLE t1 EXTENDED;
22782
Table	Op	Msg_type	Msg_text
22783
test.t1	check	note	The storage engine for the table doesn't support check
22784
CHECKSUM TABLE t1 EXTENDED;
22785
Table	Checksum
22786
test.t1	<some_value>
22787
OPTIMIZE TABLE t1;
22788
Table	Op	Msg_type	Msg_text
22789
test.t1	optimize	note	The storage engine for the table doesn't support optimize
22790
# check layout success:    1
22791
REPAIR   TABLE t1 EXTENDED;
22792
Table	Op	Msg_type	Msg_text
22793
test.t1	repair	note	The storage engine for the table doesn't support repair
22794
# check layout success:    1
22795
TRUNCATE t1;
22796
	
22797
# check TRUNCATE success: 	1
22798
# check layout success:    1
22799
# End usability test (inc/partition_check.inc)
22800
DROP TABLE t1;
22801
CREATE TABLE t1 (
22802
f_int1 INTEGER,
22803
f_int2 INTEGER,
22804
f_char1 CHAR(20),
22805
f_char2 CHAR(20),
22806
f_charbig VARCHAR(1000)
22807
, UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1)
22808
)
22809
PARTITION BY LIST(ABS(MOD(f_int1,2)))
22810
SUBPARTITION BY KEY(f_int2)  SUBPARTITIONS 3
22811
(PARTITION part1 VALUES IN (0),
22812
PARTITION part2 VALUES IN (1),
22813
PARTITION part3 VALUES IN (NULL));
22814
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
22815
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
22816
# Start usability test (inc/partition_check.inc)
22817
create_command
22818
SHOW CREATE TABLE t1;
22819
Table	Create Table
22820
t1	CREATE TABLE `t1` (
22821
  `f_int1` int(11) NOT NULL DEFAULT '0',
22822
  `f_int2` int(11) NOT NULL DEFAULT '0',
22823
  `f_char1` char(20) DEFAULT NULL,
22824
  `f_char2` char(20) DEFAULT NULL,
22825
  `f_charbig` varchar(1000) DEFAULT NULL,
22826
  PRIMARY KEY (`f_int2`,`f_int1`),
22827
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`)
22828
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
22829
22830
unified filelist
22831
$MYSQLTEST_VARDIR/master-data/test/t1.frm
22832
$MYSQLTEST_VARDIR/master-data/test/t1.par
22833
22834
# check prerequisites-1 success:    1
22835
# check COUNT(*) success:    1
22836
# check MIN/MAX(f_int1) success:    1
22837
# check MIN/MAX(f_int2) success:    1
22838
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22839
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
22840
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
22841
WHERE f_int1 IN (2,3);
22842
ERROR 23000: Can't write; duplicate key in table 't1'
22843
# check prerequisites-3 success:    1
22844
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
22845
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22846
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
22847
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
22848
WHERE f_int1 IN (2,3);
22849
DELETE FROM t1 WHERE f_charbig = 'delete me';
22850
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22851
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
22852
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
22853
WHERE f_int1 IN (2,3);
22854
DELETE FROM t1 WHERE f_charbig = 'delete me';
22855
# check read via f_int1 success: 1
22856
# check read via f_int2 success: 1
22857
	
22858
# check multiple-1 success: 	1
22859
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
22860
	
22861
# check multiple-2 success: 	1
22862
INSERT INTO t1 SELECT * FROM t0_template
22863
WHERE MOD(f_int1,3) = 0;
22864
	
22865
# check multiple-3 success: 	1
22866
UPDATE t1 SET f_int1 = f_int1 + @max_row
22867
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
22868
AND @max_row_div2 + @max_row_div4;
22869
	
22870
# check multiple-4 success: 	1
22871
DELETE FROM t1
22872
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
22873
AND @max_row_div2 + @max_row_div4 + @max_row;
22874
	
22875
# check multiple-5 success: 	1
22876
SELECT COUNT(*) INTO @try_count FROM t0_template
22877
WHERE MOD(f_int1,3) = 0
22878
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
22879
SELECT COUNT(*) INTO @clash_count
22880
FROM t1 INNER JOIN t0_template USING(f_int1)
22881
WHERE MOD(f_int1,3) = 0
22882
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
22883
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
22884
INSERT INTO t1
22885
SET f_int1 = @cur_value , f_int2 = @cur_value,
22886
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
22887
f_charbig = '#SINGLE#';
22888
	
22889
# check single-1 success: 	1
22890
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
22891
INSERT INTO t1
22892
SET f_int1 = @cur_value , f_int2 = @cur_value,
22893
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
22894
f_charbig = '#SINGLE#';
22895
	
22896
# check single-2 success: 	1
22897
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
22898
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
22899
UPDATE t1 SET f_int1 = @cur_value2
22900
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
22901
	
22902
# check single-3 success: 	1
22903
SET @cur_value1= -1;
22904
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
22905
UPDATE t1 SET f_int1 = @cur_value1
22906
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
22907
	
22908
# check single-4 success: 	1
22909
SELECT MAX(f_int1) INTO @cur_value FROM t1;
22910
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
22911
	
22912
# check single-5 success: 	1
22913
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
22914
	
22915
# check single-6 success: 	1
22916
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
22917
	
22918
# check single-7 success: 	1
22919
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
22920
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
22921
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
22922
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
22923
f_charbig = '#NULL#';
22924
INSERT INTO t1
22925
SET f_int1 = NULL , f_int2 = -@max_row,
22926
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
22927
f_charbig = '#NULL#';
22928
ERROR 23000: Column 'f_int1' cannot be null
22929
# check null success:    1
22930
DELETE FROM t1
22931
WHERE f_int1 = 0 AND f_int2 = 0
22932
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
22933
AND f_charbig = '#NULL#';
22934
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22935
SELECT f_int1, f_int1, '', '', 'was inserted'
22936
   FROM t0_template source_tab
22937
WHERE MOD(f_int1,3) = 0
22938
AND f_int1 BETWEEN @max_row_div2 AND @max_row
22939
ON DUPLICATE KEY
22940
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
22941
f_int2 = 2 * @max_row + source_tab.f_int1,
22942
f_charbig = 'was updated';
22943
	
22944
# check unique-1-a success: 	1
22945
	
22946
# check unique-1-b success: 	1
22947
DELETE FROM t1 WHERE f_charbig = 'was inserted';
22948
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
22949
f_int2 = CAST(f_char1 AS SIGNED INT),
22950
f_charbig = CONCAT('===',f_char1,'===')
22951
WHERE f_charbig = 'was updated';
22952
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22953
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
22954
   FROM t0_template source_tab
22955
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
22956
	
22957
# check replace success: 	1
22958
DELETE FROM t1
22959
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
22960
DELETE FROM t1
22961
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
22962
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
22963
UPDATE t1 SET f_int2 = f_int1,
22964
f_char1 = CAST(f_int1 AS CHAR),
22965
f_char2 = CAST(f_int1 AS CHAR),
22966
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
22967
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
22968
SET AUTOCOMMIT= 0;
22969
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22970
SELECT f_int1, f_int1, '', '', 'was inserted'
22971
FROM t0_template source_tab
22972
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
22973
	
22974
# check transactions-1 success: 	1
22975
COMMIT WORK;
22976
	
22977
# check transactions-2 success: 	1
22978
ROLLBACK WORK;
22979
	
22980
# check transactions-3 success: 	1
22981
DELETE FROM t1 WHERE f_charbig = 'was inserted';
22982
COMMIT WORK;
22983
ROLLBACK WORK;
22984
	
22985
# check transactions-4 success: 	1
22986
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
22987
SELECT f_int1, f_int1, '', '', 'was inserted'
22988
FROM t0_template source_tab
22989
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
22990
	
22991
# check transactions-5 success: 	1
22992
ROLLBACK WORK;
22993
	
22994
# check transactions-6 success: 	1
22995
# INFO: Storage engine used for t1 seems to be transactional.
22996
COMMIT;
22997
	
22998
# check transactions-7 success: 	1
22999
DELETE FROM t1 WHERE f_charbig = 'was inserted';
23000
COMMIT WORK;
23001
SET @@session.sql_mode = 'traditional';
23002
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
23003
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23004
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
23005
'', '', 'was inserted' FROM t0_template
23006
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
23007
ERROR 22012: Division by 0
23008
COMMIT;
23009
	
23010
# check transactions-8 success: 	1
23011
# INFO: Storage engine used for t1 seems to be able to revert
23012
#       changes made by the failing statement.
23013
SET @@session.sql_mode = '';
23014
SET AUTOCOMMIT= 1;
23015
DELETE FROM t1 WHERE f_charbig = 'was inserted';
23016
COMMIT WORK;
23017
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
23018
	
23019
# check special-1 success: 	1
23020
UPDATE t1 SET f_charbig = '';
23021
	
23022
# check special-2 success: 	1
23023
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
23024
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
23025
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
23026
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23027
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23028
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23029
'just inserted' FROM t0_template
23030
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23031
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
23032
BEGIN
23033
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23034
f_charbig = 'updated by trigger'
23035
      WHERE f_int1 = new.f_int1;
23036
END|
23037
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23038
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
23039
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23040
	
23041
# check trigger-1 success: 	1
23042
DROP TRIGGER trg_1;
23043
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23044
f_int2 = CAST(f_char1 AS SIGNED INT),
23045
f_charbig = 'just inserted'
23046
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23047
DELETE FROM t0_aux
23048
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23049
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23050
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23051
'just inserted' FROM t0_template
23052
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23053
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
23054
BEGIN
23055
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23056
f_charbig = 'updated by trigger'
23057
      WHERE f_int1 = new.f_int1;
23058
END|
23059
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23060
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
23061
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23062
	
23063
# check trigger-2 success: 	1
23064
DROP TRIGGER trg_1;
23065
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23066
f_int2 = CAST(f_char1 AS SIGNED INT),
23067
f_charbig = 'just inserted'
23068
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23069
DELETE FROM t0_aux
23070
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23071
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23072
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23073
'just inserted' FROM t0_template
23074
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23075
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
23076
BEGIN
23077
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23078
f_charbig = 'updated by trigger'
23079
      WHERE f_int1 = new.f_int1;
23080
END|
23081
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
23082
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
23083
	
23084
# check trigger-3 success: 	1
23085
DROP TRIGGER trg_1;
23086
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23087
f_int2 = CAST(f_char1 AS SIGNED INT),
23088
f_charbig = 'just inserted'
23089
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23090
DELETE FROM t0_aux
23091
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23092
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23093
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23094
'just inserted' FROM t0_template
23095
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23096
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
23097
BEGIN
23098
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23099
f_charbig = 'updated by trigger'
23100
      WHERE f_int1 = - old.f_int1;
23101
END|
23102
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
23103
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
23104
	
23105
# check trigger-4 success: 	1
23106
DROP TRIGGER trg_1;
23107
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23108
f_int2 = CAST(f_char1 AS SIGNED INT),
23109
f_charbig = 'just inserted'
23110
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23111
DELETE FROM t0_aux
23112
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23113
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23114
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23115
'just inserted' FROM t0_template
23116
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23117
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
23118
BEGIN
23119
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23120
f_charbig = 'updated by trigger'
23121
      WHERE f_int1 = new.f_int1;
23122
END|
23123
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
23124
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
23125
	
23126
# check trigger-5 success: 	1
23127
DROP TRIGGER trg_1;
23128
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23129
f_int2 = CAST(f_char1 AS SIGNED INT),
23130
f_charbig = 'just inserted'
23131
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23132
DELETE FROM t0_aux
23133
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23134
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23135
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23136
'just inserted' FROM t0_template
23137
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23138
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
23139
BEGIN
23140
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23141
f_charbig = 'updated by trigger'
23142
      WHERE f_int1 = - old.f_int1;
23143
END|
23144
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
23145
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
23146
	
23147
# check trigger-6 success: 	1
23148
DROP TRIGGER trg_1;
23149
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23150
f_int2 = CAST(f_char1 AS SIGNED INT),
23151
f_charbig = 'just inserted'
23152
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23153
DELETE FROM t0_aux
23154
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23155
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23156
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23157
'just inserted' FROM t0_template
23158
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23159
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
23160
BEGIN
23161
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23162
f_charbig = 'updated by trigger'
23163
      WHERE f_int1 = - old.f_int1;
23164
END|
23165
DELETE FROM t0_aux
23166
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
23167
	
23168
# check trigger-7 success: 	1
23169
DROP TRIGGER trg_1;
23170
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23171
f_int2 = CAST(f_char1 AS SIGNED INT),
23172
f_charbig = 'just inserted'
23173
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23174
DELETE FROM t0_aux
23175
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23176
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23177
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23178
'just inserted' FROM t0_template
23179
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23180
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
23181
BEGIN
23182
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23183
f_charbig = 'updated by trigger'
23184
      WHERE f_int1 = - old.f_int1;
23185
END|
23186
DELETE FROM t0_aux
23187
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
23188
	
23189
# check trigger-8 success: 	1
23190
DROP TRIGGER trg_1;
23191
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23192
f_int2 = CAST(f_char1 AS SIGNED INT),
23193
f_charbig = 'just inserted'
23194
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23195
DELETE FROM t0_aux
23196
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23197
DELETE FROM t1
23198
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23199
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
23200
BEGIN
23201
SET new.f_int1 = old.f_int1 + @max_row,
23202
new.f_int2 = old.f_int2 - @max_row,
23203
new.f_charbig = '####updated per update trigger####';
23204
END|
23205
UPDATE t1
23206
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
23207
f_charbig = '####updated per update statement itself####';
23208
	
23209
# check trigger-9 success: 	1
23210
DROP TRIGGER trg_2;
23211
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23212
f_int2 = CAST(f_char1 AS SIGNED INT),
23213
f_charbig = CONCAT('===',f_char1,'===');
23214
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
23215
BEGIN
23216
SET new.f_int1 = new.f_int1 + @max_row,
23217
new.f_int2 = new.f_int2 - @max_row,
23218
new.f_charbig = '####updated per update trigger####';
23219
END|
23220
UPDATE t1
23221
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
23222
f_charbig = '####updated per update statement itself####';
23223
	
23224
# check trigger-10 success: 	1
23225
DROP TRIGGER trg_2;
23226
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23227
f_int2 = CAST(f_char1 AS SIGNED INT),
23228
f_charbig = CONCAT('===',f_char1,'===');
23229
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
23230
BEGIN
23231
SET new.f_int1 = @my_max1 + @counter,
23232
new.f_int2 = @my_min2 - @counter,
23233
new.f_charbig = '####updated per insert trigger####';
23234
SET @counter = @counter + 1;
23235
END|
23236
SET @counter = 1;
23237
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
23238
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23239
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
23240
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
23241
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
23242
ORDER BY f_int1;
23243
DROP TRIGGER trg_3;
23244
	
23245
# check trigger-11 success: 	1
23246
DELETE FROM t1
23247
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
23248
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
23249
AND f_charbig = '####updated per insert trigger####';
23250
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
23251
BEGIN
23252
SET new.f_int1 = @my_max1 + @counter,
23253
new.f_int2 = @my_min2 - @counter,
23254
new.f_charbig = '####updated per insert trigger####';
23255
SET @counter = @counter + 1;
23256
END|
23257
SET @counter = 1;
23258
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
23259
INSERT INTO t1 (f_char1, f_char2, f_charbig)
23260
SELECT CAST(f_int1 AS CHAR),
23261
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
23262
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
23263
ORDER BY f_int1;
23264
DROP TRIGGER trg_3;
23265
	
23266
# check trigger-12 success: 	1
23267
DELETE FROM t1
23268
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
23269
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
23270
AND f_charbig = '####updated per insert trigger####';
23271
ANALYZE  TABLE t1;
23272
Table	Op	Msg_type	Msg_text
23273
test.t1	analyze	note	The storage engine for the table doesn't support analyze
23274
CHECK    TABLE t1 EXTENDED;
23275
Table	Op	Msg_type	Msg_text
23276
test.t1	check	note	The storage engine for the table doesn't support check
23277
CHECKSUM TABLE t1 EXTENDED;
23278
Table	Checksum
23279
test.t1	<some_value>
23280
OPTIMIZE TABLE t1;
23281
Table	Op	Msg_type	Msg_text
23282
test.t1	optimize	note	The storage engine for the table doesn't support optimize
23283
# check layout success:    1
23284
REPAIR   TABLE t1 EXTENDED;
23285
Table	Op	Msg_type	Msg_text
23286
test.t1	repair	note	The storage engine for the table doesn't support repair
23287
# check layout success:    1
23288
TRUNCATE t1;
23289
	
23290
# check TRUNCATE success: 	1
23291
# check layout success:    1
23292
# End usability test (inc/partition_check.inc)
23293
DROP TABLE t1;
23294
DROP TABLE IF EXISTS t1;
23295
CREATE TABLE t1 (
23296
f_int1 INTEGER,
23297
f_int2 INTEGER,
23298
f_char1 CHAR(20),
23299
f_char2 CHAR(20),
23300
f_charbig VARCHAR(1000)
23301
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
23302
)
23303
PARTITION BY HASH(f_int1 + f_int2) PARTITIONS 2;
23304
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
23305
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
23306
# Start usability test (inc/partition_check.inc)
23307
create_command
23308
SHOW CREATE TABLE t1;
23309
Table	Create Table
23310
t1	CREATE TABLE `t1` (
23311
  `f_int1` int(11) NOT NULL DEFAULT '0',
23312
  `f_int2` int(11) NOT NULL DEFAULT '0',
23313
  `f_char1` char(20) DEFAULT NULL,
23314
  `f_char2` char(20) DEFAULT NULL,
23315
  `f_charbig` varchar(1000) DEFAULT NULL,
23316
  PRIMARY KEY (`f_int1`,`f_int2`),
23317
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
23318
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (f_int1 + f_int2) PARTITIONS 2  */
23319
23320
unified filelist
23321
$MYSQLTEST_VARDIR/master-data/test/t1.frm
23322
$MYSQLTEST_VARDIR/master-data/test/t1.par
23323
23324
# check prerequisites-1 success:    1
23325
# check COUNT(*) success:    1
23326
# check MIN/MAX(f_int1) success:    1
23327
# check MIN/MAX(f_int2) success:    1
23328
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23329
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
23330
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
23331
WHERE f_int1 IN (2,3);
23332
ERROR 23000: Can't write; duplicate key in table 't1'
23333
# check prerequisites-3 success:    1
23334
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
23335
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23336
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
23337
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
23338
WHERE f_int1 IN (2,3);
23339
DELETE FROM t1 WHERE f_charbig = 'delete me';
23340
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23341
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
23342
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
23343
WHERE f_int1 IN (2,3);
23344
DELETE FROM t1 WHERE f_charbig = 'delete me';
23345
# check read via f_int1 success: 1
23346
# check read via f_int2 success: 1
23347
	
23348
# check multiple-1 success: 	1
23349
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
23350
	
23351
# check multiple-2 success: 	1
23352
INSERT INTO t1 SELECT * FROM t0_template
23353
WHERE MOD(f_int1,3) = 0;
23354
	
23355
# check multiple-3 success: 	1
23356
UPDATE t1 SET f_int1 = f_int1 + @max_row
23357
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
23358
AND @max_row_div2 + @max_row_div4;
23359
	
23360
# check multiple-4 success: 	1
23361
DELETE FROM t1
23362
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
23363
AND @max_row_div2 + @max_row_div4 + @max_row;
23364
	
23365
# check multiple-5 success: 	1
23366
SELECT COUNT(*) INTO @try_count FROM t0_template
23367
WHERE MOD(f_int1,3) = 0
23368
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
23369
SELECT COUNT(*) INTO @clash_count
23370
FROM t1 INNER JOIN t0_template USING(f_int1)
23371
WHERE MOD(f_int1,3) = 0
23372
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
23373
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
23374
INSERT INTO t1
23375
SET f_int1 = @cur_value , f_int2 = @cur_value,
23376
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
23377
f_charbig = '#SINGLE#';
23378
	
23379
# check single-1 success: 	1
23380
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
23381
INSERT INTO t1
23382
SET f_int1 = @cur_value , f_int2 = @cur_value,
23383
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
23384
f_charbig = '#SINGLE#';
23385
	
23386
# check single-2 success: 	1
23387
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
23388
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
23389
UPDATE t1 SET f_int1 = @cur_value2
23390
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
23391
	
23392
# check single-3 success: 	1
23393
SET @cur_value1= -1;
23394
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
23395
UPDATE t1 SET f_int1 = @cur_value1
23396
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
23397
	
23398
# check single-4 success: 	1
23399
SELECT MAX(f_int1) INTO @cur_value FROM t1;
23400
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
23401
	
23402
# check single-5 success: 	1
23403
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
23404
	
23405
# check single-6 success: 	1
23406
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
23407
	
23408
# check single-7 success: 	1
23409
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
23410
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
23411
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
23412
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
23413
f_charbig = '#NULL#';
23414
INSERT INTO t1
23415
SET f_int1 = NULL , f_int2 = -@max_row,
23416
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
23417
f_charbig = '#NULL#';
23418
ERROR 23000: Column 'f_int1' cannot be null
23419
# check null success:    1
23420
DELETE FROM t1
23421
WHERE f_int1 = 0 AND f_int2 = 0
23422
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
23423
AND f_charbig = '#NULL#';
23424
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23425
SELECT f_int1, f_int1, '', '', 'was inserted'
23426
   FROM t0_template source_tab
23427
WHERE MOD(f_int1,3) = 0
23428
AND f_int1 BETWEEN @max_row_div2 AND @max_row
23429
ON DUPLICATE KEY
23430
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
23431
f_int2 = 2 * @max_row + source_tab.f_int1,
23432
f_charbig = 'was updated';
23433
	
23434
# check unique-1-a success: 	1
23435
	
23436
# check unique-1-b success: 	1
23437
DELETE FROM t1 WHERE f_charbig = 'was inserted';
23438
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23439
f_int2 = CAST(f_char1 AS SIGNED INT),
23440
f_charbig = CONCAT('===',f_char1,'===')
23441
WHERE f_charbig = 'was updated';
23442
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23443
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
23444
   FROM t0_template source_tab
23445
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
23446
	
23447
# check replace success: 	1
23448
DELETE FROM t1
23449
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
23450
DELETE FROM t1
23451
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
23452
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
23453
UPDATE t1 SET f_int2 = f_int1,
23454
f_char1 = CAST(f_int1 AS CHAR),
23455
f_char2 = CAST(f_int1 AS CHAR),
23456
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
23457
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
23458
SET AUTOCOMMIT= 0;
23459
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23460
SELECT f_int1, f_int1, '', '', 'was inserted'
23461
FROM t0_template source_tab
23462
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
23463
	
23464
# check transactions-1 success: 	1
23465
COMMIT WORK;
23466
	
23467
# check transactions-2 success: 	1
23468
ROLLBACK WORK;
23469
	
23470
# check transactions-3 success: 	1
23471
DELETE FROM t1 WHERE f_charbig = 'was inserted';
23472
COMMIT WORK;
23473
ROLLBACK WORK;
23474
	
23475
# check transactions-4 success: 	1
23476
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23477
SELECT f_int1, f_int1, '', '', 'was inserted'
23478
FROM t0_template source_tab
23479
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
23480
	
23481
# check transactions-5 success: 	1
23482
ROLLBACK WORK;
23483
	
23484
# check transactions-6 success: 	1
23485
# INFO: Storage engine used for t1 seems to be transactional.
23486
COMMIT;
23487
	
23488
# check transactions-7 success: 	1
23489
DELETE FROM t1 WHERE f_charbig = 'was inserted';
23490
COMMIT WORK;
23491
SET @@session.sql_mode = 'traditional';
23492
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
23493
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23494
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
23495
'', '', 'was inserted' FROM t0_template
23496
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
23497
ERROR 22012: Division by 0
23498
COMMIT;
23499
	
23500
# check transactions-8 success: 	1
23501
# INFO: Storage engine used for t1 seems to be able to revert
23502
#       changes made by the failing statement.
23503
SET @@session.sql_mode = '';
23504
SET AUTOCOMMIT= 1;
23505
DELETE FROM t1 WHERE f_charbig = 'was inserted';
23506
COMMIT WORK;
23507
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
23508
	
23509
# check special-1 success: 	1
23510
UPDATE t1 SET f_charbig = '';
23511
	
23512
# check special-2 success: 	1
23513
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
23514
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
23515
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
23516
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23517
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23518
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23519
'just inserted' FROM t0_template
23520
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23521
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
23522
BEGIN
23523
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23524
f_charbig = 'updated by trigger'
23525
      WHERE f_int1 = new.f_int1;
23526
END|
23527
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23528
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
23529
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23530
	
23531
# check trigger-1 success: 	1
23532
DROP TRIGGER trg_1;
23533
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23534
f_int2 = CAST(f_char1 AS SIGNED INT),
23535
f_charbig = 'just inserted'
23536
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23537
DELETE FROM t0_aux
23538
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23539
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23540
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23541
'just inserted' FROM t0_template
23542
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23543
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
23544
BEGIN
23545
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23546
f_charbig = 'updated by trigger'
23547
      WHERE f_int1 = new.f_int1;
23548
END|
23549
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23550
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
23551
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23552
	
23553
# check trigger-2 success: 	1
23554
DROP TRIGGER trg_1;
23555
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23556
f_int2 = CAST(f_char1 AS SIGNED INT),
23557
f_charbig = 'just inserted'
23558
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23559
DELETE FROM t0_aux
23560
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23561
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23562
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23563
'just inserted' FROM t0_template
23564
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23565
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
23566
BEGIN
23567
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23568
f_charbig = 'updated by trigger'
23569
      WHERE f_int1 = new.f_int1;
23570
END|
23571
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
23572
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
23573
	
23574
# check trigger-3 success: 	1
23575
DROP TRIGGER trg_1;
23576
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23577
f_int2 = CAST(f_char1 AS SIGNED INT),
23578
f_charbig = 'just inserted'
23579
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23580
DELETE FROM t0_aux
23581
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23582
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23583
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23584
'just inserted' FROM t0_template
23585
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23586
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
23587
BEGIN
23588
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23589
f_charbig = 'updated by trigger'
23590
      WHERE f_int1 = - old.f_int1;
23591
END|
23592
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
23593
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
23594
	
23595
# check trigger-4 success: 	1
23596
DROP TRIGGER trg_1;
23597
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23598
f_int2 = CAST(f_char1 AS SIGNED INT),
23599
f_charbig = 'just inserted'
23600
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23601
DELETE FROM t0_aux
23602
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23603
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23604
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23605
'just inserted' FROM t0_template
23606
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23607
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
23608
BEGIN
23609
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23610
f_charbig = 'updated by trigger'
23611
      WHERE f_int1 = new.f_int1;
23612
END|
23613
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
23614
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
23615
	
23616
# check trigger-5 success: 	1
23617
DROP TRIGGER trg_1;
23618
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23619
f_int2 = CAST(f_char1 AS SIGNED INT),
23620
f_charbig = 'just inserted'
23621
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23622
DELETE FROM t0_aux
23623
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23624
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23625
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23626
'just inserted' FROM t0_template
23627
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23628
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
23629
BEGIN
23630
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23631
f_charbig = 'updated by trigger'
23632
      WHERE f_int1 = - old.f_int1;
23633
END|
23634
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
23635
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
23636
	
23637
# check trigger-6 success: 	1
23638
DROP TRIGGER trg_1;
23639
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23640
f_int2 = CAST(f_char1 AS SIGNED INT),
23641
f_charbig = 'just inserted'
23642
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23643
DELETE FROM t0_aux
23644
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23645
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23646
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23647
'just inserted' FROM t0_template
23648
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23649
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
23650
BEGIN
23651
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23652
f_charbig = 'updated by trigger'
23653
      WHERE f_int1 = - old.f_int1;
23654
END|
23655
DELETE FROM t0_aux
23656
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
23657
	
23658
# check trigger-7 success: 	1
23659
DROP TRIGGER trg_1;
23660
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23661
f_int2 = CAST(f_char1 AS SIGNED INT),
23662
f_charbig = 'just inserted'
23663
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23664
DELETE FROM t0_aux
23665
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23666
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
23667
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
23668
'just inserted' FROM t0_template
23669
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23670
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
23671
BEGIN
23672
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
23673
f_charbig = 'updated by trigger'
23674
      WHERE f_int1 = - old.f_int1;
23675
END|
23676
DELETE FROM t0_aux
23677
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
23678
	
23679
# check trigger-8 success: 	1
23680
DROP TRIGGER trg_1;
23681
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23682
f_int2 = CAST(f_char1 AS SIGNED INT),
23683
f_charbig = 'just inserted'
23684
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
23685
DELETE FROM t0_aux
23686
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23687
DELETE FROM t1
23688
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
23689
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
23690
BEGIN
23691
SET new.f_int1 = old.f_int1 + @max_row,
23692
new.f_int2 = old.f_int2 - @max_row,
23693
new.f_charbig = '####updated per update trigger####';
23694
END|
23695
UPDATE t1
23696
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
23697
f_charbig = '####updated per update statement itself####';
23698
	
23699
# check trigger-9 success: 	1
23700
DROP TRIGGER trg_2;
23701
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23702
f_int2 = CAST(f_char1 AS SIGNED INT),
23703
f_charbig = CONCAT('===',f_char1,'===');
23704
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
23705
BEGIN
23706
SET new.f_int1 = new.f_int1 + @max_row,
23707
new.f_int2 = new.f_int2 - @max_row,
23708
new.f_charbig = '####updated per update trigger####';
23709
END|
23710
UPDATE t1
23711
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
23712
f_charbig = '####updated per update statement itself####';
23713
	
23714
# check trigger-10 success: 	1
23715
DROP TRIGGER trg_2;
23716
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23717
f_int2 = CAST(f_char1 AS SIGNED INT),
23718
f_charbig = CONCAT('===',f_char1,'===');
23719
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
23720
BEGIN
23721
SET new.f_int1 = @my_max1 + @counter,
23722
new.f_int2 = @my_min2 - @counter,
23723
new.f_charbig = '####updated per insert trigger####';
23724
SET @counter = @counter + 1;
23725
END|
23726
SET @counter = 1;
23727
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
23728
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23729
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
23730
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
23731
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
23732
ORDER BY f_int1;
23733
DROP TRIGGER trg_3;
23734
	
23735
# check trigger-11 success: 	1
23736
DELETE FROM t1
23737
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
23738
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
23739
AND f_charbig = '####updated per insert trigger####';
23740
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
23741
BEGIN
23742
SET new.f_int1 = @my_max1 + @counter,
23743
new.f_int2 = @my_min2 - @counter,
23744
new.f_charbig = '####updated per insert trigger####';
23745
SET @counter = @counter + 1;
23746
END|
23747
SET @counter = 1;
23748
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
23749
INSERT INTO t1 (f_char1, f_char2, f_charbig)
23750
SELECT CAST(f_int1 AS CHAR),
23751
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
23752
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
23753
ORDER BY f_int1;
23754
DROP TRIGGER trg_3;
23755
	
23756
# check trigger-12 success: 	1
23757
DELETE FROM t1
23758
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
23759
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
23760
AND f_charbig = '####updated per insert trigger####';
23761
ANALYZE  TABLE t1;
23762
Table	Op	Msg_type	Msg_text
23763
test.t1	analyze	note	The storage engine for the table doesn't support analyze
23764
CHECK    TABLE t1 EXTENDED;
23765
Table	Op	Msg_type	Msg_text
23766
test.t1	check	note	The storage engine for the table doesn't support check
23767
CHECKSUM TABLE t1 EXTENDED;
23768
Table	Checksum
23769
test.t1	<some_value>
23770
OPTIMIZE TABLE t1;
23771
Table	Op	Msg_type	Msg_text
23772
test.t1	optimize	note	The storage engine for the table doesn't support optimize
23773
# check layout success:    1
23774
REPAIR   TABLE t1 EXTENDED;
23775
Table	Op	Msg_type	Msg_text
23776
test.t1	repair	note	The storage engine for the table doesn't support repair
23777
# check layout success:    1
23778
TRUNCATE t1;
23779
	
23780
# check TRUNCATE success: 	1
23781
# check layout success:    1
23782
# End usability test (inc/partition_check.inc)
23783
DROP TABLE t1;
23784
CREATE TABLE t1 (
23785
f_int1 INTEGER,
23786
f_int2 INTEGER,
23787
f_char1 CHAR(20),
23788
f_char2 CHAR(20),
23789
f_charbig VARCHAR(1000)
23790
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
23791
)
23792
PARTITION BY KEY(f_int1,f_int2) PARTITIONS 5;
23793
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
23794
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
23795
# Start usability test (inc/partition_check.inc)
23796
create_command
23797
SHOW CREATE TABLE t1;
23798
Table	Create Table
23799
t1	CREATE TABLE `t1` (
23800
  `f_int1` int(11) NOT NULL DEFAULT '0',
23801
  `f_int2` int(11) NOT NULL DEFAULT '0',
23802
  `f_char1` char(20) DEFAULT NULL,
23803
  `f_char2` char(20) DEFAULT NULL,
23804
  `f_charbig` varchar(1000) DEFAULT NULL,
23805
  PRIMARY KEY (`f_int1`,`f_int2`),
23806
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
23807
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5  */
23808
23809
unified filelist
23810
$MYSQLTEST_VARDIR/master-data/test/t1.frm
23811
$MYSQLTEST_VARDIR/master-data/test/t1.par
23812
23813
# check prerequisites-1 success:    1
23814
# check COUNT(*) success:    1
23815
# check MIN/MAX(f_int1) success:    1
23816
# check MIN/MAX(f_int2) success:    1
23817
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23818
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
23819
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
23820
WHERE f_int1 IN (2,3);
23821
ERROR 23000: Can't write; duplicate key in table 't1'
23822
# check prerequisites-3 success:    1
23823
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
23824
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23825
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
23826
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
23827
WHERE f_int1 IN (2,3);
23828
DELETE FROM t1 WHERE f_charbig = 'delete me';
23829
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23830
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
23831
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
23832
WHERE f_int1 IN (2,3);
23833
DELETE FROM t1 WHERE f_charbig = 'delete me';
23834
# check read via f_int1 success: 1
23835
# check read via f_int2 success: 1
23836
	
23837
# check multiple-1 success: 	1
23838
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
23839
	
23840
# check multiple-2 success: 	1
23841
INSERT INTO t1 SELECT * FROM t0_template
23842
WHERE MOD(f_int1,3) = 0;
23843
	
23844
# check multiple-3 success: 	1
23845
UPDATE t1 SET f_int1 = f_int1 + @max_row
23846
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
23847
AND @max_row_div2 + @max_row_div4;
23848
	
23849
# check multiple-4 success: 	1
23850
DELETE FROM t1
23851
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
23852
AND @max_row_div2 + @max_row_div4 + @max_row;
23853
	
23854
# check multiple-5 success: 	1
23855
SELECT COUNT(*) INTO @try_count FROM t0_template
23856
WHERE MOD(f_int1,3) = 0
23857
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
23858
SELECT COUNT(*) INTO @clash_count
23859
FROM t1 INNER JOIN t0_template USING(f_int1)
23860
WHERE MOD(f_int1,3) = 0
23861
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
23862
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
23863
INSERT INTO t1
23864
SET f_int1 = @cur_value , f_int2 = @cur_value,
23865
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
23866
f_charbig = '#SINGLE#';
23867
	
23868
# check single-1 success: 	1
23869
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
23870
INSERT INTO t1
23871
SET f_int1 = @cur_value , f_int2 = @cur_value,
23872
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
23873
f_charbig = '#SINGLE#';
23874
	
23875
# check single-2 success: 	1
23876
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
23877
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
23878
UPDATE t1 SET f_int1 = @cur_value2
23879
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
23880
	
23881
# check single-3 success: 	1
23882
SET @cur_value1= -1;
23883
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
23884
UPDATE t1 SET f_int1 = @cur_value1
23885
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
23886
	
23887
# check single-4 success: 	1
23888
SELECT MAX(f_int1) INTO @cur_value FROM t1;
23889
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
23890
	
23891
# check single-5 success: 	1
23892
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
23893
	
23894
# check single-6 success: 	1
23895
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
23896
	
23897
# check single-7 success: 	1
23898
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
23899
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
23900
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
23901
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
23902
f_charbig = '#NULL#';
23903
INSERT INTO t1
23904
SET f_int1 = NULL , f_int2 = -@max_row,
23905
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
23906
f_charbig = '#NULL#';
23907
ERROR 23000: Column 'f_int1' cannot be null
23908
# check null success:    1
23909
DELETE FROM t1
23910
WHERE f_int1 = 0 AND f_int2 = 0
23911
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
23912
AND f_charbig = '#NULL#';
23913
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23914
SELECT f_int1, f_int1, '', '', 'was inserted'
23915
   FROM t0_template source_tab
23916
WHERE MOD(f_int1,3) = 0
23917
AND f_int1 BETWEEN @max_row_div2 AND @max_row
23918
ON DUPLICATE KEY
23919
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
23920
f_int2 = 2 * @max_row + source_tab.f_int1,
23921
f_charbig = 'was updated';
23922
	
23923
# check unique-1-a success: 	1
23924
	
23925
# check unique-1-b success: 	1
23926
DELETE FROM t1 WHERE f_charbig = 'was inserted';
23927
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
23928
f_int2 = CAST(f_char1 AS SIGNED INT),
23929
f_charbig = CONCAT('===',f_char1,'===')
23930
WHERE f_charbig = 'was updated';
23931
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23932
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
23933
   FROM t0_template source_tab
23934
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
23935
	
23936
# check replace success: 	1
23937
DELETE FROM t1
23938
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
23939
DELETE FROM t1
23940
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
23941
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
23942
UPDATE t1 SET f_int2 = f_int1,
23943
f_char1 = CAST(f_int1 AS CHAR),
23944
f_char2 = CAST(f_int1 AS CHAR),
23945
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
23946
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
23947
SET AUTOCOMMIT= 0;
23948
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23949
SELECT f_int1, f_int1, '', '', 'was inserted'
23950
FROM t0_template source_tab
23951
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
23952
	
23953
# check transactions-1 success: 	1
23954
COMMIT WORK;
23955
	
23956
# check transactions-2 success: 	1
23957
ROLLBACK WORK;
23958
	
23959
# check transactions-3 success: 	1
23960
DELETE FROM t1 WHERE f_charbig = 'was inserted';
23961
COMMIT WORK;
23962
ROLLBACK WORK;
23963
	
23964
# check transactions-4 success: 	1
23965
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23966
SELECT f_int1, f_int1, '', '', 'was inserted'
23967
FROM t0_template source_tab
23968
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
23969
	
23970
# check transactions-5 success: 	1
23971
ROLLBACK WORK;
23972
	
23973
# check transactions-6 success: 	1
23974
# INFO: Storage engine used for t1 seems to be transactional.
23975
COMMIT;
23976
	
23977
# check transactions-7 success: 	1
23978
DELETE FROM t1 WHERE f_charbig = 'was inserted';
23979
COMMIT WORK;
23980
SET @@session.sql_mode = 'traditional';
23981
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
23982
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
23983
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
23984
'', '', 'was inserted' FROM t0_template
23985
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
23986
ERROR 22012: Division by 0
23987
COMMIT;
23988
	
23989
# check transactions-8 success: 	1
23990
# INFO: Storage engine used for t1 seems to be able to revert
23991
#       changes made by the failing statement.
23992
SET @@session.sql_mode = '';
23993
SET AUTOCOMMIT= 1;
23994
DELETE FROM t1 WHERE f_charbig = 'was inserted';
23995
COMMIT WORK;
23996
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
23997
	
23998
# check special-1 success: 	1
23999
UPDATE t1 SET f_charbig = '';
24000
	
24001
# check special-2 success: 	1
24002
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
24003
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
24004
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
24005
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24006
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24007
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24008
'just inserted' FROM t0_template
24009
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24010
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
24011
BEGIN
24012
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24013
f_charbig = 'updated by trigger'
24014
      WHERE f_int1 = new.f_int1;
24015
END|
24016
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24017
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
24018
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24019
	
24020
# check trigger-1 success: 	1
24021
DROP TRIGGER trg_1;
24022
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24023
f_int2 = CAST(f_char1 AS SIGNED INT),
24024
f_charbig = 'just inserted'
24025
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24026
DELETE FROM t0_aux
24027
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24028
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24029
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24030
'just inserted' FROM t0_template
24031
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24032
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
24033
BEGIN
24034
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24035
f_charbig = 'updated by trigger'
24036
      WHERE f_int1 = new.f_int1;
24037
END|
24038
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24039
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
24040
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24041
	
24042
# check trigger-2 success: 	1
24043
DROP TRIGGER trg_1;
24044
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24045
f_int2 = CAST(f_char1 AS SIGNED INT),
24046
f_charbig = 'just inserted'
24047
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24048
DELETE FROM t0_aux
24049
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24050
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24051
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24052
'just inserted' FROM t0_template
24053
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24054
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
24055
BEGIN
24056
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24057
f_charbig = 'updated by trigger'
24058
      WHERE f_int1 = new.f_int1;
24059
END|
24060
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
24061
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
24062
	
24063
# check trigger-3 success: 	1
24064
DROP TRIGGER trg_1;
24065
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24066
f_int2 = CAST(f_char1 AS SIGNED INT),
24067
f_charbig = 'just inserted'
24068
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24069
DELETE FROM t0_aux
24070
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24071
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24072
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24073
'just inserted' FROM t0_template
24074
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24075
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
24076
BEGIN
24077
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24078
f_charbig = 'updated by trigger'
24079
      WHERE f_int1 = - old.f_int1;
24080
END|
24081
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
24082
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
24083
	
24084
# check trigger-4 success: 	1
24085
DROP TRIGGER trg_1;
24086
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24087
f_int2 = CAST(f_char1 AS SIGNED INT),
24088
f_charbig = 'just inserted'
24089
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24090
DELETE FROM t0_aux
24091
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24092
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24093
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24094
'just inserted' FROM t0_template
24095
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24096
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
24097
BEGIN
24098
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24099
f_charbig = 'updated by trigger'
24100
      WHERE f_int1 = new.f_int1;
24101
END|
24102
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
24103
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
24104
	
24105
# check trigger-5 success: 	1
24106
DROP TRIGGER trg_1;
24107
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24108
f_int2 = CAST(f_char1 AS SIGNED INT),
24109
f_charbig = 'just inserted'
24110
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24111
DELETE FROM t0_aux
24112
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24113
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24114
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24115
'just inserted' FROM t0_template
24116
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24117
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
24118
BEGIN
24119
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24120
f_charbig = 'updated by trigger'
24121
      WHERE f_int1 = - old.f_int1;
24122
END|
24123
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
24124
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
24125
	
24126
# check trigger-6 success: 	1
24127
DROP TRIGGER trg_1;
24128
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24129
f_int2 = CAST(f_char1 AS SIGNED INT),
24130
f_charbig = 'just inserted'
24131
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24132
DELETE FROM t0_aux
24133
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24134
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24135
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24136
'just inserted' FROM t0_template
24137
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24138
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
24139
BEGIN
24140
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24141
f_charbig = 'updated by trigger'
24142
      WHERE f_int1 = - old.f_int1;
24143
END|
24144
DELETE FROM t0_aux
24145
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
24146
	
24147
# check trigger-7 success: 	1
24148
DROP TRIGGER trg_1;
24149
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24150
f_int2 = CAST(f_char1 AS SIGNED INT),
24151
f_charbig = 'just inserted'
24152
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24153
DELETE FROM t0_aux
24154
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24155
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24156
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24157
'just inserted' FROM t0_template
24158
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24159
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
24160
BEGIN
24161
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24162
f_charbig = 'updated by trigger'
24163
      WHERE f_int1 = - old.f_int1;
24164
END|
24165
DELETE FROM t0_aux
24166
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
24167
	
24168
# check trigger-8 success: 	1
24169
DROP TRIGGER trg_1;
24170
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24171
f_int2 = CAST(f_char1 AS SIGNED INT),
24172
f_charbig = 'just inserted'
24173
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24174
DELETE FROM t0_aux
24175
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24176
DELETE FROM t1
24177
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24178
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
24179
BEGIN
24180
SET new.f_int1 = old.f_int1 + @max_row,
24181
new.f_int2 = old.f_int2 - @max_row,
24182
new.f_charbig = '####updated per update trigger####';
24183
END|
24184
UPDATE t1
24185
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
24186
f_charbig = '####updated per update statement itself####';
24187
	
24188
# check trigger-9 success: 	1
24189
DROP TRIGGER trg_2;
24190
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24191
f_int2 = CAST(f_char1 AS SIGNED INT),
24192
f_charbig = CONCAT('===',f_char1,'===');
24193
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
24194
BEGIN
24195
SET new.f_int1 = new.f_int1 + @max_row,
24196
new.f_int2 = new.f_int2 - @max_row,
24197
new.f_charbig = '####updated per update trigger####';
24198
END|
24199
UPDATE t1
24200
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
24201
f_charbig = '####updated per update statement itself####';
24202
	
24203
# check trigger-10 success: 	1
24204
DROP TRIGGER trg_2;
24205
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24206
f_int2 = CAST(f_char1 AS SIGNED INT),
24207
f_charbig = CONCAT('===',f_char1,'===');
24208
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
24209
BEGIN
24210
SET new.f_int1 = @my_max1 + @counter,
24211
new.f_int2 = @my_min2 - @counter,
24212
new.f_charbig = '####updated per insert trigger####';
24213
SET @counter = @counter + 1;
24214
END|
24215
SET @counter = 1;
24216
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
24217
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24218
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
24219
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
24220
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
24221
ORDER BY f_int1;
24222
DROP TRIGGER trg_3;
24223
	
24224
# check trigger-11 success: 	1
24225
DELETE FROM t1
24226
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
24227
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
24228
AND f_charbig = '####updated per insert trigger####';
24229
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
24230
BEGIN
24231
SET new.f_int1 = @my_max1 + @counter,
24232
new.f_int2 = @my_min2 - @counter,
24233
new.f_charbig = '####updated per insert trigger####';
24234
SET @counter = @counter + 1;
24235
END|
24236
SET @counter = 1;
24237
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
24238
INSERT INTO t1 (f_char1, f_char2, f_charbig)
24239
SELECT CAST(f_int1 AS CHAR),
24240
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
24241
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
24242
ORDER BY f_int1;
24243
DROP TRIGGER trg_3;
24244
	
24245
# check trigger-12 success: 	1
24246
DELETE FROM t1
24247
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
24248
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
24249
AND f_charbig = '####updated per insert trigger####';
24250
ANALYZE  TABLE t1;
24251
Table	Op	Msg_type	Msg_text
24252
test.t1	analyze	note	The storage engine for the table doesn't support analyze
24253
CHECK    TABLE t1 EXTENDED;
24254
Table	Op	Msg_type	Msg_text
24255
test.t1	check	note	The storage engine for the table doesn't support check
24256
CHECKSUM TABLE t1 EXTENDED;
24257
Table	Checksum
24258
test.t1	<some_value>
24259
OPTIMIZE TABLE t1;
24260
Table	Op	Msg_type	Msg_text
24261
test.t1	optimize	note	The storage engine for the table doesn't support optimize
24262
# check layout success:    1
24263
REPAIR   TABLE t1 EXTENDED;
24264
Table	Op	Msg_type	Msg_text
24265
test.t1	repair	note	The storage engine for the table doesn't support repair
24266
# check layout success:    1
24267
TRUNCATE t1;
24268
	
24269
# check TRUNCATE success: 	1
24270
# check layout success:    1
24271
# End usability test (inc/partition_check.inc)
24272
DROP TABLE t1;
24273
CREATE TABLE t1 (
24274
f_int1 INTEGER,
24275
f_int2 INTEGER,
24276
f_char1 CHAR(20),
24277
f_char2 CHAR(20),
24278
f_charbig VARCHAR(1000)
24279
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
24280
)
24281
PARTITION BY LIST(MOD(f_int1 + f_int2,4))
24282
(PARTITION part_3 VALUES IN (-3),
24283
PARTITION part_2 VALUES IN (-2),
24284
PARTITION part_1 VALUES IN (-1),
24285
PARTITION part_N VALUES IN (NULL),
24286
PARTITION part0 VALUES IN (0),
24287
PARTITION part1 VALUES IN (1),
24288
PARTITION part2 VALUES IN (2),
24289
PARTITION part3 VALUES IN (3));
24290
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
24291
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
24292
# Start usability test (inc/partition_check.inc)
24293
create_command
24294
SHOW CREATE TABLE t1;
24295
Table	Create Table
24296
t1	CREATE TABLE `t1` (
24297
  `f_int1` int(11) NOT NULL DEFAULT '0',
24298
  `f_int2` int(11) NOT NULL DEFAULT '0',
24299
  `f_char1` char(20) DEFAULT NULL,
24300
  `f_char2` char(20) DEFAULT NULL,
24301
  `f_charbig` varchar(1000) DEFAULT NULL,
24302
  PRIMARY KEY (`f_int1`,`f_int2`),
24303
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
24304
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (MOD(f_int1 + f_int2,4)) (PARTITION part_3 VALUES IN (-3) ENGINE = InnoDB, PARTITION part_2 VALUES IN (-2) ENGINE = InnoDB, PARTITION part_1 VALUES IN (-1) ENGINE = InnoDB, PARTITION part_N VALUES IN (NULL) ENGINE = InnoDB, PARTITION part0 VALUES IN (0) ENGINE = InnoDB, PARTITION part1 VALUES IN (1) ENGINE = InnoDB, PARTITION part2 VALUES IN (2) ENGINE = InnoDB, PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
24305
24306
unified filelist
24307
$MYSQLTEST_VARDIR/master-data/test/t1.frm
24308
$MYSQLTEST_VARDIR/master-data/test/t1.par
24309
24310
# check prerequisites-1 success:    1
24311
# check COUNT(*) success:    1
24312
# check MIN/MAX(f_int1) success:    1
24313
# check MIN/MAX(f_int2) success:    1
24314
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24315
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
24316
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
24317
WHERE f_int1 IN (2,3);
24318
ERROR 23000: Can't write; duplicate key in table 't1'
24319
# check prerequisites-3 success:    1
24320
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
24321
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24322
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
24323
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
24324
WHERE f_int1 IN (2,3);
24325
DELETE FROM t1 WHERE f_charbig = 'delete me';
24326
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24327
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
24328
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
24329
WHERE f_int1 IN (2,3);
24330
DELETE FROM t1 WHERE f_charbig = 'delete me';
24331
# check read via f_int1 success: 1
24332
# check read via f_int2 success: 1
24333
	
24334
# check multiple-1 success: 	1
24335
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
24336
	
24337
# check multiple-2 success: 	1
24338
INSERT INTO t1 SELECT * FROM t0_template
24339
WHERE MOD(f_int1,3) = 0;
24340
	
24341
# check multiple-3 success: 	1
24342
UPDATE t1 SET f_int1 = f_int1 + @max_row
24343
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
24344
AND @max_row_div2 + @max_row_div4;
24345
	
24346
# check multiple-4 success: 	1
24347
DELETE FROM t1
24348
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
24349
AND @max_row_div2 + @max_row_div4 + @max_row;
24350
	
24351
# check multiple-5 success: 	1
24352
SELECT COUNT(*) INTO @try_count FROM t0_template
24353
WHERE MOD(f_int1,3) = 0
24354
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
24355
SELECT COUNT(*) INTO @clash_count
24356
FROM t1 INNER JOIN t0_template USING(f_int1)
24357
WHERE MOD(f_int1,3) = 0
24358
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
24359
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
24360
INSERT INTO t1
24361
SET f_int1 = @cur_value , f_int2 = @cur_value,
24362
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
24363
f_charbig = '#SINGLE#';
24364
	
24365
# check single-1 success: 	1
24366
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
24367
INSERT INTO t1
24368
SET f_int1 = @cur_value , f_int2 = @cur_value,
24369
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
24370
f_charbig = '#SINGLE#';
24371
	
24372
# check single-2 success: 	1
24373
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
24374
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
24375
UPDATE t1 SET f_int1 = @cur_value2
24376
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
24377
	
24378
# check single-3 success: 	1
24379
SET @cur_value1= -1;
24380
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
24381
UPDATE t1 SET f_int1 = @cur_value1
24382
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
24383
	
24384
# check single-4 success: 	1
24385
SELECT MAX(f_int1) INTO @cur_value FROM t1;
24386
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
24387
	
24388
# check single-5 success: 	1
24389
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
24390
	
24391
# check single-6 success: 	1
24392
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
24393
	
24394
# check single-7 success: 	1
24395
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
24396
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
24397
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
24398
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
24399
f_charbig = '#NULL#';
24400
INSERT INTO t1
24401
SET f_int1 = NULL , f_int2 = -@max_row,
24402
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
24403
f_charbig = '#NULL#';
24404
ERROR 23000: Column 'f_int1' cannot be null
24405
# check null success:    1
24406
DELETE FROM t1
24407
WHERE f_int1 = 0 AND f_int2 = 0
24408
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
24409
AND f_charbig = '#NULL#';
24410
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24411
SELECT f_int1, f_int1, '', '', 'was inserted'
24412
   FROM t0_template source_tab
24413
WHERE MOD(f_int1,3) = 0
24414
AND f_int1 BETWEEN @max_row_div2 AND @max_row
24415
ON DUPLICATE KEY
24416
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
24417
f_int2 = 2 * @max_row + source_tab.f_int1,
24418
f_charbig = 'was updated';
24419
	
24420
# check unique-1-a success: 	1
24421
	
24422
# check unique-1-b success: 	1
24423
DELETE FROM t1 WHERE f_charbig = 'was inserted';
24424
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24425
f_int2 = CAST(f_char1 AS SIGNED INT),
24426
f_charbig = CONCAT('===',f_char1,'===')
24427
WHERE f_charbig = 'was updated';
24428
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24429
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
24430
   FROM t0_template source_tab
24431
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
24432
	
24433
# check replace success: 	1
24434
DELETE FROM t1
24435
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
24436
DELETE FROM t1
24437
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
24438
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
24439
UPDATE t1 SET f_int2 = f_int1,
24440
f_char1 = CAST(f_int1 AS CHAR),
24441
f_char2 = CAST(f_int1 AS CHAR),
24442
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
24443
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
24444
SET AUTOCOMMIT= 0;
24445
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24446
SELECT f_int1, f_int1, '', '', 'was inserted'
24447
FROM t0_template source_tab
24448
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
24449
	
24450
# check transactions-1 success: 	1
24451
COMMIT WORK;
24452
	
24453
# check transactions-2 success: 	1
24454
ROLLBACK WORK;
24455
	
24456
# check transactions-3 success: 	1
24457
DELETE FROM t1 WHERE f_charbig = 'was inserted';
24458
COMMIT WORK;
24459
ROLLBACK WORK;
24460
	
24461
# check transactions-4 success: 	1
24462
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24463
SELECT f_int1, f_int1, '', '', 'was inserted'
24464
FROM t0_template source_tab
24465
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
24466
	
24467
# check transactions-5 success: 	1
24468
ROLLBACK WORK;
24469
	
24470
# check transactions-6 success: 	1
24471
# INFO: Storage engine used for t1 seems to be transactional.
24472
COMMIT;
24473
	
24474
# check transactions-7 success: 	1
24475
DELETE FROM t1 WHERE f_charbig = 'was inserted';
24476
COMMIT WORK;
24477
SET @@session.sql_mode = 'traditional';
24478
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
24479
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24480
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
24481
'', '', 'was inserted' FROM t0_template
24482
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
24483
ERROR 22012: Division by 0
24484
COMMIT;
24485
	
24486
# check transactions-8 success: 	1
24487
# INFO: Storage engine used for t1 seems to be able to revert
24488
#       changes made by the failing statement.
24489
SET @@session.sql_mode = '';
24490
SET AUTOCOMMIT= 1;
24491
DELETE FROM t1 WHERE f_charbig = 'was inserted';
24492
COMMIT WORK;
24493
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
24494
	
24495
# check special-1 success: 	1
24496
UPDATE t1 SET f_charbig = '';
24497
	
24498
# check special-2 success: 	1
24499
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
24500
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
24501
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
24502
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24503
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24504
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24505
'just inserted' FROM t0_template
24506
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24507
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
24508
BEGIN
24509
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24510
f_charbig = 'updated by trigger'
24511
      WHERE f_int1 = new.f_int1;
24512
END|
24513
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24514
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
24515
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24516
	
24517
# check trigger-1 success: 	1
24518
DROP TRIGGER trg_1;
24519
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24520
f_int2 = CAST(f_char1 AS SIGNED INT),
24521
f_charbig = 'just inserted'
24522
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24523
DELETE FROM t0_aux
24524
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24525
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24526
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24527
'just inserted' FROM t0_template
24528
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24529
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
24530
BEGIN
24531
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24532
f_charbig = 'updated by trigger'
24533
      WHERE f_int1 = new.f_int1;
24534
END|
24535
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24536
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
24537
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24538
	
24539
# check trigger-2 success: 	1
24540
DROP TRIGGER trg_1;
24541
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24542
f_int2 = CAST(f_char1 AS SIGNED INT),
24543
f_charbig = 'just inserted'
24544
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24545
DELETE FROM t0_aux
24546
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24547
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24548
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24549
'just inserted' FROM t0_template
24550
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24551
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
24552
BEGIN
24553
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24554
f_charbig = 'updated by trigger'
24555
      WHERE f_int1 = new.f_int1;
24556
END|
24557
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
24558
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
24559
	
24560
# check trigger-3 success: 	1
24561
DROP TRIGGER trg_1;
24562
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24563
f_int2 = CAST(f_char1 AS SIGNED INT),
24564
f_charbig = 'just inserted'
24565
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24566
DELETE FROM t0_aux
24567
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24568
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24569
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24570
'just inserted' FROM t0_template
24571
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24572
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
24573
BEGIN
24574
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24575
f_charbig = 'updated by trigger'
24576
      WHERE f_int1 = - old.f_int1;
24577
END|
24578
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
24579
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
24580
	
24581
# check trigger-4 success: 	1
24582
DROP TRIGGER trg_1;
24583
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24584
f_int2 = CAST(f_char1 AS SIGNED INT),
24585
f_charbig = 'just inserted'
24586
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24587
DELETE FROM t0_aux
24588
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24589
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24590
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24591
'just inserted' FROM t0_template
24592
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24593
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
24594
BEGIN
24595
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24596
f_charbig = 'updated by trigger'
24597
      WHERE f_int1 = new.f_int1;
24598
END|
24599
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
24600
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
24601
	
24602
# check trigger-5 success: 	1
24603
DROP TRIGGER trg_1;
24604
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24605
f_int2 = CAST(f_char1 AS SIGNED INT),
24606
f_charbig = 'just inserted'
24607
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24608
DELETE FROM t0_aux
24609
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24610
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24611
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24612
'just inserted' FROM t0_template
24613
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24614
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
24615
BEGIN
24616
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24617
f_charbig = 'updated by trigger'
24618
      WHERE f_int1 = - old.f_int1;
24619
END|
24620
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
24621
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
24622
	
24623
# check trigger-6 success: 	1
24624
DROP TRIGGER trg_1;
24625
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24626
f_int2 = CAST(f_char1 AS SIGNED INT),
24627
f_charbig = 'just inserted'
24628
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24629
DELETE FROM t0_aux
24630
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24631
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24632
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24633
'just inserted' FROM t0_template
24634
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24635
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
24636
BEGIN
24637
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24638
f_charbig = 'updated by trigger'
24639
      WHERE f_int1 = - old.f_int1;
24640
END|
24641
DELETE FROM t0_aux
24642
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
24643
	
24644
# check trigger-7 success: 	1
24645
DROP TRIGGER trg_1;
24646
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24647
f_int2 = CAST(f_char1 AS SIGNED INT),
24648
f_charbig = 'just inserted'
24649
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24650
DELETE FROM t0_aux
24651
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24652
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24653
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24654
'just inserted' FROM t0_template
24655
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24656
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
24657
BEGIN
24658
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
24659
f_charbig = 'updated by trigger'
24660
      WHERE f_int1 = - old.f_int1;
24661
END|
24662
DELETE FROM t0_aux
24663
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
24664
	
24665
# check trigger-8 success: 	1
24666
DROP TRIGGER trg_1;
24667
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24668
f_int2 = CAST(f_char1 AS SIGNED INT),
24669
f_charbig = 'just inserted'
24670
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
24671
DELETE FROM t0_aux
24672
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24673
DELETE FROM t1
24674
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24675
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
24676
BEGIN
24677
SET new.f_int1 = old.f_int1 + @max_row,
24678
new.f_int2 = old.f_int2 - @max_row,
24679
new.f_charbig = '####updated per update trigger####';
24680
END|
24681
UPDATE t1
24682
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
24683
f_charbig = '####updated per update statement itself####';
24684
	
24685
# check trigger-9 success: 	1
24686
DROP TRIGGER trg_2;
24687
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24688
f_int2 = CAST(f_char1 AS SIGNED INT),
24689
f_charbig = CONCAT('===',f_char1,'===');
24690
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
24691
BEGIN
24692
SET new.f_int1 = new.f_int1 + @max_row,
24693
new.f_int2 = new.f_int2 - @max_row,
24694
new.f_charbig = '####updated per update trigger####';
24695
END|
24696
UPDATE t1
24697
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
24698
f_charbig = '####updated per update statement itself####';
24699
	
24700
# check trigger-10 success: 	1
24701
DROP TRIGGER trg_2;
24702
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24703
f_int2 = CAST(f_char1 AS SIGNED INT),
24704
f_charbig = CONCAT('===',f_char1,'===');
24705
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
24706
BEGIN
24707
SET new.f_int1 = @my_max1 + @counter,
24708
new.f_int2 = @my_min2 - @counter,
24709
new.f_charbig = '####updated per insert trigger####';
24710
SET @counter = @counter + 1;
24711
END|
24712
SET @counter = 1;
24713
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
24714
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24715
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
24716
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
24717
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
24718
ORDER BY f_int1;
24719
DROP TRIGGER trg_3;
24720
	
24721
# check trigger-11 success: 	1
24722
DELETE FROM t1
24723
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
24724
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
24725
AND f_charbig = '####updated per insert trigger####';
24726
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
24727
BEGIN
24728
SET new.f_int1 = @my_max1 + @counter,
24729
new.f_int2 = @my_min2 - @counter,
24730
new.f_charbig = '####updated per insert trigger####';
24731
SET @counter = @counter + 1;
24732
END|
24733
SET @counter = 1;
24734
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
24735
INSERT INTO t1 (f_char1, f_char2, f_charbig)
24736
SELECT CAST(f_int1 AS CHAR),
24737
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
24738
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
24739
ORDER BY f_int1;
24740
DROP TRIGGER trg_3;
24741
	
24742
# check trigger-12 success: 	1
24743
DELETE FROM t1
24744
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
24745
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
24746
AND f_charbig = '####updated per insert trigger####';
24747
ANALYZE  TABLE t1;
24748
Table	Op	Msg_type	Msg_text
24749
test.t1	analyze	note	The storage engine for the table doesn't support analyze
24750
CHECK    TABLE t1 EXTENDED;
24751
Table	Op	Msg_type	Msg_text
24752
test.t1	check	note	The storage engine for the table doesn't support check
24753
CHECKSUM TABLE t1 EXTENDED;
24754
Table	Checksum
24755
test.t1	<some_value>
24756
OPTIMIZE TABLE t1;
24757
Table	Op	Msg_type	Msg_text
24758
test.t1	optimize	note	The storage engine for the table doesn't support optimize
24759
# check layout success:    1
24760
REPAIR   TABLE t1 EXTENDED;
24761
Table	Op	Msg_type	Msg_text
24762
test.t1	repair	note	The storage engine for the table doesn't support repair
24763
# check layout success:    1
24764
TRUNCATE t1;
24765
	
24766
# check TRUNCATE success: 	1
24767
# check layout success:    1
24768
# End usability test (inc/partition_check.inc)
24769
DROP TABLE t1;
24770
CREATE TABLE t1 (
24771
f_int1 INTEGER,
24772
f_int2 INTEGER,
24773
f_char1 CHAR(20),
24774
f_char2 CHAR(20),
24775
f_charbig VARCHAR(1000)
24776
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
24777
)
24778
PARTITION BY RANGE((f_int1 + f_int2) DIV 2)
24779
(PARTITION parta VALUES LESS THAN (0),
24780
PARTITION partb VALUES LESS THAN (5),
24781
PARTITION partc VALUES LESS THAN (10),
24782
PARTITION partd VALUES LESS THAN (10 + 5),
24783
PARTITION parte VALUES LESS THAN (20),
24784
PARTITION partf VALUES LESS THAN (2147483646));
24785
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
24786
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
24787
# Start usability test (inc/partition_check.inc)
24788
create_command
24789
SHOW CREATE TABLE t1;
24790
Table	Create Table
24791
t1	CREATE TABLE `t1` (
24792
  `f_int1` int(11) NOT NULL DEFAULT '0',
24793
  `f_int2` int(11) NOT NULL DEFAULT '0',
24794
  `f_char1` char(20) DEFAULT NULL,
24795
  `f_char2` char(20) DEFAULT NULL,
24796
  `f_charbig` varchar(1000) DEFAULT NULL,
24797
  PRIMARY KEY (`f_int1`,`f_int2`),
24798
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
24799
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE ((f_int1 + f_int2) DIV 2) (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION parte VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
24800
24801
unified filelist
24802
$MYSQLTEST_VARDIR/master-data/test/t1.frm
24803
$MYSQLTEST_VARDIR/master-data/test/t1.par
24804
24805
# check prerequisites-1 success:    1
24806
# check COUNT(*) success:    1
24807
# check MIN/MAX(f_int1) success:    1
24808
# check MIN/MAX(f_int2) success:    1
24809
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24810
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
24811
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
24812
WHERE f_int1 IN (2,3);
24813
ERROR 23000: Can't write; duplicate key in table 't1'
24814
# check prerequisites-3 success:    1
24815
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
24816
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24817
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
24818
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
24819
WHERE f_int1 IN (2,3);
24820
DELETE FROM t1 WHERE f_charbig = 'delete me';
24821
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24822
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
24823
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
24824
WHERE f_int1 IN (2,3);
24825
DELETE FROM t1 WHERE f_charbig = 'delete me';
24826
# check read via f_int1 success: 1
24827
# check read via f_int2 success: 1
24828
	
24829
# check multiple-1 success: 	1
24830
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
24831
	
24832
# check multiple-2 success: 	1
24833
INSERT INTO t1 SELECT * FROM t0_template
24834
WHERE MOD(f_int1,3) = 0;
24835
	
24836
# check multiple-3 success: 	1
24837
UPDATE t1 SET f_int1 = f_int1 + @max_row
24838
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
24839
AND @max_row_div2 + @max_row_div4;
24840
	
24841
# check multiple-4 success: 	1
24842
DELETE FROM t1
24843
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
24844
AND @max_row_div2 + @max_row_div4 + @max_row;
24845
	
24846
# check multiple-5 success: 	1
24847
SELECT COUNT(*) INTO @try_count FROM t0_template
24848
WHERE MOD(f_int1,3) = 0
24849
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
24850
SELECT COUNT(*) INTO @clash_count
24851
FROM t1 INNER JOIN t0_template USING(f_int1)
24852
WHERE MOD(f_int1,3) = 0
24853
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
24854
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
24855
INSERT INTO t1
24856
SET f_int1 = @cur_value , f_int2 = @cur_value,
24857
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
24858
f_charbig = '#SINGLE#';
24859
	
24860
# check single-1 success: 	1
24861
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
24862
INSERT INTO t1
24863
SET f_int1 = @cur_value , f_int2 = @cur_value,
24864
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
24865
f_charbig = '#SINGLE#';
24866
	
24867
# check single-2 success: 	1
24868
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
24869
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
24870
UPDATE t1 SET f_int1 = @cur_value2
24871
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
24872
	
24873
# check single-3 success: 	1
24874
SET @cur_value1= -1;
24875
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
24876
UPDATE t1 SET f_int1 = @cur_value1
24877
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
24878
	
24879
# check single-4 success: 	1
24880
SELECT MAX(f_int1) INTO @cur_value FROM t1;
24881
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
24882
	
24883
# check single-5 success: 	1
24884
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
24885
	
24886
# check single-6 success: 	1
24887
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
24888
ERROR HY000: Table has no partition for value 2147483647
24889
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
24890
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
24891
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
24892
f_charbig = '#NULL#';
24893
INSERT INTO t1
24894
SET f_int1 = NULL , f_int2 = -@max_row,
24895
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
24896
f_charbig = '#NULL#';
24897
ERROR 23000: Column 'f_int1' cannot be null
24898
# check null success:    1
24899
DELETE FROM t1
24900
WHERE f_int1 = 0 AND f_int2 = 0
24901
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
24902
AND f_charbig = '#NULL#';
24903
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24904
SELECT f_int1, f_int1, '', '', 'was inserted'
24905
   FROM t0_template source_tab
24906
WHERE MOD(f_int1,3) = 0
24907
AND f_int1 BETWEEN @max_row_div2 AND @max_row
24908
ON DUPLICATE KEY
24909
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
24910
f_int2 = 2 * @max_row + source_tab.f_int1,
24911
f_charbig = 'was updated';
24912
	
24913
# check unique-1-a success: 	1
24914
	
24915
# check unique-1-b success: 	1
24916
DELETE FROM t1 WHERE f_charbig = 'was inserted';
24917
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
24918
f_int2 = CAST(f_char1 AS SIGNED INT),
24919
f_charbig = CONCAT('===',f_char1,'===')
24920
WHERE f_charbig = 'was updated';
24921
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24922
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
24923
   FROM t0_template source_tab
24924
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
24925
	
24926
# check replace success: 	1
24927
DELETE FROM t1
24928
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
24929
DELETE FROM t1
24930
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
24931
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
24932
UPDATE t1 SET f_int2 = f_int1,
24933
f_char1 = CAST(f_int1 AS CHAR),
24934
f_char2 = CAST(f_int1 AS CHAR),
24935
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
24936
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
24937
SET AUTOCOMMIT= 0;
24938
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24939
SELECT f_int1, f_int1, '', '', 'was inserted'
24940
FROM t0_template source_tab
24941
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
24942
	
24943
# check transactions-1 success: 	1
24944
COMMIT WORK;
24945
	
24946
# check transactions-2 success: 	1
24947
ROLLBACK WORK;
24948
	
24949
# check transactions-3 success: 	1
24950
DELETE FROM t1 WHERE f_charbig = 'was inserted';
24951
COMMIT WORK;
24952
ROLLBACK WORK;
24953
	
24954
# check transactions-4 success: 	1
24955
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24956
SELECT f_int1, f_int1, '', '', 'was inserted'
24957
FROM t0_template source_tab
24958
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
24959
	
24960
# check transactions-5 success: 	1
24961
ROLLBACK WORK;
24962
	
24963
# check transactions-6 success: 	1
24964
# INFO: Storage engine used for t1 seems to be transactional.
24965
COMMIT;
24966
	
24967
# check transactions-7 success: 	1
24968
DELETE FROM t1 WHERE f_charbig = 'was inserted';
24969
COMMIT WORK;
24970
SET @@session.sql_mode = 'traditional';
24971
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
24972
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
24973
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
24974
'', '', 'was inserted' FROM t0_template
24975
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
24976
ERROR 22012: Division by 0
24977
COMMIT;
24978
	
24979
# check transactions-8 success: 	1
24980
# INFO: Storage engine used for t1 seems to be able to revert
24981
#       changes made by the failing statement.
24982
SET @@session.sql_mode = '';
24983
SET AUTOCOMMIT= 1;
24984
DELETE FROM t1 WHERE f_charbig = 'was inserted';
24985
COMMIT WORK;
24986
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
24987
	
24988
# check special-1 success: 	1
24989
UPDATE t1 SET f_charbig = '';
24990
	
24991
# check special-2 success: 	1
24992
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
24993
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
24994
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
24995
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
24996
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
24997
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
24998
'just inserted' FROM t0_template
24999
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25000
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
25001
BEGIN
25002
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25003
f_charbig = 'updated by trigger'
25004
      WHERE f_int1 = new.f_int1;
25005
END|
25006
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25007
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
25008
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25009
	
25010
# check trigger-1 success: 	1
25011
DROP TRIGGER trg_1;
25012
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25013
f_int2 = CAST(f_char1 AS SIGNED INT),
25014
f_charbig = 'just inserted'
25015
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25016
DELETE FROM t0_aux
25017
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25018
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25019
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25020
'just inserted' FROM t0_template
25021
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25022
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
25023
BEGIN
25024
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25025
f_charbig = 'updated by trigger'
25026
      WHERE f_int1 = new.f_int1;
25027
END|
25028
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25029
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
25030
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25031
	
25032
# check trigger-2 success: 	1
25033
DROP TRIGGER trg_1;
25034
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25035
f_int2 = CAST(f_char1 AS SIGNED INT),
25036
f_charbig = 'just inserted'
25037
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25038
DELETE FROM t0_aux
25039
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25040
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25041
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25042
'just inserted' FROM t0_template
25043
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25044
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
25045
BEGIN
25046
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25047
f_charbig = 'updated by trigger'
25048
      WHERE f_int1 = new.f_int1;
25049
END|
25050
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
25051
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
25052
	
25053
# check trigger-3 success: 	1
25054
DROP TRIGGER trg_1;
25055
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25056
f_int2 = CAST(f_char1 AS SIGNED INT),
25057
f_charbig = 'just inserted'
25058
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25059
DELETE FROM t0_aux
25060
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25061
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25062
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25063
'just inserted' FROM t0_template
25064
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25065
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
25066
BEGIN
25067
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25068
f_charbig = 'updated by trigger'
25069
      WHERE f_int1 = - old.f_int1;
25070
END|
25071
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
25072
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
25073
	
25074
# check trigger-4 success: 	1
25075
DROP TRIGGER trg_1;
25076
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25077
f_int2 = CAST(f_char1 AS SIGNED INT),
25078
f_charbig = 'just inserted'
25079
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25080
DELETE FROM t0_aux
25081
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25082
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25083
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25084
'just inserted' FROM t0_template
25085
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25086
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
25087
BEGIN
25088
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25089
f_charbig = 'updated by trigger'
25090
      WHERE f_int1 = new.f_int1;
25091
END|
25092
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
25093
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
25094
	
25095
# check trigger-5 success: 	1
25096
DROP TRIGGER trg_1;
25097
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25098
f_int2 = CAST(f_char1 AS SIGNED INT),
25099
f_charbig = 'just inserted'
25100
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25101
DELETE FROM t0_aux
25102
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25103
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25104
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25105
'just inserted' FROM t0_template
25106
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25107
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
25108
BEGIN
25109
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25110
f_charbig = 'updated by trigger'
25111
      WHERE f_int1 = - old.f_int1;
25112
END|
25113
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
25114
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
25115
	
25116
# check trigger-6 success: 	1
25117
DROP TRIGGER trg_1;
25118
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25119
f_int2 = CAST(f_char1 AS SIGNED INT),
25120
f_charbig = 'just inserted'
25121
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25122
DELETE FROM t0_aux
25123
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25124
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25125
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25126
'just inserted' FROM t0_template
25127
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25128
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
25129
BEGIN
25130
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25131
f_charbig = 'updated by trigger'
25132
      WHERE f_int1 = - old.f_int1;
25133
END|
25134
DELETE FROM t0_aux
25135
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
25136
	
25137
# check trigger-7 success: 	1
25138
DROP TRIGGER trg_1;
25139
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25140
f_int2 = CAST(f_char1 AS SIGNED INT),
25141
f_charbig = 'just inserted'
25142
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25143
DELETE FROM t0_aux
25144
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25145
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25146
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25147
'just inserted' FROM t0_template
25148
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25149
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
25150
BEGIN
25151
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25152
f_charbig = 'updated by trigger'
25153
      WHERE f_int1 = - old.f_int1;
25154
END|
25155
DELETE FROM t0_aux
25156
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
25157
	
25158
# check trigger-8 success: 	1
25159
DROP TRIGGER trg_1;
25160
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25161
f_int2 = CAST(f_char1 AS SIGNED INT),
25162
f_charbig = 'just inserted'
25163
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25164
DELETE FROM t0_aux
25165
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25166
DELETE FROM t1
25167
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25168
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
25169
BEGIN
25170
SET new.f_int1 = old.f_int1 + @max_row,
25171
new.f_int2 = old.f_int2 - @max_row,
25172
new.f_charbig = '####updated per update trigger####';
25173
END|
25174
UPDATE t1
25175
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
25176
f_charbig = '####updated per update statement itself####';
25177
	
25178
# check trigger-9 success: 	1
25179
DROP TRIGGER trg_2;
25180
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25181
f_int2 = CAST(f_char1 AS SIGNED INT),
25182
f_charbig = CONCAT('===',f_char1,'===');
25183
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
25184
BEGIN
25185
SET new.f_int1 = new.f_int1 + @max_row,
25186
new.f_int2 = new.f_int2 - @max_row,
25187
new.f_charbig = '####updated per update trigger####';
25188
END|
25189
UPDATE t1
25190
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
25191
f_charbig = '####updated per update statement itself####';
25192
	
25193
# check trigger-10 success: 	1
25194
DROP TRIGGER trg_2;
25195
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25196
f_int2 = CAST(f_char1 AS SIGNED INT),
25197
f_charbig = CONCAT('===',f_char1,'===');
25198
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
25199
BEGIN
25200
SET new.f_int1 = @my_max1 + @counter,
25201
new.f_int2 = @my_min2 - @counter,
25202
new.f_charbig = '####updated per insert trigger####';
25203
SET @counter = @counter + 1;
25204
END|
25205
SET @counter = 1;
25206
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
25207
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25208
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
25209
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
25210
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
25211
ORDER BY f_int1;
25212
DROP TRIGGER trg_3;
25213
	
25214
# check trigger-11 success: 	1
25215
DELETE FROM t1
25216
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
25217
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
25218
AND f_charbig = '####updated per insert trigger####';
25219
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
25220
BEGIN
25221
SET new.f_int1 = @my_max1 + @counter,
25222
new.f_int2 = @my_min2 - @counter,
25223
new.f_charbig = '####updated per insert trigger####';
25224
SET @counter = @counter + 1;
25225
END|
25226
SET @counter = 1;
25227
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
25228
INSERT INTO t1 (f_char1, f_char2, f_charbig)
25229
SELECT CAST(f_int1 AS CHAR),
25230
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
25231
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
25232
ORDER BY f_int1;
25233
DROP TRIGGER trg_3;
25234
	
25235
# check trigger-12 success: 	1
25236
DELETE FROM t1
25237
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
25238
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
25239
AND f_charbig = '####updated per insert trigger####';
25240
ANALYZE  TABLE t1;
25241
Table	Op	Msg_type	Msg_text
25242
test.t1	analyze	note	The storage engine for the table doesn't support analyze
25243
CHECK    TABLE t1 EXTENDED;
25244
Table	Op	Msg_type	Msg_text
25245
test.t1	check	note	The storage engine for the table doesn't support check
25246
CHECKSUM TABLE t1 EXTENDED;
25247
Table	Checksum
25248
test.t1	<some_value>
25249
OPTIMIZE TABLE t1;
25250
Table	Op	Msg_type	Msg_text
25251
test.t1	optimize	note	The storage engine for the table doesn't support optimize
25252
# check layout success:    1
25253
REPAIR   TABLE t1 EXTENDED;
25254
Table	Op	Msg_type	Msg_text
25255
test.t1	repair	note	The storage engine for the table doesn't support repair
25256
# check layout success:    1
25257
TRUNCATE t1;
25258
	
25259
# check TRUNCATE success: 	1
25260
# check layout success:    1
25261
# End usability test (inc/partition_check.inc)
25262
DROP TABLE t1;
25263
CREATE TABLE t1 (
25264
f_int1 INTEGER,
25265
f_int2 INTEGER,
25266
f_char1 CHAR(20),
25267
f_char2 CHAR(20),
25268
f_charbig VARCHAR(1000)
25269
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
25270
)
25271
PARTITION BY RANGE(f_int1) SUBPARTITION BY HASH(f_int2) SUBPARTITIONS 2
25272
(PARTITION parta VALUES LESS THAN (0),
25273
PARTITION partb VALUES LESS THAN (5),
25274
PARTITION partc VALUES LESS THAN (10),
25275
PARTITION partd VALUES LESS THAN (2147483646));
25276
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
25277
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
25278
# Start usability test (inc/partition_check.inc)
25279
create_command
25280
SHOW CREATE TABLE t1;
25281
Table	Create Table
25282
t1	CREATE TABLE `t1` (
25283
  `f_int1` int(11) NOT NULL DEFAULT '0',
25284
  `f_int2` int(11) NOT NULL DEFAULT '0',
25285
  `f_char1` char(20) DEFAULT NULL,
25286
  `f_char2` char(20) DEFAULT NULL,
25287
  `f_charbig` varchar(1000) DEFAULT NULL,
25288
  PRIMARY KEY (`f_int1`,`f_int2`),
25289
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
25290
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) SUBPARTITION BY HASH (f_int2) SUBPARTITIONS 2 (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
25291
25292
unified filelist
25293
$MYSQLTEST_VARDIR/master-data/test/t1.frm
25294
$MYSQLTEST_VARDIR/master-data/test/t1.par
25295
25296
# check prerequisites-1 success:    1
25297
# check COUNT(*) success:    1
25298
# check MIN/MAX(f_int1) success:    1
25299
# check MIN/MAX(f_int2) success:    1
25300
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25301
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
25302
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
25303
WHERE f_int1 IN (2,3);
25304
ERROR 23000: Can't write; duplicate key in table 't1'
25305
# check prerequisites-3 success:    1
25306
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
25307
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25308
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
25309
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
25310
WHERE f_int1 IN (2,3);
25311
DELETE FROM t1 WHERE f_charbig = 'delete me';
25312
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25313
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
25314
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
25315
WHERE f_int1 IN (2,3);
25316
DELETE FROM t1 WHERE f_charbig = 'delete me';
25317
# check read via f_int1 success: 1
25318
# check read via f_int2 success: 1
25319
	
25320
# check multiple-1 success: 	1
25321
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
25322
	
25323
# check multiple-2 success: 	1
25324
INSERT INTO t1 SELECT * FROM t0_template
25325
WHERE MOD(f_int1,3) = 0;
25326
	
25327
# check multiple-3 success: 	1
25328
UPDATE t1 SET f_int1 = f_int1 + @max_row
25329
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
25330
AND @max_row_div2 + @max_row_div4;
25331
	
25332
# check multiple-4 success: 	1
25333
DELETE FROM t1
25334
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
25335
AND @max_row_div2 + @max_row_div4 + @max_row;
25336
	
25337
# check multiple-5 success: 	1
25338
SELECT COUNT(*) INTO @try_count FROM t0_template
25339
WHERE MOD(f_int1,3) = 0
25340
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
25341
SELECT COUNT(*) INTO @clash_count
25342
FROM t1 INNER JOIN t0_template USING(f_int1)
25343
WHERE MOD(f_int1,3) = 0
25344
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
25345
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
25346
INSERT INTO t1
25347
SET f_int1 = @cur_value , f_int2 = @cur_value,
25348
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
25349
f_charbig = '#SINGLE#';
25350
	
25351
# check single-1 success: 	1
25352
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
25353
INSERT INTO t1
25354
SET f_int1 = @cur_value , f_int2 = @cur_value,
25355
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
25356
f_charbig = '#SINGLE#';
25357
	
25358
# check single-2 success: 	1
25359
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
25360
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
25361
UPDATE t1 SET f_int1 = @cur_value2
25362
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
25363
	
25364
# check single-3 success: 	1
25365
SET @cur_value1= -1;
25366
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
25367
UPDATE t1 SET f_int1 = @cur_value1
25368
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
25369
	
25370
# check single-4 success: 	1
25371
SELECT MAX(f_int1) INTO @cur_value FROM t1;
25372
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
25373
	
25374
# check single-5 success: 	1
25375
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
25376
	
25377
# check single-6 success: 	1
25378
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
25379
ERROR HY000: Table has no partition for value 2147483647
25380
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
25381
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
25382
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
25383
f_charbig = '#NULL#';
25384
INSERT INTO t1
25385
SET f_int1 = NULL , f_int2 = -@max_row,
25386
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
25387
f_charbig = '#NULL#';
25388
ERROR 23000: Column 'f_int1' cannot be null
25389
# check null success:    1
25390
DELETE FROM t1
25391
WHERE f_int1 = 0 AND f_int2 = 0
25392
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
25393
AND f_charbig = '#NULL#';
25394
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25395
SELECT f_int1, f_int1, '', '', 'was inserted'
25396
   FROM t0_template source_tab
25397
WHERE MOD(f_int1,3) = 0
25398
AND f_int1 BETWEEN @max_row_div2 AND @max_row
25399
ON DUPLICATE KEY
25400
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
25401
f_int2 = 2 * @max_row + source_tab.f_int1,
25402
f_charbig = 'was updated';
25403
	
25404
# check unique-1-a success: 	1
25405
	
25406
# check unique-1-b success: 	1
25407
DELETE FROM t1 WHERE f_charbig = 'was inserted';
25408
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25409
f_int2 = CAST(f_char1 AS SIGNED INT),
25410
f_charbig = CONCAT('===',f_char1,'===')
25411
WHERE f_charbig = 'was updated';
25412
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25413
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
25414
   FROM t0_template source_tab
25415
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
25416
	
25417
# check replace success: 	1
25418
DELETE FROM t1
25419
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
25420
DELETE FROM t1
25421
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
25422
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
25423
UPDATE t1 SET f_int2 = f_int1,
25424
f_char1 = CAST(f_int1 AS CHAR),
25425
f_char2 = CAST(f_int1 AS CHAR),
25426
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
25427
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
25428
SET AUTOCOMMIT= 0;
25429
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25430
SELECT f_int1, f_int1, '', '', 'was inserted'
25431
FROM t0_template source_tab
25432
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
25433
	
25434
# check transactions-1 success: 	1
25435
COMMIT WORK;
25436
	
25437
# check transactions-2 success: 	1
25438
ROLLBACK WORK;
25439
	
25440
# check transactions-3 success: 	1
25441
DELETE FROM t1 WHERE f_charbig = 'was inserted';
25442
COMMIT WORK;
25443
ROLLBACK WORK;
25444
	
25445
# check transactions-4 success: 	1
25446
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25447
SELECT f_int1, f_int1, '', '', 'was inserted'
25448
FROM t0_template source_tab
25449
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
25450
	
25451
# check transactions-5 success: 	1
25452
ROLLBACK WORK;
25453
	
25454
# check transactions-6 success: 	1
25455
# INFO: Storage engine used for t1 seems to be transactional.
25456
COMMIT;
25457
	
25458
# check transactions-7 success: 	1
25459
DELETE FROM t1 WHERE f_charbig = 'was inserted';
25460
COMMIT WORK;
25461
SET @@session.sql_mode = 'traditional';
25462
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
25463
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25464
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
25465
'', '', 'was inserted' FROM t0_template
25466
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
25467
ERROR 22012: Division by 0
25468
COMMIT;
25469
	
25470
# check transactions-8 success: 	1
25471
# INFO: Storage engine used for t1 seems to be able to revert
25472
#       changes made by the failing statement.
25473
SET @@session.sql_mode = '';
25474
SET AUTOCOMMIT= 1;
25475
DELETE FROM t1 WHERE f_charbig = 'was inserted';
25476
COMMIT WORK;
25477
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
25478
	
25479
# check special-1 success: 	1
25480
UPDATE t1 SET f_charbig = '';
25481
	
25482
# check special-2 success: 	1
25483
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
25484
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
25485
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
25486
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25487
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25488
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25489
'just inserted' FROM t0_template
25490
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25491
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
25492
BEGIN
25493
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25494
f_charbig = 'updated by trigger'
25495
      WHERE f_int1 = new.f_int1;
25496
END|
25497
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25498
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
25499
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25500
	
25501
# check trigger-1 success: 	1
25502
DROP TRIGGER trg_1;
25503
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25504
f_int2 = CAST(f_char1 AS SIGNED INT),
25505
f_charbig = 'just inserted'
25506
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25507
DELETE FROM t0_aux
25508
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25509
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25510
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25511
'just inserted' FROM t0_template
25512
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25513
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
25514
BEGIN
25515
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25516
f_charbig = 'updated by trigger'
25517
      WHERE f_int1 = new.f_int1;
25518
END|
25519
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25520
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
25521
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25522
	
25523
# check trigger-2 success: 	1
25524
DROP TRIGGER trg_1;
25525
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25526
f_int2 = CAST(f_char1 AS SIGNED INT),
25527
f_charbig = 'just inserted'
25528
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25529
DELETE FROM t0_aux
25530
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25531
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25532
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25533
'just inserted' FROM t0_template
25534
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25535
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
25536
BEGIN
25537
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25538
f_charbig = 'updated by trigger'
25539
      WHERE f_int1 = new.f_int1;
25540
END|
25541
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
25542
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
25543
	
25544
# check trigger-3 success: 	1
25545
DROP TRIGGER trg_1;
25546
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25547
f_int2 = CAST(f_char1 AS SIGNED INT),
25548
f_charbig = 'just inserted'
25549
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25550
DELETE FROM t0_aux
25551
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25552
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25553
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25554
'just inserted' FROM t0_template
25555
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25556
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
25557
BEGIN
25558
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25559
f_charbig = 'updated by trigger'
25560
      WHERE f_int1 = - old.f_int1;
25561
END|
25562
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
25563
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
25564
	
25565
# check trigger-4 success: 	1
25566
DROP TRIGGER trg_1;
25567
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25568
f_int2 = CAST(f_char1 AS SIGNED INT),
25569
f_charbig = 'just inserted'
25570
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25571
DELETE FROM t0_aux
25572
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25573
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25574
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25575
'just inserted' FROM t0_template
25576
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25577
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
25578
BEGIN
25579
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25580
f_charbig = 'updated by trigger'
25581
      WHERE f_int1 = new.f_int1;
25582
END|
25583
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
25584
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
25585
	
25586
# check trigger-5 success: 	1
25587
DROP TRIGGER trg_1;
25588
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25589
f_int2 = CAST(f_char1 AS SIGNED INT),
25590
f_charbig = 'just inserted'
25591
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25592
DELETE FROM t0_aux
25593
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25594
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25595
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25596
'just inserted' FROM t0_template
25597
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25598
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
25599
BEGIN
25600
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25601
f_charbig = 'updated by trigger'
25602
      WHERE f_int1 = - old.f_int1;
25603
END|
25604
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
25605
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
25606
	
25607
# check trigger-6 success: 	1
25608
DROP TRIGGER trg_1;
25609
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25610
f_int2 = CAST(f_char1 AS SIGNED INT),
25611
f_charbig = 'just inserted'
25612
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25613
DELETE FROM t0_aux
25614
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25615
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25616
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25617
'just inserted' FROM t0_template
25618
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25619
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
25620
BEGIN
25621
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25622
f_charbig = 'updated by trigger'
25623
      WHERE f_int1 = - old.f_int1;
25624
END|
25625
DELETE FROM t0_aux
25626
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
25627
	
25628
# check trigger-7 success: 	1
25629
DROP TRIGGER trg_1;
25630
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25631
f_int2 = CAST(f_char1 AS SIGNED INT),
25632
f_charbig = 'just inserted'
25633
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25634
DELETE FROM t0_aux
25635
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25636
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25637
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25638
'just inserted' FROM t0_template
25639
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25640
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
25641
BEGIN
25642
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25643
f_charbig = 'updated by trigger'
25644
      WHERE f_int1 = - old.f_int1;
25645
END|
25646
DELETE FROM t0_aux
25647
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
25648
	
25649
# check trigger-8 success: 	1
25650
DROP TRIGGER trg_1;
25651
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25652
f_int2 = CAST(f_char1 AS SIGNED INT),
25653
f_charbig = 'just inserted'
25654
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
25655
DELETE FROM t0_aux
25656
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25657
DELETE FROM t1
25658
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25659
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
25660
BEGIN
25661
SET new.f_int1 = old.f_int1 + @max_row,
25662
new.f_int2 = old.f_int2 - @max_row,
25663
new.f_charbig = '####updated per update trigger####';
25664
END|
25665
UPDATE t1
25666
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
25667
f_charbig = '####updated per update statement itself####';
25668
	
25669
# check trigger-9 success: 	1
25670
DROP TRIGGER trg_2;
25671
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25672
f_int2 = CAST(f_char1 AS SIGNED INT),
25673
f_charbig = CONCAT('===',f_char1,'===');
25674
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
25675
BEGIN
25676
SET new.f_int1 = new.f_int1 + @max_row,
25677
new.f_int2 = new.f_int2 - @max_row,
25678
new.f_charbig = '####updated per update trigger####';
25679
END|
25680
UPDATE t1
25681
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
25682
f_charbig = '####updated per update statement itself####';
25683
	
25684
# check trigger-10 success: 	1
25685
DROP TRIGGER trg_2;
25686
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25687
f_int2 = CAST(f_char1 AS SIGNED INT),
25688
f_charbig = CONCAT('===',f_char1,'===');
25689
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
25690
BEGIN
25691
SET new.f_int1 = @my_max1 + @counter,
25692
new.f_int2 = @my_min2 - @counter,
25693
new.f_charbig = '####updated per insert trigger####';
25694
SET @counter = @counter + 1;
25695
END|
25696
SET @counter = 1;
25697
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
25698
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25699
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
25700
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
25701
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
25702
ORDER BY f_int1;
25703
DROP TRIGGER trg_3;
25704
	
25705
# check trigger-11 success: 	1
25706
DELETE FROM t1
25707
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
25708
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
25709
AND f_charbig = '####updated per insert trigger####';
25710
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
25711
BEGIN
25712
SET new.f_int1 = @my_max1 + @counter,
25713
new.f_int2 = @my_min2 - @counter,
25714
new.f_charbig = '####updated per insert trigger####';
25715
SET @counter = @counter + 1;
25716
END|
25717
SET @counter = 1;
25718
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
25719
INSERT INTO t1 (f_char1, f_char2, f_charbig)
25720
SELECT CAST(f_int1 AS CHAR),
25721
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
25722
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
25723
ORDER BY f_int1;
25724
DROP TRIGGER trg_3;
25725
	
25726
# check trigger-12 success: 	1
25727
DELETE FROM t1
25728
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
25729
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
25730
AND f_charbig = '####updated per insert trigger####';
25731
ANALYZE  TABLE t1;
25732
Table	Op	Msg_type	Msg_text
25733
test.t1	analyze	note	The storage engine for the table doesn't support analyze
25734
CHECK    TABLE t1 EXTENDED;
25735
Table	Op	Msg_type	Msg_text
25736
test.t1	check	note	The storage engine for the table doesn't support check
25737
CHECKSUM TABLE t1 EXTENDED;
25738
Table	Checksum
25739
test.t1	<some_value>
25740
OPTIMIZE TABLE t1;
25741
Table	Op	Msg_type	Msg_text
25742
test.t1	optimize	note	The storage engine for the table doesn't support optimize
25743
# check layout success:    1
25744
REPAIR   TABLE t1 EXTENDED;
25745
Table	Op	Msg_type	Msg_text
25746
test.t1	repair	note	The storage engine for the table doesn't support repair
25747
# check layout success:    1
25748
TRUNCATE t1;
25749
	
25750
# check TRUNCATE success: 	1
25751
# check layout success:    1
25752
# End usability test (inc/partition_check.inc)
25753
DROP TABLE t1;
25754
CREATE TABLE t1 (
25755
f_int1 INTEGER,
25756
f_int2 INTEGER,
25757
f_char1 CHAR(20),
25758
f_char2 CHAR(20),
25759
f_charbig VARCHAR(1000)
25760
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
25761
)
25762
PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int2)
25763
(PARTITION part1 VALUES LESS THAN (0)
25764
(SUBPARTITION subpart11, SUBPARTITION subpart12),
25765
PARTITION part2 VALUES LESS THAN (5)
25766
(SUBPARTITION subpart21, SUBPARTITION subpart22),
25767
PARTITION part3 VALUES LESS THAN (10)
25768
(SUBPARTITION subpart31, SUBPARTITION subpart32),
25769
PARTITION part4 VALUES LESS THAN (2147483646)
25770
(SUBPARTITION subpart41, SUBPARTITION subpart42));
25771
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
25772
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
25773
# Start usability test (inc/partition_check.inc)
25774
create_command
25775
SHOW CREATE TABLE t1;
25776
Table	Create Table
25777
t1	CREATE TABLE `t1` (
25778
  `f_int1` int(11) NOT NULL DEFAULT '0',
25779
  `f_int2` int(11) NOT NULL DEFAULT '0',
25780
  `f_char1` char(20) DEFAULT NULL,
25781
  `f_char2` char(20) DEFAULT NULL,
25782
  `f_charbig` varchar(1000) DEFAULT NULL,
25783
  PRIMARY KEY (`f_int1`,`f_int2`),
25784
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
25785
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), PARTITION part2 VALUES LESS THAN (5) (SUBPARTITION subpart21 ENGINE = InnoDB, SUBPARTITION subpart22 ENGINE = InnoDB), PARTITION part3 VALUES LESS THAN (10) (SUBPARTITION subpart31 ENGINE = InnoDB, SUBPARTITION subpart32 ENGINE = InnoDB), PARTITION part4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41 ENGINE = InnoDB, SUBPARTITION subpart42 ENGINE = InnoDB)) */
25786
25787
unified filelist
25788
$MYSQLTEST_VARDIR/master-data/test/t1.frm
25789
$MYSQLTEST_VARDIR/master-data/test/t1.par
25790
25791
# check prerequisites-1 success:    1
25792
# check COUNT(*) success:    1
25793
# check MIN/MAX(f_int1) success:    1
25794
# check MIN/MAX(f_int2) success:    1
25795
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25796
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
25797
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
25798
WHERE f_int1 IN (2,3);
25799
ERROR 23000: Can't write; duplicate key in table 't1'
25800
# check prerequisites-3 success:    1
25801
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
25802
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25803
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
25804
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
25805
WHERE f_int1 IN (2,3);
25806
DELETE FROM t1 WHERE f_charbig = 'delete me';
25807
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25808
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
25809
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
25810
WHERE f_int1 IN (2,3);
25811
DELETE FROM t1 WHERE f_charbig = 'delete me';
25812
# check read via f_int1 success: 1
25813
# check read via f_int2 success: 1
25814
	
25815
# check multiple-1 success: 	1
25816
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
25817
	
25818
# check multiple-2 success: 	1
25819
INSERT INTO t1 SELECT * FROM t0_template
25820
WHERE MOD(f_int1,3) = 0;
25821
	
25822
# check multiple-3 success: 	1
25823
UPDATE t1 SET f_int1 = f_int1 + @max_row
25824
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
25825
AND @max_row_div2 + @max_row_div4;
25826
	
25827
# check multiple-4 success: 	1
25828
DELETE FROM t1
25829
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
25830
AND @max_row_div2 + @max_row_div4 + @max_row;
25831
	
25832
# check multiple-5 success: 	1
25833
SELECT COUNT(*) INTO @try_count FROM t0_template
25834
WHERE MOD(f_int1,3) = 0
25835
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
25836
SELECT COUNT(*) INTO @clash_count
25837
FROM t1 INNER JOIN t0_template USING(f_int1)
25838
WHERE MOD(f_int1,3) = 0
25839
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
25840
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
25841
INSERT INTO t1
25842
SET f_int1 = @cur_value , f_int2 = @cur_value,
25843
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
25844
f_charbig = '#SINGLE#';
25845
	
25846
# check single-1 success: 	1
25847
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
25848
INSERT INTO t1
25849
SET f_int1 = @cur_value , f_int2 = @cur_value,
25850
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
25851
f_charbig = '#SINGLE#';
25852
	
25853
# check single-2 success: 	1
25854
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
25855
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
25856
UPDATE t1 SET f_int1 = @cur_value2
25857
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
25858
	
25859
# check single-3 success: 	1
25860
SET @cur_value1= -1;
25861
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
25862
UPDATE t1 SET f_int1 = @cur_value1
25863
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
25864
	
25865
# check single-4 success: 	1
25866
SELECT MAX(f_int1) INTO @cur_value FROM t1;
25867
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
25868
	
25869
# check single-5 success: 	1
25870
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
25871
	
25872
# check single-6 success: 	1
25873
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
25874
ERROR HY000: Table has no partition for value 2147483647
25875
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
25876
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
25877
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
25878
f_charbig = '#NULL#';
25879
INSERT INTO t1
25880
SET f_int1 = NULL , f_int2 = -@max_row,
25881
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
25882
f_charbig = '#NULL#';
25883
ERROR 23000: Column 'f_int1' cannot be null
25884
# check null success:    1
25885
DELETE FROM t1
25886
WHERE f_int1 = 0 AND f_int2 = 0
25887
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
25888
AND f_charbig = '#NULL#';
25889
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25890
SELECT f_int1, f_int1, '', '', 'was inserted'
25891
   FROM t0_template source_tab
25892
WHERE MOD(f_int1,3) = 0
25893
AND f_int1 BETWEEN @max_row_div2 AND @max_row
25894
ON DUPLICATE KEY
25895
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
25896
f_int2 = 2 * @max_row + source_tab.f_int1,
25897
f_charbig = 'was updated';
25898
	
25899
# check unique-1-a success: 	1
25900
	
25901
# check unique-1-b success: 	1
25902
DELETE FROM t1 WHERE f_charbig = 'was inserted';
25903
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25904
f_int2 = CAST(f_char1 AS SIGNED INT),
25905
f_charbig = CONCAT('===',f_char1,'===')
25906
WHERE f_charbig = 'was updated';
25907
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25908
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
25909
   FROM t0_template source_tab
25910
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
25911
	
25912
# check replace success: 	1
25913
DELETE FROM t1
25914
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
25915
DELETE FROM t1
25916
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
25917
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
25918
UPDATE t1 SET f_int2 = f_int1,
25919
f_char1 = CAST(f_int1 AS CHAR),
25920
f_char2 = CAST(f_int1 AS CHAR),
25921
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
25922
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
25923
SET AUTOCOMMIT= 0;
25924
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25925
SELECT f_int1, f_int1, '', '', 'was inserted'
25926
FROM t0_template source_tab
25927
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
25928
	
25929
# check transactions-1 success: 	1
25930
COMMIT WORK;
25931
	
25932
# check transactions-2 success: 	1
25933
ROLLBACK WORK;
25934
	
25935
# check transactions-3 success: 	1
25936
DELETE FROM t1 WHERE f_charbig = 'was inserted';
25937
COMMIT WORK;
25938
ROLLBACK WORK;
25939
	
25940
# check transactions-4 success: 	1
25941
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25942
SELECT f_int1, f_int1, '', '', 'was inserted'
25943
FROM t0_template source_tab
25944
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
25945
	
25946
# check transactions-5 success: 	1
25947
ROLLBACK WORK;
25948
	
25949
# check transactions-6 success: 	1
25950
# INFO: Storage engine used for t1 seems to be transactional.
25951
COMMIT;
25952
	
25953
# check transactions-7 success: 	1
25954
DELETE FROM t1 WHERE f_charbig = 'was inserted';
25955
COMMIT WORK;
25956
SET @@session.sql_mode = 'traditional';
25957
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
25958
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
25959
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
25960
'', '', 'was inserted' FROM t0_template
25961
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
25962
ERROR 22012: Division by 0
25963
COMMIT;
25964
	
25965
# check transactions-8 success: 	1
25966
# INFO: Storage engine used for t1 seems to be able to revert
25967
#       changes made by the failing statement.
25968
SET @@session.sql_mode = '';
25969
SET AUTOCOMMIT= 1;
25970
DELETE FROM t1 WHERE f_charbig = 'was inserted';
25971
COMMIT WORK;
25972
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
25973
	
25974
# check special-1 success: 	1
25975
UPDATE t1 SET f_charbig = '';
25976
	
25977
# check special-2 success: 	1
25978
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
25979
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
25980
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
25981
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25982
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25983
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
25984
'just inserted' FROM t0_template
25985
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25986
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
25987
BEGIN
25988
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
25989
f_charbig = 'updated by trigger'
25990
      WHERE f_int1 = new.f_int1;
25991
END|
25992
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
25993
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
25994
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
25995
	
25996
# check trigger-1 success: 	1
25997
DROP TRIGGER trg_1;
25998
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
25999
f_int2 = CAST(f_char1 AS SIGNED INT),
26000
f_charbig = 'just inserted'
26001
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26002
DELETE FROM t0_aux
26003
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26004
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26005
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26006
'just inserted' FROM t0_template
26007
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26008
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
26009
BEGIN
26010
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26011
f_charbig = 'updated by trigger'
26012
      WHERE f_int1 = new.f_int1;
26013
END|
26014
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26015
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
26016
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26017
	
26018
# check trigger-2 success: 	1
26019
DROP TRIGGER trg_1;
26020
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26021
f_int2 = CAST(f_char1 AS SIGNED INT),
26022
f_charbig = 'just inserted'
26023
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26024
DELETE FROM t0_aux
26025
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26026
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26027
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26028
'just inserted' FROM t0_template
26029
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26030
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
26031
BEGIN
26032
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26033
f_charbig = 'updated by trigger'
26034
      WHERE f_int1 = new.f_int1;
26035
END|
26036
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
26037
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
26038
	
26039
# check trigger-3 success: 	1
26040
DROP TRIGGER trg_1;
26041
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26042
f_int2 = CAST(f_char1 AS SIGNED INT),
26043
f_charbig = 'just inserted'
26044
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26045
DELETE FROM t0_aux
26046
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26047
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26048
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26049
'just inserted' FROM t0_template
26050
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26051
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
26052
BEGIN
26053
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26054
f_charbig = 'updated by trigger'
26055
      WHERE f_int1 = - old.f_int1;
26056
END|
26057
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
26058
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
26059
	
26060
# check trigger-4 success: 	1
26061
DROP TRIGGER trg_1;
26062
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26063
f_int2 = CAST(f_char1 AS SIGNED INT),
26064
f_charbig = 'just inserted'
26065
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26066
DELETE FROM t0_aux
26067
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26068
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26069
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26070
'just inserted' FROM t0_template
26071
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26072
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
26073
BEGIN
26074
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26075
f_charbig = 'updated by trigger'
26076
      WHERE f_int1 = new.f_int1;
26077
END|
26078
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
26079
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
26080
	
26081
# check trigger-5 success: 	1
26082
DROP TRIGGER trg_1;
26083
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26084
f_int2 = CAST(f_char1 AS SIGNED INT),
26085
f_charbig = 'just inserted'
26086
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26087
DELETE FROM t0_aux
26088
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26089
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26090
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26091
'just inserted' FROM t0_template
26092
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26093
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
26094
BEGIN
26095
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26096
f_charbig = 'updated by trigger'
26097
      WHERE f_int1 = - old.f_int1;
26098
END|
26099
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
26100
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
26101
	
26102
# check trigger-6 success: 	1
26103
DROP TRIGGER trg_1;
26104
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26105
f_int2 = CAST(f_char1 AS SIGNED INT),
26106
f_charbig = 'just inserted'
26107
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26108
DELETE FROM t0_aux
26109
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26110
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26111
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26112
'just inserted' FROM t0_template
26113
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26114
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
26115
BEGIN
26116
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26117
f_charbig = 'updated by trigger'
26118
      WHERE f_int1 = - old.f_int1;
26119
END|
26120
DELETE FROM t0_aux
26121
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
26122
	
26123
# check trigger-7 success: 	1
26124
DROP TRIGGER trg_1;
26125
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26126
f_int2 = CAST(f_char1 AS SIGNED INT),
26127
f_charbig = 'just inserted'
26128
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26129
DELETE FROM t0_aux
26130
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26131
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26132
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26133
'just inserted' FROM t0_template
26134
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26135
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
26136
BEGIN
26137
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26138
f_charbig = 'updated by trigger'
26139
      WHERE f_int1 = - old.f_int1;
26140
END|
26141
DELETE FROM t0_aux
26142
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
26143
	
26144
# check trigger-8 success: 	1
26145
DROP TRIGGER trg_1;
26146
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26147
f_int2 = CAST(f_char1 AS SIGNED INT),
26148
f_charbig = 'just inserted'
26149
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26150
DELETE FROM t0_aux
26151
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26152
DELETE FROM t1
26153
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26154
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
26155
BEGIN
26156
SET new.f_int1 = old.f_int1 + @max_row,
26157
new.f_int2 = old.f_int2 - @max_row,
26158
new.f_charbig = '####updated per update trigger####';
26159
END|
26160
UPDATE t1
26161
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
26162
f_charbig = '####updated per update statement itself####';
26163
	
26164
# check trigger-9 success: 	1
26165
DROP TRIGGER trg_2;
26166
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26167
f_int2 = CAST(f_char1 AS SIGNED INT),
26168
f_charbig = CONCAT('===',f_char1,'===');
26169
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
26170
BEGIN
26171
SET new.f_int1 = new.f_int1 + @max_row,
26172
new.f_int2 = new.f_int2 - @max_row,
26173
new.f_charbig = '####updated per update trigger####';
26174
END|
26175
UPDATE t1
26176
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
26177
f_charbig = '####updated per update statement itself####';
26178
	
26179
# check trigger-10 success: 	1
26180
DROP TRIGGER trg_2;
26181
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26182
f_int2 = CAST(f_char1 AS SIGNED INT),
26183
f_charbig = CONCAT('===',f_char1,'===');
26184
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
26185
BEGIN
26186
SET new.f_int1 = @my_max1 + @counter,
26187
new.f_int2 = @my_min2 - @counter,
26188
new.f_charbig = '####updated per insert trigger####';
26189
SET @counter = @counter + 1;
26190
END|
26191
SET @counter = 1;
26192
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
26193
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26194
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
26195
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
26196
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
26197
ORDER BY f_int1;
26198
DROP TRIGGER trg_3;
26199
	
26200
# check trigger-11 success: 	1
26201
DELETE FROM t1
26202
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
26203
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
26204
AND f_charbig = '####updated per insert trigger####';
26205
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
26206
BEGIN
26207
SET new.f_int1 = @my_max1 + @counter,
26208
new.f_int2 = @my_min2 - @counter,
26209
new.f_charbig = '####updated per insert trigger####';
26210
SET @counter = @counter + 1;
26211
END|
26212
SET @counter = 1;
26213
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
26214
INSERT INTO t1 (f_char1, f_char2, f_charbig)
26215
SELECT CAST(f_int1 AS CHAR),
26216
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
26217
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
26218
ORDER BY f_int1;
26219
DROP TRIGGER trg_3;
26220
	
26221
# check trigger-12 success: 	1
26222
DELETE FROM t1
26223
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
26224
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
26225
AND f_charbig = '####updated per insert trigger####';
26226
ANALYZE  TABLE t1;
26227
Table	Op	Msg_type	Msg_text
26228
test.t1	analyze	note	The storage engine for the table doesn't support analyze
26229
CHECK    TABLE t1 EXTENDED;
26230
Table	Op	Msg_type	Msg_text
26231
test.t1	check	note	The storage engine for the table doesn't support check
26232
CHECKSUM TABLE t1 EXTENDED;
26233
Table	Checksum
26234
test.t1	<some_value>
26235
OPTIMIZE TABLE t1;
26236
Table	Op	Msg_type	Msg_text
26237
test.t1	optimize	note	The storage engine for the table doesn't support optimize
26238
# check layout success:    1
26239
REPAIR   TABLE t1 EXTENDED;
26240
Table	Op	Msg_type	Msg_text
26241
test.t1	repair	note	The storage engine for the table doesn't support repair
26242
# check layout success:    1
26243
TRUNCATE t1;
26244
	
26245
# check TRUNCATE success: 	1
26246
# check layout success:    1
26247
# End usability test (inc/partition_check.inc)
26248
DROP TABLE t1;
26249
CREATE TABLE t1 (
26250
f_int1 INTEGER,
26251
f_int2 INTEGER,
26252
f_char1 CHAR(20),
26253
f_char2 CHAR(20),
26254
f_charbig VARCHAR(1000)
26255
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
26256
)
26257
PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int2 + 1)
26258
(PARTITION part1 VALUES IN (0)
26259
(SUBPARTITION sp11, SUBPARTITION sp12),
26260
PARTITION part2 VALUES IN (1)
26261
(SUBPARTITION sp21, SUBPARTITION sp22),
26262
PARTITION part3 VALUES IN (2)
26263
(SUBPARTITION sp31, SUBPARTITION sp32),
26264
PARTITION part4 VALUES IN (NULL)
26265
(SUBPARTITION sp41, SUBPARTITION sp42));
26266
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
26267
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
26268
# Start usability test (inc/partition_check.inc)
26269
create_command
26270
SHOW CREATE TABLE t1;
26271
Table	Create Table
26272
t1	CREATE TABLE `t1` (
26273
  `f_int1` int(11) NOT NULL DEFAULT '0',
26274
  `f_int2` int(11) NOT NULL DEFAULT '0',
26275
  `f_char1` char(20) DEFAULT NULL,
26276
  `f_char2` char(20) DEFAULT NULL,
26277
  `f_charbig` varchar(1000) DEFAULT NULL,
26278
  PRIMARY KEY (`f_int1`,`f_int2`),
26279
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
26280
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,3))) SUBPARTITION BY HASH (f_int2 + 1) (PARTITION part1 VALUES IN (0) (SUBPARTITION sp11 ENGINE = InnoDB, SUBPARTITION sp12 ENGINE = InnoDB), PARTITION part2 VALUES IN (1) (SUBPARTITION sp21 ENGINE = InnoDB, SUBPARTITION sp22 ENGINE = InnoDB), PARTITION part3 VALUES IN (2) (SUBPARTITION sp31 ENGINE = InnoDB, SUBPARTITION sp32 ENGINE = InnoDB), PARTITION part4 VALUES IN (NULL) (SUBPARTITION sp41 ENGINE = InnoDB, SUBPARTITION sp42 ENGINE = InnoDB)) */
26281
26282
unified filelist
26283
$MYSQLTEST_VARDIR/master-data/test/t1.frm
26284
$MYSQLTEST_VARDIR/master-data/test/t1.par
26285
26286
# check prerequisites-1 success:    1
26287
# check COUNT(*) success:    1
26288
# check MIN/MAX(f_int1) success:    1
26289
# check MIN/MAX(f_int2) success:    1
26290
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26291
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
26292
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
26293
WHERE f_int1 IN (2,3);
26294
ERROR 23000: Can't write; duplicate key in table 't1'
26295
# check prerequisites-3 success:    1
26296
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
26297
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26298
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
26299
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
26300
WHERE f_int1 IN (2,3);
26301
DELETE FROM t1 WHERE f_charbig = 'delete me';
26302
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26303
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
26304
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
26305
WHERE f_int1 IN (2,3);
26306
DELETE FROM t1 WHERE f_charbig = 'delete me';
26307
# check read via f_int1 success: 1
26308
# check read via f_int2 success: 1
26309
	
26310
# check multiple-1 success: 	1
26311
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
26312
	
26313
# check multiple-2 success: 	1
26314
INSERT INTO t1 SELECT * FROM t0_template
26315
WHERE MOD(f_int1,3) = 0;
26316
	
26317
# check multiple-3 success: 	1
26318
UPDATE t1 SET f_int1 = f_int1 + @max_row
26319
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
26320
AND @max_row_div2 + @max_row_div4;
26321
	
26322
# check multiple-4 success: 	1
26323
DELETE FROM t1
26324
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
26325
AND @max_row_div2 + @max_row_div4 + @max_row;
26326
	
26327
# check multiple-5 success: 	1
26328
SELECT COUNT(*) INTO @try_count FROM t0_template
26329
WHERE MOD(f_int1,3) = 0
26330
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
26331
SELECT COUNT(*) INTO @clash_count
26332
FROM t1 INNER JOIN t0_template USING(f_int1)
26333
WHERE MOD(f_int1,3) = 0
26334
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
26335
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
26336
INSERT INTO t1
26337
SET f_int1 = @cur_value , f_int2 = @cur_value,
26338
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
26339
f_charbig = '#SINGLE#';
26340
	
26341
# check single-1 success: 	1
26342
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
26343
INSERT INTO t1
26344
SET f_int1 = @cur_value , f_int2 = @cur_value,
26345
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
26346
f_charbig = '#SINGLE#';
26347
	
26348
# check single-2 success: 	1
26349
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
26350
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
26351
UPDATE t1 SET f_int1 = @cur_value2
26352
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
26353
	
26354
# check single-3 success: 	1
26355
SET @cur_value1= -1;
26356
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
26357
UPDATE t1 SET f_int1 = @cur_value1
26358
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
26359
	
26360
# check single-4 success: 	1
26361
SELECT MAX(f_int1) INTO @cur_value FROM t1;
26362
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
26363
	
26364
# check single-5 success: 	1
26365
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
26366
	
26367
# check single-6 success: 	1
26368
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
26369
	
26370
# check single-7 success: 	1
26371
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
26372
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
26373
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
26374
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
26375
f_charbig = '#NULL#';
26376
INSERT INTO t1
26377
SET f_int1 = NULL , f_int2 = -@max_row,
26378
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
26379
f_charbig = '#NULL#';
26380
ERROR 23000: Column 'f_int1' cannot be null
26381
# check null success:    1
26382
DELETE FROM t1
26383
WHERE f_int1 = 0 AND f_int2 = 0
26384
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
26385
AND f_charbig = '#NULL#';
26386
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26387
SELECT f_int1, f_int1, '', '', 'was inserted'
26388
   FROM t0_template source_tab
26389
WHERE MOD(f_int1,3) = 0
26390
AND f_int1 BETWEEN @max_row_div2 AND @max_row
26391
ON DUPLICATE KEY
26392
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
26393
f_int2 = 2 * @max_row + source_tab.f_int1,
26394
f_charbig = 'was updated';
26395
	
26396
# check unique-1-a success: 	1
26397
	
26398
# check unique-1-b success: 	1
26399
DELETE FROM t1 WHERE f_charbig = 'was inserted';
26400
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26401
f_int2 = CAST(f_char1 AS SIGNED INT),
26402
f_charbig = CONCAT('===',f_char1,'===')
26403
WHERE f_charbig = 'was updated';
26404
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26405
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
26406
   FROM t0_template source_tab
26407
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
26408
	
26409
# check replace success: 	1
26410
DELETE FROM t1
26411
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
26412
DELETE FROM t1
26413
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
26414
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
26415
UPDATE t1 SET f_int2 = f_int1,
26416
f_char1 = CAST(f_int1 AS CHAR),
26417
f_char2 = CAST(f_int1 AS CHAR),
26418
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
26419
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
26420
SET AUTOCOMMIT= 0;
26421
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26422
SELECT f_int1, f_int1, '', '', 'was inserted'
26423
FROM t0_template source_tab
26424
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
26425
	
26426
# check transactions-1 success: 	1
26427
COMMIT WORK;
26428
	
26429
# check transactions-2 success: 	1
26430
ROLLBACK WORK;
26431
	
26432
# check transactions-3 success: 	1
26433
DELETE FROM t1 WHERE f_charbig = 'was inserted';
26434
COMMIT WORK;
26435
ROLLBACK WORK;
26436
	
26437
# check transactions-4 success: 	1
26438
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26439
SELECT f_int1, f_int1, '', '', 'was inserted'
26440
FROM t0_template source_tab
26441
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
26442
	
26443
# check transactions-5 success: 	1
26444
ROLLBACK WORK;
26445
	
26446
# check transactions-6 success: 	1
26447
# INFO: Storage engine used for t1 seems to be transactional.
26448
COMMIT;
26449
	
26450
# check transactions-7 success: 	1
26451
DELETE FROM t1 WHERE f_charbig = 'was inserted';
26452
COMMIT WORK;
26453
SET @@session.sql_mode = 'traditional';
26454
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
26455
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26456
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
26457
'', '', 'was inserted' FROM t0_template
26458
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
26459
ERROR 22012: Division by 0
26460
COMMIT;
26461
	
26462
# check transactions-8 success: 	1
26463
# INFO: Storage engine used for t1 seems to be able to revert
26464
#       changes made by the failing statement.
26465
SET @@session.sql_mode = '';
26466
SET AUTOCOMMIT= 1;
26467
DELETE FROM t1 WHERE f_charbig = 'was inserted';
26468
COMMIT WORK;
26469
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
26470
	
26471
# check special-1 success: 	1
26472
UPDATE t1 SET f_charbig = '';
26473
	
26474
# check special-2 success: 	1
26475
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
26476
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
26477
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
26478
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26479
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26480
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26481
'just inserted' FROM t0_template
26482
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26483
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
26484
BEGIN
26485
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26486
f_charbig = 'updated by trigger'
26487
      WHERE f_int1 = new.f_int1;
26488
END|
26489
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26490
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
26491
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26492
	
26493
# check trigger-1 success: 	1
26494
DROP TRIGGER trg_1;
26495
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26496
f_int2 = CAST(f_char1 AS SIGNED INT),
26497
f_charbig = 'just inserted'
26498
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26499
DELETE FROM t0_aux
26500
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26501
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26502
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26503
'just inserted' FROM t0_template
26504
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26505
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
26506
BEGIN
26507
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26508
f_charbig = 'updated by trigger'
26509
      WHERE f_int1 = new.f_int1;
26510
END|
26511
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26512
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
26513
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26514
	
26515
# check trigger-2 success: 	1
26516
DROP TRIGGER trg_1;
26517
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26518
f_int2 = CAST(f_char1 AS SIGNED INT),
26519
f_charbig = 'just inserted'
26520
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26521
DELETE FROM t0_aux
26522
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26523
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26524
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26525
'just inserted' FROM t0_template
26526
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26527
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
26528
BEGIN
26529
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26530
f_charbig = 'updated by trigger'
26531
      WHERE f_int1 = new.f_int1;
26532
END|
26533
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
26534
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
26535
	
26536
# check trigger-3 success: 	1
26537
DROP TRIGGER trg_1;
26538
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26539
f_int2 = CAST(f_char1 AS SIGNED INT),
26540
f_charbig = 'just inserted'
26541
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26542
DELETE FROM t0_aux
26543
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26544
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26545
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26546
'just inserted' FROM t0_template
26547
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26548
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
26549
BEGIN
26550
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26551
f_charbig = 'updated by trigger'
26552
      WHERE f_int1 = - old.f_int1;
26553
END|
26554
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
26555
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
26556
	
26557
# check trigger-4 success: 	1
26558
DROP TRIGGER trg_1;
26559
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26560
f_int2 = CAST(f_char1 AS SIGNED INT),
26561
f_charbig = 'just inserted'
26562
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26563
DELETE FROM t0_aux
26564
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26565
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26566
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26567
'just inserted' FROM t0_template
26568
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26569
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
26570
BEGIN
26571
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26572
f_charbig = 'updated by trigger'
26573
      WHERE f_int1 = new.f_int1;
26574
END|
26575
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
26576
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
26577
	
26578
# check trigger-5 success: 	1
26579
DROP TRIGGER trg_1;
26580
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26581
f_int2 = CAST(f_char1 AS SIGNED INT),
26582
f_charbig = 'just inserted'
26583
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26584
DELETE FROM t0_aux
26585
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26586
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26587
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26588
'just inserted' FROM t0_template
26589
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26590
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
26591
BEGIN
26592
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26593
f_charbig = 'updated by trigger'
26594
      WHERE f_int1 = - old.f_int1;
26595
END|
26596
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
26597
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
26598
	
26599
# check trigger-6 success: 	1
26600
DROP TRIGGER trg_1;
26601
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26602
f_int2 = CAST(f_char1 AS SIGNED INT),
26603
f_charbig = 'just inserted'
26604
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26605
DELETE FROM t0_aux
26606
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26607
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26608
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26609
'just inserted' FROM t0_template
26610
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26611
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
26612
BEGIN
26613
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26614
f_charbig = 'updated by trigger'
26615
      WHERE f_int1 = - old.f_int1;
26616
END|
26617
DELETE FROM t0_aux
26618
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
26619
	
26620
# check trigger-7 success: 	1
26621
DROP TRIGGER trg_1;
26622
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26623
f_int2 = CAST(f_char1 AS SIGNED INT),
26624
f_charbig = 'just inserted'
26625
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26626
DELETE FROM t0_aux
26627
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26628
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26629
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26630
'just inserted' FROM t0_template
26631
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26632
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
26633
BEGIN
26634
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26635
f_charbig = 'updated by trigger'
26636
      WHERE f_int1 = - old.f_int1;
26637
END|
26638
DELETE FROM t0_aux
26639
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
26640
	
26641
# check trigger-8 success: 	1
26642
DROP TRIGGER trg_1;
26643
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26644
f_int2 = CAST(f_char1 AS SIGNED INT),
26645
f_charbig = 'just inserted'
26646
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26647
DELETE FROM t0_aux
26648
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26649
DELETE FROM t1
26650
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26651
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
26652
BEGIN
26653
SET new.f_int1 = old.f_int1 + @max_row,
26654
new.f_int2 = old.f_int2 - @max_row,
26655
new.f_charbig = '####updated per update trigger####';
26656
END|
26657
UPDATE t1
26658
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
26659
f_charbig = '####updated per update statement itself####';
26660
	
26661
# check trigger-9 success: 	1
26662
DROP TRIGGER trg_2;
26663
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26664
f_int2 = CAST(f_char1 AS SIGNED INT),
26665
f_charbig = CONCAT('===',f_char1,'===');
26666
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
26667
BEGIN
26668
SET new.f_int1 = new.f_int1 + @max_row,
26669
new.f_int2 = new.f_int2 - @max_row,
26670
new.f_charbig = '####updated per update trigger####';
26671
END|
26672
UPDATE t1
26673
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
26674
f_charbig = '####updated per update statement itself####';
26675
	
26676
# check trigger-10 success: 	1
26677
DROP TRIGGER trg_2;
26678
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26679
f_int2 = CAST(f_char1 AS SIGNED INT),
26680
f_charbig = CONCAT('===',f_char1,'===');
26681
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
26682
BEGIN
26683
SET new.f_int1 = @my_max1 + @counter,
26684
new.f_int2 = @my_min2 - @counter,
26685
new.f_charbig = '####updated per insert trigger####';
26686
SET @counter = @counter + 1;
26687
END|
26688
SET @counter = 1;
26689
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
26690
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26691
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
26692
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
26693
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
26694
ORDER BY f_int1;
26695
DROP TRIGGER trg_3;
26696
	
26697
# check trigger-11 success: 	1
26698
DELETE FROM t1
26699
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
26700
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
26701
AND f_charbig = '####updated per insert trigger####';
26702
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
26703
BEGIN
26704
SET new.f_int1 = @my_max1 + @counter,
26705
new.f_int2 = @my_min2 - @counter,
26706
new.f_charbig = '####updated per insert trigger####';
26707
SET @counter = @counter + 1;
26708
END|
26709
SET @counter = 1;
26710
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
26711
INSERT INTO t1 (f_char1, f_char2, f_charbig)
26712
SELECT CAST(f_int1 AS CHAR),
26713
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
26714
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
26715
ORDER BY f_int1;
26716
DROP TRIGGER trg_3;
26717
	
26718
# check trigger-12 success: 	1
26719
DELETE FROM t1
26720
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
26721
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
26722
AND f_charbig = '####updated per insert trigger####';
26723
ANALYZE  TABLE t1;
26724
Table	Op	Msg_type	Msg_text
26725
test.t1	analyze	note	The storage engine for the table doesn't support analyze
26726
CHECK    TABLE t1 EXTENDED;
26727
Table	Op	Msg_type	Msg_text
26728
test.t1	check	note	The storage engine for the table doesn't support check
26729
CHECKSUM TABLE t1 EXTENDED;
26730
Table	Checksum
26731
test.t1	<some_value>
26732
OPTIMIZE TABLE t1;
26733
Table	Op	Msg_type	Msg_text
26734
test.t1	optimize	note	The storage engine for the table doesn't support optimize
26735
# check layout success:    1
26736
REPAIR   TABLE t1 EXTENDED;
26737
Table	Op	Msg_type	Msg_text
26738
test.t1	repair	note	The storage engine for the table doesn't support repair
26739
# check layout success:    1
26740
TRUNCATE t1;
26741
	
26742
# check TRUNCATE success: 	1
26743
# check layout success:    1
26744
# End usability test (inc/partition_check.inc)
26745
DROP TABLE t1;
26746
CREATE TABLE t1 (
26747
f_int1 INTEGER,
26748
f_int2 INTEGER,
26749
f_char1 CHAR(20),
26750
f_char2 CHAR(20),
26751
f_charbig VARCHAR(1000)
26752
, UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2)
26753
)
26754
PARTITION BY LIST(ABS(MOD(f_int1,2)))
26755
SUBPARTITION BY KEY(f_int2)  SUBPARTITIONS 3
26756
(PARTITION part1 VALUES IN (0),
26757
PARTITION part2 VALUES IN (1),
26758
PARTITION part3 VALUES IN (NULL));
26759
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
26760
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
26761
# Start usability test (inc/partition_check.inc)
26762
create_command
26763
SHOW CREATE TABLE t1;
26764
Table	Create Table
26765
t1	CREATE TABLE `t1` (
26766
  `f_int1` int(11) NOT NULL DEFAULT '0',
26767
  `f_int2` int(11) NOT NULL DEFAULT '0',
26768
  `f_char1` char(20) DEFAULT NULL,
26769
  `f_char2` char(20) DEFAULT NULL,
26770
  `f_charbig` varchar(1000) DEFAULT NULL,
26771
  PRIMARY KEY (`f_int1`,`f_int2`),
26772
  UNIQUE KEY `uidx1` (`f_int2`,`f_int1`)
26773
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
26774
26775
unified filelist
26776
$MYSQLTEST_VARDIR/master-data/test/t1.frm
26777
$MYSQLTEST_VARDIR/master-data/test/t1.par
26778
26779
# check prerequisites-1 success:    1
26780
# check COUNT(*) success:    1
26781
# check MIN/MAX(f_int1) success:    1
26782
# check MIN/MAX(f_int2) success:    1
26783
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26784
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
26785
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
26786
WHERE f_int1 IN (2,3);
26787
ERROR 23000: Can't write; duplicate key in table 't1'
26788
# check prerequisites-3 success:    1
26789
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
26790
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26791
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
26792
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
26793
WHERE f_int1 IN (2,3);
26794
DELETE FROM t1 WHERE f_charbig = 'delete me';
26795
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26796
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
26797
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
26798
WHERE f_int1 IN (2,3);
26799
DELETE FROM t1 WHERE f_charbig = 'delete me';
26800
# check read via f_int1 success: 1
26801
# check read via f_int2 success: 1
26802
	
26803
# check multiple-1 success: 	1
26804
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
26805
	
26806
# check multiple-2 success: 	1
26807
INSERT INTO t1 SELECT * FROM t0_template
26808
WHERE MOD(f_int1,3) = 0;
26809
	
26810
# check multiple-3 success: 	1
26811
UPDATE t1 SET f_int1 = f_int1 + @max_row
26812
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
26813
AND @max_row_div2 + @max_row_div4;
26814
	
26815
# check multiple-4 success: 	1
26816
DELETE FROM t1
26817
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
26818
AND @max_row_div2 + @max_row_div4 + @max_row;
26819
	
26820
# check multiple-5 success: 	1
26821
SELECT COUNT(*) INTO @try_count FROM t0_template
26822
WHERE MOD(f_int1,3) = 0
26823
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
26824
SELECT COUNT(*) INTO @clash_count
26825
FROM t1 INNER JOIN t0_template USING(f_int1)
26826
WHERE MOD(f_int1,3) = 0
26827
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
26828
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
26829
INSERT INTO t1
26830
SET f_int1 = @cur_value , f_int2 = @cur_value,
26831
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
26832
f_charbig = '#SINGLE#';
26833
	
26834
# check single-1 success: 	1
26835
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
26836
INSERT INTO t1
26837
SET f_int1 = @cur_value , f_int2 = @cur_value,
26838
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
26839
f_charbig = '#SINGLE#';
26840
	
26841
# check single-2 success: 	1
26842
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
26843
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
26844
UPDATE t1 SET f_int1 = @cur_value2
26845
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
26846
	
26847
# check single-3 success: 	1
26848
SET @cur_value1= -1;
26849
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
26850
UPDATE t1 SET f_int1 = @cur_value1
26851
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
26852
	
26853
# check single-4 success: 	1
26854
SELECT MAX(f_int1) INTO @cur_value FROM t1;
26855
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
26856
	
26857
# check single-5 success: 	1
26858
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
26859
	
26860
# check single-6 success: 	1
26861
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
26862
	
26863
# check single-7 success: 	1
26864
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
26865
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
26866
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
26867
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
26868
f_charbig = '#NULL#';
26869
INSERT INTO t1
26870
SET f_int1 = NULL , f_int2 = -@max_row,
26871
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
26872
f_charbig = '#NULL#';
26873
ERROR 23000: Column 'f_int1' cannot be null
26874
# check null success:    1
26875
DELETE FROM t1
26876
WHERE f_int1 = 0 AND f_int2 = 0
26877
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
26878
AND f_charbig = '#NULL#';
26879
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26880
SELECT f_int1, f_int1, '', '', 'was inserted'
26881
   FROM t0_template source_tab
26882
WHERE MOD(f_int1,3) = 0
26883
AND f_int1 BETWEEN @max_row_div2 AND @max_row
26884
ON DUPLICATE KEY
26885
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
26886
f_int2 = 2 * @max_row + source_tab.f_int1,
26887
f_charbig = 'was updated';
26888
	
26889
# check unique-1-a success: 	1
26890
	
26891
# check unique-1-b success: 	1
26892
DELETE FROM t1 WHERE f_charbig = 'was inserted';
26893
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26894
f_int2 = CAST(f_char1 AS SIGNED INT),
26895
f_charbig = CONCAT('===',f_char1,'===')
26896
WHERE f_charbig = 'was updated';
26897
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26898
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
26899
   FROM t0_template source_tab
26900
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
26901
	
26902
# check replace success: 	1
26903
DELETE FROM t1
26904
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
26905
DELETE FROM t1
26906
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
26907
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
26908
UPDATE t1 SET f_int2 = f_int1,
26909
f_char1 = CAST(f_int1 AS CHAR),
26910
f_char2 = CAST(f_int1 AS CHAR),
26911
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
26912
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
26913
SET AUTOCOMMIT= 0;
26914
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26915
SELECT f_int1, f_int1, '', '', 'was inserted'
26916
FROM t0_template source_tab
26917
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
26918
	
26919
# check transactions-1 success: 	1
26920
COMMIT WORK;
26921
	
26922
# check transactions-2 success: 	1
26923
ROLLBACK WORK;
26924
	
26925
# check transactions-3 success: 	1
26926
DELETE FROM t1 WHERE f_charbig = 'was inserted';
26927
COMMIT WORK;
26928
ROLLBACK WORK;
26929
	
26930
# check transactions-4 success: 	1
26931
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26932
SELECT f_int1, f_int1, '', '', 'was inserted'
26933
FROM t0_template source_tab
26934
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
26935
	
26936
# check transactions-5 success: 	1
26937
ROLLBACK WORK;
26938
	
26939
# check transactions-6 success: 	1
26940
# INFO: Storage engine used for t1 seems to be transactional.
26941
COMMIT;
26942
	
26943
# check transactions-7 success: 	1
26944
DELETE FROM t1 WHERE f_charbig = 'was inserted';
26945
COMMIT WORK;
26946
SET @@session.sql_mode = 'traditional';
26947
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
26948
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
26949
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
26950
'', '', 'was inserted' FROM t0_template
26951
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
26952
ERROR 22012: Division by 0
26953
COMMIT;
26954
	
26955
# check transactions-8 success: 	1
26956
# INFO: Storage engine used for t1 seems to be able to revert
26957
#       changes made by the failing statement.
26958
SET @@session.sql_mode = '';
26959
SET AUTOCOMMIT= 1;
26960
DELETE FROM t1 WHERE f_charbig = 'was inserted';
26961
COMMIT WORK;
26962
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
26963
	
26964
# check special-1 success: 	1
26965
UPDATE t1 SET f_charbig = '';
26966
	
26967
# check special-2 success: 	1
26968
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
26969
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
26970
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
26971
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26972
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26973
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26974
'just inserted' FROM t0_template
26975
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26976
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
26977
BEGIN
26978
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
26979
f_charbig = 'updated by trigger'
26980
      WHERE f_int1 = new.f_int1;
26981
END|
26982
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26983
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
26984
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26985
	
26986
# check trigger-1 success: 	1
26987
DROP TRIGGER trg_1;
26988
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
26989
f_int2 = CAST(f_char1 AS SIGNED INT),
26990
f_charbig = 'just inserted'
26991
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
26992
DELETE FROM t0_aux
26993
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26994
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
26995
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
26996
'just inserted' FROM t0_template
26997
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
26998
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
26999
BEGIN
27000
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27001
f_charbig = 'updated by trigger'
27002
      WHERE f_int1 = new.f_int1;
27003
END|
27004
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27005
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
27006
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27007
	
27008
# check trigger-2 success: 	1
27009
DROP TRIGGER trg_1;
27010
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27011
f_int2 = CAST(f_char1 AS SIGNED INT),
27012
f_charbig = 'just inserted'
27013
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
27014
DELETE FROM t0_aux
27015
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27016
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27017
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
27018
'just inserted' FROM t0_template
27019
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27020
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
27021
BEGIN
27022
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27023
f_charbig = 'updated by trigger'
27024
      WHERE f_int1 = new.f_int1;
27025
END|
27026
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
27027
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
27028
	
27029
# check trigger-3 success: 	1
27030
DROP TRIGGER trg_1;
27031
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27032
f_int2 = CAST(f_char1 AS SIGNED INT),
27033
f_charbig = 'just inserted'
27034
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
27035
DELETE FROM t0_aux
27036
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27037
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27038
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
27039
'just inserted' FROM t0_template
27040
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27041
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
27042
BEGIN
27043
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27044
f_charbig = 'updated by trigger'
27045
      WHERE f_int1 = - old.f_int1;
27046
END|
27047
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
27048
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
27049
	
27050
# check trigger-4 success: 	1
27051
DROP TRIGGER trg_1;
27052
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27053
f_int2 = CAST(f_char1 AS SIGNED INT),
27054
f_charbig = 'just inserted'
27055
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
27056
DELETE FROM t0_aux
27057
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27058
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27059
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
27060
'just inserted' FROM t0_template
27061
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27062
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
27063
BEGIN
27064
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27065
f_charbig = 'updated by trigger'
27066
      WHERE f_int1 = new.f_int1;
27067
END|
27068
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
27069
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
27070
	
27071
# check trigger-5 success: 	1
27072
DROP TRIGGER trg_1;
27073
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27074
f_int2 = CAST(f_char1 AS SIGNED INT),
27075
f_charbig = 'just inserted'
27076
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
27077
DELETE FROM t0_aux
27078
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27079
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27080
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
27081
'just inserted' FROM t0_template
27082
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27083
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
27084
BEGIN
27085
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27086
f_charbig = 'updated by trigger'
27087
      WHERE f_int1 = - old.f_int1;
27088
END|
27089
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
27090
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
27091
	
27092
# check trigger-6 success: 	1
27093
DROP TRIGGER trg_1;
27094
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27095
f_int2 = CAST(f_char1 AS SIGNED INT),
27096
f_charbig = 'just inserted'
27097
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
27098
DELETE FROM t0_aux
27099
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27100
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27101
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
27102
'just inserted' FROM t0_template
27103
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27104
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
27105
BEGIN
27106
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27107
f_charbig = 'updated by trigger'
27108
      WHERE f_int1 = - old.f_int1;
27109
END|
27110
DELETE FROM t0_aux
27111
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
27112
	
27113
# check trigger-7 success: 	1
27114
DROP TRIGGER trg_1;
27115
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27116
f_int2 = CAST(f_char1 AS SIGNED INT),
27117
f_charbig = 'just inserted'
27118
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
27119
DELETE FROM t0_aux
27120
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27121
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27122
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
27123
'just inserted' FROM t0_template
27124
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27125
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
27126
BEGIN
27127
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27128
f_charbig = 'updated by trigger'
27129
      WHERE f_int1 = - old.f_int1;
27130
END|
27131
DELETE FROM t0_aux
27132
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
27133
	
27134
# check trigger-8 success: 	1
27135
DROP TRIGGER trg_1;
27136
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27137
f_int2 = CAST(f_char1 AS SIGNED INT),
27138
f_charbig = 'just inserted'
27139
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
27140
DELETE FROM t0_aux
27141
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27142
DELETE FROM t1
27143
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27144
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
27145
BEGIN
27146
SET new.f_int1 = old.f_int1 + @max_row,
27147
new.f_int2 = old.f_int2 - @max_row,
27148
new.f_charbig = '####updated per update trigger####';
27149
END|
27150
UPDATE t1
27151
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
27152
f_charbig = '####updated per update statement itself####';
27153
	
27154
# check trigger-9 success: 	1
27155
DROP TRIGGER trg_2;
27156
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27157
f_int2 = CAST(f_char1 AS SIGNED INT),
27158
f_charbig = CONCAT('===',f_char1,'===');
27159
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
27160
BEGIN
27161
SET new.f_int1 = new.f_int1 + @max_row,
27162
new.f_int2 = new.f_int2 - @max_row,
27163
new.f_charbig = '####updated per update trigger####';
27164
END|
27165
UPDATE t1
27166
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
27167
f_charbig = '####updated per update statement itself####';
27168
	
27169
# check trigger-10 success: 	1
27170
DROP TRIGGER trg_2;
27171
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27172
f_int2 = CAST(f_char1 AS SIGNED INT),
27173
f_charbig = CONCAT('===',f_char1,'===');
27174
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
27175
BEGIN
27176
SET new.f_int1 = @my_max1 + @counter,
27177
new.f_int2 = @my_min2 - @counter,
27178
new.f_charbig = '####updated per insert trigger####';
27179
SET @counter = @counter + 1;
27180
END|
27181
SET @counter = 1;
27182
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
27183
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27184
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
27185
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
27186
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
27187
ORDER BY f_int1;
27188
DROP TRIGGER trg_3;
27189
	
27190
# check trigger-11 success: 	1
27191
DELETE FROM t1
27192
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
27193
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
27194
AND f_charbig = '####updated per insert trigger####';
27195
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
27196
BEGIN
27197
SET new.f_int1 = @my_max1 + @counter,
27198
new.f_int2 = @my_min2 - @counter,
27199
new.f_charbig = '####updated per insert trigger####';
27200
SET @counter = @counter + 1;
27201
END|
27202
SET @counter = 1;
27203
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
27204
INSERT INTO t1 (f_char1, f_char2, f_charbig)
27205
SELECT CAST(f_int1 AS CHAR),
27206
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
27207
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
27208
ORDER BY f_int1;
27209
DROP TRIGGER trg_3;
27210
	
27211
# check trigger-12 success: 	1
27212
DELETE FROM t1
27213
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
27214
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
27215
AND f_charbig = '####updated per insert trigger####';
27216
ANALYZE  TABLE t1;
27217
Table	Op	Msg_type	Msg_text
27218
test.t1	analyze	note	The storage engine for the table doesn't support analyze
27219
CHECK    TABLE t1 EXTENDED;
27220
Table	Op	Msg_type	Msg_text
27221
test.t1	check	note	The storage engine for the table doesn't support check
27222
CHECKSUM TABLE t1 EXTENDED;
27223
Table	Checksum
27224
test.t1	<some_value>
27225
OPTIMIZE TABLE t1;
27226
Table	Op	Msg_type	Msg_text
27227
test.t1	optimize	note	The storage engine for the table doesn't support optimize
27228
# check layout success:    1
27229
REPAIR   TABLE t1 EXTENDED;
27230
Table	Op	Msg_type	Msg_text
27231
test.t1	repair	note	The storage engine for the table doesn't support repair
27232
# check layout success:    1
27233
TRUNCATE t1;
27234
	
27235
# check TRUNCATE success: 	1
27236
# check layout success:    1
27237
# End usability test (inc/partition_check.inc)
27238
DROP TABLE t1;
27239
DROP TABLE IF EXISTS t1;
27240
CREATE TABLE t1 (
27241
f_int1 INTEGER,
27242
f_int2 INTEGER,
27243
f_char1 CHAR(20),
27244
f_char2 CHAR(20),
27245
f_charbig VARCHAR(1000)
27246
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
27247
)
27248
PARTITION BY HASH(f_int1 + f_int2) PARTITIONS 2;
27249
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
27250
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
27251
# Start usability test (inc/partition_check.inc)
27252
create_command
27253
SHOW CREATE TABLE t1;
27254
Table	Create Table
27255
t1	CREATE TABLE `t1` (
27256
  `f_int1` int(11) DEFAULT NULL,
27257
  `f_int2` int(11) DEFAULT NULL,
27258
  `f_char1` char(20) DEFAULT NULL,
27259
  `f_char2` char(20) DEFAULT NULL,
27260
  `f_charbig` varchar(1000) DEFAULT NULL,
27261
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
27262
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
27263
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (f_int1 + f_int2) PARTITIONS 2  */
27264
27265
unified filelist
27266
$MYSQLTEST_VARDIR/master-data/test/t1.frm
27267
$MYSQLTEST_VARDIR/master-data/test/t1.par
27268
27269
# check prerequisites-1 success:    1
27270
# check COUNT(*) success:    1
27271
# check MIN/MAX(f_int1) success:    1
27272
# check MIN/MAX(f_int2) success:    1
27273
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27274
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
27275
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
27276
WHERE f_int1 IN (2,3);
27277
ERROR 23000: Can't write; duplicate key in table 't1'
27278
# check prerequisites-3 success:    1
27279
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
27280
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27281
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
27282
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
27283
WHERE f_int1 IN (2,3);
27284
DELETE FROM t1 WHERE f_charbig = 'delete me';
27285
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27286
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
27287
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
27288
WHERE f_int1 IN (2,3);
27289
DELETE FROM t1 WHERE f_charbig = 'delete me';
27290
# check read via f_int1 success: 1
27291
# check read via f_int2 success: 1
27292
	
27293
# check multiple-1 success: 	1
27294
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
27295
	
27296
# check multiple-2 success: 	1
27297
INSERT INTO t1 SELECT * FROM t0_template
27298
WHERE MOD(f_int1,3) = 0;
27299
	
27300
# check multiple-3 success: 	1
27301
UPDATE t1 SET f_int1 = f_int1 + @max_row
27302
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
27303
AND @max_row_div2 + @max_row_div4;
27304
	
27305
# check multiple-4 success: 	1
27306
DELETE FROM t1
27307
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
27308
AND @max_row_div2 + @max_row_div4 + @max_row;
27309
	
27310
# check multiple-5 success: 	1
27311
SELECT COUNT(*) INTO @try_count FROM t0_template
27312
WHERE MOD(f_int1,3) = 0
27313
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
27314
SELECT COUNT(*) INTO @clash_count
27315
FROM t1 INNER JOIN t0_template USING(f_int1)
27316
WHERE MOD(f_int1,3) = 0
27317
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
27318
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
27319
INSERT INTO t1
27320
SET f_int1 = @cur_value , f_int2 = @cur_value,
27321
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
27322
f_charbig = '#SINGLE#';
27323
	
27324
# check single-1 success: 	1
27325
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
27326
INSERT INTO t1
27327
SET f_int1 = @cur_value , f_int2 = @cur_value,
27328
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
27329
f_charbig = '#SINGLE#';
27330
	
27331
# check single-2 success: 	1
27332
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
27333
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
27334
UPDATE t1 SET f_int1 = @cur_value2
27335
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
27336
	
27337
# check single-3 success: 	1
27338
SET @cur_value1= -1;
27339
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
27340
UPDATE t1 SET f_int1 = @cur_value1
27341
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
27342
	
27343
# check single-4 success: 	1
27344
SELECT MAX(f_int1) INTO @cur_value FROM t1;
27345
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
27346
	
27347
# check single-5 success: 	1
27348
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
27349
	
27350
# check single-6 success: 	1
27351
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
27352
	
27353
# check single-7 success: 	1
27354
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
27355
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
27356
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
27357
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
27358
f_charbig = '#NULL#';
27359
INSERT INTO t1
27360
SET f_int1 = NULL , f_int2 = -@max_row,
27361
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
27362
f_charbig = '#NULL#';
27363
# check null success:    1
27364
	
27365
# check null-1 success: 	1
27366
UPDATE t1 SET f_int1 = -@max_row
27367
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
27368
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
27369
	
27370
# check null-2 success: 	1
27371
UPDATE t1 SET f_int1 = NULL
27372
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
27373
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
27374
	
27375
# check null-3 success: 	1
27376
DELETE FROM t1
27377
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
27378
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
27379
	
27380
# check null-4 success: 	1
27381
DELETE FROM t1
27382
WHERE f_int1 = 0 AND f_int2 = 0
27383
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
27384
AND f_charbig = '#NULL#';
27385
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27386
SELECT f_int1, f_int1, '', '', 'was inserted'
27387
   FROM t0_template source_tab
27388
WHERE MOD(f_int1,3) = 0
27389
AND f_int1 BETWEEN @max_row_div2 AND @max_row
27390
ON DUPLICATE KEY
27391
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
27392
f_int2 = 2 * @max_row + source_tab.f_int1,
27393
f_charbig = 'was updated';
27394
	
27395
# check unique-1-a success: 	1
27396
	
27397
# check unique-1-b success: 	1
27398
DELETE FROM t1 WHERE f_charbig = 'was inserted';
27399
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27400
f_int2 = CAST(f_char1 AS SIGNED INT),
27401
f_charbig = CONCAT('===',f_char1,'===')
27402
WHERE f_charbig = 'was updated';
27403
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27404
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
27405
   FROM t0_template source_tab
27406
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
27407
	
27408
# check replace success: 	1
27409
DELETE FROM t1
27410
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
27411
DELETE FROM t1
27412
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
27413
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
27414
UPDATE t1 SET f_int2 = f_int1,
27415
f_char1 = CAST(f_int1 AS CHAR),
27416
f_char2 = CAST(f_int1 AS CHAR),
27417
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
27418
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
27419
SET AUTOCOMMIT= 0;
27420
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27421
SELECT f_int1, f_int1, '', '', 'was inserted'
27422
FROM t0_template source_tab
27423
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
27424
	
27425
# check transactions-1 success: 	1
27426
COMMIT WORK;
27427
	
27428
# check transactions-2 success: 	1
27429
ROLLBACK WORK;
27430
	
27431
# check transactions-3 success: 	1
27432
DELETE FROM t1 WHERE f_charbig = 'was inserted';
27433
COMMIT WORK;
27434
ROLLBACK WORK;
27435
	
27436
# check transactions-4 success: 	1
27437
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27438
SELECT f_int1, f_int1, '', '', 'was inserted'
27439
FROM t0_template source_tab
27440
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
27441
	
27442
# check transactions-5 success: 	1
27443
ROLLBACK WORK;
27444
	
27445
# check transactions-6 success: 	1
27446
# INFO: Storage engine used for t1 seems to be transactional.
27447
COMMIT;
27448
	
27449
# check transactions-7 success: 	1
27450
DELETE FROM t1 WHERE f_charbig = 'was inserted';
27451
COMMIT WORK;
27452
SET @@session.sql_mode = 'traditional';
27453
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
27454
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27455
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
27456
'', '', 'was inserted' FROM t0_template
27457
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
27458
ERROR 22012: Division by 0
27459
COMMIT;
27460
	
27461
# check transactions-8 success: 	1
27462
# INFO: Storage engine used for t1 seems to be able to revert
27463
#       changes made by the failing statement.
27464
SET @@session.sql_mode = '';
27465
SET AUTOCOMMIT= 1;
27466
DELETE FROM t1 WHERE f_charbig = 'was inserted';
27467
COMMIT WORK;
27468
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
27469
	
27470
# check special-1 success: 	1
27471
UPDATE t1 SET f_charbig = '';
27472
	
27473
# check special-2 success: 	1
27474
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
27475
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
27476
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
27477
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27478
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27479
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
27480
'just inserted' FROM t0_template
27481
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27482
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
27483
BEGIN
27484
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27485
f_charbig = 'updated by trigger'
27486
      WHERE f_int1 = new.f_int1;
27487
END|
27488
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27489
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
27490
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27491
	
27492
# check trigger-1 success: 	1
27493
DROP TRIGGER trg_1;
27494
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27495
f_int2 = CAST(f_char1 AS SIGNED INT),
27496
f_charbig = 'just inserted'
27497
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
27498
DELETE FROM t0_aux
27499
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27500
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27501
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
27502
'just inserted' FROM t0_template
27503
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27504
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
27505
BEGIN
27506
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27507
f_charbig = 'updated by trigger'
27508
      WHERE f_int1 = new.f_int1;
27509
END|
27510
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27511
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
27512
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27513
	
27514
# check trigger-2 success: 	1
27515
DROP TRIGGER trg_1;
27516
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27517
f_int2 = CAST(f_char1 AS SIGNED INT),
27518
f_charbig = 'just inserted'
27519
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
27520
DELETE FROM t0_aux
27521
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27522
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27523
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
27524
'just inserted' FROM t0_template
27525
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27526
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
27527
BEGIN
27528
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27529
f_charbig = 'updated by trigger'
27530
      WHERE f_int1 = new.f_int1;
27531
END|
27532
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
27533
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
27534
	
27535
# check trigger-3 success: 	1
27536
DROP TRIGGER trg_1;
27537
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27538
f_int2 = CAST(f_char1 AS SIGNED INT),
27539
f_charbig = 'just inserted'
27540
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
27541
DELETE FROM t0_aux
27542
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27543
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27544
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
27545
'just inserted' FROM t0_template
27546
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27547
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
27548
BEGIN
27549
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27550
f_charbig = 'updated by trigger'
27551
      WHERE f_int1 = - old.f_int1;
27552
END|
27553
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
27554
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
27555
	
27556
# check trigger-4 success: 	1
27557
DROP TRIGGER trg_1;
27558
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27559
f_int2 = CAST(f_char1 AS SIGNED INT),
27560
f_charbig = 'just inserted'
27561
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
27562
DELETE FROM t0_aux
27563
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27564
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27565
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
27566
'just inserted' FROM t0_template
27567
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27568
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
27569
BEGIN
27570
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27571
f_charbig = 'updated by trigger'
27572
      WHERE f_int1 = new.f_int1;
27573
END|
27574
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
27575
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
27576
	
27577
# check trigger-5 success: 	1
27578
DROP TRIGGER trg_1;
27579
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27580
f_int2 = CAST(f_char1 AS SIGNED INT),
27581
f_charbig = 'just inserted'
27582
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
27583
DELETE FROM t0_aux
27584
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27585
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27586
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
27587
'just inserted' FROM t0_template
27588
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27589
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
27590
BEGIN
27591
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27592
f_charbig = 'updated by trigger'
27593
      WHERE f_int1 = - old.f_int1;
27594
END|
27595
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
27596
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
27597
	
27598
# check trigger-6 success: 	1
27599
DROP TRIGGER trg_1;
27600
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27601
f_int2 = CAST(f_char1 AS SIGNED INT),
27602
f_charbig = 'just inserted'
27603
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
27604
DELETE FROM t0_aux
27605
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27606
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27607
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
27608
'just inserted' FROM t0_template
27609
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27610
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
27611
BEGIN
27612
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27613
f_charbig = 'updated by trigger'
27614
      WHERE f_int1 = - old.f_int1;
27615
END|
27616
DELETE FROM t0_aux
27617
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
27618
	
27619
# check trigger-7 success: 	1
27620
DROP TRIGGER trg_1;
27621
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27622
f_int2 = CAST(f_char1 AS SIGNED INT),
27623
f_charbig = 'just inserted'
27624
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
27625
DELETE FROM t0_aux
27626
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27627
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27628
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
27629
'just inserted' FROM t0_template
27630
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27631
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
27632
BEGIN
27633
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27634
f_charbig = 'updated by trigger'
27635
      WHERE f_int1 = - old.f_int1;
27636
END|
27637
DELETE FROM t0_aux
27638
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
27639
	
27640
# check trigger-8 success: 	1
27641
DROP TRIGGER trg_1;
27642
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27643
f_int2 = CAST(f_char1 AS SIGNED INT),
27644
f_charbig = 'just inserted'
27645
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
27646
DELETE FROM t0_aux
27647
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27648
DELETE FROM t1
27649
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27650
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
27651
BEGIN
27652
SET new.f_int1 = old.f_int1 + @max_row,
27653
new.f_int2 = old.f_int2 - @max_row,
27654
new.f_charbig = '####updated per update trigger####';
27655
END|
27656
UPDATE t1
27657
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
27658
f_charbig = '####updated per update statement itself####';
27659
	
27660
# check trigger-9 success: 	1
27661
DROP TRIGGER trg_2;
27662
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27663
f_int2 = CAST(f_char1 AS SIGNED INT),
27664
f_charbig = CONCAT('===',f_char1,'===');
27665
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
27666
BEGIN
27667
SET new.f_int1 = new.f_int1 + @max_row,
27668
new.f_int2 = new.f_int2 - @max_row,
27669
new.f_charbig = '####updated per update trigger####';
27670
END|
27671
UPDATE t1
27672
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
27673
f_charbig = '####updated per update statement itself####';
27674
	
27675
# check trigger-10 success: 	1
27676
DROP TRIGGER trg_2;
27677
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27678
f_int2 = CAST(f_char1 AS SIGNED INT),
27679
f_charbig = CONCAT('===',f_char1,'===');
27680
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
27681
BEGIN
27682
SET new.f_int1 = @my_max1 + @counter,
27683
new.f_int2 = @my_min2 - @counter,
27684
new.f_charbig = '####updated per insert trigger####';
27685
SET @counter = @counter + 1;
27686
END|
27687
SET @counter = 1;
27688
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
27689
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27690
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
27691
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
27692
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
27693
ORDER BY f_int1;
27694
DROP TRIGGER trg_3;
27695
	
27696
# check trigger-11 success: 	1
27697
DELETE FROM t1
27698
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
27699
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
27700
AND f_charbig = '####updated per insert trigger####';
27701
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
27702
BEGIN
27703
SET new.f_int1 = @my_max1 + @counter,
27704
new.f_int2 = @my_min2 - @counter,
27705
new.f_charbig = '####updated per insert trigger####';
27706
SET @counter = @counter + 1;
27707
END|
27708
SET @counter = 1;
27709
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
27710
INSERT INTO t1 (f_char1, f_char2, f_charbig)
27711
SELECT CAST(f_int1 AS CHAR),
27712
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
27713
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
27714
ORDER BY f_int1;
27715
DROP TRIGGER trg_3;
27716
	
27717
# check trigger-12 success: 	1
27718
DELETE FROM t1
27719
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
27720
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
27721
AND f_charbig = '####updated per insert trigger####';
27722
ANALYZE  TABLE t1;
27723
Table	Op	Msg_type	Msg_text
27724
test.t1	analyze	note	The storage engine for the table doesn't support analyze
27725
CHECK    TABLE t1 EXTENDED;
27726
Table	Op	Msg_type	Msg_text
27727
test.t1	check	note	The storage engine for the table doesn't support check
27728
CHECKSUM TABLE t1 EXTENDED;
27729
Table	Checksum
27730
test.t1	<some_value>
27731
OPTIMIZE TABLE t1;
27732
Table	Op	Msg_type	Msg_text
27733
test.t1	optimize	note	The storage engine for the table doesn't support optimize
27734
# check layout success:    1
27735
REPAIR   TABLE t1 EXTENDED;
27736
Table	Op	Msg_type	Msg_text
27737
test.t1	repair	note	The storage engine for the table doesn't support repair
27738
# check layout success:    1
27739
TRUNCATE t1;
27740
	
27741
# check TRUNCATE success: 	1
27742
# check layout success:    1
27743
# End usability test (inc/partition_check.inc)
27744
DROP TABLE t1;
27745
CREATE TABLE t1 (
27746
f_int1 INTEGER,
27747
f_int2 INTEGER,
27748
f_char1 CHAR(20),
27749
f_char2 CHAR(20),
27750
f_charbig VARCHAR(1000)
27751
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
27752
)
27753
PARTITION BY KEY(f_int1,f_int2) PARTITIONS 5;
27754
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
27755
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
27756
# Start usability test (inc/partition_check.inc)
27757
create_command
27758
SHOW CREATE TABLE t1;
27759
Table	Create Table
27760
t1	CREATE TABLE `t1` (
27761
  `f_int1` int(11) DEFAULT NULL,
27762
  `f_int2` int(11) DEFAULT NULL,
27763
  `f_char1` char(20) DEFAULT NULL,
27764
  `f_char2` char(20) DEFAULT NULL,
27765
  `f_charbig` varchar(1000) DEFAULT NULL,
27766
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
27767
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
27768
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (f_int1,f_int2) PARTITIONS 5  */
27769
27770
unified filelist
27771
$MYSQLTEST_VARDIR/master-data/test/t1.frm
27772
$MYSQLTEST_VARDIR/master-data/test/t1.par
27773
27774
# check prerequisites-1 success:    1
27775
# check COUNT(*) success:    1
27776
# check MIN/MAX(f_int1) success:    1
27777
# check MIN/MAX(f_int2) success:    1
27778
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27779
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
27780
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
27781
WHERE f_int1 IN (2,3);
27782
ERROR 23000: Can't write; duplicate key in table 't1'
27783
# check prerequisites-3 success:    1
27784
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
27785
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27786
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
27787
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
27788
WHERE f_int1 IN (2,3);
27789
DELETE FROM t1 WHERE f_charbig = 'delete me';
27790
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27791
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
27792
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
27793
WHERE f_int1 IN (2,3);
27794
DELETE FROM t1 WHERE f_charbig = 'delete me';
27795
# check read via f_int1 success: 1
27796
# check read via f_int2 success: 1
27797
	
27798
# check multiple-1 success: 	1
27799
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
27800
	
27801
# check multiple-2 success: 	1
27802
INSERT INTO t1 SELECT * FROM t0_template
27803
WHERE MOD(f_int1,3) = 0;
27804
	
27805
# check multiple-3 success: 	1
27806
UPDATE t1 SET f_int1 = f_int1 + @max_row
27807
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
27808
AND @max_row_div2 + @max_row_div4;
27809
	
27810
# check multiple-4 success: 	1
27811
DELETE FROM t1
27812
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
27813
AND @max_row_div2 + @max_row_div4 + @max_row;
27814
	
27815
# check multiple-5 success: 	1
27816
SELECT COUNT(*) INTO @try_count FROM t0_template
27817
WHERE MOD(f_int1,3) = 0
27818
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
27819
SELECT COUNT(*) INTO @clash_count
27820
FROM t1 INNER JOIN t0_template USING(f_int1)
27821
WHERE MOD(f_int1,3) = 0
27822
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
27823
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
27824
INSERT INTO t1
27825
SET f_int1 = @cur_value , f_int2 = @cur_value,
27826
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
27827
f_charbig = '#SINGLE#';
27828
	
27829
# check single-1 success: 	1
27830
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
27831
INSERT INTO t1
27832
SET f_int1 = @cur_value , f_int2 = @cur_value,
27833
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
27834
f_charbig = '#SINGLE#';
27835
	
27836
# check single-2 success: 	1
27837
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
27838
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
27839
UPDATE t1 SET f_int1 = @cur_value2
27840
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
27841
	
27842
# check single-3 success: 	1
27843
SET @cur_value1= -1;
27844
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
27845
UPDATE t1 SET f_int1 = @cur_value1
27846
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
27847
	
27848
# check single-4 success: 	1
27849
SELECT MAX(f_int1) INTO @cur_value FROM t1;
27850
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
27851
	
27852
# check single-5 success: 	1
27853
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
27854
	
27855
# check single-6 success: 	1
27856
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
27857
	
27858
# check single-7 success: 	1
27859
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
27860
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
27861
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
27862
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
27863
f_charbig = '#NULL#';
27864
INSERT INTO t1
27865
SET f_int1 = NULL , f_int2 = -@max_row,
27866
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
27867
f_charbig = '#NULL#';
27868
# check null success:    1
27869
	
27870
# check null-1 success: 	1
27871
UPDATE t1 SET f_int1 = -@max_row
27872
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
27873
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
27874
	
27875
# check null-2 success: 	1
27876
UPDATE t1 SET f_int1 = NULL
27877
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
27878
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
27879
	
27880
# check null-3 success: 	1
27881
DELETE FROM t1
27882
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
27883
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
27884
	
27885
# check null-4 success: 	1
27886
DELETE FROM t1
27887
WHERE f_int1 = 0 AND f_int2 = 0
27888
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
27889
AND f_charbig = '#NULL#';
27890
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27891
SELECT f_int1, f_int1, '', '', 'was inserted'
27892
   FROM t0_template source_tab
27893
WHERE MOD(f_int1,3) = 0
27894
AND f_int1 BETWEEN @max_row_div2 AND @max_row
27895
ON DUPLICATE KEY
27896
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
27897
f_int2 = 2 * @max_row + source_tab.f_int1,
27898
f_charbig = 'was updated';
27899
	
27900
# check unique-1-a success: 	1
27901
	
27902
# check unique-1-b success: 	1
27903
DELETE FROM t1 WHERE f_charbig = 'was inserted';
27904
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
27905
f_int2 = CAST(f_char1 AS SIGNED INT),
27906
f_charbig = CONCAT('===',f_char1,'===')
27907
WHERE f_charbig = 'was updated';
27908
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27909
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
27910
   FROM t0_template source_tab
27911
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
27912
	
27913
# check replace success: 	1
27914
DELETE FROM t1
27915
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
27916
DELETE FROM t1
27917
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
27918
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
27919
UPDATE t1 SET f_int2 = f_int1,
27920
f_char1 = CAST(f_int1 AS CHAR),
27921
f_char2 = CAST(f_int1 AS CHAR),
27922
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
27923
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
27924
SET AUTOCOMMIT= 0;
27925
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27926
SELECT f_int1, f_int1, '', '', 'was inserted'
27927
FROM t0_template source_tab
27928
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
27929
	
27930
# check transactions-1 success: 	1
27931
COMMIT WORK;
27932
	
27933
# check transactions-2 success: 	1
27934
ROLLBACK WORK;
27935
	
27936
# check transactions-3 success: 	1
27937
DELETE FROM t1 WHERE f_charbig = 'was inserted';
27938
COMMIT WORK;
27939
ROLLBACK WORK;
27940
	
27941
# check transactions-4 success: 	1
27942
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27943
SELECT f_int1, f_int1, '', '', 'was inserted'
27944
FROM t0_template source_tab
27945
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
27946
	
27947
# check transactions-5 success: 	1
27948
ROLLBACK WORK;
27949
	
27950
# check transactions-6 success: 	1
27951
# INFO: Storage engine used for t1 seems to be transactional.
27952
COMMIT;
27953
	
27954
# check transactions-7 success: 	1
27955
DELETE FROM t1 WHERE f_charbig = 'was inserted';
27956
COMMIT WORK;
27957
SET @@session.sql_mode = 'traditional';
27958
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
27959
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
27960
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
27961
'', '', 'was inserted' FROM t0_template
27962
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
27963
ERROR 22012: Division by 0
27964
COMMIT;
27965
	
27966
# check transactions-8 success: 	1
27967
# INFO: Storage engine used for t1 seems to be able to revert
27968
#       changes made by the failing statement.
27969
SET @@session.sql_mode = '';
27970
SET AUTOCOMMIT= 1;
27971
DELETE FROM t1 WHERE f_charbig = 'was inserted';
27972
COMMIT WORK;
27973
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
27974
	
27975
# check special-1 success: 	1
27976
UPDATE t1 SET f_charbig = '';
27977
	
27978
# check special-2 success: 	1
27979
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
27980
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
27981
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
27982
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27983
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27984
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
27985
'just inserted' FROM t0_template
27986
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27987
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
27988
BEGIN
27989
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
27990
f_charbig = 'updated by trigger'
27991
      WHERE f_int1 = new.f_int1;
27992
END|
27993
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
27994
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
27995
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
27996
	
27997
# check trigger-1 success: 	1
27998
DROP TRIGGER trg_1;
27999
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28000
f_int2 = CAST(f_char1 AS SIGNED INT),
28001
f_charbig = 'just inserted'
28002
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28003
DELETE FROM t0_aux
28004
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28005
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28006
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
28007
'just inserted' FROM t0_template
28008
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28009
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
28010
BEGIN
28011
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
28012
f_charbig = 'updated by trigger'
28013
      WHERE f_int1 = new.f_int1;
28014
END|
28015
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28016
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
28017
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28018
	
28019
# check trigger-2 success: 	1
28020
DROP TRIGGER trg_1;
28021
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28022
f_int2 = CAST(f_char1 AS SIGNED INT),
28023
f_charbig = 'just inserted'
28024
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28025
DELETE FROM t0_aux
28026
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28027
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28028
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
28029
'just inserted' FROM t0_template
28030
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28031
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
28032
BEGIN
28033
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
28034
f_charbig = 'updated by trigger'
28035
      WHERE f_int1 = new.f_int1;
28036
END|
28037
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
28038
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
28039
	
28040
# check trigger-3 success: 	1
28041
DROP TRIGGER trg_1;
28042
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28043
f_int2 = CAST(f_char1 AS SIGNED INT),
28044
f_charbig = 'just inserted'
28045
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28046
DELETE FROM t0_aux
28047
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28048
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28049
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
28050
'just inserted' FROM t0_template
28051
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28052
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
28053
BEGIN
28054
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
28055
f_charbig = 'updated by trigger'
28056
      WHERE f_int1 = - old.f_int1;
28057
END|
28058
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
28059
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
28060
	
28061
# check trigger-4 success: 	1
28062
DROP TRIGGER trg_1;
28063
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28064
f_int2 = CAST(f_char1 AS SIGNED INT),
28065
f_charbig = 'just inserted'
28066
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28067
DELETE FROM t0_aux
28068
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28069
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28070
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
28071
'just inserted' FROM t0_template
28072
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28073
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
28074
BEGIN
28075
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
28076
f_charbig = 'updated by trigger'
28077
      WHERE f_int1 = new.f_int1;
28078
END|
28079
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
28080
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
28081
	
28082
# check trigger-5 success: 	1
28083
DROP TRIGGER trg_1;
28084
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28085
f_int2 = CAST(f_char1 AS SIGNED INT),
28086
f_charbig = 'just inserted'
28087
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28088
DELETE FROM t0_aux
28089
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28090
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28091
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
28092
'just inserted' FROM t0_template
28093
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28094
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
28095
BEGIN
28096
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
28097
f_charbig = 'updated by trigger'
28098
      WHERE f_int1 = - old.f_int1;
28099
END|
28100
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
28101
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
28102
	
28103
# check trigger-6 success: 	1
28104
DROP TRIGGER trg_1;
28105
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28106
f_int2 = CAST(f_char1 AS SIGNED INT),
28107
f_charbig = 'just inserted'
28108
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28109
DELETE FROM t0_aux
28110
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28111
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28112
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
28113
'just inserted' FROM t0_template
28114
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28115
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
28116
BEGIN
28117
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
28118
f_charbig = 'updated by trigger'
28119
      WHERE f_int1 = - old.f_int1;
28120
END|
28121
DELETE FROM t0_aux
28122
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
28123
	
28124
# check trigger-7 success: 	1
28125
DROP TRIGGER trg_1;
28126
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28127
f_int2 = CAST(f_char1 AS SIGNED INT),
28128
f_charbig = 'just inserted'
28129
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28130
DELETE FROM t0_aux
28131
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28132
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28133
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
28134
'just inserted' FROM t0_template
28135
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28136
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
28137
BEGIN
28138
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
28139
f_charbig = 'updated by trigger'
28140
      WHERE f_int1 = - old.f_int1;
28141
END|
28142
DELETE FROM t0_aux
28143
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
28144
	
28145
# check trigger-8 success: 	1
28146
DROP TRIGGER trg_1;
28147
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28148
f_int2 = CAST(f_char1 AS SIGNED INT),
28149
f_charbig = 'just inserted'
28150
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28151
DELETE FROM t0_aux
28152
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28153
DELETE FROM t1
28154
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28155
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
28156
BEGIN
28157
SET new.f_int1 = old.f_int1 + @max_row,
28158
new.f_int2 = old.f_int2 - @max_row,
28159
new.f_charbig = '####updated per update trigger####';
28160
END|
28161
UPDATE t1
28162
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
28163
f_charbig = '####updated per update statement itself####';
28164
	
28165
# check trigger-9 success: 	1
28166
DROP TRIGGER trg_2;
28167
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28168
f_int2 = CAST(f_char1 AS SIGNED INT),
28169
f_charbig = CONCAT('===',f_char1,'===');
28170
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
28171
BEGIN
28172
SET new.f_int1 = new.f_int1 + @max_row,
28173
new.f_int2 = new.f_int2 - @max_row,
28174
new.f_charbig = '####updated per update trigger####';
28175
END|
28176
UPDATE t1
28177
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
28178
f_charbig = '####updated per update statement itself####';
28179
	
28180
# check trigger-10 success: 	1
28181
DROP TRIGGER trg_2;
28182
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28183
f_int2 = CAST(f_char1 AS SIGNED INT),
28184
f_charbig = CONCAT('===',f_char1,'===');
28185
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
28186
BEGIN
28187
SET new.f_int1 = @my_max1 + @counter,
28188
new.f_int2 = @my_min2 - @counter,
28189
new.f_charbig = '####updated per insert trigger####';
28190
SET @counter = @counter + 1;
28191
END|
28192
SET @counter = 1;
28193
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
28194
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28195
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
28196
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
28197
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
28198
ORDER BY f_int1;
28199
DROP TRIGGER trg_3;
28200
	
28201
# check trigger-11 success: 	1
28202
DELETE FROM t1
28203
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
28204
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
28205
AND f_charbig = '####updated per insert trigger####';
28206
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
28207
BEGIN
28208
SET new.f_int1 = @my_max1 + @counter,
28209
new.f_int2 = @my_min2 - @counter,
28210
new.f_charbig = '####updated per insert trigger####';
28211
SET @counter = @counter + 1;
28212
END|
28213
SET @counter = 1;
28214
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
28215
INSERT INTO t1 (f_char1, f_char2, f_charbig)
28216
SELECT CAST(f_int1 AS CHAR),
28217
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
28218
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
28219
ORDER BY f_int1;
28220
DROP TRIGGER trg_3;
28221
	
28222
# check trigger-12 success: 	1
28223
DELETE FROM t1
28224
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
28225
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
28226
AND f_charbig = '####updated per insert trigger####';
28227
ANALYZE  TABLE t1;
28228
Table	Op	Msg_type	Msg_text
28229
test.t1	analyze	note	The storage engine for the table doesn't support analyze
28230
CHECK    TABLE t1 EXTENDED;
28231
Table	Op	Msg_type	Msg_text
28232
test.t1	check	note	The storage engine for the table doesn't support check
28233
CHECKSUM TABLE t1 EXTENDED;
28234
Table	Checksum
28235
test.t1	<some_value>
28236
OPTIMIZE TABLE t1;
28237
Table	Op	Msg_type	Msg_text
28238
test.t1	optimize	note	The storage engine for the table doesn't support optimize
28239
# check layout success:    1
28240
REPAIR   TABLE t1 EXTENDED;
28241
Table	Op	Msg_type	Msg_text
28242
test.t1	repair	note	The storage engine for the table doesn't support repair
28243
# check layout success:    1
28244
TRUNCATE t1;
28245
	
28246
# check TRUNCATE success: 	1
28247
# check layout success:    1
28248
# End usability test (inc/partition_check.inc)
28249
DROP TABLE t1;
28250
CREATE TABLE t1 (
28251
f_int1 INTEGER,
28252
f_int2 INTEGER,
28253
f_char1 CHAR(20),
28254
f_char2 CHAR(20),
28255
f_charbig VARCHAR(1000)
28256
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
28257
)
28258
PARTITION BY LIST(MOD(f_int1 + f_int2,4))
28259
(PARTITION part_3 VALUES IN (-3),
28260
PARTITION part_2 VALUES IN (-2),
28261
PARTITION part_1 VALUES IN (-1),
28262
PARTITION part_N VALUES IN (NULL),
28263
PARTITION part0 VALUES IN (0),
28264
PARTITION part1 VALUES IN (1),
28265
PARTITION part2 VALUES IN (2),
28266
PARTITION part3 VALUES IN (3));
28267
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
28268
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
28269
# Start usability test (inc/partition_check.inc)
28270
create_command
28271
SHOW CREATE TABLE t1;
28272
Table	Create Table
28273
t1	CREATE TABLE `t1` (
28274
  `f_int1` int(11) DEFAULT NULL,
28275
  `f_int2` int(11) DEFAULT NULL,
28276
  `f_char1` char(20) DEFAULT NULL,
28277
  `f_char2` char(20) DEFAULT NULL,
28278
  `f_charbig` varchar(1000) DEFAULT NULL,
28279
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
28280
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
28281
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (MOD(f_int1 + f_int2,4)) (PARTITION part_3 VALUES IN (-3) ENGINE = InnoDB, PARTITION part_2 VALUES IN (-2) ENGINE = InnoDB, PARTITION part_1 VALUES IN (-1) ENGINE = InnoDB, PARTITION part_N VALUES IN (NULL) ENGINE = InnoDB, PARTITION part0 VALUES IN (0) ENGINE = InnoDB, PARTITION part1 VALUES IN (1) ENGINE = InnoDB, PARTITION part2 VALUES IN (2) ENGINE = InnoDB, PARTITION part3 VALUES IN (3) ENGINE = InnoDB) */
28282
28283
unified filelist
28284
$MYSQLTEST_VARDIR/master-data/test/t1.frm
28285
$MYSQLTEST_VARDIR/master-data/test/t1.par
28286
28287
# check prerequisites-1 success:    1
28288
# check COUNT(*) success:    1
28289
# check MIN/MAX(f_int1) success:    1
28290
# check MIN/MAX(f_int2) success:    1
28291
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28292
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
28293
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
28294
WHERE f_int1 IN (2,3);
28295
ERROR 23000: Can't write; duplicate key in table 't1'
28296
# check prerequisites-3 success:    1
28297
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
28298
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28299
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
28300
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
28301
WHERE f_int1 IN (2,3);
28302
DELETE FROM t1 WHERE f_charbig = 'delete me';
28303
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28304
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
28305
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
28306
WHERE f_int1 IN (2,3);
28307
DELETE FROM t1 WHERE f_charbig = 'delete me';
28308
# check read via f_int1 success: 1
28309
# check read via f_int2 success: 1
28310
	
28311
# check multiple-1 success: 	1
28312
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
28313
	
28314
# check multiple-2 success: 	1
28315
INSERT INTO t1 SELECT * FROM t0_template
28316
WHERE MOD(f_int1,3) = 0;
28317
	
28318
# check multiple-3 success: 	1
28319
UPDATE t1 SET f_int1 = f_int1 + @max_row
28320
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
28321
AND @max_row_div2 + @max_row_div4;
28322
	
28323
# check multiple-4 success: 	1
28324
DELETE FROM t1
28325
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
28326
AND @max_row_div2 + @max_row_div4 + @max_row;
28327
	
28328
# check multiple-5 success: 	1
28329
SELECT COUNT(*) INTO @try_count FROM t0_template
28330
WHERE MOD(f_int1,3) = 0
28331
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
28332
SELECT COUNT(*) INTO @clash_count
28333
FROM t1 INNER JOIN t0_template USING(f_int1)
28334
WHERE MOD(f_int1,3) = 0
28335
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
28336
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
28337
INSERT INTO t1
28338
SET f_int1 = @cur_value , f_int2 = @cur_value,
28339
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
28340
f_charbig = '#SINGLE#';
28341
	
28342
# check single-1 success: 	1
28343
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
28344
INSERT INTO t1
28345
SET f_int1 = @cur_value , f_int2 = @cur_value,
28346
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
28347
f_charbig = '#SINGLE#';
28348
	
28349
# check single-2 success: 	1
28350
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
28351
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
28352
UPDATE t1 SET f_int1 = @cur_value2
28353
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
28354
	
28355
# check single-3 success: 	1
28356
SET @cur_value1= -1;
28357
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
28358
UPDATE t1 SET f_int1 = @cur_value1
28359
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
28360
	
28361
# check single-4 success: 	1
28362
SELECT MAX(f_int1) INTO @cur_value FROM t1;
28363
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
28364
	
28365
# check single-5 success: 	1
28366
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
28367
	
28368
# check single-6 success: 	1
28369
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
28370
	
28371
# check single-7 success: 	1
28372
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
28373
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
28374
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
28375
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
28376
f_charbig = '#NULL#';
28377
INSERT INTO t1
28378
SET f_int1 = NULL , f_int2 = -@max_row,
28379
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
28380
f_charbig = '#NULL#';
28381
# check null success:    1
28382
	
28383
# check null-1 success: 	1
28384
UPDATE t1 SET f_int1 = -@max_row
28385
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
28386
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
28387
	
28388
# check null-2 success: 	1
28389
UPDATE t1 SET f_int1 = NULL
28390
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
28391
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
28392
	
28393
# check null-3 success: 	1
28394
DELETE FROM t1
28395
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
28396
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
28397
	
28398
# check null-4 success: 	1
28399
DELETE FROM t1
28400
WHERE f_int1 = 0 AND f_int2 = 0
28401
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
28402
AND f_charbig = '#NULL#';
28403
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28404
SELECT f_int1, f_int1, '', '', 'was inserted'
28405
   FROM t0_template source_tab
28406
WHERE MOD(f_int1,3) = 0
28407
AND f_int1 BETWEEN @max_row_div2 AND @max_row
28408
ON DUPLICATE KEY
28409
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
28410
f_int2 = 2 * @max_row + source_tab.f_int1,
28411
f_charbig = 'was updated';
28412
	
28413
# check unique-1-a success: 	1
28414
	
28415
# check unique-1-b success: 	1
28416
DELETE FROM t1 WHERE f_charbig = 'was inserted';
28417
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28418
f_int2 = CAST(f_char1 AS SIGNED INT),
28419
f_charbig = CONCAT('===',f_char1,'===')
28420
WHERE f_charbig = 'was updated';
28421
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28422
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
28423
   FROM t0_template source_tab
28424
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
28425
	
28426
# check replace success: 	1
28427
DELETE FROM t1
28428
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
28429
DELETE FROM t1
28430
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
28431
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
28432
UPDATE t1 SET f_int2 = f_int1,
28433
f_char1 = CAST(f_int1 AS CHAR),
28434
f_char2 = CAST(f_int1 AS CHAR),
28435
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
28436
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
28437
SET AUTOCOMMIT= 0;
28438
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28439
SELECT f_int1, f_int1, '', '', 'was inserted'
28440
FROM t0_template source_tab
28441
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
28442
	
28443
# check transactions-1 success: 	1
28444
COMMIT WORK;
28445
	
28446
# check transactions-2 success: 	1
28447
ROLLBACK WORK;
28448
	
28449
# check transactions-3 success: 	1
28450
DELETE FROM t1 WHERE f_charbig = 'was inserted';
28451
COMMIT WORK;
28452
ROLLBACK WORK;
28453
	
28454
# check transactions-4 success: 	1
28455
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28456
SELECT f_int1, f_int1, '', '', 'was inserted'
28457
FROM t0_template source_tab
28458
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
28459
	
28460
# check transactions-5 success: 	1
28461
ROLLBACK WORK;
28462
	
28463
# check transactions-6 success: 	1
28464
# INFO: Storage engine used for t1 seems to be transactional.
28465
COMMIT;
28466
	
28467
# check transactions-7 success: 	1
28468
DELETE FROM t1 WHERE f_charbig = 'was inserted';
28469
COMMIT WORK;
28470
SET @@session.sql_mode = 'traditional';
28471
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
28472
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28473
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
28474
'', '', 'was inserted' FROM t0_template
28475
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
28476
ERROR 22012: Division by 0
28477
COMMIT;
28478
	
28479
# check transactions-8 success: 	1
28480
# INFO: Storage engine used for t1 seems to be able to revert
28481
#       changes made by the failing statement.
28482
SET @@session.sql_mode = '';
28483
SET AUTOCOMMIT= 1;
28484
DELETE FROM t1 WHERE f_charbig = 'was inserted';
28485
COMMIT WORK;
28486
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
28487
	
28488
# check special-1 success: 	1
28489
UPDATE t1 SET f_charbig = '';
28490
	
28491
# check special-2 success: 	1
28492
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
28493
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
28494
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
28495
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28496
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28497
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
28498
'just inserted' FROM t0_template
28499
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28500
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
28501
BEGIN
28502
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
28503
f_charbig = 'updated by trigger'
28504
      WHERE f_int1 = new.f_int1;
28505
END|
28506
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28507
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
28508
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28509
	
28510
# check trigger-1 success: 	1
28511
DROP TRIGGER trg_1;
28512
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28513
f_int2 = CAST(f_char1 AS SIGNED INT),
28514
f_charbig = 'just inserted'
28515
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28516
DELETE FROM t0_aux
28517
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28518
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28519
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
28520
'just inserted' FROM t0_template
28521
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28522
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
28523
BEGIN
28524
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
28525
f_charbig = 'updated by trigger'
28526
      WHERE f_int1 = new.f_int1;
28527
END|
28528
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28529
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
28530
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28531
	
28532
# check trigger-2 success: 	1
28533
DROP TRIGGER trg_1;
28534
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28535
f_int2 = CAST(f_char1 AS SIGNED INT),
28536
f_charbig = 'just inserted'
28537
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28538
DELETE FROM t0_aux
28539
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28540
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28541
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
28542
'just inserted' FROM t0_template
28543
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28544
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
28545
BEGIN
28546
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
28547
f_charbig = 'updated by trigger'
28548
      WHERE f_int1 = new.f_int1;
28549
END|
28550
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
28551
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
28552
	
28553
# check trigger-3 success: 	1
28554
DROP TRIGGER trg_1;
28555
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28556
f_int2 = CAST(f_char1 AS SIGNED INT),
28557
f_charbig = 'just inserted'
28558
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28559
DELETE FROM t0_aux
28560
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28561
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28562
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
28563
'just inserted' FROM t0_template
28564
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28565
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
28566
BEGIN
28567
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
28568
f_charbig = 'updated by trigger'
28569
      WHERE f_int1 = - old.f_int1;
28570
END|
28571
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
28572
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
28573
	
28574
# check trigger-4 success: 	1
28575
DROP TRIGGER trg_1;
28576
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28577
f_int2 = CAST(f_char1 AS SIGNED INT),
28578
f_charbig = 'just inserted'
28579
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28580
DELETE FROM t0_aux
28581
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28582
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28583
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
28584
'just inserted' FROM t0_template
28585
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28586
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
28587
BEGIN
28588
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
28589
f_charbig = 'updated by trigger'
28590
      WHERE f_int1 = new.f_int1;
28591
END|
28592
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
28593
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
28594
	
28595
# check trigger-5 success: 	1
28596
DROP TRIGGER trg_1;
28597
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28598
f_int2 = CAST(f_char1 AS SIGNED INT),
28599
f_charbig = 'just inserted'
28600
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28601
DELETE FROM t0_aux
28602
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28603
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28604
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
28605
'just inserted' FROM t0_template
28606
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28607
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
28608
BEGIN
28609
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
28610
f_charbig = 'updated by trigger'
28611
      WHERE f_int1 = - old.f_int1;
28612
END|
28613
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
28614
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
28615
	
28616
# check trigger-6 success: 	1
28617
DROP TRIGGER trg_1;
28618
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28619
f_int2 = CAST(f_char1 AS SIGNED INT),
28620
f_charbig = 'just inserted'
28621
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28622
DELETE FROM t0_aux
28623
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28624
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28625
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
28626
'just inserted' FROM t0_template
28627
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28628
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
28629
BEGIN
28630
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
28631
f_charbig = 'updated by trigger'
28632
      WHERE f_int1 = - old.f_int1;
28633
END|
28634
DELETE FROM t0_aux
28635
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
28636
	
28637
# check trigger-7 success: 	1
28638
DROP TRIGGER trg_1;
28639
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28640
f_int2 = CAST(f_char1 AS SIGNED INT),
28641
f_charbig = 'just inserted'
28642
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28643
DELETE FROM t0_aux
28644
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28645
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
28646
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
28647
'just inserted' FROM t0_template
28648
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28649
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
28650
BEGIN
28651
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
28652
f_charbig = 'updated by trigger'
28653
      WHERE f_int1 = - old.f_int1;
28654
END|
28655
DELETE FROM t0_aux
28656
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
28657
	
28658
# check trigger-8 success: 	1
28659
DROP TRIGGER trg_1;
28660
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28661
f_int2 = CAST(f_char1 AS SIGNED INT),
28662
f_charbig = 'just inserted'
28663
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
28664
DELETE FROM t0_aux
28665
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28666
DELETE FROM t1
28667
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
28668
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
28669
BEGIN
28670
SET new.f_int1 = old.f_int1 + @max_row,
28671
new.f_int2 = old.f_int2 - @max_row,
28672
new.f_charbig = '####updated per update trigger####';
28673
END|
28674
UPDATE t1
28675
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
28676
f_charbig = '####updated per update statement itself####';
28677
	
28678
# check trigger-9 success: 	1
28679
DROP TRIGGER trg_2;
28680
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28681
f_int2 = CAST(f_char1 AS SIGNED INT),
28682
f_charbig = CONCAT('===',f_char1,'===');
28683
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
28684
BEGIN
28685
SET new.f_int1 = new.f_int1 + @max_row,
28686
new.f_int2 = new.f_int2 - @max_row,
28687
new.f_charbig = '####updated per update trigger####';
28688
END|
28689
UPDATE t1
28690
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
28691
f_charbig = '####updated per update statement itself####';
28692
	
28693
# check trigger-10 success: 	1
28694
DROP TRIGGER trg_2;
28695
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28696
f_int2 = CAST(f_char1 AS SIGNED INT),
28697
f_charbig = CONCAT('===',f_char1,'===');
28698
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
28699
BEGIN
28700
SET new.f_int1 = @my_max1 + @counter,
28701
new.f_int2 = @my_min2 - @counter,
28702
new.f_charbig = '####updated per insert trigger####';
28703
SET @counter = @counter + 1;
28704
END|
28705
SET @counter = 1;
28706
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
28707
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28708
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
28709
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
28710
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
28711
ORDER BY f_int1;
28712
DROP TRIGGER trg_3;
28713
	
28714
# check trigger-11 success: 	1
28715
DELETE FROM t1
28716
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
28717
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
28718
AND f_charbig = '####updated per insert trigger####';
28719
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
28720
BEGIN
28721
SET new.f_int1 = @my_max1 + @counter,
28722
new.f_int2 = @my_min2 - @counter,
28723
new.f_charbig = '####updated per insert trigger####';
28724
SET @counter = @counter + 1;
28725
END|
28726
SET @counter = 1;
28727
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
28728
INSERT INTO t1 (f_char1, f_char2, f_charbig)
28729
SELECT CAST(f_int1 AS CHAR),
28730
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
28731
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
28732
ORDER BY f_int1;
28733
DROP TRIGGER trg_3;
28734
	
28735
# check trigger-12 success: 	1
28736
DELETE FROM t1
28737
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
28738
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
28739
AND f_charbig = '####updated per insert trigger####';
28740
ANALYZE  TABLE t1;
28741
Table	Op	Msg_type	Msg_text
28742
test.t1	analyze	note	The storage engine for the table doesn't support analyze
28743
CHECK    TABLE t1 EXTENDED;
28744
Table	Op	Msg_type	Msg_text
28745
test.t1	check	note	The storage engine for the table doesn't support check
28746
CHECKSUM TABLE t1 EXTENDED;
28747
Table	Checksum
28748
test.t1	<some_value>
28749
OPTIMIZE TABLE t1;
28750
Table	Op	Msg_type	Msg_text
28751
test.t1	optimize	note	The storage engine for the table doesn't support optimize
28752
# check layout success:    1
28753
REPAIR   TABLE t1 EXTENDED;
28754
Table	Op	Msg_type	Msg_text
28755
test.t1	repair	note	The storage engine for the table doesn't support repair
28756
# check layout success:    1
28757
TRUNCATE t1;
28758
	
28759
# check TRUNCATE success: 	1
28760
# check layout success:    1
28761
# End usability test (inc/partition_check.inc)
28762
DROP TABLE t1;
28763
CREATE TABLE t1 (
28764
f_int1 INTEGER,
28765
f_int2 INTEGER,
28766
f_char1 CHAR(20),
28767
f_char2 CHAR(20),
28768
f_charbig VARCHAR(1000)
28769
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
28770
)
28771
PARTITION BY RANGE((f_int1 + f_int2) DIV 2)
28772
(PARTITION parta VALUES LESS THAN (0),
28773
PARTITION partb VALUES LESS THAN (5),
28774
PARTITION partc VALUES LESS THAN (10),
28775
PARTITION partd VALUES LESS THAN (10 + 5),
28776
PARTITION parte VALUES LESS THAN (20),
28777
PARTITION partf VALUES LESS THAN (2147483646));
28778
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
28779
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
28780
# Start usability test (inc/partition_check.inc)
28781
create_command
28782
SHOW CREATE TABLE t1;
28783
Table	Create Table
28784
t1	CREATE TABLE `t1` (
28785
  `f_int1` int(11) DEFAULT NULL,
28786
  `f_int2` int(11) DEFAULT NULL,
28787
  `f_char1` char(20) DEFAULT NULL,
28788
  `f_char2` char(20) DEFAULT NULL,
28789
  `f_charbig` varchar(1000) DEFAULT NULL,
28790
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
28791
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
28792
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE ((f_int1 + f_int2) DIV 2) (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (15) ENGINE = InnoDB, PARTITION parte VALUES LESS THAN (20) ENGINE = InnoDB, PARTITION partf VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
28793
28794
unified filelist
28795
$MYSQLTEST_VARDIR/master-data/test/t1.frm
28796
$MYSQLTEST_VARDIR/master-data/test/t1.par
28797
28798
# check prerequisites-1 success:    1
28799
# check COUNT(*) success:    1
28800
# check MIN/MAX(f_int1) success:    1
28801
# check MIN/MAX(f_int2) success:    1
28802
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28803
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
28804
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
28805
WHERE f_int1 IN (2,3);
28806
ERROR 23000: Can't write; duplicate key in table 't1'
28807
# check prerequisites-3 success:    1
28808
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
28809
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28810
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
28811
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
28812
WHERE f_int1 IN (2,3);
28813
DELETE FROM t1 WHERE f_charbig = 'delete me';
28814
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28815
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
28816
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
28817
WHERE f_int1 IN (2,3);
28818
DELETE FROM t1 WHERE f_charbig = 'delete me';
28819
# check read via f_int1 success: 1
28820
# check read via f_int2 success: 1
28821
	
28822
# check multiple-1 success: 	1
28823
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
28824
	
28825
# check multiple-2 success: 	1
28826
INSERT INTO t1 SELECT * FROM t0_template
28827
WHERE MOD(f_int1,3) = 0;
28828
	
28829
# check multiple-3 success: 	1
28830
UPDATE t1 SET f_int1 = f_int1 + @max_row
28831
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
28832
AND @max_row_div2 + @max_row_div4;
28833
	
28834
# check multiple-4 success: 	1
28835
DELETE FROM t1
28836
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
28837
AND @max_row_div2 + @max_row_div4 + @max_row;
28838
	
28839
# check multiple-5 success: 	1
28840
SELECT COUNT(*) INTO @try_count FROM t0_template
28841
WHERE MOD(f_int1,3) = 0
28842
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
28843
SELECT COUNT(*) INTO @clash_count
28844
FROM t1 INNER JOIN t0_template USING(f_int1)
28845
WHERE MOD(f_int1,3) = 0
28846
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
28847
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
28848
INSERT INTO t1
28849
SET f_int1 = @cur_value , f_int2 = @cur_value,
28850
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
28851
f_charbig = '#SINGLE#';
28852
	
28853
# check single-1 success: 	1
28854
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
28855
INSERT INTO t1
28856
SET f_int1 = @cur_value , f_int2 = @cur_value,
28857
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
28858
f_charbig = '#SINGLE#';
28859
	
28860
# check single-2 success: 	1
28861
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
28862
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
28863
UPDATE t1 SET f_int1 = @cur_value2
28864
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
28865
	
28866
# check single-3 success: 	1
28867
SET @cur_value1= -1;
28868
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
28869
UPDATE t1 SET f_int1 = @cur_value1
28870
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
28871
	
28872
# check single-4 success: 	1
28873
SELECT MAX(f_int1) INTO @cur_value FROM t1;
28874
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
28875
	
28876
# check single-5 success: 	1
28877
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
28878
	
28879
# check single-6 success: 	1
28880
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
28881
ERROR HY000: Table has no partition for value 2147483647
28882
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
28883
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
28884
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
28885
f_charbig = '#NULL#';
28886
INSERT INTO t1
28887
SET f_int1 = NULL , f_int2 = -@max_row,
28888
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
28889
f_charbig = '#NULL#';
28890
# check null success:    1
28891
	
28892
# check null-1 success: 	1
28893
UPDATE t1 SET f_int1 = -@max_row
28894
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
28895
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
28896
	
28897
# check null-2 success: 	1
28898
UPDATE t1 SET f_int1 = NULL
28899
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
28900
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
28901
	
28902
# check null-3 success: 	1
28903
DELETE FROM t1
28904
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
28905
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
28906
	
28907
# check null-4 success: 	1
28908
DELETE FROM t1
28909
WHERE f_int1 = 0 AND f_int2 = 0
28910
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
28911
AND f_charbig = '#NULL#';
28912
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28913
SELECT f_int1, f_int1, '', '', 'was inserted'
28914
   FROM t0_template source_tab
28915
WHERE MOD(f_int1,3) = 0
28916
AND f_int1 BETWEEN @max_row_div2 AND @max_row
28917
ON DUPLICATE KEY
28918
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
28919
f_int2 = 2 * @max_row + source_tab.f_int1,
28920
f_charbig = 'was updated';
28921
	
28922
# check unique-1-a success: 	1
28923
	
28924
# check unique-1-b success: 	1
28925
DELETE FROM t1 WHERE f_charbig = 'was inserted';
28926
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
28927
f_int2 = CAST(f_char1 AS SIGNED INT),
28928
f_charbig = CONCAT('===',f_char1,'===')
28929
WHERE f_charbig = 'was updated';
28930
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28931
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
28932
   FROM t0_template source_tab
28933
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
28934
	
28935
# check replace success: 	1
28936
DELETE FROM t1
28937
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
28938
DELETE FROM t1
28939
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
28940
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
28941
UPDATE t1 SET f_int2 = f_int1,
28942
f_char1 = CAST(f_int1 AS CHAR),
28943
f_char2 = CAST(f_int1 AS CHAR),
28944
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
28945
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
28946
SET AUTOCOMMIT= 0;
28947
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28948
SELECT f_int1, f_int1, '', '', 'was inserted'
28949
FROM t0_template source_tab
28950
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
28951
	
28952
# check transactions-1 success: 	1
28953
COMMIT WORK;
28954
	
28955
# check transactions-2 success: 	1
28956
ROLLBACK WORK;
28957
	
28958
# check transactions-3 success: 	1
28959
DELETE FROM t1 WHERE f_charbig = 'was inserted';
28960
COMMIT WORK;
28961
ROLLBACK WORK;
28962
	
28963
# check transactions-4 success: 	1
28964
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28965
SELECT f_int1, f_int1, '', '', 'was inserted'
28966
FROM t0_template source_tab
28967
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
28968
	
28969
# check transactions-5 success: 	1
28970
ROLLBACK WORK;
28971
	
28972
# check transactions-6 success: 	1
28973
# INFO: Storage engine used for t1 seems to be transactional.
28974
COMMIT;
28975
	
28976
# check transactions-7 success: 	1
28977
DELETE FROM t1 WHERE f_charbig = 'was inserted';
28978
COMMIT WORK;
28979
SET @@session.sql_mode = 'traditional';
28980
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
28981
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
28982
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
28983
'', '', 'was inserted' FROM t0_template
28984
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
28985
ERROR 22012: Division by 0
28986
COMMIT;
28987
	
28988
# check transactions-8 success: 	1
28989
# INFO: Storage engine used for t1 seems to be able to revert
28990
#       changes made by the failing statement.
28991
SET @@session.sql_mode = '';
28992
SET AUTOCOMMIT= 1;
28993
DELETE FROM t1 WHERE f_charbig = 'was inserted';
28994
COMMIT WORK;
28995
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
28996
	
28997
# check special-1 success: 	1
28998
UPDATE t1 SET f_charbig = '';
28999
	
29000
# check special-2 success: 	1
29001
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
29002
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
29003
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
29004
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29005
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29006
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29007
'just inserted' FROM t0_template
29008
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29009
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
29010
BEGIN
29011
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29012
f_charbig = 'updated by trigger'
29013
      WHERE f_int1 = new.f_int1;
29014
END|
29015
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29016
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
29017
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29018
	
29019
# check trigger-1 success: 	1
29020
DROP TRIGGER trg_1;
29021
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29022
f_int2 = CAST(f_char1 AS SIGNED INT),
29023
f_charbig = 'just inserted'
29024
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29025
DELETE FROM t0_aux
29026
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29027
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29028
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29029
'just inserted' FROM t0_template
29030
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29031
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
29032
BEGIN
29033
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29034
f_charbig = 'updated by trigger'
29035
      WHERE f_int1 = new.f_int1;
29036
END|
29037
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29038
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
29039
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29040
	
29041
# check trigger-2 success: 	1
29042
DROP TRIGGER trg_1;
29043
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29044
f_int2 = CAST(f_char1 AS SIGNED INT),
29045
f_charbig = 'just inserted'
29046
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29047
DELETE FROM t0_aux
29048
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29049
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29050
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29051
'just inserted' FROM t0_template
29052
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29053
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
29054
BEGIN
29055
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29056
f_charbig = 'updated by trigger'
29057
      WHERE f_int1 = new.f_int1;
29058
END|
29059
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
29060
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
29061
	
29062
# check trigger-3 success: 	1
29063
DROP TRIGGER trg_1;
29064
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29065
f_int2 = CAST(f_char1 AS SIGNED INT),
29066
f_charbig = 'just inserted'
29067
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29068
DELETE FROM t0_aux
29069
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29070
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29071
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29072
'just inserted' FROM t0_template
29073
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29074
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
29075
BEGIN
29076
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29077
f_charbig = 'updated by trigger'
29078
      WHERE f_int1 = - old.f_int1;
29079
END|
29080
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
29081
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
29082
	
29083
# check trigger-4 success: 	1
29084
DROP TRIGGER trg_1;
29085
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29086
f_int2 = CAST(f_char1 AS SIGNED INT),
29087
f_charbig = 'just inserted'
29088
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29089
DELETE FROM t0_aux
29090
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29091
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29092
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29093
'just inserted' FROM t0_template
29094
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29095
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
29096
BEGIN
29097
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29098
f_charbig = 'updated by trigger'
29099
      WHERE f_int1 = new.f_int1;
29100
END|
29101
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
29102
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
29103
	
29104
# check trigger-5 success: 	1
29105
DROP TRIGGER trg_1;
29106
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29107
f_int2 = CAST(f_char1 AS SIGNED INT),
29108
f_charbig = 'just inserted'
29109
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29110
DELETE FROM t0_aux
29111
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29112
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29113
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29114
'just inserted' FROM t0_template
29115
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29116
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
29117
BEGIN
29118
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29119
f_charbig = 'updated by trigger'
29120
      WHERE f_int1 = - old.f_int1;
29121
END|
29122
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
29123
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
29124
	
29125
# check trigger-6 success: 	1
29126
DROP TRIGGER trg_1;
29127
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29128
f_int2 = CAST(f_char1 AS SIGNED INT),
29129
f_charbig = 'just inserted'
29130
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29131
DELETE FROM t0_aux
29132
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29133
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29134
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29135
'just inserted' FROM t0_template
29136
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29137
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
29138
BEGIN
29139
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29140
f_charbig = 'updated by trigger'
29141
      WHERE f_int1 = - old.f_int1;
29142
END|
29143
DELETE FROM t0_aux
29144
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
29145
	
29146
# check trigger-7 success: 	1
29147
DROP TRIGGER trg_1;
29148
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29149
f_int2 = CAST(f_char1 AS SIGNED INT),
29150
f_charbig = 'just inserted'
29151
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29152
DELETE FROM t0_aux
29153
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29154
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29155
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29156
'just inserted' FROM t0_template
29157
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29158
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
29159
BEGIN
29160
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29161
f_charbig = 'updated by trigger'
29162
      WHERE f_int1 = - old.f_int1;
29163
END|
29164
DELETE FROM t0_aux
29165
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
29166
	
29167
# check trigger-8 success: 	1
29168
DROP TRIGGER trg_1;
29169
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29170
f_int2 = CAST(f_char1 AS SIGNED INT),
29171
f_charbig = 'just inserted'
29172
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29173
DELETE FROM t0_aux
29174
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29175
DELETE FROM t1
29176
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29177
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
29178
BEGIN
29179
SET new.f_int1 = old.f_int1 + @max_row,
29180
new.f_int2 = old.f_int2 - @max_row,
29181
new.f_charbig = '####updated per update trigger####';
29182
END|
29183
UPDATE t1
29184
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
29185
f_charbig = '####updated per update statement itself####';
29186
	
29187
# check trigger-9 success: 	1
29188
DROP TRIGGER trg_2;
29189
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29190
f_int2 = CAST(f_char1 AS SIGNED INT),
29191
f_charbig = CONCAT('===',f_char1,'===');
29192
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
29193
BEGIN
29194
SET new.f_int1 = new.f_int1 + @max_row,
29195
new.f_int2 = new.f_int2 - @max_row,
29196
new.f_charbig = '####updated per update trigger####';
29197
END|
29198
UPDATE t1
29199
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
29200
f_charbig = '####updated per update statement itself####';
29201
	
29202
# check trigger-10 success: 	1
29203
DROP TRIGGER trg_2;
29204
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29205
f_int2 = CAST(f_char1 AS SIGNED INT),
29206
f_charbig = CONCAT('===',f_char1,'===');
29207
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
29208
BEGIN
29209
SET new.f_int1 = @my_max1 + @counter,
29210
new.f_int2 = @my_min2 - @counter,
29211
new.f_charbig = '####updated per insert trigger####';
29212
SET @counter = @counter + 1;
29213
END|
29214
SET @counter = 1;
29215
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
29216
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29217
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
29218
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
29219
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
29220
ORDER BY f_int1;
29221
DROP TRIGGER trg_3;
29222
	
29223
# check trigger-11 success: 	1
29224
DELETE FROM t1
29225
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
29226
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
29227
AND f_charbig = '####updated per insert trigger####';
29228
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
29229
BEGIN
29230
SET new.f_int1 = @my_max1 + @counter,
29231
new.f_int2 = @my_min2 - @counter,
29232
new.f_charbig = '####updated per insert trigger####';
29233
SET @counter = @counter + 1;
29234
END|
29235
SET @counter = 1;
29236
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
29237
INSERT INTO t1 (f_char1, f_char2, f_charbig)
29238
SELECT CAST(f_int1 AS CHAR),
29239
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
29240
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
29241
ORDER BY f_int1;
29242
DROP TRIGGER trg_3;
29243
	
29244
# check trigger-12 success: 	1
29245
DELETE FROM t1
29246
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
29247
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
29248
AND f_charbig = '####updated per insert trigger####';
29249
ANALYZE  TABLE t1;
29250
Table	Op	Msg_type	Msg_text
29251
test.t1	analyze	note	The storage engine for the table doesn't support analyze
29252
CHECK    TABLE t1 EXTENDED;
29253
Table	Op	Msg_type	Msg_text
29254
test.t1	check	note	The storage engine for the table doesn't support check
29255
CHECKSUM TABLE t1 EXTENDED;
29256
Table	Checksum
29257
test.t1	<some_value>
29258
OPTIMIZE TABLE t1;
29259
Table	Op	Msg_type	Msg_text
29260
test.t1	optimize	note	The storage engine for the table doesn't support optimize
29261
# check layout success:    1
29262
REPAIR   TABLE t1 EXTENDED;
29263
Table	Op	Msg_type	Msg_text
29264
test.t1	repair	note	The storage engine for the table doesn't support repair
29265
# check layout success:    1
29266
TRUNCATE t1;
29267
	
29268
# check TRUNCATE success: 	1
29269
# check layout success:    1
29270
# End usability test (inc/partition_check.inc)
29271
DROP TABLE t1;
29272
CREATE TABLE t1 (
29273
f_int1 INTEGER,
29274
f_int2 INTEGER,
29275
f_char1 CHAR(20),
29276
f_char2 CHAR(20),
29277
f_charbig VARCHAR(1000)
29278
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
29279
)
29280
PARTITION BY RANGE(f_int1) SUBPARTITION BY HASH(f_int2) SUBPARTITIONS 2
29281
(PARTITION parta VALUES LESS THAN (0),
29282
PARTITION partb VALUES LESS THAN (5),
29283
PARTITION partc VALUES LESS THAN (10),
29284
PARTITION partd VALUES LESS THAN (2147483646));
29285
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
29286
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
29287
# Start usability test (inc/partition_check.inc)
29288
create_command
29289
SHOW CREATE TABLE t1;
29290
Table	Create Table
29291
t1	CREATE TABLE `t1` (
29292
  `f_int1` int(11) DEFAULT NULL,
29293
  `f_int2` int(11) DEFAULT NULL,
29294
  `f_char1` char(20) DEFAULT NULL,
29295
  `f_char2` char(20) DEFAULT NULL,
29296
  `f_charbig` varchar(1000) DEFAULT NULL,
29297
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
29298
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
29299
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) SUBPARTITION BY HASH (f_int2) SUBPARTITIONS 2 (PARTITION parta VALUES LESS THAN (0) ENGINE = InnoDB, PARTITION partb VALUES LESS THAN (5) ENGINE = InnoDB, PARTITION partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION partd VALUES LESS THAN (2147483646) ENGINE = InnoDB) */
29300
29301
unified filelist
29302
$MYSQLTEST_VARDIR/master-data/test/t1.frm
29303
$MYSQLTEST_VARDIR/master-data/test/t1.par
29304
29305
# check prerequisites-1 success:    1
29306
# check COUNT(*) success:    1
29307
# check MIN/MAX(f_int1) success:    1
29308
# check MIN/MAX(f_int2) success:    1
29309
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29310
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
29311
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
29312
WHERE f_int1 IN (2,3);
29313
ERROR 23000: Can't write; duplicate key in table 't1'
29314
# check prerequisites-3 success:    1
29315
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
29316
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29317
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
29318
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
29319
WHERE f_int1 IN (2,3);
29320
DELETE FROM t1 WHERE f_charbig = 'delete me';
29321
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29322
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
29323
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
29324
WHERE f_int1 IN (2,3);
29325
DELETE FROM t1 WHERE f_charbig = 'delete me';
29326
# check read via f_int1 success: 1
29327
# check read via f_int2 success: 1
29328
	
29329
# check multiple-1 success: 	1
29330
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
29331
	
29332
# check multiple-2 success: 	1
29333
INSERT INTO t1 SELECT * FROM t0_template
29334
WHERE MOD(f_int1,3) = 0;
29335
	
29336
# check multiple-3 success: 	1
29337
UPDATE t1 SET f_int1 = f_int1 + @max_row
29338
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
29339
AND @max_row_div2 + @max_row_div4;
29340
	
29341
# check multiple-4 success: 	1
29342
DELETE FROM t1
29343
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
29344
AND @max_row_div2 + @max_row_div4 + @max_row;
29345
	
29346
# check multiple-5 success: 	1
29347
SELECT COUNT(*) INTO @try_count FROM t0_template
29348
WHERE MOD(f_int1,3) = 0
29349
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
29350
SELECT COUNT(*) INTO @clash_count
29351
FROM t1 INNER JOIN t0_template USING(f_int1)
29352
WHERE MOD(f_int1,3) = 0
29353
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
29354
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
29355
INSERT INTO t1
29356
SET f_int1 = @cur_value , f_int2 = @cur_value,
29357
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
29358
f_charbig = '#SINGLE#';
29359
	
29360
# check single-1 success: 	1
29361
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
29362
INSERT INTO t1
29363
SET f_int1 = @cur_value , f_int2 = @cur_value,
29364
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
29365
f_charbig = '#SINGLE#';
29366
	
29367
# check single-2 success: 	1
29368
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
29369
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
29370
UPDATE t1 SET f_int1 = @cur_value2
29371
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
29372
	
29373
# check single-3 success: 	1
29374
SET @cur_value1= -1;
29375
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
29376
UPDATE t1 SET f_int1 = @cur_value1
29377
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
29378
	
29379
# check single-4 success: 	1
29380
SELECT MAX(f_int1) INTO @cur_value FROM t1;
29381
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
29382
	
29383
# check single-5 success: 	1
29384
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
29385
	
29386
# check single-6 success: 	1
29387
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
29388
ERROR HY000: Table has no partition for value 2147483647
29389
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
29390
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
29391
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
29392
f_charbig = '#NULL#';
29393
INSERT INTO t1
29394
SET f_int1 = NULL , f_int2 = -@max_row,
29395
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
29396
f_charbig = '#NULL#';
29397
# check null success:    1
29398
	
29399
# check null-1 success: 	1
29400
UPDATE t1 SET f_int1 = -@max_row
29401
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
29402
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
29403
	
29404
# check null-2 success: 	1
29405
UPDATE t1 SET f_int1 = NULL
29406
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
29407
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
29408
	
29409
# check null-3 success: 	1
29410
DELETE FROM t1
29411
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
29412
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
29413
	
29414
# check null-4 success: 	1
29415
DELETE FROM t1
29416
WHERE f_int1 = 0 AND f_int2 = 0
29417
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
29418
AND f_charbig = '#NULL#';
29419
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29420
SELECT f_int1, f_int1, '', '', 'was inserted'
29421
   FROM t0_template source_tab
29422
WHERE MOD(f_int1,3) = 0
29423
AND f_int1 BETWEEN @max_row_div2 AND @max_row
29424
ON DUPLICATE KEY
29425
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
29426
f_int2 = 2 * @max_row + source_tab.f_int1,
29427
f_charbig = 'was updated';
29428
	
29429
# check unique-1-a success: 	1
29430
	
29431
# check unique-1-b success: 	1
29432
DELETE FROM t1 WHERE f_charbig = 'was inserted';
29433
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29434
f_int2 = CAST(f_char1 AS SIGNED INT),
29435
f_charbig = CONCAT('===',f_char1,'===')
29436
WHERE f_charbig = 'was updated';
29437
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29438
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
29439
   FROM t0_template source_tab
29440
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
29441
	
29442
# check replace success: 	1
29443
DELETE FROM t1
29444
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
29445
DELETE FROM t1
29446
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
29447
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
29448
UPDATE t1 SET f_int2 = f_int1,
29449
f_char1 = CAST(f_int1 AS CHAR),
29450
f_char2 = CAST(f_int1 AS CHAR),
29451
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
29452
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
29453
SET AUTOCOMMIT= 0;
29454
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29455
SELECT f_int1, f_int1, '', '', 'was inserted'
29456
FROM t0_template source_tab
29457
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
29458
	
29459
# check transactions-1 success: 	1
29460
COMMIT WORK;
29461
	
29462
# check transactions-2 success: 	1
29463
ROLLBACK WORK;
29464
	
29465
# check transactions-3 success: 	1
29466
DELETE FROM t1 WHERE f_charbig = 'was inserted';
29467
COMMIT WORK;
29468
ROLLBACK WORK;
29469
	
29470
# check transactions-4 success: 	1
29471
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29472
SELECT f_int1, f_int1, '', '', 'was inserted'
29473
FROM t0_template source_tab
29474
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
29475
	
29476
# check transactions-5 success: 	1
29477
ROLLBACK WORK;
29478
	
29479
# check transactions-6 success: 	1
29480
# INFO: Storage engine used for t1 seems to be transactional.
29481
COMMIT;
29482
	
29483
# check transactions-7 success: 	1
29484
DELETE FROM t1 WHERE f_charbig = 'was inserted';
29485
COMMIT WORK;
29486
SET @@session.sql_mode = 'traditional';
29487
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
29488
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29489
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
29490
'', '', 'was inserted' FROM t0_template
29491
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
29492
ERROR 22012: Division by 0
29493
COMMIT;
29494
	
29495
# check transactions-8 success: 	1
29496
# INFO: Storage engine used for t1 seems to be able to revert
29497
#       changes made by the failing statement.
29498
SET @@session.sql_mode = '';
29499
SET AUTOCOMMIT= 1;
29500
DELETE FROM t1 WHERE f_charbig = 'was inserted';
29501
COMMIT WORK;
29502
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
29503
	
29504
# check special-1 success: 	1
29505
UPDATE t1 SET f_charbig = '';
29506
	
29507
# check special-2 success: 	1
29508
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
29509
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
29510
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
29511
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29512
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29513
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29514
'just inserted' FROM t0_template
29515
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29516
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
29517
BEGIN
29518
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29519
f_charbig = 'updated by trigger'
29520
      WHERE f_int1 = new.f_int1;
29521
END|
29522
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29523
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
29524
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29525
	
29526
# check trigger-1 success: 	1
29527
DROP TRIGGER trg_1;
29528
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29529
f_int2 = CAST(f_char1 AS SIGNED INT),
29530
f_charbig = 'just inserted'
29531
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29532
DELETE FROM t0_aux
29533
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29534
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29535
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29536
'just inserted' FROM t0_template
29537
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29538
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
29539
BEGIN
29540
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29541
f_charbig = 'updated by trigger'
29542
      WHERE f_int1 = new.f_int1;
29543
END|
29544
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29545
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
29546
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29547
	
29548
# check trigger-2 success: 	1
29549
DROP TRIGGER trg_1;
29550
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29551
f_int2 = CAST(f_char1 AS SIGNED INT),
29552
f_charbig = 'just inserted'
29553
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29554
DELETE FROM t0_aux
29555
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29556
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29557
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29558
'just inserted' FROM t0_template
29559
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29560
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
29561
BEGIN
29562
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29563
f_charbig = 'updated by trigger'
29564
      WHERE f_int1 = new.f_int1;
29565
END|
29566
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
29567
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
29568
	
29569
# check trigger-3 success: 	1
29570
DROP TRIGGER trg_1;
29571
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29572
f_int2 = CAST(f_char1 AS SIGNED INT),
29573
f_charbig = 'just inserted'
29574
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29575
DELETE FROM t0_aux
29576
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29577
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29578
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29579
'just inserted' FROM t0_template
29580
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29581
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
29582
BEGIN
29583
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29584
f_charbig = 'updated by trigger'
29585
      WHERE f_int1 = - old.f_int1;
29586
END|
29587
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
29588
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
29589
	
29590
# check trigger-4 success: 	1
29591
DROP TRIGGER trg_1;
29592
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29593
f_int2 = CAST(f_char1 AS SIGNED INT),
29594
f_charbig = 'just inserted'
29595
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29596
DELETE FROM t0_aux
29597
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29598
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29599
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29600
'just inserted' FROM t0_template
29601
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29602
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
29603
BEGIN
29604
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29605
f_charbig = 'updated by trigger'
29606
      WHERE f_int1 = new.f_int1;
29607
END|
29608
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
29609
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
29610
	
29611
# check trigger-5 success: 	1
29612
DROP TRIGGER trg_1;
29613
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29614
f_int2 = CAST(f_char1 AS SIGNED INT),
29615
f_charbig = 'just inserted'
29616
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29617
DELETE FROM t0_aux
29618
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29619
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29620
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29621
'just inserted' FROM t0_template
29622
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29623
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
29624
BEGIN
29625
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29626
f_charbig = 'updated by trigger'
29627
      WHERE f_int1 = - old.f_int1;
29628
END|
29629
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
29630
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
29631
	
29632
# check trigger-6 success: 	1
29633
DROP TRIGGER trg_1;
29634
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29635
f_int2 = CAST(f_char1 AS SIGNED INT),
29636
f_charbig = 'just inserted'
29637
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29638
DELETE FROM t0_aux
29639
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29640
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29641
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29642
'just inserted' FROM t0_template
29643
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29644
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
29645
BEGIN
29646
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29647
f_charbig = 'updated by trigger'
29648
      WHERE f_int1 = - old.f_int1;
29649
END|
29650
DELETE FROM t0_aux
29651
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
29652
	
29653
# check trigger-7 success: 	1
29654
DROP TRIGGER trg_1;
29655
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29656
f_int2 = CAST(f_char1 AS SIGNED INT),
29657
f_charbig = 'just inserted'
29658
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29659
DELETE FROM t0_aux
29660
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29661
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
29662
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
29663
'just inserted' FROM t0_template
29664
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29665
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
29666
BEGIN
29667
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
29668
f_charbig = 'updated by trigger'
29669
      WHERE f_int1 = - old.f_int1;
29670
END|
29671
DELETE FROM t0_aux
29672
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
29673
	
29674
# check trigger-8 success: 	1
29675
DROP TRIGGER trg_1;
29676
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29677
f_int2 = CAST(f_char1 AS SIGNED INT),
29678
f_charbig = 'just inserted'
29679
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
29680
DELETE FROM t0_aux
29681
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29682
DELETE FROM t1
29683
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
29684
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
29685
BEGIN
29686
SET new.f_int1 = old.f_int1 + @max_row,
29687
new.f_int2 = old.f_int2 - @max_row,
29688
new.f_charbig = '####updated per update trigger####';
29689
END|
29690
UPDATE t1
29691
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
29692
f_charbig = '####updated per update statement itself####';
29693
	
29694
# check trigger-9 success: 	1
29695
DROP TRIGGER trg_2;
29696
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29697
f_int2 = CAST(f_char1 AS SIGNED INT),
29698
f_charbig = CONCAT('===',f_char1,'===');
29699
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
29700
BEGIN
29701
SET new.f_int1 = new.f_int1 + @max_row,
29702
new.f_int2 = new.f_int2 - @max_row,
29703
new.f_charbig = '####updated per update trigger####';
29704
END|
29705
UPDATE t1
29706
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
29707
f_charbig = '####updated per update statement itself####';
29708
	
29709
# check trigger-10 success: 	1
29710
DROP TRIGGER trg_2;
29711
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29712
f_int2 = CAST(f_char1 AS SIGNED INT),
29713
f_charbig = CONCAT('===',f_char1,'===');
29714
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
29715
BEGIN
29716
SET new.f_int1 = @my_max1 + @counter,
29717
new.f_int2 = @my_min2 - @counter,
29718
new.f_charbig = '####updated per insert trigger####';
29719
SET @counter = @counter + 1;
29720
END|
29721
SET @counter = 1;
29722
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
29723
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29724
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
29725
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
29726
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
29727
ORDER BY f_int1;
29728
DROP TRIGGER trg_3;
29729
	
29730
# check trigger-11 success: 	1
29731
DELETE FROM t1
29732
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
29733
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
29734
AND f_charbig = '####updated per insert trigger####';
29735
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
29736
BEGIN
29737
SET new.f_int1 = @my_max1 + @counter,
29738
new.f_int2 = @my_min2 - @counter,
29739
new.f_charbig = '####updated per insert trigger####';
29740
SET @counter = @counter + 1;
29741
END|
29742
SET @counter = 1;
29743
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
29744
INSERT INTO t1 (f_char1, f_char2, f_charbig)
29745
SELECT CAST(f_int1 AS CHAR),
29746
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
29747
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
29748
ORDER BY f_int1;
29749
DROP TRIGGER trg_3;
29750
	
29751
# check trigger-12 success: 	1
29752
DELETE FROM t1
29753
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
29754
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
29755
AND f_charbig = '####updated per insert trigger####';
29756
ANALYZE  TABLE t1;
29757
Table	Op	Msg_type	Msg_text
29758
test.t1	analyze	note	The storage engine for the table doesn't support analyze
29759
CHECK    TABLE t1 EXTENDED;
29760
Table	Op	Msg_type	Msg_text
29761
test.t1	check	note	The storage engine for the table doesn't support check
29762
CHECKSUM TABLE t1 EXTENDED;
29763
Table	Checksum
29764
test.t1	<some_value>
29765
OPTIMIZE TABLE t1;
29766
Table	Op	Msg_type	Msg_text
29767
test.t1	optimize	note	The storage engine for the table doesn't support optimize
29768
# check layout success:    1
29769
REPAIR   TABLE t1 EXTENDED;
29770
Table	Op	Msg_type	Msg_text
29771
test.t1	repair	note	The storage engine for the table doesn't support repair
29772
# check layout success:    1
29773
TRUNCATE t1;
29774
	
29775
# check TRUNCATE success: 	1
29776
# check layout success:    1
29777
# End usability test (inc/partition_check.inc)
29778
DROP TABLE t1;
29779
CREATE TABLE t1 (
29780
f_int1 INTEGER,
29781
f_int2 INTEGER,
29782
f_char1 CHAR(20),
29783
f_char2 CHAR(20),
29784
f_charbig VARCHAR(1000)
29785
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
29786
)
29787
PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int2)
29788
(PARTITION part1 VALUES LESS THAN (0)
29789
(SUBPARTITION subpart11, SUBPARTITION subpart12),
29790
PARTITION part2 VALUES LESS THAN (5)
29791
(SUBPARTITION subpart21, SUBPARTITION subpart22),
29792
PARTITION part3 VALUES LESS THAN (10)
29793
(SUBPARTITION subpart31, SUBPARTITION subpart32),
29794
PARTITION part4 VALUES LESS THAN (2147483646)
29795
(SUBPARTITION subpart41, SUBPARTITION subpart42));
29796
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
29797
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
29798
# Start usability test (inc/partition_check.inc)
29799
create_command
29800
SHOW CREATE TABLE t1;
29801
Table	Create Table
29802
t1	CREATE TABLE `t1` (
29803
  `f_int1` int(11) DEFAULT NULL,
29804
  `f_int2` int(11) DEFAULT NULL,
29805
  `f_char1` char(20) DEFAULT NULL,
29806
  `f_char2` char(20) DEFAULT NULL,
29807
  `f_charbig` varchar(1000) DEFAULT NULL,
29808
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
29809
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
29810
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (f_int1) SUBPARTITION BY KEY (f_int2) (PARTITION part1 VALUES LESS THAN (0) (SUBPARTITION subpart11 ENGINE = InnoDB, SUBPARTITION subpart12 ENGINE = InnoDB), PARTITION part2 VALUES LESS THAN (5) (SUBPARTITION subpart21 ENGINE = InnoDB, SUBPARTITION subpart22 ENGINE = InnoDB), PARTITION part3 VALUES LESS THAN (10) (SUBPARTITION subpart31 ENGINE = InnoDB, SUBPARTITION subpart32 ENGINE = InnoDB), PARTITION part4 VALUES LESS THAN (2147483646) (SUBPARTITION subpart41 ENGINE = InnoDB, SUBPARTITION subpart42 ENGINE = InnoDB)) */
29811
29812
unified filelist
29813
$MYSQLTEST_VARDIR/master-data/test/t1.frm
29814
$MYSQLTEST_VARDIR/master-data/test/t1.par
29815
29816
# check prerequisites-1 success:    1
29817
# check COUNT(*) success:    1
29818
# check MIN/MAX(f_int1) success:    1
29819
# check MIN/MAX(f_int2) success:    1
29820
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29821
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
29822
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
29823
WHERE f_int1 IN (2,3);
29824
ERROR 23000: Can't write; duplicate key in table 't1'
29825
# check prerequisites-3 success:    1
29826
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
29827
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29828
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
29829
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
29830
WHERE f_int1 IN (2,3);
29831
DELETE FROM t1 WHERE f_charbig = 'delete me';
29832
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29833
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
29834
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
29835
WHERE f_int1 IN (2,3);
29836
DELETE FROM t1 WHERE f_charbig = 'delete me';
29837
# check read via f_int1 success: 1
29838
# check read via f_int2 success: 1
29839
	
29840
# check multiple-1 success: 	1
29841
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
29842
	
29843
# check multiple-2 success: 	1
29844
INSERT INTO t1 SELECT * FROM t0_template
29845
WHERE MOD(f_int1,3) = 0;
29846
	
29847
# check multiple-3 success: 	1
29848
UPDATE t1 SET f_int1 = f_int1 + @max_row
29849
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
29850
AND @max_row_div2 + @max_row_div4;
29851
	
29852
# check multiple-4 success: 	1
29853
DELETE FROM t1
29854
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
29855
AND @max_row_div2 + @max_row_div4 + @max_row;
29856
	
29857
# check multiple-5 success: 	1
29858
SELECT COUNT(*) INTO @try_count FROM t0_template
29859
WHERE MOD(f_int1,3) = 0
29860
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
29861
SELECT COUNT(*) INTO @clash_count
29862
FROM t1 INNER JOIN t0_template USING(f_int1)
29863
WHERE MOD(f_int1,3) = 0
29864
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
29865
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
29866
INSERT INTO t1
29867
SET f_int1 = @cur_value , f_int2 = @cur_value,
29868
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
29869
f_charbig = '#SINGLE#';
29870
	
29871
# check single-1 success: 	1
29872
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
29873
INSERT INTO t1
29874
SET f_int1 = @cur_value , f_int2 = @cur_value,
29875
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
29876
f_charbig = '#SINGLE#';
29877
	
29878
# check single-2 success: 	1
29879
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
29880
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
29881
UPDATE t1 SET f_int1 = @cur_value2
29882
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
29883
	
29884
# check single-3 success: 	1
29885
SET @cur_value1= -1;
29886
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
29887
UPDATE t1 SET f_int1 = @cur_value1
29888
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
29889
	
29890
# check single-4 success: 	1
29891
SELECT MAX(f_int1) INTO @cur_value FROM t1;
29892
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
29893
	
29894
# check single-5 success: 	1
29895
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
29896
	
29897
# check single-6 success: 	1
29898
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
29899
ERROR HY000: Table has no partition for value 2147483647
29900
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
29901
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
29902
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
29903
f_charbig = '#NULL#';
29904
INSERT INTO t1
29905
SET f_int1 = NULL , f_int2 = -@max_row,
29906
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
29907
f_charbig = '#NULL#';
29908
# check null success:    1
29909
	
29910
# check null-1 success: 	1
29911
UPDATE t1 SET f_int1 = -@max_row
29912
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
29913
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
29914
	
29915
# check null-2 success: 	1
29916
UPDATE t1 SET f_int1 = NULL
29917
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
29918
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
29919
	
29920
# check null-3 success: 	1
29921
DELETE FROM t1
29922
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
29923
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
29924
	
29925
# check null-4 success: 	1
29926
DELETE FROM t1
29927
WHERE f_int1 = 0 AND f_int2 = 0
29928
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
29929
AND f_charbig = '#NULL#';
29930
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29931
SELECT f_int1, f_int1, '', '', 'was inserted'
29932
   FROM t0_template source_tab
29933
WHERE MOD(f_int1,3) = 0
29934
AND f_int1 BETWEEN @max_row_div2 AND @max_row
29935
ON DUPLICATE KEY
29936
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
29937
f_int2 = 2 * @max_row + source_tab.f_int1,
29938
f_charbig = 'was updated';
29939
	
29940
# check unique-1-a success: 	1
29941
	
29942
# check unique-1-b success: 	1
29943
DELETE FROM t1 WHERE f_charbig = 'was inserted';
29944
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
29945
f_int2 = CAST(f_char1 AS SIGNED INT),
29946
f_charbig = CONCAT('===',f_char1,'===')
29947
WHERE f_charbig = 'was updated';
29948
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29949
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
29950
   FROM t0_template source_tab
29951
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
29952
	
29953
# check replace success: 	1
29954
DELETE FROM t1
29955
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
29956
DELETE FROM t1
29957
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
29958
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
29959
UPDATE t1 SET f_int2 = f_int1,
29960
f_char1 = CAST(f_int1 AS CHAR),
29961
f_char2 = CAST(f_int1 AS CHAR),
29962
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
29963
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
29964
SET AUTOCOMMIT= 0;
29965
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29966
SELECT f_int1, f_int1, '', '', 'was inserted'
29967
FROM t0_template source_tab
29968
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
29969
	
29970
# check transactions-1 success: 	1
29971
COMMIT WORK;
29972
	
29973
# check transactions-2 success: 	1
29974
ROLLBACK WORK;
29975
	
29976
# check transactions-3 success: 	1
29977
DELETE FROM t1 WHERE f_charbig = 'was inserted';
29978
COMMIT WORK;
29979
ROLLBACK WORK;
29980
	
29981
# check transactions-4 success: 	1
29982
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
29983
SELECT f_int1, f_int1, '', '', 'was inserted'
29984
FROM t0_template source_tab
29985
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
29986
	
29987
# check transactions-5 success: 	1
29988
ROLLBACK WORK;
29989
	
29990
# check transactions-6 success: 	1
29991
# INFO: Storage engine used for t1 seems to be transactional.
29992
COMMIT;
29993
	
29994
# check transactions-7 success: 	1
29995
DELETE FROM t1 WHERE f_charbig = 'was inserted';
29996
COMMIT WORK;
29997
SET @@session.sql_mode = 'traditional';
29998
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
29999
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30000
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
30001
'', '', 'was inserted' FROM t0_template
30002
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
30003
ERROR 22012: Division by 0
30004
COMMIT;
30005
	
30006
# check transactions-8 success: 	1
30007
# INFO: Storage engine used for t1 seems to be able to revert
30008
#       changes made by the failing statement.
30009
SET @@session.sql_mode = '';
30010
SET AUTOCOMMIT= 1;
30011
DELETE FROM t1 WHERE f_charbig = 'was inserted';
30012
COMMIT WORK;
30013
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
30014
	
30015
# check special-1 success: 	1
30016
UPDATE t1 SET f_charbig = '';
30017
	
30018
# check special-2 success: 	1
30019
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
30020
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
30021
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
30022
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30023
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30024
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30025
'just inserted' FROM t0_template
30026
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30027
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
30028
BEGIN
30029
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30030
f_charbig = 'updated by trigger'
30031
      WHERE f_int1 = new.f_int1;
30032
END|
30033
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30034
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
30035
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30036
	
30037
# check trigger-1 success: 	1
30038
DROP TRIGGER trg_1;
30039
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30040
f_int2 = CAST(f_char1 AS SIGNED INT),
30041
f_charbig = 'just inserted'
30042
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30043
DELETE FROM t0_aux
30044
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30045
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30046
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30047
'just inserted' FROM t0_template
30048
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30049
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
30050
BEGIN
30051
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30052
f_charbig = 'updated by trigger'
30053
      WHERE f_int1 = new.f_int1;
30054
END|
30055
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30056
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
30057
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30058
	
30059
# check trigger-2 success: 	1
30060
DROP TRIGGER trg_1;
30061
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30062
f_int2 = CAST(f_char1 AS SIGNED INT),
30063
f_charbig = 'just inserted'
30064
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30065
DELETE FROM t0_aux
30066
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30067
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30068
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30069
'just inserted' FROM t0_template
30070
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30071
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
30072
BEGIN
30073
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30074
f_charbig = 'updated by trigger'
30075
      WHERE f_int1 = new.f_int1;
30076
END|
30077
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
30078
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
30079
	
30080
# check trigger-3 success: 	1
30081
DROP TRIGGER trg_1;
30082
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30083
f_int2 = CAST(f_char1 AS SIGNED INT),
30084
f_charbig = 'just inserted'
30085
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30086
DELETE FROM t0_aux
30087
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30088
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30089
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30090
'just inserted' FROM t0_template
30091
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30092
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
30093
BEGIN
30094
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30095
f_charbig = 'updated by trigger'
30096
      WHERE f_int1 = - old.f_int1;
30097
END|
30098
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
30099
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
30100
	
30101
# check trigger-4 success: 	1
30102
DROP TRIGGER trg_1;
30103
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30104
f_int2 = CAST(f_char1 AS SIGNED INT),
30105
f_charbig = 'just inserted'
30106
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30107
DELETE FROM t0_aux
30108
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30109
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30110
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30111
'just inserted' FROM t0_template
30112
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30113
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
30114
BEGIN
30115
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30116
f_charbig = 'updated by trigger'
30117
      WHERE f_int1 = new.f_int1;
30118
END|
30119
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
30120
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
30121
	
30122
# check trigger-5 success: 	1
30123
DROP TRIGGER trg_1;
30124
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30125
f_int2 = CAST(f_char1 AS SIGNED INT),
30126
f_charbig = 'just inserted'
30127
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30128
DELETE FROM t0_aux
30129
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30130
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30131
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30132
'just inserted' FROM t0_template
30133
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30134
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
30135
BEGIN
30136
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30137
f_charbig = 'updated by trigger'
30138
      WHERE f_int1 = - old.f_int1;
30139
END|
30140
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
30141
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
30142
	
30143
# check trigger-6 success: 	1
30144
DROP TRIGGER trg_1;
30145
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30146
f_int2 = CAST(f_char1 AS SIGNED INT),
30147
f_charbig = 'just inserted'
30148
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30149
DELETE FROM t0_aux
30150
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30151
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30152
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30153
'just inserted' FROM t0_template
30154
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30155
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
30156
BEGIN
30157
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30158
f_charbig = 'updated by trigger'
30159
      WHERE f_int1 = - old.f_int1;
30160
END|
30161
DELETE FROM t0_aux
30162
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
30163
	
30164
# check trigger-7 success: 	1
30165
DROP TRIGGER trg_1;
30166
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30167
f_int2 = CAST(f_char1 AS SIGNED INT),
30168
f_charbig = 'just inserted'
30169
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30170
DELETE FROM t0_aux
30171
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30172
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30173
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30174
'just inserted' FROM t0_template
30175
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30176
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
30177
BEGIN
30178
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30179
f_charbig = 'updated by trigger'
30180
      WHERE f_int1 = - old.f_int1;
30181
END|
30182
DELETE FROM t0_aux
30183
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
30184
	
30185
# check trigger-8 success: 	1
30186
DROP TRIGGER trg_1;
30187
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30188
f_int2 = CAST(f_char1 AS SIGNED INT),
30189
f_charbig = 'just inserted'
30190
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30191
DELETE FROM t0_aux
30192
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30193
DELETE FROM t1
30194
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30195
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
30196
BEGIN
30197
SET new.f_int1 = old.f_int1 + @max_row,
30198
new.f_int2 = old.f_int2 - @max_row,
30199
new.f_charbig = '####updated per update trigger####';
30200
END|
30201
UPDATE t1
30202
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
30203
f_charbig = '####updated per update statement itself####';
30204
	
30205
# check trigger-9 success: 	1
30206
DROP TRIGGER trg_2;
30207
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30208
f_int2 = CAST(f_char1 AS SIGNED INT),
30209
f_charbig = CONCAT('===',f_char1,'===');
30210
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
30211
BEGIN
30212
SET new.f_int1 = new.f_int1 + @max_row,
30213
new.f_int2 = new.f_int2 - @max_row,
30214
new.f_charbig = '####updated per update trigger####';
30215
END|
30216
UPDATE t1
30217
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
30218
f_charbig = '####updated per update statement itself####';
30219
	
30220
# check trigger-10 success: 	1
30221
DROP TRIGGER trg_2;
30222
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30223
f_int2 = CAST(f_char1 AS SIGNED INT),
30224
f_charbig = CONCAT('===',f_char1,'===');
30225
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
30226
BEGIN
30227
SET new.f_int1 = @my_max1 + @counter,
30228
new.f_int2 = @my_min2 - @counter,
30229
new.f_charbig = '####updated per insert trigger####';
30230
SET @counter = @counter + 1;
30231
END|
30232
SET @counter = 1;
30233
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
30234
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30235
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
30236
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
30237
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
30238
ORDER BY f_int1;
30239
DROP TRIGGER trg_3;
30240
	
30241
# check trigger-11 success: 	1
30242
DELETE FROM t1
30243
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
30244
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
30245
AND f_charbig = '####updated per insert trigger####';
30246
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
30247
BEGIN
30248
SET new.f_int1 = @my_max1 + @counter,
30249
new.f_int2 = @my_min2 - @counter,
30250
new.f_charbig = '####updated per insert trigger####';
30251
SET @counter = @counter + 1;
30252
END|
30253
SET @counter = 1;
30254
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
30255
INSERT INTO t1 (f_char1, f_char2, f_charbig)
30256
SELECT CAST(f_int1 AS CHAR),
30257
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
30258
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
30259
ORDER BY f_int1;
30260
DROP TRIGGER trg_3;
30261
	
30262
# check trigger-12 success: 	1
30263
DELETE FROM t1
30264
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
30265
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
30266
AND f_charbig = '####updated per insert trigger####';
30267
ANALYZE  TABLE t1;
30268
Table	Op	Msg_type	Msg_text
30269
test.t1	analyze	note	The storage engine for the table doesn't support analyze
30270
CHECK    TABLE t1 EXTENDED;
30271
Table	Op	Msg_type	Msg_text
30272
test.t1	check	note	The storage engine for the table doesn't support check
30273
CHECKSUM TABLE t1 EXTENDED;
30274
Table	Checksum
30275
test.t1	<some_value>
30276
OPTIMIZE TABLE t1;
30277
Table	Op	Msg_type	Msg_text
30278
test.t1	optimize	note	The storage engine for the table doesn't support optimize
30279
# check layout success:    1
30280
REPAIR   TABLE t1 EXTENDED;
30281
Table	Op	Msg_type	Msg_text
30282
test.t1	repair	note	The storage engine for the table doesn't support repair
30283
# check layout success:    1
30284
TRUNCATE t1;
30285
	
30286
# check TRUNCATE success: 	1
30287
# check layout success:    1
30288
# End usability test (inc/partition_check.inc)
30289
DROP TABLE t1;
30290
CREATE TABLE t1 (
30291
f_int1 INTEGER,
30292
f_int2 INTEGER,
30293
f_char1 CHAR(20),
30294
f_char2 CHAR(20),
30295
f_charbig VARCHAR(1000)
30296
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
30297
)
30298
PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int2 + 1)
30299
(PARTITION part1 VALUES IN (0)
30300
(SUBPARTITION sp11, SUBPARTITION sp12),
30301
PARTITION part2 VALUES IN (1)
30302
(SUBPARTITION sp21, SUBPARTITION sp22),
30303
PARTITION part3 VALUES IN (2)
30304
(SUBPARTITION sp31, SUBPARTITION sp32),
30305
PARTITION part4 VALUES IN (NULL)
30306
(SUBPARTITION sp41, SUBPARTITION sp42));
30307
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
30308
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
30309
# Start usability test (inc/partition_check.inc)
30310
create_command
30311
SHOW CREATE TABLE t1;
30312
Table	Create Table
30313
t1	CREATE TABLE `t1` (
30314
  `f_int1` int(11) DEFAULT NULL,
30315
  `f_int2` int(11) DEFAULT NULL,
30316
  `f_char1` char(20) DEFAULT NULL,
30317
  `f_char2` char(20) DEFAULT NULL,
30318
  `f_charbig` varchar(1000) DEFAULT NULL,
30319
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
30320
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
30321
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,3))) SUBPARTITION BY HASH (f_int2 + 1) (PARTITION part1 VALUES IN (0) (SUBPARTITION sp11 ENGINE = InnoDB, SUBPARTITION sp12 ENGINE = InnoDB), PARTITION part2 VALUES IN (1) (SUBPARTITION sp21 ENGINE = InnoDB, SUBPARTITION sp22 ENGINE = InnoDB), PARTITION part3 VALUES IN (2) (SUBPARTITION sp31 ENGINE = InnoDB, SUBPARTITION sp32 ENGINE = InnoDB), PARTITION part4 VALUES IN (NULL) (SUBPARTITION sp41 ENGINE = InnoDB, SUBPARTITION sp42 ENGINE = InnoDB)) */
30322
30323
unified filelist
30324
$MYSQLTEST_VARDIR/master-data/test/t1.frm
30325
$MYSQLTEST_VARDIR/master-data/test/t1.par
30326
30327
# check prerequisites-1 success:    1
30328
# check COUNT(*) success:    1
30329
# check MIN/MAX(f_int1) success:    1
30330
# check MIN/MAX(f_int2) success:    1
30331
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30332
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
30333
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
30334
WHERE f_int1 IN (2,3);
30335
ERROR 23000: Can't write; duplicate key in table 't1'
30336
# check prerequisites-3 success:    1
30337
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
30338
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30339
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
30340
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
30341
WHERE f_int1 IN (2,3);
30342
DELETE FROM t1 WHERE f_charbig = 'delete me';
30343
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30344
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
30345
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
30346
WHERE f_int1 IN (2,3);
30347
DELETE FROM t1 WHERE f_charbig = 'delete me';
30348
# check read via f_int1 success: 1
30349
# check read via f_int2 success: 1
30350
	
30351
# check multiple-1 success: 	1
30352
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
30353
	
30354
# check multiple-2 success: 	1
30355
INSERT INTO t1 SELECT * FROM t0_template
30356
WHERE MOD(f_int1,3) = 0;
30357
	
30358
# check multiple-3 success: 	1
30359
UPDATE t1 SET f_int1 = f_int1 + @max_row
30360
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
30361
AND @max_row_div2 + @max_row_div4;
30362
	
30363
# check multiple-4 success: 	1
30364
DELETE FROM t1
30365
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
30366
AND @max_row_div2 + @max_row_div4 + @max_row;
30367
	
30368
# check multiple-5 success: 	1
30369
SELECT COUNT(*) INTO @try_count FROM t0_template
30370
WHERE MOD(f_int1,3) = 0
30371
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
30372
SELECT COUNT(*) INTO @clash_count
30373
FROM t1 INNER JOIN t0_template USING(f_int1)
30374
WHERE MOD(f_int1,3) = 0
30375
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
30376
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
30377
INSERT INTO t1
30378
SET f_int1 = @cur_value , f_int2 = @cur_value,
30379
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
30380
f_charbig = '#SINGLE#';
30381
	
30382
# check single-1 success: 	1
30383
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
30384
INSERT INTO t1
30385
SET f_int1 = @cur_value , f_int2 = @cur_value,
30386
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
30387
f_charbig = '#SINGLE#';
30388
	
30389
# check single-2 success: 	1
30390
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
30391
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
30392
UPDATE t1 SET f_int1 = @cur_value2
30393
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
30394
	
30395
# check single-3 success: 	1
30396
SET @cur_value1= -1;
30397
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
30398
UPDATE t1 SET f_int1 = @cur_value1
30399
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
30400
	
30401
# check single-4 success: 	1
30402
SELECT MAX(f_int1) INTO @cur_value FROM t1;
30403
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
30404
	
30405
# check single-5 success: 	1
30406
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
30407
	
30408
# check single-6 success: 	1
30409
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
30410
	
30411
# check single-7 success: 	1
30412
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
30413
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
30414
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
30415
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
30416
f_charbig = '#NULL#';
30417
INSERT INTO t1
30418
SET f_int1 = NULL , f_int2 = -@max_row,
30419
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
30420
f_charbig = '#NULL#';
30421
# check null success:    1
30422
	
30423
# check null-1 success: 	1
30424
UPDATE t1 SET f_int1 = -@max_row
30425
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
30426
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
30427
	
30428
# check null-2 success: 	1
30429
UPDATE t1 SET f_int1 = NULL
30430
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
30431
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
30432
	
30433
# check null-3 success: 	1
30434
DELETE FROM t1
30435
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
30436
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
30437
	
30438
# check null-4 success: 	1
30439
DELETE FROM t1
30440
WHERE f_int1 = 0 AND f_int2 = 0
30441
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
30442
AND f_charbig = '#NULL#';
30443
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30444
SELECT f_int1, f_int1, '', '', 'was inserted'
30445
   FROM t0_template source_tab
30446
WHERE MOD(f_int1,3) = 0
30447
AND f_int1 BETWEEN @max_row_div2 AND @max_row
30448
ON DUPLICATE KEY
30449
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
30450
f_int2 = 2 * @max_row + source_tab.f_int1,
30451
f_charbig = 'was updated';
30452
	
30453
# check unique-1-a success: 	1
30454
	
30455
# check unique-1-b success: 	1
30456
DELETE FROM t1 WHERE f_charbig = 'was inserted';
30457
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30458
f_int2 = CAST(f_char1 AS SIGNED INT),
30459
f_charbig = CONCAT('===',f_char1,'===')
30460
WHERE f_charbig = 'was updated';
30461
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30462
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
30463
   FROM t0_template source_tab
30464
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
30465
	
30466
# check replace success: 	1
30467
DELETE FROM t1
30468
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
30469
DELETE FROM t1
30470
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
30471
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
30472
UPDATE t1 SET f_int2 = f_int1,
30473
f_char1 = CAST(f_int1 AS CHAR),
30474
f_char2 = CAST(f_int1 AS CHAR),
30475
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
30476
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
30477
SET AUTOCOMMIT= 0;
30478
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30479
SELECT f_int1, f_int1, '', '', 'was inserted'
30480
FROM t0_template source_tab
30481
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
30482
	
30483
# check transactions-1 success: 	1
30484
COMMIT WORK;
30485
	
30486
# check transactions-2 success: 	1
30487
ROLLBACK WORK;
30488
	
30489
# check transactions-3 success: 	1
30490
DELETE FROM t1 WHERE f_charbig = 'was inserted';
30491
COMMIT WORK;
30492
ROLLBACK WORK;
30493
	
30494
# check transactions-4 success: 	1
30495
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30496
SELECT f_int1, f_int1, '', '', 'was inserted'
30497
FROM t0_template source_tab
30498
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
30499
	
30500
# check transactions-5 success: 	1
30501
ROLLBACK WORK;
30502
	
30503
# check transactions-6 success: 	1
30504
# INFO: Storage engine used for t1 seems to be transactional.
30505
COMMIT;
30506
	
30507
# check transactions-7 success: 	1
30508
DELETE FROM t1 WHERE f_charbig = 'was inserted';
30509
COMMIT WORK;
30510
SET @@session.sql_mode = 'traditional';
30511
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
30512
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30513
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
30514
'', '', 'was inserted' FROM t0_template
30515
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
30516
ERROR 22012: Division by 0
30517
COMMIT;
30518
	
30519
# check transactions-8 success: 	1
30520
# INFO: Storage engine used for t1 seems to be able to revert
30521
#       changes made by the failing statement.
30522
SET @@session.sql_mode = '';
30523
SET AUTOCOMMIT= 1;
30524
DELETE FROM t1 WHERE f_charbig = 'was inserted';
30525
COMMIT WORK;
30526
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
30527
	
30528
# check special-1 success: 	1
30529
UPDATE t1 SET f_charbig = '';
30530
	
30531
# check special-2 success: 	1
30532
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
30533
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
30534
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
30535
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30536
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30537
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30538
'just inserted' FROM t0_template
30539
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30540
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
30541
BEGIN
30542
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30543
f_charbig = 'updated by trigger'
30544
      WHERE f_int1 = new.f_int1;
30545
END|
30546
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30547
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
30548
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30549
	
30550
# check trigger-1 success: 	1
30551
DROP TRIGGER trg_1;
30552
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30553
f_int2 = CAST(f_char1 AS SIGNED INT),
30554
f_charbig = 'just inserted'
30555
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30556
DELETE FROM t0_aux
30557
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30558
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30559
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30560
'just inserted' FROM t0_template
30561
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30562
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
30563
BEGIN
30564
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30565
f_charbig = 'updated by trigger'
30566
      WHERE f_int1 = new.f_int1;
30567
END|
30568
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30569
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
30570
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30571
	
30572
# check trigger-2 success: 	1
30573
DROP TRIGGER trg_1;
30574
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30575
f_int2 = CAST(f_char1 AS SIGNED INT),
30576
f_charbig = 'just inserted'
30577
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30578
DELETE FROM t0_aux
30579
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30580
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30581
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30582
'just inserted' FROM t0_template
30583
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30584
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
30585
BEGIN
30586
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30587
f_charbig = 'updated by trigger'
30588
      WHERE f_int1 = new.f_int1;
30589
END|
30590
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
30591
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
30592
	
30593
# check trigger-3 success: 	1
30594
DROP TRIGGER trg_1;
30595
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30596
f_int2 = CAST(f_char1 AS SIGNED INT),
30597
f_charbig = 'just inserted'
30598
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30599
DELETE FROM t0_aux
30600
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30601
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30602
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30603
'just inserted' FROM t0_template
30604
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30605
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
30606
BEGIN
30607
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30608
f_charbig = 'updated by trigger'
30609
      WHERE f_int1 = - old.f_int1;
30610
END|
30611
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
30612
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
30613
	
30614
# check trigger-4 success: 	1
30615
DROP TRIGGER trg_1;
30616
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30617
f_int2 = CAST(f_char1 AS SIGNED INT),
30618
f_charbig = 'just inserted'
30619
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30620
DELETE FROM t0_aux
30621
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30622
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30623
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30624
'just inserted' FROM t0_template
30625
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30626
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
30627
BEGIN
30628
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30629
f_charbig = 'updated by trigger'
30630
      WHERE f_int1 = new.f_int1;
30631
END|
30632
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
30633
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
30634
	
30635
# check trigger-5 success: 	1
30636
DROP TRIGGER trg_1;
30637
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30638
f_int2 = CAST(f_char1 AS SIGNED INT),
30639
f_charbig = 'just inserted'
30640
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30641
DELETE FROM t0_aux
30642
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30643
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30644
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30645
'just inserted' FROM t0_template
30646
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30647
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
30648
BEGIN
30649
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30650
f_charbig = 'updated by trigger'
30651
      WHERE f_int1 = - old.f_int1;
30652
END|
30653
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
30654
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
30655
	
30656
# check trigger-6 success: 	1
30657
DROP TRIGGER trg_1;
30658
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30659
f_int2 = CAST(f_char1 AS SIGNED INT),
30660
f_charbig = 'just inserted'
30661
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30662
DELETE FROM t0_aux
30663
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30664
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30665
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30666
'just inserted' FROM t0_template
30667
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30668
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
30669
BEGIN
30670
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30671
f_charbig = 'updated by trigger'
30672
      WHERE f_int1 = - old.f_int1;
30673
END|
30674
DELETE FROM t0_aux
30675
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
30676
	
30677
# check trigger-7 success: 	1
30678
DROP TRIGGER trg_1;
30679
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30680
f_int2 = CAST(f_char1 AS SIGNED INT),
30681
f_charbig = 'just inserted'
30682
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30683
DELETE FROM t0_aux
30684
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30685
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
30686
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
30687
'just inserted' FROM t0_template
30688
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30689
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
30690
BEGIN
30691
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
30692
f_charbig = 'updated by trigger'
30693
      WHERE f_int1 = - old.f_int1;
30694
END|
30695
DELETE FROM t0_aux
30696
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
30697
	
30698
# check trigger-8 success: 	1
30699
DROP TRIGGER trg_1;
30700
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30701
f_int2 = CAST(f_char1 AS SIGNED INT),
30702
f_charbig = 'just inserted'
30703
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
30704
DELETE FROM t0_aux
30705
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30706
DELETE FROM t1
30707
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
30708
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
30709
BEGIN
30710
SET new.f_int1 = old.f_int1 + @max_row,
30711
new.f_int2 = old.f_int2 - @max_row,
30712
new.f_charbig = '####updated per update trigger####';
30713
END|
30714
UPDATE t1
30715
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
30716
f_charbig = '####updated per update statement itself####';
30717
	
30718
# check trigger-9 success: 	1
30719
DROP TRIGGER trg_2;
30720
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30721
f_int2 = CAST(f_char1 AS SIGNED INT),
30722
f_charbig = CONCAT('===',f_char1,'===');
30723
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
30724
BEGIN
30725
SET new.f_int1 = new.f_int1 + @max_row,
30726
new.f_int2 = new.f_int2 - @max_row,
30727
new.f_charbig = '####updated per update trigger####';
30728
END|
30729
UPDATE t1
30730
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
30731
f_charbig = '####updated per update statement itself####';
30732
	
30733
# check trigger-10 success: 	1
30734
DROP TRIGGER trg_2;
30735
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30736
f_int2 = CAST(f_char1 AS SIGNED INT),
30737
f_charbig = CONCAT('===',f_char1,'===');
30738
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
30739
BEGIN
30740
SET new.f_int1 = @my_max1 + @counter,
30741
new.f_int2 = @my_min2 - @counter,
30742
new.f_charbig = '####updated per insert trigger####';
30743
SET @counter = @counter + 1;
30744
END|
30745
SET @counter = 1;
30746
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
30747
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30748
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
30749
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
30750
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
30751
ORDER BY f_int1;
30752
DROP TRIGGER trg_3;
30753
	
30754
# check trigger-11 success: 	1
30755
DELETE FROM t1
30756
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
30757
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
30758
AND f_charbig = '####updated per insert trigger####';
30759
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
30760
BEGIN
30761
SET new.f_int1 = @my_max1 + @counter,
30762
new.f_int2 = @my_min2 - @counter,
30763
new.f_charbig = '####updated per insert trigger####';
30764
SET @counter = @counter + 1;
30765
END|
30766
SET @counter = 1;
30767
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
30768
INSERT INTO t1 (f_char1, f_char2, f_charbig)
30769
SELECT CAST(f_int1 AS CHAR),
30770
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
30771
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
30772
ORDER BY f_int1;
30773
DROP TRIGGER trg_3;
30774
	
30775
# check trigger-12 success: 	1
30776
DELETE FROM t1
30777
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
30778
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
30779
AND f_charbig = '####updated per insert trigger####';
30780
ANALYZE  TABLE t1;
30781
Table	Op	Msg_type	Msg_text
30782
test.t1	analyze	note	The storage engine for the table doesn't support analyze
30783
CHECK    TABLE t1 EXTENDED;
30784
Table	Op	Msg_type	Msg_text
30785
test.t1	check	note	The storage engine for the table doesn't support check
30786
CHECKSUM TABLE t1 EXTENDED;
30787
Table	Checksum
30788
test.t1	<some_value>
30789
OPTIMIZE TABLE t1;
30790
Table	Op	Msg_type	Msg_text
30791
test.t1	optimize	note	The storage engine for the table doesn't support optimize
30792
# check layout success:    1
30793
REPAIR   TABLE t1 EXTENDED;
30794
Table	Op	Msg_type	Msg_text
30795
test.t1	repair	note	The storage engine for the table doesn't support repair
30796
# check layout success:    1
30797
TRUNCATE t1;
30798
	
30799
# check TRUNCATE success: 	1
30800
# check layout success:    1
30801
# End usability test (inc/partition_check.inc)
30802
DROP TABLE t1;
30803
CREATE TABLE t1 (
30804
f_int1 INTEGER,
30805
f_int2 INTEGER,
30806
f_char1 CHAR(20),
30807
f_char2 CHAR(20),
30808
f_charbig VARCHAR(1000)
30809
, UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1)
30810
)
30811
PARTITION BY LIST(ABS(MOD(f_int1,2)))
30812
SUBPARTITION BY KEY(f_int2)  SUBPARTITIONS 3
30813
(PARTITION part1 VALUES IN (0),
30814
PARTITION part2 VALUES IN (1),
30815
PARTITION part3 VALUES IN (NULL));
30816
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
30817
SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
30818
# Start usability test (inc/partition_check.inc)
30819
create_command
30820
SHOW CREATE TABLE t1;
30821
Table	Create Table
30822
t1	CREATE TABLE `t1` (
30823
  `f_int1` int(11) DEFAULT NULL,
30824
  `f_int2` int(11) DEFAULT NULL,
30825
  `f_char1` char(20) DEFAULT NULL,
30826
  `f_char2` char(20) DEFAULT NULL,
30827
  `f_charbig` varchar(1000) DEFAULT NULL,
30828
  UNIQUE KEY `uidx1` (`f_int1`,`f_int2`),
30829
  UNIQUE KEY `uidx2` (`f_int2`,`f_int1`)
30830
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (ABS(MOD(f_int1,2))) SUBPARTITION BY KEY (f_int2) SUBPARTITIONS 3 (PARTITION part1 VALUES IN (0) ENGINE = InnoDB, PARTITION part2 VALUES IN (1) ENGINE = InnoDB, PARTITION part3 VALUES IN (NULL) ENGINE = InnoDB) */
30831
30832
unified filelist
30833
$MYSQLTEST_VARDIR/master-data/test/t1.frm
30834
$MYSQLTEST_VARDIR/master-data/test/t1.par
30835
30836
# check prerequisites-1 success:    1
30837
# check COUNT(*) success:    1
30838
# check MIN/MAX(f_int1) success:    1
30839
# check MIN/MAX(f_int2) success:    1
30840
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30841
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
30842
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
30843
WHERE f_int1 IN (2,3);
30844
ERROR 23000: Can't write; duplicate key in table 't1'
30845
# check prerequisites-3 success:    1
30846
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
30847
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30848
SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
30849
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
30850
WHERE f_int1 IN (2,3);
30851
DELETE FROM t1 WHERE f_charbig = 'delete me';
30852
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30853
SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
30854
CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
30855
WHERE f_int1 IN (2,3);
30856
DELETE FROM t1 WHERE f_charbig = 'delete me';
30857
# check read via f_int1 success: 1
30858
# check read via f_int2 success: 1
30859
	
30860
# check multiple-1 success: 	1
30861
DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
30862
	
30863
# check multiple-2 success: 	1
30864
INSERT INTO t1 SELECT * FROM t0_template
30865
WHERE MOD(f_int1,3) = 0;
30866
	
30867
# check multiple-3 success: 	1
30868
UPDATE t1 SET f_int1 = f_int1 + @max_row
30869
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
30870
AND @max_row_div2 + @max_row_div4;
30871
	
30872
# check multiple-4 success: 	1
30873
DELETE FROM t1
30874
WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
30875
AND @max_row_div2 + @max_row_div4 + @max_row;
30876
	
30877
# check multiple-5 success: 	1
30878
SELECT COUNT(*) INTO @try_count FROM t0_template
30879
WHERE MOD(f_int1,3) = 0
30880
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
30881
SELECT COUNT(*) INTO @clash_count
30882
FROM t1 INNER JOIN t0_template USING(f_int1)
30883
WHERE MOD(f_int1,3) = 0
30884
AND f_int1 BETWEEN @max_row_div2 AND @max_row;
30885
SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
30886
INSERT INTO t1
30887
SET f_int1 = @cur_value , f_int2 = @cur_value,
30888
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
30889
f_charbig = '#SINGLE#';
30890
	
30891
# check single-1 success: 	1
30892
SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
30893
INSERT INTO t1
30894
SET f_int1 = @cur_value , f_int2 = @cur_value,
30895
f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
30896
f_charbig = '#SINGLE#';
30897
	
30898
# check single-2 success: 	1
30899
SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
30900
SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
30901
UPDATE t1 SET f_int1 = @cur_value2
30902
WHERE  f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
30903
	
30904
# check single-3 success: 	1
30905
SET @cur_value1= -1;
30906
SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
30907
UPDATE t1 SET f_int1 = @cur_value1
30908
WHERE  f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
30909
	
30910
# check single-4 success: 	1
30911
SELECT MAX(f_int1) INTO @cur_value FROM t1;
30912
DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
30913
	
30914
# check single-5 success: 	1
30915
DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
30916
	
30917
# check single-6 success: 	1
30918
INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#2147483647##';
30919
	
30920
# check single-7 success: 	1
30921
DELETE FROM t1 WHERE f_charbig = '#2147483647##';
30922
DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
30923
INSERT t1 SET f_int1 = 0 , f_int2 = 0,
30924
f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
30925
f_charbig = '#NULL#';
30926
INSERT INTO t1
30927
SET f_int1 = NULL , f_int2 = -@max_row,
30928
f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
30929
f_charbig = '#NULL#';
30930
# check null success:    1
30931
	
30932
# check null-1 success: 	1
30933
UPDATE t1 SET f_int1 = -@max_row
30934
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
30935
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
30936
	
30937
# check null-2 success: 	1
30938
UPDATE t1 SET f_int1 = NULL
30939
WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
30940
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
30941
	
30942
# check null-3 success: 	1
30943
DELETE FROM t1
30944
WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
30945
AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
30946
	
30947
# check null-4 success: 	1
30948
DELETE FROM t1
30949
WHERE f_int1 = 0 AND f_int2 = 0
30950
AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
30951
AND f_charbig = '#NULL#';
30952
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30953
SELECT f_int1, f_int1, '', '', 'was inserted'
30954
   FROM t0_template source_tab
30955
WHERE MOD(f_int1,3) = 0
30956
AND f_int1 BETWEEN @max_row_div2 AND @max_row
30957
ON DUPLICATE KEY
30958
UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
30959
f_int2 = 2 * @max_row + source_tab.f_int1,
30960
f_charbig = 'was updated';
30961
	
30962
# check unique-1-a success: 	1
30963
	
30964
# check unique-1-b success: 	1
30965
DELETE FROM t1 WHERE f_charbig = 'was inserted';
30966
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
30967
f_int2 = CAST(f_char1 AS SIGNED INT),
30968
f_charbig = CONCAT('===',f_char1,'===')
30969
WHERE f_charbig = 'was updated';
30970
REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30971
SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
30972
   FROM t0_template source_tab
30973
WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
30974
	
30975
# check replace success: 	1
30976
DELETE FROM t1
30977
WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
30978
DELETE FROM t1
30979
WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
30980
f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
30981
UPDATE t1 SET f_int2 = f_int1,
30982
f_char1 = CAST(f_int1 AS CHAR),
30983
f_char2 = CAST(f_int1 AS CHAR),
30984
f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
30985
WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
30986
SET AUTOCOMMIT= 0;
30987
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
30988
SELECT f_int1, f_int1, '', '', 'was inserted'
30989
FROM t0_template source_tab
30990
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
30991
	
30992
# check transactions-1 success: 	1
30993
COMMIT WORK;
30994
	
30995
# check transactions-2 success: 	1
30996
ROLLBACK WORK;
30997
	
30998
# check transactions-3 success: 	1
30999
DELETE FROM t1 WHERE f_charbig = 'was inserted';
31000
COMMIT WORK;
31001
ROLLBACK WORK;
31002
	
31003
# check transactions-4 success: 	1
31004
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
31005
SELECT f_int1, f_int1, '', '', 'was inserted'
31006
FROM t0_template source_tab
31007
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
31008
	
31009
# check transactions-5 success: 	1
31010
ROLLBACK WORK;
31011
	
31012
# check transactions-6 success: 	1
31013
# INFO: Storage engine used for t1 seems to be transactional.
31014
COMMIT;
31015
	
31016
# check transactions-7 success: 	1
31017
DELETE FROM t1 WHERE f_charbig = 'was inserted';
31018
COMMIT WORK;
31019
SET @@session.sql_mode = 'traditional';
31020
SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
31021
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
31022
SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
31023
'', '', 'was inserted' FROM t0_template
31024
WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
31025
ERROR 22012: Division by 0
31026
COMMIT;
31027
	
31028
# check transactions-8 success: 	1
31029
# INFO: Storage engine used for t1 seems to be able to revert
31030
#       changes made by the failing statement.
31031
SET @@session.sql_mode = '';
31032
SET AUTOCOMMIT= 1;
31033
DELETE FROM t1 WHERE f_charbig = 'was inserted';
31034
COMMIT WORK;
31035
UPDATE t1 SET f_charbig = REPEAT('b', 1000);
31036
	
31037
# check special-1 success: 	1
31038
UPDATE t1 SET f_charbig = '';
31039
	
31040
# check special-2 success: 	1
31041
UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
31042
INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
31043
SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
31044
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31045
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
31046
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
31047
'just inserted' FROM t0_template
31048
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31049
CREATE TRIGGER trg_1 BEFORE INSERT ON t0_aux FOR EACH ROW
31050
BEGIN
31051
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
31052
f_charbig = 'updated by trigger'
31053
      WHERE f_int1 = new.f_int1;
31054
END|
31055
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
31056
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
31057
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31058
	
31059
# check trigger-1 success: 	1
31060
DROP TRIGGER trg_1;
31061
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
31062
f_int2 = CAST(f_char1 AS SIGNED INT),
31063
f_charbig = 'just inserted'
31064
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
31065
DELETE FROM t0_aux
31066
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31067
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
31068
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
31069
'just inserted' FROM t0_template
31070
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31071
CREATE TRIGGER trg_1 AFTER INSERT ON t0_aux FOR EACH ROW
31072
BEGIN
31073
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
31074
f_charbig = 'updated by trigger'
31075
      WHERE f_int1 = new.f_int1;
31076
END|
31077
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
31078
SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
31079
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31080
	
31081
# check trigger-2 success: 	1
31082
DROP TRIGGER trg_1;
31083
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
31084
f_int2 = CAST(f_char1 AS SIGNED INT),
31085
f_charbig = 'just inserted'
31086
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
31087
DELETE FROM t0_aux
31088
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31089
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
31090
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
31091
'just inserted' FROM t0_template
31092
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31093
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
31094
BEGIN
31095
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
31096
f_charbig = 'updated by trigger'
31097
      WHERE f_int1 = new.f_int1;
31098
END|
31099
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
31100
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
31101
	
31102
# check trigger-3 success: 	1
31103
DROP TRIGGER trg_1;
31104
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
31105
f_int2 = CAST(f_char1 AS SIGNED INT),
31106
f_charbig = 'just inserted'
31107
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
31108
DELETE FROM t0_aux
31109
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31110
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
31111
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
31112
'just inserted' FROM t0_template
31113
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31114
CREATE TRIGGER trg_1 BEFORE UPDATE ON t0_aux FOR EACH ROW
31115
BEGIN
31116
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
31117
f_charbig = 'updated by trigger'
31118
      WHERE f_int1 = - old.f_int1;
31119
END|
31120
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
31121
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
31122
	
31123
# check trigger-4 success: 	1
31124
DROP TRIGGER trg_1;
31125
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
31126
f_int2 = CAST(f_char1 AS SIGNED INT),
31127
f_charbig = 'just inserted'
31128
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
31129
DELETE FROM t0_aux
31130
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31131
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
31132
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
31133
'just inserted' FROM t0_template
31134
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31135
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
31136
BEGIN
31137
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
31138
f_charbig = 'updated by trigger'
31139
      WHERE f_int1 = new.f_int1;
31140
END|
31141
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
31142
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
31143
	
31144
# check trigger-5 success: 	1
31145
DROP TRIGGER trg_1;
31146
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
31147
f_int2 = CAST(f_char1 AS SIGNED INT),
31148
f_charbig = 'just inserted'
31149
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
31150
DELETE FROM t0_aux
31151
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31152
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
31153
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
31154
'just inserted' FROM t0_template
31155
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31156
CREATE TRIGGER trg_1 AFTER UPDATE ON t0_aux FOR EACH ROW
31157
BEGIN
31158
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
31159
f_charbig = 'updated by trigger'
31160
      WHERE f_int1 = - old.f_int1;
31161
END|
31162
UPDATE t0_aux SET f_int1 =  - f_int1, f_int2 = - f_int2
31163
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
31164
	
31165
# check trigger-6 success: 	1
31166
DROP TRIGGER trg_1;
31167
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
31168
f_int2 = CAST(f_char1 AS SIGNED INT),
31169
f_charbig = 'just inserted'
31170
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
31171
DELETE FROM t0_aux
31172
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31173
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
31174
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
31175
'just inserted' FROM t0_template
31176
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31177
CREATE TRIGGER trg_1 BEFORE DELETE ON t0_aux FOR EACH ROW
31178
BEGIN
31179
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
31180
f_charbig = 'updated by trigger'
31181
      WHERE f_int1 = - old.f_int1;
31182
END|
31183
DELETE FROM t0_aux
31184
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
31185
	
31186
# check trigger-7 success: 	1
31187
DROP TRIGGER trg_1;
31188
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
31189
f_int2 = CAST(f_char1 AS SIGNED INT),
31190
f_charbig = 'just inserted'
31191
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
31192
DELETE FROM t0_aux
31193
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31194
INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
31195
SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
31196
'just inserted' FROM t0_template
31197
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31198
CREATE TRIGGER trg_1 AFTER DELETE ON t0_aux FOR EACH ROW
31199
BEGIN
31200
UPDATE t1 SET f_int1 = -f_int1, f_int2 = -f_int2,
31201
f_charbig = 'updated by trigger'
31202
      WHERE f_int1 = - old.f_int1;
31203
END|
31204
DELETE FROM t0_aux
31205
WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
31206
	
31207
# check trigger-8 success: 	1
31208
DROP TRIGGER trg_1;
31209
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
31210
f_int2 = CAST(f_char1 AS SIGNED INT),
31211
f_charbig = 'just inserted'
31212
   WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
31213
DELETE FROM t0_aux
31214
WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31215
DELETE FROM t1
31216
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
31217
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
31218
BEGIN
31219
SET new.f_int1 = old.f_int1 + @max_row,
31220
new.f_int2 = old.f_int2 - @max_row,
31221
new.f_charbig = '####updated per update trigger####';
31222
END|
31223
UPDATE t1
31224
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
31225
f_charbig = '####updated per update statement itself####';
31226
	
31227
# check trigger-9 success: 	1
31228
DROP TRIGGER trg_2;
31229
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
31230
f_int2 = CAST(f_char1 AS SIGNED INT),
31231
f_charbig = CONCAT('===',f_char1,'===');
31232
CREATE TRIGGER trg_2 BEFORE UPDATE ON t1 FOR EACH ROW
31233
BEGIN
31234
SET new.f_int1 = new.f_int1 + @max_row,
31235
new.f_int2 = new.f_int2 - @max_row,
31236
new.f_charbig = '####updated per update trigger####';
31237
END|
31238
UPDATE t1
31239
SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
31240
f_charbig = '####updated per update statement itself####';
31241
	
31242
# check trigger-10 success: 	1
31243
DROP TRIGGER trg_2;
31244
UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
31245
f_int2 = CAST(f_char1 AS SIGNED INT),
31246
f_charbig = CONCAT('===',f_char1,'===');
31247
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
31248
BEGIN
31249
SET new.f_int1 = @my_max1 + @counter,
31250
new.f_int2 = @my_min2 - @counter,
31251
new.f_charbig = '####updated per insert trigger####';
31252
SET @counter = @counter + 1;
31253
END|
31254
SET @counter = 1;
31255
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
31256
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
31257
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
31258
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
31259
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
31260
ORDER BY f_int1;
31261
DROP TRIGGER trg_3;
31262
	
31263
# check trigger-11 success: 	1
31264
DELETE FROM t1
31265
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
31266
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
31267
AND f_charbig = '####updated per insert trigger####';
31268
CREATE TRIGGER trg_3 BEFORE INSERT ON t1 FOR EACH ROW
31269
BEGIN
31270
SET new.f_int1 = @my_max1 + @counter,
31271
new.f_int2 = @my_min2 - @counter,
31272
new.f_charbig = '####updated per insert trigger####';
31273
SET @counter = @counter + 1;
31274
END|
31275
SET @counter = 1;
31276
SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
31277
INSERT INTO t1 (f_char1, f_char2, f_charbig)
31278
SELECT CAST(f_int1 AS CHAR),
31279
CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
31280
WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
31281
ORDER BY f_int1;
31282
DROP TRIGGER trg_3;
31283
	
31284
# check trigger-12 success: 	1
31285
DELETE FROM t1
31286
WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
31287
AND f_int2 <> CAST(f_char1 AS SIGNED INT)
31288
AND f_charbig = '####updated per insert trigger####';
31289
ANALYZE  TABLE t1;
31290
Table	Op	Msg_type	Msg_text
31291
test.t1	analyze	note	The storage engine for the table doesn't support analyze
31292
CHECK    TABLE t1 EXTENDED;
31293
Table	Op	Msg_type	Msg_text
31294
test.t1	check	note	The storage engine for the table doesn't support check
31295
CHECKSUM TABLE t1 EXTENDED;
31296
Table	Checksum
31297
test.t1	<some_value>
31298
OPTIMIZE TABLE t1;
31299
Table	Op	Msg_type	Msg_text
31300
test.t1	optimize	note	The storage engine for the table doesn't support optimize
31301
# check layout success:    1
31302
REPAIR   TABLE t1 EXTENDED;
31303
Table	Op	Msg_type	Msg_text
31304
test.t1	repair	note	The storage engine for the table doesn't support repair
31305
# check layout success:    1
31306
TRUNCATE t1;
31307
	
31308
# check TRUNCATE success: 	1
31309
# check layout success:    1
31310
# End usability test (inc/partition_check.inc)
31311
DROP TABLE t1;
31312
DROP VIEW  IF EXISTS v1;
31313
DROP TABLE IF EXISTS t1;
31314
DROP TABLE IF EXISTS t0_aux;
31315
DROP TABLE IF EXISTS t0_definition;
31316
DROP TABLE IF EXISTS t0_template;