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

« back to all changes in this revision

Viewing changes to mysql-test/suite/parts/r/part_supported_sql_func_innodb.result

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-------------------------------------------------------------------------
 
2
---  abs(col1)  in partition with coltype  int
 
3
-------------------------------------------------------------------------
 
4
drop table if exists t1 ;
 
5
drop table if exists t2 ;
 
6
drop table if exists t3 ;
 
7
drop table if exists t4 ;
 
8
drop table if exists t5 ;
 
9
drop table if exists t6 ;
 
10
-------------------------------------------------------------------------
 
11
---  Create tables with abs(col1)
 
12
-------------------------------------------------------------------------
 
13
create table t1 (col1 int) engine='INNODB' 
 
14
partition by range(abs(col1)) 
 
15
(partition p0 values less than (15),
 
16
partition p1 values less than maxvalue);
 
17
create table t2 (col1 int) engine='INNODB' 
 
18
partition by list(abs(col1)) 
 
19
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
20
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
21
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
22
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
23
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
24
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
25
);
 
26
create table t3 (col1 int) engine='INNODB' 
 
27
partition by hash(abs(col1));
 
28
create table t4 (colint int, col1 int) engine='INNODB' 
 
29
partition by range(colint) 
 
30
subpartition by hash(abs(col1)) subpartitions 2 
 
31
(partition p0 values less than (15),
 
32
partition p1 values less than maxvalue);
 
33
create table t5 (colint int, col1 int) engine='INNODB' 
 
34
partition by list(colint)
 
35
subpartition by hash(abs(col1)) subpartitions 2 
 
36
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
37
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
38
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
39
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
40
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
41
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
42
);
 
43
create table t6 (colint int, col1 int) engine='INNODB' 
 
44
partition by range(colint) 
 
45
(partition p0 values less than (abs(15)),
 
46
partition p1 values less than maxvalue);
 
47
-------------------------------------------------------------------------
 
48
---  Access tables with abs(col1) 
 
49
-------------------------------------------------------------------------
 
50
insert into t1 values (5 );
 
51
insert into t1 values (13 );
 
52
insert into t2 values (5 );
 
53
insert into t2 values (13 );
 
54
insert into t2 values (17 );
 
55
insert into t3 values (5 );
 
56
insert into t3 values (13 );
 
57
insert into t3 values (17 );
 
58
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t4;
 
59
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t5;
 
60
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t6;
 
61
select abs(col1) from t1 order by col1;
 
62
abs(col1)
 
63
5
 
64
13
 
65
select * from t1 order by col1;
 
66
col1
 
67
5
 
68
13
 
69
select * from t2 order by col1;
 
70
col1
 
71
5
 
72
13
 
73
17
 
74
select * from t3 order by col1;
 
75
col1
 
76
5
 
77
13
 
78
17
 
79
select * from t4 order by colint;
 
80
colint  col1
 
81
1       5
 
82
2       13
 
83
3       15
 
84
4       17
 
85
5       23
 
86
6       34
 
87
7       56
 
88
8       56
 
89
9       45
 
90
10      34
 
91
11      78
 
92
12      89
 
93
13      67
 
94
14      46
 
95
15      34
 
96
16      324
 
97
17      345
 
98
18      34
 
99
19      78
 
100
20      567
 
101
21      4
 
102
22      435
 
103
23      34
 
104
24      45
 
105
25      4565
 
106
26      4
 
107
27      3
 
108
28      2
 
109
29      3
 
110
30      5
 
111
31      6
 
112
32      8
 
113
33      9
 
114
34      745
 
115
35      34
 
116
36      34
 
117
37      324
 
118
38      67
 
119
39      78
 
120
40      89
 
121
41      90
 
122
42      78967
 
123
50      56
 
124
51      34
 
125
55      123
 
126
select * from t5 order by colint;
 
127
colint  col1
 
128
1       5
 
129
2       13
 
130
3       15
 
131
4       17
 
132
5       23
 
133
6       34
 
134
7       56
 
135
8       56
 
136
9       45
 
137
10      34
 
138
11      78
 
139
12      89
 
140
13      67
 
141
14      46
 
142
15      34
 
143
16      324
 
144
17      345
 
145
18      34
 
146
19      78
 
147
20      567
 
148
21      4
 
149
22      435
 
150
23      34
 
151
24      45
 
152
25      4565
 
153
26      4
 
154
27      3
 
155
28      2
 
156
29      3
 
157
30      5
 
158
31      6
 
159
32      8
 
160
33      9
 
161
34      745
 
162
35      34
 
163
36      34
 
164
37      324
 
165
38      67
 
166
39      78
 
167
40      89
 
168
41      90
 
169
42      78967
 
170
50      56
 
171
51      34
 
172
55      123
 
173
select * from t6 order by colint;
 
174
colint  col1
 
175
1       5
 
176
2       13
 
177
3       15
 
178
4       17
 
179
5       23
 
180
6       34
 
181
7       56
 
182
8       56
 
183
9       45
 
184
10      34
 
185
11      78
 
186
12      89
 
187
13      67
 
188
14      46
 
189
15      34
 
190
16      324
 
191
17      345
 
192
18      34
 
193
19      78
 
194
20      567
 
195
21      4
 
196
22      435
 
197
23      34
 
198
24      45
 
199
25      4565
 
200
26      4
 
201
27      3
 
202
28      2
 
203
29      3
 
204
30      5
 
205
31      6
 
206
32      8
 
207
33      9
 
208
34      745
 
209
35      34
 
210
36      34
 
211
37      324
 
212
38      67
 
213
39      78
 
214
40      89
 
215
41      90
 
216
42      78967
 
217
50      56
 
218
51      34
 
219
55      123
 
220
update t1 set col1=15  where col1=5 ;
 
221
update t2 set col1=15  where col1=5 ;
 
222
update t3 set col1=15  where col1=5 ;
 
223
update t4 set col1=15  where col1=5 ;
 
224
update t5 set col1=15  where col1=5 ;
 
225
update t6 set col1=15  where col1=5 ;
 
226
select * from t1 order by col1;
 
227
col1
 
228
13
 
229
15
 
230
select * from t2 order by col1;
 
231
col1
 
232
13
 
233
15
 
234
17
 
235
select * from t3 order by col1;
 
236
col1
 
237
13
 
238
15
 
239
17
 
240
select * from t4 order by colint;
 
241
colint  col1
 
242
1       15
 
243
2       13
 
244
3       15
 
245
4       17
 
246
5       23
 
247
6       34
 
248
7       56
 
249
8       56
 
250
9       45
 
251
10      34
 
252
11      78
 
253
12      89
 
254
13      67
 
255
14      46
 
256
15      34
 
257
16      324
 
258
17      345
 
259
18      34
 
260
19      78
 
261
20      567
 
262
21      4
 
263
22      435
 
264
23      34
 
265
24      45
 
266
25      4565
 
267
26      4
 
268
27      3
 
269
28      2
 
270
29      3
 
271
30      15
 
272
31      6
 
273
32      8
 
274
33      9
 
275
34      745
 
276
35      34
 
277
36      34
 
278
37      324
 
279
38      67
 
280
39      78
 
281
40      89
 
282
41      90
 
283
42      78967
 
284
50      56
 
285
51      34
 
286
55      123
 
287
select * from t5 order by colint;
 
288
colint  col1
 
289
1       15
 
290
2       13
 
291
3       15
 
292
4       17
 
293
5       23
 
294
6       34
 
295
7       56
 
296
8       56
 
297
9       45
 
298
10      34
 
299
11      78
 
300
12      89
 
301
13      67
 
302
14      46
 
303
15      34
 
304
16      324
 
305
17      345
 
306
18      34
 
307
19      78
 
308
20      567
 
309
21      4
 
310
22      435
 
311
23      34
 
312
24      45
 
313
25      4565
 
314
26      4
 
315
27      3
 
316
28      2
 
317
29      3
 
318
30      15
 
319
31      6
 
320
32      8
 
321
33      9
 
322
34      745
 
323
35      34
 
324
36      34
 
325
37      324
 
326
38      67
 
327
39      78
 
328
40      89
 
329
41      90
 
330
42      78967
 
331
50      56
 
332
51      34
 
333
55      123
 
334
select * from t6 order by colint;
 
335
colint  col1
 
336
1       15
 
337
2       13
 
338
3       15
 
339
4       17
 
340
5       23
 
341
6       34
 
342
7       56
 
343
8       56
 
344
9       45
 
345
10      34
 
346
11      78
 
347
12      89
 
348
13      67
 
349
14      46
 
350
15      34
 
351
16      324
 
352
17      345
 
353
18      34
 
354
19      78
 
355
20      567
 
356
21      4
 
357
22      435
 
358
23      34
 
359
24      45
 
360
25      4565
 
361
26      4
 
362
27      3
 
363
28      2
 
364
29      3
 
365
30      15
 
366
31      6
 
367
32      8
 
368
33      9
 
369
34      745
 
370
35      34
 
371
36      34
 
372
37      324
 
373
38      67
 
374
39      78
 
375
40      89
 
376
41      90
 
377
42      78967
 
378
50      56
 
379
51      34
 
380
55      123
 
381
-------------------------------------------------------------------------
 
382
---  Alter tables with abs(col1)
 
383
-------------------------------------------------------------------------
 
384
drop table if exists t11 ;
 
385
drop table if exists t22 ;
 
386
drop table if exists t33 ;
 
387
drop table if exists t44 ;
 
388
drop table if exists t55 ;
 
389
drop table if exists t66 ;
 
390
create table t11 engine='INNODB' as select * from t1;
 
391
create table t22 engine='INNODB' as select * from t2;
 
392
create table t33 engine='INNODB' as select * from t3;
 
393
create table t44 engine='INNODB' as select * from t4;
 
394
create table t55 engine='INNODB' as select * from t5;
 
395
create table t66 engine='INNODB' as select * from t6;
 
396
alter table t11
 
397
partition by range(abs(col1)) 
 
398
(partition p0 values less than (15),
 
399
partition p1 values less than maxvalue);
 
400
alter table t22
 
401
partition by list(abs(col1)) 
 
402
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
403
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
404
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
405
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
406
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
407
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
408
);
 
409
alter table t33
 
410
partition by hash(abs(col1));
 
411
alter table t44
 
412
partition by range(colint) 
 
413
subpartition by hash(abs(col1)) subpartitions 2 
 
414
(partition p0 values less than (15),
 
415
partition p1 values less than maxvalue);
 
416
alter table t55
 
417
partition by list(colint)
 
418
subpartition by hash(abs(col1)) subpartitions 2 
 
419
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
420
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
421
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
422
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
423
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
424
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
425
);
 
426
alter table t66
 
427
partition by range(colint) 
 
428
(partition p0 values less than (abs(15)),
 
429
partition p1 values less than maxvalue);
 
430
select * from t11 order by col1;
 
431
col1
 
432
13
 
433
15
 
434
select * from t22 order by col1;
 
435
col1
 
436
13
 
437
15
 
438
17
 
439
select * from t33 order by col1;
 
440
col1
 
441
13
 
442
15
 
443
17
 
444
select * from t44 order by colint;
 
445
colint  col1
 
446
1       15
 
447
2       13
 
448
3       15
 
449
4       17
 
450
5       23
 
451
6       34
 
452
7       56
 
453
8       56
 
454
9       45
 
455
10      34
 
456
11      78
 
457
12      89
 
458
13      67
 
459
14      46
 
460
15      34
 
461
16      324
 
462
17      345
 
463
18      34
 
464
19      78
 
465
20      567
 
466
21      4
 
467
22      435
 
468
23      34
 
469
24      45
 
470
25      4565
 
471
26      4
 
472
27      3
 
473
28      2
 
474
29      3
 
475
30      15
 
476
31      6
 
477
32      8
 
478
33      9
 
479
34      745
 
480
35      34
 
481
36      34
 
482
37      324
 
483
38      67
 
484
39      78
 
485
40      89
 
486
41      90
 
487
42      78967
 
488
50      56
 
489
51      34
 
490
55      123
 
491
select * from t55 order by colint;
 
492
colint  col1
 
493
1       15
 
494
2       13
 
495
3       15
 
496
4       17
 
497
5       23
 
498
6       34
 
499
7       56
 
500
8       56
 
501
9       45
 
502
10      34
 
503
11      78
 
504
12      89
 
505
13      67
 
506
14      46
 
507
15      34
 
508
16      324
 
509
17      345
 
510
18      34
 
511
19      78
 
512
20      567
 
513
21      4
 
514
22      435
 
515
23      34
 
516
24      45
 
517
25      4565
 
518
26      4
 
519
27      3
 
520
28      2
 
521
29      3
 
522
30      15
 
523
31      6
 
524
32      8
 
525
33      9
 
526
34      745
 
527
35      34
 
528
36      34
 
529
37      324
 
530
38      67
 
531
39      78
 
532
40      89
 
533
41      90
 
534
42      78967
 
535
50      56
 
536
51      34
 
537
55      123
 
538
select * from t66 order by colint;
 
539
colint  col1
 
540
1       15
 
541
2       13
 
542
3       15
 
543
4       17
 
544
5       23
 
545
6       34
 
546
7       56
 
547
8       56
 
548
9       45
 
549
10      34
 
550
11      78
 
551
12      89
 
552
13      67
 
553
14      46
 
554
15      34
 
555
16      324
 
556
17      345
 
557
18      34
 
558
19      78
 
559
20      567
 
560
21      4
 
561
22      435
 
562
23      34
 
563
24      45
 
564
25      4565
 
565
26      4
 
566
27      3
 
567
28      2
 
568
29      3
 
569
30      15
 
570
31      6
 
571
32      8
 
572
33      9
 
573
34      745
 
574
35      34
 
575
36      34
 
576
37      324
 
577
38      67
 
578
39      78
 
579
40      89
 
580
41      90
 
581
42      78967
 
582
50      56
 
583
51      34
 
584
55      123
 
585
---------------------------
 
586
---- some alter table begin
 
587
---------------------------
 
588
alter table t11
 
589
reorganize partition p0,p1 into
 
590
(partition s1 values less than maxvalue);
 
591
select * from t11 order by col1;
 
592
col1
 
593
13
 
594
15
 
595
alter table t11
 
596
reorganize partition s1 into
 
597
(partition p0 values less than (15),
 
598
partition p1 values less than maxvalue);
 
599
select * from t11 order by col1;
 
600
col1
 
601
13
 
602
15
 
603
alter table t55
 
604
partition by list(colint)
 
605
subpartition by hash(abs(col1)) subpartitions 5 
 
606
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
607
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
608
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
609
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
610
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
611
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
612
);
 
613
show create table t55;
 
614
Table   Create Table
 
615
t55     CREATE TABLE `t55` (
 
616
  `colint` int(11) DEFAULT NULL,
 
617
  `col1` int(11) DEFAULT NULL
 
618
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
619
/*!50100 PARTITION BY LIST (colint)
 
620
SUBPARTITION BY HASH (abs(col1))
 
621
SUBPARTITIONS 5
 
622
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
623
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
624
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
625
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
626
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
627
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
628
select * from t55 order by colint;
 
629
colint  col1
 
630
1       15
 
631
2       13
 
632
3       15
 
633
4       17
 
634
5       23
 
635
6       34
 
636
7       56
 
637
8       56
 
638
9       45
 
639
10      34
 
640
11      78
 
641
12      89
 
642
13      67
 
643
14      46
 
644
15      34
 
645
16      324
 
646
17      345
 
647
18      34
 
648
19      78
 
649
20      567
 
650
21      4
 
651
22      435
 
652
23      34
 
653
24      45
 
654
25      4565
 
655
26      4
 
656
27      3
 
657
28      2
 
658
29      3
 
659
30      15
 
660
31      6
 
661
32      8
 
662
33      9
 
663
34      745
 
664
35      34
 
665
36      34
 
666
37      324
 
667
38      67
 
668
39      78
 
669
40      89
 
670
41      90
 
671
42      78967
 
672
50      56
 
673
51      34
 
674
55      123
 
675
alter table t66
 
676
reorganize partition p0,p1 into
 
677
(partition s1 values less than maxvalue);
 
678
select * from t66 order by colint;
 
679
colint  col1
 
680
1       15
 
681
2       13
 
682
3       15
 
683
4       17
 
684
5       23
 
685
6       34
 
686
7       56
 
687
8       56
 
688
9       45
 
689
10      34
 
690
11      78
 
691
12      89
 
692
13      67
 
693
14      46
 
694
15      34
 
695
16      324
 
696
17      345
 
697
18      34
 
698
19      78
 
699
20      567
 
700
21      4
 
701
22      435
 
702
23      34
 
703
24      45
 
704
25      4565
 
705
26      4
 
706
27      3
 
707
28      2
 
708
29      3
 
709
30      15
 
710
31      6
 
711
32      8
 
712
33      9
 
713
34      745
 
714
35      34
 
715
36      34
 
716
37      324
 
717
38      67
 
718
39      78
 
719
40      89
 
720
41      90
 
721
42      78967
 
722
50      56
 
723
51      34
 
724
55      123
 
725
alter table t66
 
726
reorganize partition s1 into
 
727
(partition p0 values less than (abs(15)),
 
728
partition p1 values less than maxvalue);
 
729
select * from t66 order by colint;
 
730
colint  col1
 
731
1       15
 
732
2       13
 
733
3       15
 
734
4       17
 
735
5       23
 
736
6       34
 
737
7       56
 
738
8       56
 
739
9       45
 
740
10      34
 
741
11      78
 
742
12      89
 
743
13      67
 
744
14      46
 
745
15      34
 
746
16      324
 
747
17      345
 
748
18      34
 
749
19      78
 
750
20      567
 
751
21      4
 
752
22      435
 
753
23      34
 
754
24      45
 
755
25      4565
 
756
26      4
 
757
27      3
 
758
28      2
 
759
29      3
 
760
30      15
 
761
31      6
 
762
32      8
 
763
33      9
 
764
34      745
 
765
35      34
 
766
36      34
 
767
37      324
 
768
38      67
 
769
39      78
 
770
40      89
 
771
41      90
 
772
42      78967
 
773
50      56
 
774
51      34
 
775
55      123
 
776
alter table t66
 
777
reorganize partition p0,p1 into
 
778
(partition s1 values less than maxvalue);
 
779
select * from t66 order by colint;
 
780
colint  col1
 
781
1       15
 
782
2       13
 
783
3       15
 
784
4       17
 
785
5       23
 
786
6       34
 
787
7       56
 
788
8       56
 
789
9       45
 
790
10      34
 
791
11      78
 
792
12      89
 
793
13      67
 
794
14      46
 
795
15      34
 
796
16      324
 
797
17      345
 
798
18      34
 
799
19      78
 
800
20      567
 
801
21      4
 
802
22      435
 
803
23      34
 
804
24      45
 
805
25      4565
 
806
26      4
 
807
27      3
 
808
28      2
 
809
29      3
 
810
30      15
 
811
31      6
 
812
32      8
 
813
33      9
 
814
34      745
 
815
35      34
 
816
36      34
 
817
37      324
 
818
38      67
 
819
39      78
 
820
40      89
 
821
41      90
 
822
42      78967
 
823
50      56
 
824
51      34
 
825
55      123
 
826
alter table t66
 
827
reorganize partition s1 into
 
828
(partition p0 values less than (abs(15)),
 
829
partition p1 values less than maxvalue);
 
830
select * from t66 order by colint;
 
831
colint  col1
 
832
1       15
 
833
2       13
 
834
3       15
 
835
4       17
 
836
5       23
 
837
6       34
 
838
7       56
 
839
8       56
 
840
9       45
 
841
10      34
 
842
11      78
 
843
12      89
 
844
13      67
 
845
14      46
 
846
15      34
 
847
16      324
 
848
17      345
 
849
18      34
 
850
19      78
 
851
20      567
 
852
21      4
 
853
22      435
 
854
23      34
 
855
24      45
 
856
25      4565
 
857
26      4
 
858
27      3
 
859
28      2
 
860
29      3
 
861
30      15
 
862
31      6
 
863
32      8
 
864
33      9
 
865
34      745
 
866
35      34
 
867
36      34
 
868
37      324
 
869
38      67
 
870
39      78
 
871
40      89
 
872
41      90
 
873
42      78967
 
874
50      56
 
875
51      34
 
876
55      123
 
877
-------------------------------------------------------------------------
 
878
---  Delete rows and partitions of tables with abs(col1)
 
879
-------------------------------------------------------------------------
 
880
delete from t1 where col1=13 ;
 
881
delete from t2 where col1=13 ;
 
882
delete from t3 where col1=13 ;
 
883
delete from t4 where col1=13 ;
 
884
delete from t5 where col1=13 ;
 
885
delete from t6 where col1=13 ;
 
886
select * from t1 order by col1;
 
887
col1
 
888
15
 
889
select * from t2 order by col1;
 
890
col1
 
891
15
 
892
17
 
893
select * from t3 order by col1;
 
894
col1
 
895
15
 
896
17
 
897
select * from t4 order by colint;
 
898
colint  col1
 
899
1       15
 
900
3       15
 
901
4       17
 
902
5       23
 
903
6       34
 
904
7       56
 
905
8       56
 
906
9       45
 
907
10      34
 
908
11      78
 
909
12      89
 
910
13      67
 
911
14      46
 
912
15      34
 
913
16      324
 
914
17      345
 
915
18      34
 
916
19      78
 
917
20      567
 
918
21      4
 
919
22      435
 
920
23      34
 
921
24      45
 
922
25      4565
 
923
26      4
 
924
27      3
 
925
28      2
 
926
29      3
 
927
30      15
 
928
31      6
 
929
32      8
 
930
33      9
 
931
34      745
 
932
35      34
 
933
36      34
 
934
37      324
 
935
38      67
 
936
39      78
 
937
40      89
 
938
41      90
 
939
42      78967
 
940
50      56
 
941
51      34
 
942
55      123
 
943
select * from t5 order by colint;
 
944
colint  col1
 
945
1       15
 
946
3       15
 
947
4       17
 
948
5       23
 
949
6       34
 
950
7       56
 
951
8       56
 
952
9       45
 
953
10      34
 
954
11      78
 
955
12      89
 
956
13      67
 
957
14      46
 
958
15      34
 
959
16      324
 
960
17      345
 
961
18      34
 
962
19      78
 
963
20      567
 
964
21      4
 
965
22      435
 
966
23      34
 
967
24      45
 
968
25      4565
 
969
26      4
 
970
27      3
 
971
28      2
 
972
29      3
 
973
30      15
 
974
31      6
 
975
32      8
 
976
33      9
 
977
34      745
 
978
35      34
 
979
36      34
 
980
37      324
 
981
38      67
 
982
39      78
 
983
40      89
 
984
41      90
 
985
42      78967
 
986
50      56
 
987
51      34
 
988
55      123
 
989
insert into t1 values (13 );
 
990
insert into t2 values (13 );
 
991
insert into t3 values (13 );
 
992
insert into t4 values (60,13 );
 
993
insert into t5 values (60,13 );
 
994
insert into t6 values (60,13 );
 
995
select * from t1 order by col1;
 
996
col1
 
997
13
 
998
15
 
999
select * from t2 order by col1;
 
1000
col1
 
1001
13
 
1002
15
 
1003
17
 
1004
select * from t3 order by col1;
 
1005
col1
 
1006
13
 
1007
15
 
1008
17
 
1009
select * from t4 order by colint;
 
1010
colint  col1
 
1011
1       15
 
1012
3       15
 
1013
4       17
 
1014
5       23
 
1015
6       34
 
1016
7       56
 
1017
8       56
 
1018
9       45
 
1019
10      34
 
1020
11      78
 
1021
12      89
 
1022
13      67
 
1023
14      46
 
1024
15      34
 
1025
16      324
 
1026
17      345
 
1027
18      34
 
1028
19      78
 
1029
20      567
 
1030
21      4
 
1031
22      435
 
1032
23      34
 
1033
24      45
 
1034
25      4565
 
1035
26      4
 
1036
27      3
 
1037
28      2
 
1038
29      3
 
1039
30      15
 
1040
31      6
 
1041
32      8
 
1042
33      9
 
1043
34      745
 
1044
35      34
 
1045
36      34
 
1046
37      324
 
1047
38      67
 
1048
39      78
 
1049
40      89
 
1050
41      90
 
1051
42      78967
 
1052
50      56
 
1053
51      34
 
1054
55      123
 
1055
60      13
 
1056
select * from t5 order by colint;
 
1057
colint  col1
 
1058
1       15
 
1059
3       15
 
1060
4       17
 
1061
5       23
 
1062
6       34
 
1063
7       56
 
1064
8       56
 
1065
9       45
 
1066
10      34
 
1067
11      78
 
1068
12      89
 
1069
13      67
 
1070
14      46
 
1071
15      34
 
1072
16      324
 
1073
17      345
 
1074
18      34
 
1075
19      78
 
1076
20      567
 
1077
21      4
 
1078
22      435
 
1079
23      34
 
1080
24      45
 
1081
25      4565
 
1082
26      4
 
1083
27      3
 
1084
28      2
 
1085
29      3
 
1086
30      15
 
1087
31      6
 
1088
32      8
 
1089
33      9
 
1090
34      745
 
1091
35      34
 
1092
36      34
 
1093
37      324
 
1094
38      67
 
1095
39      78
 
1096
40      89
 
1097
41      90
 
1098
42      78967
 
1099
50      56
 
1100
51      34
 
1101
55      123
 
1102
60      13
 
1103
select * from t6 order by colint;
 
1104
colint  col1
 
1105
1       15
 
1106
3       15
 
1107
4       17
 
1108
5       23
 
1109
6       34
 
1110
7       56
 
1111
8       56
 
1112
9       45
 
1113
10      34
 
1114
11      78
 
1115
12      89
 
1116
13      67
 
1117
14      46
 
1118
15      34
 
1119
16      324
 
1120
17      345
 
1121
18      34
 
1122
19      78
 
1123
20      567
 
1124
21      4
 
1125
22      435
 
1126
23      34
 
1127
24      45
 
1128
25      4565
 
1129
26      4
 
1130
27      3
 
1131
28      2
 
1132
29      3
 
1133
30      15
 
1134
31      6
 
1135
32      8
 
1136
33      9
 
1137
34      745
 
1138
35      34
 
1139
36      34
 
1140
37      324
 
1141
38      67
 
1142
39      78
 
1143
40      89
 
1144
41      90
 
1145
42      78967
 
1146
50      56
 
1147
51      34
 
1148
55      123
 
1149
60      13
 
1150
alter table t1 drop partition p0;
 
1151
alter table t2 drop partition p0;
 
1152
alter table t4 drop partition p0;
 
1153
alter table t5 drop partition p0;
 
1154
alter table t6 drop partition p0;
 
1155
select * from t1 order by col1;
 
1156
col1
 
1157
15
 
1158
select * from t2 order by col1;
 
1159
col1
 
1160
13
 
1161
15
 
1162
17
 
1163
select * from t3 order by col1;
 
1164
col1
 
1165
13
 
1166
15
 
1167
17
 
1168
select * from t4 order by colint;
 
1169
colint  col1
 
1170
15      34
 
1171
16      324
 
1172
17      345
 
1173
18      34
 
1174
19      78
 
1175
20      567
 
1176
21      4
 
1177
22      435
 
1178
23      34
 
1179
24      45
 
1180
25      4565
 
1181
26      4
 
1182
27      3
 
1183
28      2
 
1184
29      3
 
1185
30      15
 
1186
31      6
 
1187
32      8
 
1188
33      9
 
1189
34      745
 
1190
35      34
 
1191
36      34
 
1192
37      324
 
1193
38      67
 
1194
39      78
 
1195
40      89
 
1196
41      90
 
1197
42      78967
 
1198
50      56
 
1199
51      34
 
1200
55      123
 
1201
60      13
 
1202
select * from t5 order by colint;
 
1203
colint  col1
 
1204
11      78
 
1205
12      89
 
1206
13      67
 
1207
14      46
 
1208
15      34
 
1209
16      324
 
1210
17      345
 
1211
18      34
 
1212
19      78
 
1213
20      567
 
1214
21      4
 
1215
22      435
 
1216
23      34
 
1217
24      45
 
1218
25      4565
 
1219
26      4
 
1220
27      3
 
1221
28      2
 
1222
29      3
 
1223
30      15
 
1224
31      6
 
1225
32      8
 
1226
33      9
 
1227
34      745
 
1228
35      34
 
1229
36      34
 
1230
37      324
 
1231
38      67
 
1232
39      78
 
1233
40      89
 
1234
41      90
 
1235
42      78967
 
1236
50      56
 
1237
51      34
 
1238
55      123
 
1239
60      13
 
1240
select * from t6 order by colint;
 
1241
colint  col1
 
1242
15      34
 
1243
16      324
 
1244
17      345
 
1245
18      34
 
1246
19      78
 
1247
20      567
 
1248
21      4
 
1249
22      435
 
1250
23      34
 
1251
24      45
 
1252
25      4565
 
1253
26      4
 
1254
27      3
 
1255
28      2
 
1256
29      3
 
1257
30      15
 
1258
31      6
 
1259
32      8
 
1260
33      9
 
1261
34      745
 
1262
35      34
 
1263
36      34
 
1264
37      324
 
1265
38      67
 
1266
39      78
 
1267
40      89
 
1268
41      90
 
1269
42      78967
 
1270
50      56
 
1271
51      34
 
1272
55      123
 
1273
60      13
 
1274
-------------------------------------------------------------------------
 
1275
---  Delete rows and partitions of tables with abs(col1)
 
1276
-------------------------------------------------------------------------
 
1277
delete from t11 where col1=13 ;
 
1278
delete from t22 where col1=13 ;
 
1279
delete from t33 where col1=13 ;
 
1280
delete from t44 where col1=13 ;
 
1281
delete from t55 where col1=13 ;
 
1282
delete from t66 where col1=13 ;
 
1283
select * from t11 order by col1;
 
1284
col1
 
1285
15
 
1286
select * from t22 order by col1;
 
1287
col1
 
1288
15
 
1289
17
 
1290
select * from t33 order by col1;
 
1291
col1
 
1292
15
 
1293
17
 
1294
select * from t44 order by colint;
 
1295
colint  col1
 
1296
1       15
 
1297
3       15
 
1298
4       17
 
1299
5       23
 
1300
6       34
 
1301
7       56
 
1302
8       56
 
1303
9       45
 
1304
10      34
 
1305
11      78
 
1306
12      89
 
1307
13      67
 
1308
14      46
 
1309
15      34
 
1310
16      324
 
1311
17      345
 
1312
18      34
 
1313
19      78
 
1314
20      567
 
1315
21      4
 
1316
22      435
 
1317
23      34
 
1318
24      45
 
1319
25      4565
 
1320
26      4
 
1321
27      3
 
1322
28      2
 
1323
29      3
 
1324
30      15
 
1325
31      6
 
1326
32      8
 
1327
33      9
 
1328
34      745
 
1329
35      34
 
1330
36      34
 
1331
37      324
 
1332
38      67
 
1333
39      78
 
1334
40      89
 
1335
41      90
 
1336
42      78967
 
1337
50      56
 
1338
51      34
 
1339
55      123
 
1340
select * from t55 order by colint;
 
1341
colint  col1
 
1342
1       15
 
1343
3       15
 
1344
4       17
 
1345
5       23
 
1346
6       34
 
1347
7       56
 
1348
8       56
 
1349
9       45
 
1350
10      34
 
1351
11      78
 
1352
12      89
 
1353
13      67
 
1354
14      46
 
1355
15      34
 
1356
16      324
 
1357
17      345
 
1358
18      34
 
1359
19      78
 
1360
20      567
 
1361
21      4
 
1362
22      435
 
1363
23      34
 
1364
24      45
 
1365
25      4565
 
1366
26      4
 
1367
27      3
 
1368
28      2
 
1369
29      3
 
1370
30      15
 
1371
31      6
 
1372
32      8
 
1373
33      9
 
1374
34      745
 
1375
35      34
 
1376
36      34
 
1377
37      324
 
1378
38      67
 
1379
39      78
 
1380
40      89
 
1381
41      90
 
1382
42      78967
 
1383
50      56
 
1384
51      34
 
1385
55      123
 
1386
insert into t11 values (13 );
 
1387
insert into t22 values (13 );
 
1388
insert into t33 values (13 );
 
1389
insert into t44 values (60,13 );
 
1390
insert into t55 values (60,13 );
 
1391
insert into t66 values (60,13 );
 
1392
select * from t11 order by col1;
 
1393
col1
 
1394
13
 
1395
15
 
1396
select * from t22 order by col1;
 
1397
col1
 
1398
13
 
1399
15
 
1400
17
 
1401
select * from t33 order by col1;
 
1402
col1
 
1403
13
 
1404
15
 
1405
17
 
1406
select * from t44 order by colint;
 
1407
colint  col1
 
1408
1       15
 
1409
3       15
 
1410
4       17
 
1411
5       23
 
1412
6       34
 
1413
7       56
 
1414
8       56
 
1415
9       45
 
1416
10      34
 
1417
11      78
 
1418
12      89
 
1419
13      67
 
1420
14      46
 
1421
15      34
 
1422
16      324
 
1423
17      345
 
1424
18      34
 
1425
19      78
 
1426
20      567
 
1427
21      4
 
1428
22      435
 
1429
23      34
 
1430
24      45
 
1431
25      4565
 
1432
26      4
 
1433
27      3
 
1434
28      2
 
1435
29      3
 
1436
30      15
 
1437
31      6
 
1438
32      8
 
1439
33      9
 
1440
34      745
 
1441
35      34
 
1442
36      34
 
1443
37      324
 
1444
38      67
 
1445
39      78
 
1446
40      89
 
1447
41      90
 
1448
42      78967
 
1449
50      56
 
1450
51      34
 
1451
55      123
 
1452
60      13
 
1453
select * from t55 order by colint;
 
1454
colint  col1
 
1455
1       15
 
1456
3       15
 
1457
4       17
 
1458
5       23
 
1459
6       34
 
1460
7       56
 
1461
8       56
 
1462
9       45
 
1463
10      34
 
1464
11      78
 
1465
12      89
 
1466
13      67
 
1467
14      46
 
1468
15      34
 
1469
16      324
 
1470
17      345
 
1471
18      34
 
1472
19      78
 
1473
20      567
 
1474
21      4
 
1475
22      435
 
1476
23      34
 
1477
24      45
 
1478
25      4565
 
1479
26      4
 
1480
27      3
 
1481
28      2
 
1482
29      3
 
1483
30      15
 
1484
31      6
 
1485
32      8
 
1486
33      9
 
1487
34      745
 
1488
35      34
 
1489
36      34
 
1490
37      324
 
1491
38      67
 
1492
39      78
 
1493
40      89
 
1494
41      90
 
1495
42      78967
 
1496
50      56
 
1497
51      34
 
1498
55      123
 
1499
60      13
 
1500
select * from t66 order by colint;
 
1501
colint  col1
 
1502
1       15
 
1503
3       15
 
1504
4       17
 
1505
5       23
 
1506
6       34
 
1507
7       56
 
1508
8       56
 
1509
9       45
 
1510
10      34
 
1511
11      78
 
1512
12      89
 
1513
13      67
 
1514
14      46
 
1515
15      34
 
1516
16      324
 
1517
17      345
 
1518
18      34
 
1519
19      78
 
1520
20      567
 
1521
21      4
 
1522
22      435
 
1523
23      34
 
1524
24      45
 
1525
25      4565
 
1526
26      4
 
1527
27      3
 
1528
28      2
 
1529
29      3
 
1530
30      15
 
1531
31      6
 
1532
32      8
 
1533
33      9
 
1534
34      745
 
1535
35      34
 
1536
36      34
 
1537
37      324
 
1538
38      67
 
1539
39      78
 
1540
40      89
 
1541
41      90
 
1542
42      78967
 
1543
50      56
 
1544
51      34
 
1545
55      123
 
1546
60      13
 
1547
alter table t11 drop partition p0;
 
1548
alter table t22 drop partition p0;
 
1549
alter table t44 drop partition p0;
 
1550
alter table t55 drop partition p0;
 
1551
alter table t66 drop partition p0;
 
1552
select * from t11 order by col1;
 
1553
col1
 
1554
15
 
1555
select * from t22 order by col1;
 
1556
col1
 
1557
13
 
1558
15
 
1559
17
 
1560
select * from t33 order by col1;
 
1561
col1
 
1562
13
 
1563
15
 
1564
17
 
1565
select * from t44 order by colint;
 
1566
colint  col1
 
1567
15      34
 
1568
16      324
 
1569
17      345
 
1570
18      34
 
1571
19      78
 
1572
20      567
 
1573
21      4
 
1574
22      435
 
1575
23      34
 
1576
24      45
 
1577
25      4565
 
1578
26      4
 
1579
27      3
 
1580
28      2
 
1581
29      3
 
1582
30      15
 
1583
31      6
 
1584
32      8
 
1585
33      9
 
1586
34      745
 
1587
35      34
 
1588
36      34
 
1589
37      324
 
1590
38      67
 
1591
39      78
 
1592
40      89
 
1593
41      90
 
1594
42      78967
 
1595
50      56
 
1596
51      34
 
1597
55      123
 
1598
60      13
 
1599
select * from t55 order by colint;
 
1600
colint  col1
 
1601
11      78
 
1602
12      89
 
1603
13      67
 
1604
14      46
 
1605
15      34
 
1606
16      324
 
1607
17      345
 
1608
18      34
 
1609
19      78
 
1610
20      567
 
1611
21      4
 
1612
22      435
 
1613
23      34
 
1614
24      45
 
1615
25      4565
 
1616
26      4
 
1617
27      3
 
1618
28      2
 
1619
29      3
 
1620
30      15
 
1621
31      6
 
1622
32      8
 
1623
33      9
 
1624
34      745
 
1625
35      34
 
1626
36      34
 
1627
37      324
 
1628
38      67
 
1629
39      78
 
1630
40      89
 
1631
41      90
 
1632
42      78967
 
1633
50      56
 
1634
51      34
 
1635
55      123
 
1636
60      13
 
1637
select * from t66 order by colint;
 
1638
colint  col1
 
1639
15      34
 
1640
16      324
 
1641
17      345
 
1642
18      34
 
1643
19      78
 
1644
20      567
 
1645
21      4
 
1646
22      435
 
1647
23      34
 
1648
24      45
 
1649
25      4565
 
1650
26      4
 
1651
27      3
 
1652
28      2
 
1653
29      3
 
1654
30      15
 
1655
31      6
 
1656
32      8
 
1657
33      9
 
1658
34      745
 
1659
35      34
 
1660
36      34
 
1661
37      324
 
1662
38      67
 
1663
39      78
 
1664
40      89
 
1665
41      90
 
1666
42      78967
 
1667
50      56
 
1668
51      34
 
1669
55      123
 
1670
60      13
 
1671
-------------------------
 
1672
---- some alter table end
 
1673
-------------------------
 
1674
drop table if exists t1 ;
 
1675
drop table if exists t2 ;
 
1676
drop table if exists t3 ;
 
1677
drop table if exists t4 ;
 
1678
drop table if exists t5 ;
 
1679
drop table if exists t6 ;
 
1680
drop table if exists t11 ;
 
1681
drop table if exists t22 ;
 
1682
drop table if exists t33 ;
 
1683
drop table if exists t44 ;
 
1684
drop table if exists t55 ;
 
1685
drop table if exists t66 ;
 
1686
-------------------------------------------------------------------------
 
1687
---  mod(col1,10)  in partition with coltype  int
 
1688
-------------------------------------------------------------------------
 
1689
drop table if exists t1 ;
 
1690
drop table if exists t2 ;
 
1691
drop table if exists t3 ;
 
1692
drop table if exists t4 ;
 
1693
drop table if exists t5 ;
 
1694
drop table if exists t6 ;
 
1695
-------------------------------------------------------------------------
 
1696
---  Create tables with mod(col1,10)
 
1697
-------------------------------------------------------------------------
 
1698
create table t1 (col1 int) engine='INNODB' 
 
1699
partition by range(mod(col1,10)) 
 
1700
(partition p0 values less than (15),
 
1701
partition p1 values less than maxvalue);
 
1702
create table t2 (col1 int) engine='INNODB' 
 
1703
partition by list(mod(col1,10)) 
 
1704
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
1705
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
1706
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
1707
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
1708
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
1709
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
1710
);
 
1711
create table t3 (col1 int) engine='INNODB' 
 
1712
partition by hash(mod(col1,10));
 
1713
create table t4 (colint int, col1 int) engine='INNODB' 
 
1714
partition by range(colint) 
 
1715
subpartition by hash(mod(col1,10)) subpartitions 2 
 
1716
(partition p0 values less than (15),
 
1717
partition p1 values less than maxvalue);
 
1718
create table t5 (colint int, col1 int) engine='INNODB' 
 
1719
partition by list(colint)
 
1720
subpartition by hash(mod(col1,10)) subpartitions 2 
 
1721
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
1722
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
1723
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
1724
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
1725
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
1726
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
1727
);
 
1728
create table t6 (colint int, col1 int) engine='INNODB' 
 
1729
partition by range(colint) 
 
1730
(partition p0 values less than (mod(15,10)),
 
1731
partition p1 values less than maxvalue);
 
1732
-------------------------------------------------------------------------
 
1733
---  Access tables with mod(col1,10) 
 
1734
-------------------------------------------------------------------------
 
1735
insert into t1 values (5);
 
1736
insert into t1 values (19);
 
1737
insert into t2 values (5);
 
1738
insert into t2 values (19);
 
1739
insert into t2 values (17);
 
1740
insert into t3 values (5);
 
1741
insert into t3 values (19);
 
1742
insert into t3 values (17);
 
1743
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t4;
 
1744
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t5;
 
1745
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_int.inc' into table t6;
 
1746
select mod(col1,10) from t1 order by col1;
 
1747
mod(col1,10)
 
1748
5
 
1749
9
 
1750
select * from t1 order by col1;
 
1751
col1
 
1752
5
 
1753
19
 
1754
select * from t2 order by col1;
 
1755
col1
 
1756
5
 
1757
17
 
1758
19
 
1759
select * from t3 order by col1;
 
1760
col1
 
1761
5
 
1762
17
 
1763
19
 
1764
select * from t4 order by colint;
 
1765
colint  col1
 
1766
1       5
 
1767
2       13
 
1768
3       15
 
1769
4       17
 
1770
5       23
 
1771
6       34
 
1772
7       56
 
1773
8       56
 
1774
9       45
 
1775
10      34
 
1776
11      78
 
1777
12      89
 
1778
13      67
 
1779
14      46
 
1780
15      34
 
1781
16      324
 
1782
17      345
 
1783
18      34
 
1784
19      78
 
1785
20      567
 
1786
21      4
 
1787
22      435
 
1788
23      34
 
1789
24      45
 
1790
25      4565
 
1791
26      4
 
1792
27      3
 
1793
28      2
 
1794
29      3
 
1795
30      5
 
1796
31      6
 
1797
32      8
 
1798
33      9
 
1799
34      745
 
1800
35      34
 
1801
36      34
 
1802
37      324
 
1803
38      67
 
1804
39      78
 
1805
40      89
 
1806
41      90
 
1807
42      78967
 
1808
50      56
 
1809
51      34
 
1810
55      123
 
1811
select * from t5 order by colint;
 
1812
colint  col1
 
1813
1       5
 
1814
2       13
 
1815
3       15
 
1816
4       17
 
1817
5       23
 
1818
6       34
 
1819
7       56
 
1820
8       56
 
1821
9       45
 
1822
10      34
 
1823
11      78
 
1824
12      89
 
1825
13      67
 
1826
14      46
 
1827
15      34
 
1828
16      324
 
1829
17      345
 
1830
18      34
 
1831
19      78
 
1832
20      567
 
1833
21      4
 
1834
22      435
 
1835
23      34
 
1836
24      45
 
1837
25      4565
 
1838
26      4
 
1839
27      3
 
1840
28      2
 
1841
29      3
 
1842
30      5
 
1843
31      6
 
1844
32      8
 
1845
33      9
 
1846
34      745
 
1847
35      34
 
1848
36      34
 
1849
37      324
 
1850
38      67
 
1851
39      78
 
1852
40      89
 
1853
41      90
 
1854
42      78967
 
1855
50      56
 
1856
51      34
 
1857
55      123
 
1858
select * from t6 order by colint;
 
1859
colint  col1
 
1860
1       5
 
1861
2       13
 
1862
3       15
 
1863
4       17
 
1864
5       23
 
1865
6       34
 
1866
7       56
 
1867
8       56
 
1868
9       45
 
1869
10      34
 
1870
11      78
 
1871
12      89
 
1872
13      67
 
1873
14      46
 
1874
15      34
 
1875
16      324
 
1876
17      345
 
1877
18      34
 
1878
19      78
 
1879
20      567
 
1880
21      4
 
1881
22      435
 
1882
23      34
 
1883
24      45
 
1884
25      4565
 
1885
26      4
 
1886
27      3
 
1887
28      2
 
1888
29      3
 
1889
30      5
 
1890
31      6
 
1891
32      8
 
1892
33      9
 
1893
34      745
 
1894
35      34
 
1895
36      34
 
1896
37      324
 
1897
38      67
 
1898
39      78
 
1899
40      89
 
1900
41      90
 
1901
42      78967
 
1902
50      56
 
1903
51      34
 
1904
55      123
 
1905
update t1 set col1=15  where col1=5;
 
1906
update t2 set col1=15  where col1=5;
 
1907
update t3 set col1=15  where col1=5;
 
1908
update t4 set col1=15  where col1=5;
 
1909
update t5 set col1=15  where col1=5;
 
1910
update t6 set col1=15  where col1=5;
 
1911
select * from t1 order by col1;
 
1912
col1
 
1913
15
 
1914
19
 
1915
select * from t2 order by col1;
 
1916
col1
 
1917
15
 
1918
17
 
1919
19
 
1920
select * from t3 order by col1;
 
1921
col1
 
1922
15
 
1923
17
 
1924
19
 
1925
select * from t4 order by colint;
 
1926
colint  col1
 
1927
1       15
 
1928
2       13
 
1929
3       15
 
1930
4       17
 
1931
5       23
 
1932
6       34
 
1933
7       56
 
1934
8       56
 
1935
9       45
 
1936
10      34
 
1937
11      78
 
1938
12      89
 
1939
13      67
 
1940
14      46
 
1941
15      34
 
1942
16      324
 
1943
17      345
 
1944
18      34
 
1945
19      78
 
1946
20      567
 
1947
21      4
 
1948
22      435
 
1949
23      34
 
1950
24      45
 
1951
25      4565
 
1952
26      4
 
1953
27      3
 
1954
28      2
 
1955
29      3
 
1956
30      15
 
1957
31      6
 
1958
32      8
 
1959
33      9
 
1960
34      745
 
1961
35      34
 
1962
36      34
 
1963
37      324
 
1964
38      67
 
1965
39      78
 
1966
40      89
 
1967
41      90
 
1968
42      78967
 
1969
50      56
 
1970
51      34
 
1971
55      123
 
1972
select * from t5 order by colint;
 
1973
colint  col1
 
1974
1       15
 
1975
2       13
 
1976
3       15
 
1977
4       17
 
1978
5       23
 
1979
6       34
 
1980
7       56
 
1981
8       56
 
1982
9       45
 
1983
10      34
 
1984
11      78
 
1985
12      89
 
1986
13      67
 
1987
14      46
 
1988
15      34
 
1989
16      324
 
1990
17      345
 
1991
18      34
 
1992
19      78
 
1993
20      567
 
1994
21      4
 
1995
22      435
 
1996
23      34
 
1997
24      45
 
1998
25      4565
 
1999
26      4
 
2000
27      3
 
2001
28      2
 
2002
29      3
 
2003
30      15
 
2004
31      6
 
2005
32      8
 
2006
33      9
 
2007
34      745
 
2008
35      34
 
2009
36      34
 
2010
37      324
 
2011
38      67
 
2012
39      78
 
2013
40      89
 
2014
41      90
 
2015
42      78967
 
2016
50      56
 
2017
51      34
 
2018
55      123
 
2019
select * from t6 order by colint;
 
2020
colint  col1
 
2021
1       15
 
2022
2       13
 
2023
3       15
 
2024
4       17
 
2025
5       23
 
2026
6       34
 
2027
7       56
 
2028
8       56
 
2029
9       45
 
2030
10      34
 
2031
11      78
 
2032
12      89
 
2033
13      67
 
2034
14      46
 
2035
15      34
 
2036
16      324
 
2037
17      345
 
2038
18      34
 
2039
19      78
 
2040
20      567
 
2041
21      4
 
2042
22      435
 
2043
23      34
 
2044
24      45
 
2045
25      4565
 
2046
26      4
 
2047
27      3
 
2048
28      2
 
2049
29      3
 
2050
30      15
 
2051
31      6
 
2052
32      8
 
2053
33      9
 
2054
34      745
 
2055
35      34
 
2056
36      34
 
2057
37      324
 
2058
38      67
 
2059
39      78
 
2060
40      89
 
2061
41      90
 
2062
42      78967
 
2063
50      56
 
2064
51      34
 
2065
55      123
 
2066
-------------------------------------------------------------------------
 
2067
---  Alter tables with mod(col1,10)
 
2068
-------------------------------------------------------------------------
 
2069
drop table if exists t11 ;
 
2070
drop table if exists t22 ;
 
2071
drop table if exists t33 ;
 
2072
drop table if exists t44 ;
 
2073
drop table if exists t55 ;
 
2074
drop table if exists t66 ;
 
2075
create table t11 engine='INNODB' as select * from t1;
 
2076
create table t22 engine='INNODB' as select * from t2;
 
2077
create table t33 engine='INNODB' as select * from t3;
 
2078
create table t44 engine='INNODB' as select * from t4;
 
2079
create table t55 engine='INNODB' as select * from t5;
 
2080
create table t66 engine='INNODB' as select * from t6;
 
2081
alter table t11
 
2082
partition by range(mod(col1,10)) 
 
2083
(partition p0 values less than (15),
 
2084
partition p1 values less than maxvalue);
 
2085
alter table t22
 
2086
partition by list(mod(col1,10)) 
 
2087
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
2088
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
2089
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
2090
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
2091
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
2092
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
2093
);
 
2094
alter table t33
 
2095
partition by hash(mod(col1,10));
 
2096
alter table t44
 
2097
partition by range(colint) 
 
2098
subpartition by hash(mod(col1,10)) subpartitions 2 
 
2099
(partition p0 values less than (15),
 
2100
partition p1 values less than maxvalue);
 
2101
alter table t55
 
2102
partition by list(colint)
 
2103
subpartition by hash(mod(col1,10)) subpartitions 2 
 
2104
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
2105
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
2106
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
2107
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
2108
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
2109
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
2110
);
 
2111
alter table t66
 
2112
partition by range(colint) 
 
2113
(partition p0 values less than (mod(15,10)),
 
2114
partition p1 values less than maxvalue);
 
2115
select * from t11 order by col1;
 
2116
col1
 
2117
15
 
2118
19
 
2119
select * from t22 order by col1;
 
2120
col1
 
2121
15
 
2122
17
 
2123
19
 
2124
select * from t33 order by col1;
 
2125
col1
 
2126
15
 
2127
17
 
2128
19
 
2129
select * from t44 order by colint;
 
2130
colint  col1
 
2131
1       15
 
2132
2       13
 
2133
3       15
 
2134
4       17
 
2135
5       23
 
2136
6       34
 
2137
7       56
 
2138
8       56
 
2139
9       45
 
2140
10      34
 
2141
11      78
 
2142
12      89
 
2143
13      67
 
2144
14      46
 
2145
15      34
 
2146
16      324
 
2147
17      345
 
2148
18      34
 
2149
19      78
 
2150
20      567
 
2151
21      4
 
2152
22      435
 
2153
23      34
 
2154
24      45
 
2155
25      4565
 
2156
26      4
 
2157
27      3
 
2158
28      2
 
2159
29      3
 
2160
30      15
 
2161
31      6
 
2162
32      8
 
2163
33      9
 
2164
34      745
 
2165
35      34
 
2166
36      34
 
2167
37      324
 
2168
38      67
 
2169
39      78
 
2170
40      89
 
2171
41      90
 
2172
42      78967
 
2173
50      56
 
2174
51      34
 
2175
55      123
 
2176
select * from t55 order by colint;
 
2177
colint  col1
 
2178
1       15
 
2179
2       13
 
2180
3       15
 
2181
4       17
 
2182
5       23
 
2183
6       34
 
2184
7       56
 
2185
8       56
 
2186
9       45
 
2187
10      34
 
2188
11      78
 
2189
12      89
 
2190
13      67
 
2191
14      46
 
2192
15      34
 
2193
16      324
 
2194
17      345
 
2195
18      34
 
2196
19      78
 
2197
20      567
 
2198
21      4
 
2199
22      435
 
2200
23      34
 
2201
24      45
 
2202
25      4565
 
2203
26      4
 
2204
27      3
 
2205
28      2
 
2206
29      3
 
2207
30      15
 
2208
31      6
 
2209
32      8
 
2210
33      9
 
2211
34      745
 
2212
35      34
 
2213
36      34
 
2214
37      324
 
2215
38      67
 
2216
39      78
 
2217
40      89
 
2218
41      90
 
2219
42      78967
 
2220
50      56
 
2221
51      34
 
2222
55      123
 
2223
select * from t66 order by colint;
 
2224
colint  col1
 
2225
1       15
 
2226
2       13
 
2227
3       15
 
2228
4       17
 
2229
5       23
 
2230
6       34
 
2231
7       56
 
2232
8       56
 
2233
9       45
 
2234
10      34
 
2235
11      78
 
2236
12      89
 
2237
13      67
 
2238
14      46
 
2239
15      34
 
2240
16      324
 
2241
17      345
 
2242
18      34
 
2243
19      78
 
2244
20      567
 
2245
21      4
 
2246
22      435
 
2247
23      34
 
2248
24      45
 
2249
25      4565
 
2250
26      4
 
2251
27      3
 
2252
28      2
 
2253
29      3
 
2254
30      15
 
2255
31      6
 
2256
32      8
 
2257
33      9
 
2258
34      745
 
2259
35      34
 
2260
36      34
 
2261
37      324
 
2262
38      67
 
2263
39      78
 
2264
40      89
 
2265
41      90
 
2266
42      78967
 
2267
50      56
 
2268
51      34
 
2269
55      123
 
2270
---------------------------
 
2271
---- some alter table begin
 
2272
---------------------------
 
2273
alter table t11
 
2274
reorganize partition p0,p1 into
 
2275
(partition s1 values less than maxvalue);
 
2276
select * from t11 order by col1;
 
2277
col1
 
2278
15
 
2279
19
 
2280
alter table t11
 
2281
reorganize partition s1 into
 
2282
(partition p0 values less than (15),
 
2283
partition p1 values less than maxvalue);
 
2284
select * from t11 order by col1;
 
2285
col1
 
2286
15
 
2287
19
 
2288
alter table t55
 
2289
partition by list(colint)
 
2290
subpartition by hash(mod(col1,10)) subpartitions 5 
 
2291
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
2292
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
2293
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
2294
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
2295
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
2296
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
2297
);
 
2298
show create table t55;
 
2299
Table   Create Table
 
2300
t55     CREATE TABLE `t55` (
 
2301
  `colint` int(11) DEFAULT NULL,
 
2302
  `col1` int(11) DEFAULT NULL
 
2303
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
2304
/*!50100 PARTITION BY LIST (colint)
 
2305
SUBPARTITION BY HASH (mod(col1,10))
 
2306
SUBPARTITIONS 5
 
2307
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
2308
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
2309
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
2310
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
2311
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
2312
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
2313
select * from t55 order by colint;
 
2314
colint  col1
 
2315
1       15
 
2316
2       13
 
2317
3       15
 
2318
4       17
 
2319
5       23
 
2320
6       34
 
2321
7       56
 
2322
8       56
 
2323
9       45
 
2324
10      34
 
2325
11      78
 
2326
12      89
 
2327
13      67
 
2328
14      46
 
2329
15      34
 
2330
16      324
 
2331
17      345
 
2332
18      34
 
2333
19      78
 
2334
20      567
 
2335
21      4
 
2336
22      435
 
2337
23      34
 
2338
24      45
 
2339
25      4565
 
2340
26      4
 
2341
27      3
 
2342
28      2
 
2343
29      3
 
2344
30      15
 
2345
31      6
 
2346
32      8
 
2347
33      9
 
2348
34      745
 
2349
35      34
 
2350
36      34
 
2351
37      324
 
2352
38      67
 
2353
39      78
 
2354
40      89
 
2355
41      90
 
2356
42      78967
 
2357
50      56
 
2358
51      34
 
2359
55      123
 
2360
alter table t66
 
2361
reorganize partition p0,p1 into
 
2362
(partition s1 values less than maxvalue);
 
2363
select * from t66 order by colint;
 
2364
colint  col1
 
2365
1       15
 
2366
2       13
 
2367
3       15
 
2368
4       17
 
2369
5       23
 
2370
6       34
 
2371
7       56
 
2372
8       56
 
2373
9       45
 
2374
10      34
 
2375
11      78
 
2376
12      89
 
2377
13      67
 
2378
14      46
 
2379
15      34
 
2380
16      324
 
2381
17      345
 
2382
18      34
 
2383
19      78
 
2384
20      567
 
2385
21      4
 
2386
22      435
 
2387
23      34
 
2388
24      45
 
2389
25      4565
 
2390
26      4
 
2391
27      3
 
2392
28      2
 
2393
29      3
 
2394
30      15
 
2395
31      6
 
2396
32      8
 
2397
33      9
 
2398
34      745
 
2399
35      34
 
2400
36      34
 
2401
37      324
 
2402
38      67
 
2403
39      78
 
2404
40      89
 
2405
41      90
 
2406
42      78967
 
2407
50      56
 
2408
51      34
 
2409
55      123
 
2410
alter table t66
 
2411
reorganize partition s1 into
 
2412
(partition p0 values less than (mod(15,10)),
 
2413
partition p1 values less than maxvalue);
 
2414
select * from t66 order by colint;
 
2415
colint  col1
 
2416
1       15
 
2417
2       13
 
2418
3       15
 
2419
4       17
 
2420
5       23
 
2421
6       34
 
2422
7       56
 
2423
8       56
 
2424
9       45
 
2425
10      34
 
2426
11      78
 
2427
12      89
 
2428
13      67
 
2429
14      46
 
2430
15      34
 
2431
16      324
 
2432
17      345
 
2433
18      34
 
2434
19      78
 
2435
20      567
 
2436
21      4
 
2437
22      435
 
2438
23      34
 
2439
24      45
 
2440
25      4565
 
2441
26      4
 
2442
27      3
 
2443
28      2
 
2444
29      3
 
2445
30      15
 
2446
31      6
 
2447
32      8
 
2448
33      9
 
2449
34      745
 
2450
35      34
 
2451
36      34
 
2452
37      324
 
2453
38      67
 
2454
39      78
 
2455
40      89
 
2456
41      90
 
2457
42      78967
 
2458
50      56
 
2459
51      34
 
2460
55      123
 
2461
alter table t66
 
2462
reorganize partition p0,p1 into
 
2463
(partition s1 values less than maxvalue);
 
2464
select * from t66 order by colint;
 
2465
colint  col1
 
2466
1       15
 
2467
2       13
 
2468
3       15
 
2469
4       17
 
2470
5       23
 
2471
6       34
 
2472
7       56
 
2473
8       56
 
2474
9       45
 
2475
10      34
 
2476
11      78
 
2477
12      89
 
2478
13      67
 
2479
14      46
 
2480
15      34
 
2481
16      324
 
2482
17      345
 
2483
18      34
 
2484
19      78
 
2485
20      567
 
2486
21      4
 
2487
22      435
 
2488
23      34
 
2489
24      45
 
2490
25      4565
 
2491
26      4
 
2492
27      3
 
2493
28      2
 
2494
29      3
 
2495
30      15
 
2496
31      6
 
2497
32      8
 
2498
33      9
 
2499
34      745
 
2500
35      34
 
2501
36      34
 
2502
37      324
 
2503
38      67
 
2504
39      78
 
2505
40      89
 
2506
41      90
 
2507
42      78967
 
2508
50      56
 
2509
51      34
 
2510
55      123
 
2511
alter table t66
 
2512
reorganize partition s1 into
 
2513
(partition p0 values less than (mod(15,10)),
 
2514
partition p1 values less than maxvalue);
 
2515
select * from t66 order by colint;
 
2516
colint  col1
 
2517
1       15
 
2518
2       13
 
2519
3       15
 
2520
4       17
 
2521
5       23
 
2522
6       34
 
2523
7       56
 
2524
8       56
 
2525
9       45
 
2526
10      34
 
2527
11      78
 
2528
12      89
 
2529
13      67
 
2530
14      46
 
2531
15      34
 
2532
16      324
 
2533
17      345
 
2534
18      34
 
2535
19      78
 
2536
20      567
 
2537
21      4
 
2538
22      435
 
2539
23      34
 
2540
24      45
 
2541
25      4565
 
2542
26      4
 
2543
27      3
 
2544
28      2
 
2545
29      3
 
2546
30      15
 
2547
31      6
 
2548
32      8
 
2549
33      9
 
2550
34      745
 
2551
35      34
 
2552
36      34
 
2553
37      324
 
2554
38      67
 
2555
39      78
 
2556
40      89
 
2557
41      90
 
2558
42      78967
 
2559
50      56
 
2560
51      34
 
2561
55      123
 
2562
-------------------------------------------------------------------------
 
2563
---  Delete rows and partitions of tables with mod(col1,10)
 
2564
-------------------------------------------------------------------------
 
2565
delete from t1 where col1=19;
 
2566
delete from t2 where col1=19;
 
2567
delete from t3 where col1=19;
 
2568
delete from t4 where col1=19;
 
2569
delete from t5 where col1=19;
 
2570
delete from t6 where col1=19;
 
2571
select * from t1 order by col1;
 
2572
col1
 
2573
15
 
2574
select * from t2 order by col1;
 
2575
col1
 
2576
15
 
2577
17
 
2578
select * from t3 order by col1;
 
2579
col1
 
2580
15
 
2581
17
 
2582
select * from t4 order by colint;
 
2583
colint  col1
 
2584
1       15
 
2585
2       13
 
2586
3       15
 
2587
4       17
 
2588
5       23
 
2589
6       34
 
2590
7       56
 
2591
8       56
 
2592
9       45
 
2593
10      34
 
2594
11      78
 
2595
12      89
 
2596
13      67
 
2597
14      46
 
2598
15      34
 
2599
16      324
 
2600
17      345
 
2601
18      34
 
2602
19      78
 
2603
20      567
 
2604
21      4
 
2605
22      435
 
2606
23      34
 
2607
24      45
 
2608
25      4565
 
2609
26      4
 
2610
27      3
 
2611
28      2
 
2612
29      3
 
2613
30      15
 
2614
31      6
 
2615
32      8
 
2616
33      9
 
2617
34      745
 
2618
35      34
 
2619
36      34
 
2620
37      324
 
2621
38      67
 
2622
39      78
 
2623
40      89
 
2624
41      90
 
2625
42      78967
 
2626
50      56
 
2627
51      34
 
2628
55      123
 
2629
select * from t5 order by colint;
 
2630
colint  col1
 
2631
1       15
 
2632
2       13
 
2633
3       15
 
2634
4       17
 
2635
5       23
 
2636
6       34
 
2637
7       56
 
2638
8       56
 
2639
9       45
 
2640
10      34
 
2641
11      78
 
2642
12      89
 
2643
13      67
 
2644
14      46
 
2645
15      34
 
2646
16      324
 
2647
17      345
 
2648
18      34
 
2649
19      78
 
2650
20      567
 
2651
21      4
 
2652
22      435
 
2653
23      34
 
2654
24      45
 
2655
25      4565
 
2656
26      4
 
2657
27      3
 
2658
28      2
 
2659
29      3
 
2660
30      15
 
2661
31      6
 
2662
32      8
 
2663
33      9
 
2664
34      745
 
2665
35      34
 
2666
36      34
 
2667
37      324
 
2668
38      67
 
2669
39      78
 
2670
40      89
 
2671
41      90
 
2672
42      78967
 
2673
50      56
 
2674
51      34
 
2675
55      123
 
2676
insert into t1 values (19);
 
2677
insert into t2 values (19);
 
2678
insert into t3 values (19);
 
2679
insert into t4 values (60,19);
 
2680
insert into t5 values (60,19);
 
2681
insert into t6 values (60,19);
 
2682
select * from t1 order by col1;
 
2683
col1
 
2684
15
 
2685
19
 
2686
select * from t2 order by col1;
 
2687
col1
 
2688
15
 
2689
17
 
2690
19
 
2691
select * from t3 order by col1;
 
2692
col1
 
2693
15
 
2694
17
 
2695
19
 
2696
select * from t4 order by colint;
 
2697
colint  col1
 
2698
1       15
 
2699
2       13
 
2700
3       15
 
2701
4       17
 
2702
5       23
 
2703
6       34
 
2704
7       56
 
2705
8       56
 
2706
9       45
 
2707
10      34
 
2708
11      78
 
2709
12      89
 
2710
13      67
 
2711
14      46
 
2712
15      34
 
2713
16      324
 
2714
17      345
 
2715
18      34
 
2716
19      78
 
2717
20      567
 
2718
21      4
 
2719
22      435
 
2720
23      34
 
2721
24      45
 
2722
25      4565
 
2723
26      4
 
2724
27      3
 
2725
28      2
 
2726
29      3
 
2727
30      15
 
2728
31      6
 
2729
32      8
 
2730
33      9
 
2731
34      745
 
2732
35      34
 
2733
36      34
 
2734
37      324
 
2735
38      67
 
2736
39      78
 
2737
40      89
 
2738
41      90
 
2739
42      78967
 
2740
50      56
 
2741
51      34
 
2742
55      123
 
2743
60      19
 
2744
select * from t5 order by colint;
 
2745
colint  col1
 
2746
1       15
 
2747
2       13
 
2748
3       15
 
2749
4       17
 
2750
5       23
 
2751
6       34
 
2752
7       56
 
2753
8       56
 
2754
9       45
 
2755
10      34
 
2756
11      78
 
2757
12      89
 
2758
13      67
 
2759
14      46
 
2760
15      34
 
2761
16      324
 
2762
17      345
 
2763
18      34
 
2764
19      78
 
2765
20      567
 
2766
21      4
 
2767
22      435
 
2768
23      34
 
2769
24      45
 
2770
25      4565
 
2771
26      4
 
2772
27      3
 
2773
28      2
 
2774
29      3
 
2775
30      15
 
2776
31      6
 
2777
32      8
 
2778
33      9
 
2779
34      745
 
2780
35      34
 
2781
36      34
 
2782
37      324
 
2783
38      67
 
2784
39      78
 
2785
40      89
 
2786
41      90
 
2787
42      78967
 
2788
50      56
 
2789
51      34
 
2790
55      123
 
2791
60      19
 
2792
select * from t6 order by colint;
 
2793
colint  col1
 
2794
1       15
 
2795
2       13
 
2796
3       15
 
2797
4       17
 
2798
5       23
 
2799
6       34
 
2800
7       56
 
2801
8       56
 
2802
9       45
 
2803
10      34
 
2804
11      78
 
2805
12      89
 
2806
13      67
 
2807
14      46
 
2808
15      34
 
2809
16      324
 
2810
17      345
 
2811
18      34
 
2812
19      78
 
2813
20      567
 
2814
21      4
 
2815
22      435
 
2816
23      34
 
2817
24      45
 
2818
25      4565
 
2819
26      4
 
2820
27      3
 
2821
28      2
 
2822
29      3
 
2823
30      15
 
2824
31      6
 
2825
32      8
 
2826
33      9
 
2827
34      745
 
2828
35      34
 
2829
36      34
 
2830
37      324
 
2831
38      67
 
2832
39      78
 
2833
40      89
 
2834
41      90
 
2835
42      78967
 
2836
50      56
 
2837
51      34
 
2838
55      123
 
2839
60      19
 
2840
alter table t1 drop partition p0;
 
2841
alter table t2 drop partition p0;
 
2842
alter table t4 drop partition p0;
 
2843
alter table t5 drop partition p0;
 
2844
alter table t6 drop partition p0;
 
2845
select * from t1 order by col1;
 
2846
col1
 
2847
select * from t2 order by col1;
 
2848
col1
 
2849
select * from t3 order by col1;
 
2850
col1
 
2851
15
 
2852
17
 
2853
19
 
2854
select * from t4 order by colint;
 
2855
colint  col1
 
2856
15      34
 
2857
16      324
 
2858
17      345
 
2859
18      34
 
2860
19      78
 
2861
20      567
 
2862
21      4
 
2863
22      435
 
2864
23      34
 
2865
24      45
 
2866
25      4565
 
2867
26      4
 
2868
27      3
 
2869
28      2
 
2870
29      3
 
2871
30      15
 
2872
31      6
 
2873
32      8
 
2874
33      9
 
2875
34      745
 
2876
35      34
 
2877
36      34
 
2878
37      324
 
2879
38      67
 
2880
39      78
 
2881
40      89
 
2882
41      90
 
2883
42      78967
 
2884
50      56
 
2885
51      34
 
2886
55      123
 
2887
60      19
 
2888
select * from t5 order by colint;
 
2889
colint  col1
 
2890
11      78
 
2891
12      89
 
2892
13      67
 
2893
14      46
 
2894
15      34
 
2895
16      324
 
2896
17      345
 
2897
18      34
 
2898
19      78
 
2899
20      567
 
2900
21      4
 
2901
22      435
 
2902
23      34
 
2903
24      45
 
2904
25      4565
 
2905
26      4
 
2906
27      3
 
2907
28      2
 
2908
29      3
 
2909
30      15
 
2910
31      6
 
2911
32      8
 
2912
33      9
 
2913
34      745
 
2914
35      34
 
2915
36      34
 
2916
37      324
 
2917
38      67
 
2918
39      78
 
2919
40      89
 
2920
41      90
 
2921
42      78967
 
2922
50      56
 
2923
51      34
 
2924
55      123
 
2925
60      19
 
2926
select * from t6 order by colint;
 
2927
colint  col1
 
2928
5       23
 
2929
6       34
 
2930
7       56
 
2931
8       56
 
2932
9       45
 
2933
10      34
 
2934
11      78
 
2935
12      89
 
2936
13      67
 
2937
14      46
 
2938
15      34
 
2939
16      324
 
2940
17      345
 
2941
18      34
 
2942
19      78
 
2943
20      567
 
2944
21      4
 
2945
22      435
 
2946
23      34
 
2947
24      45
 
2948
25      4565
 
2949
26      4
 
2950
27      3
 
2951
28      2
 
2952
29      3
 
2953
30      15
 
2954
31      6
 
2955
32      8
 
2956
33      9
 
2957
34      745
 
2958
35      34
 
2959
36      34
 
2960
37      324
 
2961
38      67
 
2962
39      78
 
2963
40      89
 
2964
41      90
 
2965
42      78967
 
2966
50      56
 
2967
51      34
 
2968
55      123
 
2969
60      19
 
2970
-------------------------------------------------------------------------
 
2971
---  Delete rows and partitions of tables with mod(col1,10)
 
2972
-------------------------------------------------------------------------
 
2973
delete from t11 where col1=19;
 
2974
delete from t22 where col1=19;
 
2975
delete from t33 where col1=19;
 
2976
delete from t44 where col1=19;
 
2977
delete from t55 where col1=19;
 
2978
delete from t66 where col1=19;
 
2979
select * from t11 order by col1;
 
2980
col1
 
2981
15
 
2982
select * from t22 order by col1;
 
2983
col1
 
2984
15
 
2985
17
 
2986
select * from t33 order by col1;
 
2987
col1
 
2988
15
 
2989
17
 
2990
select * from t44 order by colint;
 
2991
colint  col1
 
2992
1       15
 
2993
2       13
 
2994
3       15
 
2995
4       17
 
2996
5       23
 
2997
6       34
 
2998
7       56
 
2999
8       56
 
3000
9       45
 
3001
10      34
 
3002
11      78
 
3003
12      89
 
3004
13      67
 
3005
14      46
 
3006
15      34
 
3007
16      324
 
3008
17      345
 
3009
18      34
 
3010
19      78
 
3011
20      567
 
3012
21      4
 
3013
22      435
 
3014
23      34
 
3015
24      45
 
3016
25      4565
 
3017
26      4
 
3018
27      3
 
3019
28      2
 
3020
29      3
 
3021
30      15
 
3022
31      6
 
3023
32      8
 
3024
33      9
 
3025
34      745
 
3026
35      34
 
3027
36      34
 
3028
37      324
 
3029
38      67
 
3030
39      78
 
3031
40      89
 
3032
41      90
 
3033
42      78967
 
3034
50      56
 
3035
51      34
 
3036
55      123
 
3037
select * from t55 order by colint;
 
3038
colint  col1
 
3039
1       15
 
3040
2       13
 
3041
3       15
 
3042
4       17
 
3043
5       23
 
3044
6       34
 
3045
7       56
 
3046
8       56
 
3047
9       45
 
3048
10      34
 
3049
11      78
 
3050
12      89
 
3051
13      67
 
3052
14      46
 
3053
15      34
 
3054
16      324
 
3055
17      345
 
3056
18      34
 
3057
19      78
 
3058
20      567
 
3059
21      4
 
3060
22      435
 
3061
23      34
 
3062
24      45
 
3063
25      4565
 
3064
26      4
 
3065
27      3
 
3066
28      2
 
3067
29      3
 
3068
30      15
 
3069
31      6
 
3070
32      8
 
3071
33      9
 
3072
34      745
 
3073
35      34
 
3074
36      34
 
3075
37      324
 
3076
38      67
 
3077
39      78
 
3078
40      89
 
3079
41      90
 
3080
42      78967
 
3081
50      56
 
3082
51      34
 
3083
55      123
 
3084
insert into t11 values (19);
 
3085
insert into t22 values (19);
 
3086
insert into t33 values (19);
 
3087
insert into t44 values (60,19);
 
3088
insert into t55 values (60,19);
 
3089
insert into t66 values (60,19);
 
3090
select * from t11 order by col1;
 
3091
col1
 
3092
15
 
3093
19
 
3094
select * from t22 order by col1;
 
3095
col1
 
3096
15
 
3097
17
 
3098
19
 
3099
select * from t33 order by col1;
 
3100
col1
 
3101
15
 
3102
17
 
3103
19
 
3104
select * from t44 order by colint;
 
3105
colint  col1
 
3106
1       15
 
3107
2       13
 
3108
3       15
 
3109
4       17
 
3110
5       23
 
3111
6       34
 
3112
7       56
 
3113
8       56
 
3114
9       45
 
3115
10      34
 
3116
11      78
 
3117
12      89
 
3118
13      67
 
3119
14      46
 
3120
15      34
 
3121
16      324
 
3122
17      345
 
3123
18      34
 
3124
19      78
 
3125
20      567
 
3126
21      4
 
3127
22      435
 
3128
23      34
 
3129
24      45
 
3130
25      4565
 
3131
26      4
 
3132
27      3
 
3133
28      2
 
3134
29      3
 
3135
30      15
 
3136
31      6
 
3137
32      8
 
3138
33      9
 
3139
34      745
 
3140
35      34
 
3141
36      34
 
3142
37      324
 
3143
38      67
 
3144
39      78
 
3145
40      89
 
3146
41      90
 
3147
42      78967
 
3148
50      56
 
3149
51      34
 
3150
55      123
 
3151
60      19
 
3152
select * from t55 order by colint;
 
3153
colint  col1
 
3154
1       15
 
3155
2       13
 
3156
3       15
 
3157
4       17
 
3158
5       23
 
3159
6       34
 
3160
7       56
 
3161
8       56
 
3162
9       45
 
3163
10      34
 
3164
11      78
 
3165
12      89
 
3166
13      67
 
3167
14      46
 
3168
15      34
 
3169
16      324
 
3170
17      345
 
3171
18      34
 
3172
19      78
 
3173
20      567
 
3174
21      4
 
3175
22      435
 
3176
23      34
 
3177
24      45
 
3178
25      4565
 
3179
26      4
 
3180
27      3
 
3181
28      2
 
3182
29      3
 
3183
30      15
 
3184
31      6
 
3185
32      8
 
3186
33      9
 
3187
34      745
 
3188
35      34
 
3189
36      34
 
3190
37      324
 
3191
38      67
 
3192
39      78
 
3193
40      89
 
3194
41      90
 
3195
42      78967
 
3196
50      56
 
3197
51      34
 
3198
55      123
 
3199
60      19
 
3200
select * from t66 order by colint;
 
3201
colint  col1
 
3202
1       15
 
3203
2       13
 
3204
3       15
 
3205
4       17
 
3206
5       23
 
3207
6       34
 
3208
7       56
 
3209
8       56
 
3210
9       45
 
3211
10      34
 
3212
11      78
 
3213
12      89
 
3214
13      67
 
3215
14      46
 
3216
15      34
 
3217
16      324
 
3218
17      345
 
3219
18      34
 
3220
19      78
 
3221
20      567
 
3222
21      4
 
3223
22      435
 
3224
23      34
 
3225
24      45
 
3226
25      4565
 
3227
26      4
 
3228
27      3
 
3229
28      2
 
3230
29      3
 
3231
30      15
 
3232
31      6
 
3233
32      8
 
3234
33      9
 
3235
34      745
 
3236
35      34
 
3237
36      34
 
3238
37      324
 
3239
38      67
 
3240
39      78
 
3241
40      89
 
3242
41      90
 
3243
42      78967
 
3244
50      56
 
3245
51      34
 
3246
55      123
 
3247
60      19
 
3248
alter table t11 drop partition p0;
 
3249
alter table t22 drop partition p0;
 
3250
alter table t44 drop partition p0;
 
3251
alter table t55 drop partition p0;
 
3252
alter table t66 drop partition p0;
 
3253
select * from t11 order by col1;
 
3254
col1
 
3255
select * from t22 order by col1;
 
3256
col1
 
3257
select * from t33 order by col1;
 
3258
col1
 
3259
15
 
3260
17
 
3261
19
 
3262
select * from t44 order by colint;
 
3263
colint  col1
 
3264
15      34
 
3265
16      324
 
3266
17      345
 
3267
18      34
 
3268
19      78
 
3269
20      567
 
3270
21      4
 
3271
22      435
 
3272
23      34
 
3273
24      45
 
3274
25      4565
 
3275
26      4
 
3276
27      3
 
3277
28      2
 
3278
29      3
 
3279
30      15
 
3280
31      6
 
3281
32      8
 
3282
33      9
 
3283
34      745
 
3284
35      34
 
3285
36      34
 
3286
37      324
 
3287
38      67
 
3288
39      78
 
3289
40      89
 
3290
41      90
 
3291
42      78967
 
3292
50      56
 
3293
51      34
 
3294
55      123
 
3295
60      19
 
3296
select * from t55 order by colint;
 
3297
colint  col1
 
3298
11      78
 
3299
12      89
 
3300
13      67
 
3301
14      46
 
3302
15      34
 
3303
16      324
 
3304
17      345
 
3305
18      34
 
3306
19      78
 
3307
20      567
 
3308
21      4
 
3309
22      435
 
3310
23      34
 
3311
24      45
 
3312
25      4565
 
3313
26      4
 
3314
27      3
 
3315
28      2
 
3316
29      3
 
3317
30      15
 
3318
31      6
 
3319
32      8
 
3320
33      9
 
3321
34      745
 
3322
35      34
 
3323
36      34
 
3324
37      324
 
3325
38      67
 
3326
39      78
 
3327
40      89
 
3328
41      90
 
3329
42      78967
 
3330
50      56
 
3331
51      34
 
3332
55      123
 
3333
60      19
 
3334
select * from t66 order by colint;
 
3335
colint  col1
 
3336
5       23
 
3337
6       34
 
3338
7       56
 
3339
8       56
 
3340
9       45
 
3341
10      34
 
3342
11      78
 
3343
12      89
 
3344
13      67
 
3345
14      46
 
3346
15      34
 
3347
16      324
 
3348
17      345
 
3349
18      34
 
3350
19      78
 
3351
20      567
 
3352
21      4
 
3353
22      435
 
3354
23      34
 
3355
24      45
 
3356
25      4565
 
3357
26      4
 
3358
27      3
 
3359
28      2
 
3360
29      3
 
3361
30      15
 
3362
31      6
 
3363
32      8
 
3364
33      9
 
3365
34      745
 
3366
35      34
 
3367
36      34
 
3368
37      324
 
3369
38      67
 
3370
39      78
 
3371
40      89
 
3372
41      90
 
3373
42      78967
 
3374
50      56
 
3375
51      34
 
3376
55      123
 
3377
60      19
 
3378
-------------------------
 
3379
---- some alter table end
 
3380
-------------------------
 
3381
drop table if exists t1 ;
 
3382
drop table if exists t2 ;
 
3383
drop table if exists t3 ;
 
3384
drop table if exists t4 ;
 
3385
drop table if exists t5 ;
 
3386
drop table if exists t6 ;
 
3387
drop table if exists t11 ;
 
3388
drop table if exists t22 ;
 
3389
drop table if exists t33 ;
 
3390
drop table if exists t44 ;
 
3391
drop table if exists t55 ;
 
3392
drop table if exists t66 ;
 
3393
-------------------------------------------------------------------------
 
3394
---  day(col1)  in partition with coltype  date
 
3395
-------------------------------------------------------------------------
 
3396
drop table if exists t1 ;
 
3397
drop table if exists t2 ;
 
3398
drop table if exists t3 ;
 
3399
drop table if exists t4 ;
 
3400
drop table if exists t5 ;
 
3401
drop table if exists t6 ;
 
3402
-------------------------------------------------------------------------
 
3403
---  Create tables with day(col1)
 
3404
-------------------------------------------------------------------------
 
3405
create table t1 (col1 date) engine='INNODB' 
 
3406
partition by range(day(col1)) 
 
3407
(partition p0 values less than (15),
 
3408
partition p1 values less than maxvalue);
 
3409
create table t2 (col1 date) engine='INNODB' 
 
3410
partition by list(day(col1)) 
 
3411
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
3412
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
3413
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
3414
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
3415
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
3416
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
3417
);
 
3418
create table t3 (col1 date) engine='INNODB' 
 
3419
partition by hash(day(col1));
 
3420
create table t4 (colint int, col1 date) engine='INNODB' 
 
3421
partition by range(colint) 
 
3422
subpartition by hash(day(col1)) subpartitions 2 
 
3423
(partition p0 values less than (15),
 
3424
partition p1 values less than maxvalue);
 
3425
create table t5 (colint int, col1 date) engine='INNODB' 
 
3426
partition by list(colint)
 
3427
subpartition by hash(day(col1)) subpartitions 2 
 
3428
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
3429
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
3430
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
3431
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
3432
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
3433
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
3434
);
 
3435
create table t6 (colint int, col1 date) engine='INNODB' 
 
3436
partition by range(colint) 
 
3437
(partition p0 values less than (day('2006-12-21')),
 
3438
partition p1 values less than maxvalue);
 
3439
-------------------------------------------------------------------------
 
3440
---  Access tables with day(col1) 
 
3441
-------------------------------------------------------------------------
 
3442
insert into t1 values ('2006-02-03');
 
3443
insert into t1 values ('2006-01-17');
 
3444
insert into t2 values ('2006-02-03');
 
3445
insert into t2 values ('2006-01-17');
 
3446
insert into t2 values ('2006-01-25');
 
3447
insert into t3 values ('2006-02-03');
 
3448
insert into t3 values ('2006-01-17');
 
3449
insert into t3 values ('2006-01-25');
 
3450
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
 
3451
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
 
3452
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
 
3453
select day(col1) from t1 order by col1;
 
3454
day(col1)
 
3455
17
 
3456
3
 
3457
select * from t1 order by col1;
 
3458
col1
 
3459
2006-01-17
 
3460
2006-02-03
 
3461
select * from t2 order by col1;
 
3462
col1
 
3463
2006-01-17
 
3464
2006-01-25
 
3465
2006-02-03
 
3466
select * from t3 order by col1;
 
3467
col1
 
3468
2006-01-17
 
3469
2006-01-25
 
3470
2006-02-03
 
3471
select * from t4 order by colint;
 
3472
colint  col1
 
3473
1       2006-02-03
 
3474
2       2006-01-17
 
3475
3       2006-01-25
 
3476
4       2006-02-05
 
3477
select * from t5 order by colint;
 
3478
colint  col1
 
3479
1       2006-02-03
 
3480
2       2006-01-17
 
3481
3       2006-01-25
 
3482
4       2006-02-05
 
3483
select * from t6 order by colint;
 
3484
colint  col1
 
3485
1       2006-02-03
 
3486
2       2006-01-17
 
3487
3       2006-01-25
 
3488
4       2006-02-05
 
3489
update t1 set col1='2006-02-05' where col1='2006-02-03';
 
3490
update t2 set col1='2006-02-05' where col1='2006-02-03';
 
3491
update t3 set col1='2006-02-05' where col1='2006-02-03';
 
3492
update t4 set col1='2006-02-05' where col1='2006-02-03';
 
3493
update t5 set col1='2006-02-05' where col1='2006-02-03';
 
3494
update t6 set col1='2006-02-05' where col1='2006-02-03';
 
3495
select * from t1 order by col1;
 
3496
col1
 
3497
2006-01-17
 
3498
2006-02-05
 
3499
select * from t2 order by col1;
 
3500
col1
 
3501
2006-01-17
 
3502
2006-01-25
 
3503
2006-02-05
 
3504
select * from t3 order by col1;
 
3505
col1
 
3506
2006-01-17
 
3507
2006-01-25
 
3508
2006-02-05
 
3509
select * from t4 order by colint;
 
3510
colint  col1
 
3511
1       2006-02-05
 
3512
2       2006-01-17
 
3513
3       2006-01-25
 
3514
4       2006-02-05
 
3515
select * from t5 order by colint;
 
3516
colint  col1
 
3517
1       2006-02-05
 
3518
2       2006-01-17
 
3519
3       2006-01-25
 
3520
4       2006-02-05
 
3521
select * from t6 order by colint;
 
3522
colint  col1
 
3523
1       2006-02-05
 
3524
2       2006-01-17
 
3525
3       2006-01-25
 
3526
4       2006-02-05
 
3527
-------------------------------------------------------------------------
 
3528
---  Alter tables with day(col1)
 
3529
-------------------------------------------------------------------------
 
3530
drop table if exists t11 ;
 
3531
drop table if exists t22 ;
 
3532
drop table if exists t33 ;
 
3533
drop table if exists t44 ;
 
3534
drop table if exists t55 ;
 
3535
drop table if exists t66 ;
 
3536
create table t11 engine='INNODB' as select * from t1;
 
3537
create table t22 engine='INNODB' as select * from t2;
 
3538
create table t33 engine='INNODB' as select * from t3;
 
3539
create table t44 engine='INNODB' as select * from t4;
 
3540
create table t55 engine='INNODB' as select * from t5;
 
3541
create table t66 engine='INNODB' as select * from t6;
 
3542
alter table t11
 
3543
partition by range(day(col1)) 
 
3544
(partition p0 values less than (15),
 
3545
partition p1 values less than maxvalue);
 
3546
alter table t22
 
3547
partition by list(day(col1)) 
 
3548
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
3549
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
3550
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
3551
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
3552
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
3553
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
3554
);
 
3555
alter table t33
 
3556
partition by hash(day(col1));
 
3557
alter table t44
 
3558
partition by range(colint) 
 
3559
subpartition by hash(day(col1)) subpartitions 2 
 
3560
(partition p0 values less than (15),
 
3561
partition p1 values less than maxvalue);
 
3562
alter table t55
 
3563
partition by list(colint)
 
3564
subpartition by hash(day(col1)) subpartitions 2 
 
3565
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
3566
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
3567
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
3568
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
3569
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
3570
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
3571
);
 
3572
alter table t66
 
3573
partition by range(colint) 
 
3574
(partition p0 values less than (day('2006-12-21')),
 
3575
partition p1 values less than maxvalue);
 
3576
select * from t11 order by col1;
 
3577
col1
 
3578
2006-01-17
 
3579
2006-02-05
 
3580
select * from t22 order by col1;
 
3581
col1
 
3582
2006-01-17
 
3583
2006-01-25
 
3584
2006-02-05
 
3585
select * from t33 order by col1;
 
3586
col1
 
3587
2006-01-17
 
3588
2006-01-25
 
3589
2006-02-05
 
3590
select * from t44 order by colint;
 
3591
colint  col1
 
3592
1       2006-02-05
 
3593
2       2006-01-17
 
3594
3       2006-01-25
 
3595
4       2006-02-05
 
3596
select * from t55 order by colint;
 
3597
colint  col1
 
3598
1       2006-02-05
 
3599
2       2006-01-17
 
3600
3       2006-01-25
 
3601
4       2006-02-05
 
3602
select * from t66 order by colint;
 
3603
colint  col1
 
3604
1       2006-02-05
 
3605
2       2006-01-17
 
3606
3       2006-01-25
 
3607
4       2006-02-05
 
3608
---------------------------
 
3609
---- some alter table begin
 
3610
---------------------------
 
3611
alter table t11
 
3612
reorganize partition p0,p1 into
 
3613
(partition s1 values less than maxvalue);
 
3614
select * from t11 order by col1;
 
3615
col1
 
3616
2006-01-17
 
3617
2006-02-05
 
3618
alter table t11
 
3619
reorganize partition s1 into
 
3620
(partition p0 values less than (15),
 
3621
partition p1 values less than maxvalue);
 
3622
select * from t11 order by col1;
 
3623
col1
 
3624
2006-01-17
 
3625
2006-02-05
 
3626
alter table t55
 
3627
partition by list(colint)
 
3628
subpartition by hash(day(col1)) subpartitions 5 
 
3629
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
3630
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
3631
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
3632
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
3633
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
3634
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
3635
);
 
3636
show create table t55;
 
3637
Table   Create Table
 
3638
t55     CREATE TABLE `t55` (
 
3639
  `colint` int(11) DEFAULT NULL,
 
3640
  `col1` date DEFAULT NULL
 
3641
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
3642
/*!50100 PARTITION BY LIST (colint)
 
3643
SUBPARTITION BY HASH (day(col1))
 
3644
SUBPARTITIONS 5
 
3645
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
3646
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
3647
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
3648
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
3649
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
3650
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
3651
select * from t55 order by colint;
 
3652
colint  col1
 
3653
1       2006-02-05
 
3654
2       2006-01-17
 
3655
3       2006-01-25
 
3656
4       2006-02-05
 
3657
alter table t66
 
3658
reorganize partition p0,p1 into
 
3659
(partition s1 values less than maxvalue);
 
3660
select * from t66 order by colint;
 
3661
colint  col1
 
3662
1       2006-02-05
 
3663
2       2006-01-17
 
3664
3       2006-01-25
 
3665
4       2006-02-05
 
3666
alter table t66
 
3667
reorganize partition s1 into
 
3668
(partition p0 values less than (day('2006-12-21')),
 
3669
partition p1 values less than maxvalue);
 
3670
select * from t66 order by colint;
 
3671
colint  col1
 
3672
1       2006-02-05
 
3673
2       2006-01-17
 
3674
3       2006-01-25
 
3675
4       2006-02-05
 
3676
alter table t66
 
3677
reorganize partition p0,p1 into
 
3678
(partition s1 values less than maxvalue);
 
3679
select * from t66 order by colint;
 
3680
colint  col1
 
3681
1       2006-02-05
 
3682
2       2006-01-17
 
3683
3       2006-01-25
 
3684
4       2006-02-05
 
3685
alter table t66
 
3686
reorganize partition s1 into
 
3687
(partition p0 values less than (day('2006-12-21')),
 
3688
partition p1 values less than maxvalue);
 
3689
select * from t66 order by colint;
 
3690
colint  col1
 
3691
1       2006-02-05
 
3692
2       2006-01-17
 
3693
3       2006-01-25
 
3694
4       2006-02-05
 
3695
-------------------------------------------------------------------------
 
3696
---  Delete rows and partitions of tables with day(col1)
 
3697
-------------------------------------------------------------------------
 
3698
delete from t1 where col1='2006-01-17';
 
3699
delete from t2 where col1='2006-01-17';
 
3700
delete from t3 where col1='2006-01-17';
 
3701
delete from t4 where col1='2006-01-17';
 
3702
delete from t5 where col1='2006-01-17';
 
3703
delete from t6 where col1='2006-01-17';
 
3704
select * from t1 order by col1;
 
3705
col1
 
3706
2006-02-05
 
3707
select * from t2 order by col1;
 
3708
col1
 
3709
2006-01-25
 
3710
2006-02-05
 
3711
select * from t3 order by col1;
 
3712
col1
 
3713
2006-01-25
 
3714
2006-02-05
 
3715
select * from t4 order by colint;
 
3716
colint  col1
 
3717
1       2006-02-05
 
3718
3       2006-01-25
 
3719
4       2006-02-05
 
3720
select * from t5 order by colint;
 
3721
colint  col1
 
3722
1       2006-02-05
 
3723
3       2006-01-25
 
3724
4       2006-02-05
 
3725
insert into t1 values ('2006-01-17');
 
3726
insert into t2 values ('2006-01-17');
 
3727
insert into t3 values ('2006-01-17');
 
3728
insert into t4 values (60,'2006-01-17');
 
3729
insert into t5 values (60,'2006-01-17');
 
3730
insert into t6 values (60,'2006-01-17');
 
3731
select * from t1 order by col1;
 
3732
col1
 
3733
2006-01-17
 
3734
2006-02-05
 
3735
select * from t2 order by col1;
 
3736
col1
 
3737
2006-01-17
 
3738
2006-01-25
 
3739
2006-02-05
 
3740
select * from t3 order by col1;
 
3741
col1
 
3742
2006-01-17
 
3743
2006-01-25
 
3744
2006-02-05
 
3745
select * from t4 order by colint;
 
3746
colint  col1
 
3747
1       2006-02-05
 
3748
3       2006-01-25
 
3749
4       2006-02-05
 
3750
60      2006-01-17
 
3751
select * from t5 order by colint;
 
3752
colint  col1
 
3753
1       2006-02-05
 
3754
3       2006-01-25
 
3755
4       2006-02-05
 
3756
60      2006-01-17
 
3757
select * from t6 order by colint;
 
3758
colint  col1
 
3759
1       2006-02-05
 
3760
3       2006-01-25
 
3761
4       2006-02-05
 
3762
60      2006-01-17
 
3763
alter table t1 drop partition p0;
 
3764
alter table t2 drop partition p0;
 
3765
alter table t4 drop partition p0;
 
3766
alter table t5 drop partition p0;
 
3767
alter table t6 drop partition p0;
 
3768
select * from t1 order by col1;
 
3769
col1
 
3770
2006-01-17
 
3771
select * from t2 order by col1;
 
3772
col1
 
3773
2006-01-17
 
3774
2006-01-25
 
3775
select * from t3 order by col1;
 
3776
col1
 
3777
2006-01-17
 
3778
2006-01-25
 
3779
2006-02-05
 
3780
select * from t4 order by colint;
 
3781
colint  col1
 
3782
60      2006-01-17
 
3783
select * from t5 order by colint;
 
3784
colint  col1
 
3785
60      2006-01-17
 
3786
select * from t6 order by colint;
 
3787
colint  col1
 
3788
60      2006-01-17
 
3789
-------------------------------------------------------------------------
 
3790
---  Delete rows and partitions of tables with day(col1)
 
3791
-------------------------------------------------------------------------
 
3792
delete from t11 where col1='2006-01-17';
 
3793
delete from t22 where col1='2006-01-17';
 
3794
delete from t33 where col1='2006-01-17';
 
3795
delete from t44 where col1='2006-01-17';
 
3796
delete from t55 where col1='2006-01-17';
 
3797
delete from t66 where col1='2006-01-17';
 
3798
select * from t11 order by col1;
 
3799
col1
 
3800
2006-02-05
 
3801
select * from t22 order by col1;
 
3802
col1
 
3803
2006-01-25
 
3804
2006-02-05
 
3805
select * from t33 order by col1;
 
3806
col1
 
3807
2006-01-25
 
3808
2006-02-05
 
3809
select * from t44 order by colint;
 
3810
colint  col1
 
3811
1       2006-02-05
 
3812
3       2006-01-25
 
3813
4       2006-02-05
 
3814
select * from t55 order by colint;
 
3815
colint  col1
 
3816
1       2006-02-05
 
3817
3       2006-01-25
 
3818
4       2006-02-05
 
3819
insert into t11 values ('2006-01-17');
 
3820
insert into t22 values ('2006-01-17');
 
3821
insert into t33 values ('2006-01-17');
 
3822
insert into t44 values (60,'2006-01-17');
 
3823
insert into t55 values (60,'2006-01-17');
 
3824
insert into t66 values (60,'2006-01-17');
 
3825
select * from t11 order by col1;
 
3826
col1
 
3827
2006-01-17
 
3828
2006-02-05
 
3829
select * from t22 order by col1;
 
3830
col1
 
3831
2006-01-17
 
3832
2006-01-25
 
3833
2006-02-05
 
3834
select * from t33 order by col1;
 
3835
col1
 
3836
2006-01-17
 
3837
2006-01-25
 
3838
2006-02-05
 
3839
select * from t44 order by colint;
 
3840
colint  col1
 
3841
1       2006-02-05
 
3842
3       2006-01-25
 
3843
4       2006-02-05
 
3844
60      2006-01-17
 
3845
select * from t55 order by colint;
 
3846
colint  col1
 
3847
1       2006-02-05
 
3848
3       2006-01-25
 
3849
4       2006-02-05
 
3850
60      2006-01-17
 
3851
select * from t66 order by colint;
 
3852
colint  col1
 
3853
1       2006-02-05
 
3854
3       2006-01-25
 
3855
4       2006-02-05
 
3856
60      2006-01-17
 
3857
alter table t11 drop partition p0;
 
3858
alter table t22 drop partition p0;
 
3859
alter table t44 drop partition p0;
 
3860
alter table t55 drop partition p0;
 
3861
alter table t66 drop partition p0;
 
3862
select * from t11 order by col1;
 
3863
col1
 
3864
2006-01-17
 
3865
select * from t22 order by col1;
 
3866
col1
 
3867
2006-01-17
 
3868
2006-01-25
 
3869
select * from t33 order by col1;
 
3870
col1
 
3871
2006-01-17
 
3872
2006-01-25
 
3873
2006-02-05
 
3874
select * from t44 order by colint;
 
3875
colint  col1
 
3876
60      2006-01-17
 
3877
select * from t55 order by colint;
 
3878
colint  col1
 
3879
60      2006-01-17
 
3880
select * from t66 order by colint;
 
3881
colint  col1
 
3882
60      2006-01-17
 
3883
-------------------------
 
3884
---- some alter table end
 
3885
-------------------------
 
3886
drop table if exists t1 ;
 
3887
drop table if exists t2 ;
 
3888
drop table if exists t3 ;
 
3889
drop table if exists t4 ;
 
3890
drop table if exists t5 ;
 
3891
drop table if exists t6 ;
 
3892
drop table if exists t11 ;
 
3893
drop table if exists t22 ;
 
3894
drop table if exists t33 ;
 
3895
drop table if exists t44 ;
 
3896
drop table if exists t55 ;
 
3897
drop table if exists t66 ;
 
3898
-------------------------------------------------------------------------
 
3899
---  dayofmonth(col1)  in partition with coltype  date
 
3900
-------------------------------------------------------------------------
 
3901
drop table if exists t1 ;
 
3902
drop table if exists t2 ;
 
3903
drop table if exists t3 ;
 
3904
drop table if exists t4 ;
 
3905
drop table if exists t5 ;
 
3906
drop table if exists t6 ;
 
3907
-------------------------------------------------------------------------
 
3908
---  Create tables with dayofmonth(col1)
 
3909
-------------------------------------------------------------------------
 
3910
create table t1 (col1 date) engine='INNODB' 
 
3911
partition by range(dayofmonth(col1)) 
 
3912
(partition p0 values less than (15),
 
3913
partition p1 values less than maxvalue);
 
3914
create table t2 (col1 date) engine='INNODB' 
 
3915
partition by list(dayofmonth(col1)) 
 
3916
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
3917
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
3918
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
3919
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
3920
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
3921
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
3922
);
 
3923
create table t3 (col1 date) engine='INNODB' 
 
3924
partition by hash(dayofmonth(col1));
 
3925
create table t4 (colint int, col1 date) engine='INNODB' 
 
3926
partition by range(colint) 
 
3927
subpartition by hash(dayofmonth(col1)) subpartitions 2 
 
3928
(partition p0 values less than (15),
 
3929
partition p1 values less than maxvalue);
 
3930
create table t5 (colint int, col1 date) engine='INNODB' 
 
3931
partition by list(colint)
 
3932
subpartition by hash(dayofmonth(col1)) subpartitions 2 
 
3933
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
3934
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
3935
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
3936
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
3937
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
3938
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
3939
);
 
3940
create table t6 (colint int, col1 date) engine='INNODB' 
 
3941
partition by range(colint) 
 
3942
(partition p0 values less than (dayofmonth('2006-12-24')),
 
3943
partition p1 values less than maxvalue);
 
3944
-------------------------------------------------------------------------
 
3945
---  Access tables with dayofmonth(col1) 
 
3946
-------------------------------------------------------------------------
 
3947
insert into t1 values ('2006-02-03');
 
3948
insert into t1 values ('2006-01-17');
 
3949
insert into t2 values ('2006-02-03');
 
3950
insert into t2 values ('2006-01-17');
 
3951
insert into t2 values ('2006-01-25');
 
3952
insert into t3 values ('2006-02-03');
 
3953
insert into t3 values ('2006-01-17');
 
3954
insert into t3 values ('2006-01-25');
 
3955
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
 
3956
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
 
3957
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
 
3958
select dayofmonth(col1) from t1 order by col1;
 
3959
dayofmonth(col1)
 
3960
17
 
3961
3
 
3962
select * from t1 order by col1;
 
3963
col1
 
3964
2006-01-17
 
3965
2006-02-03
 
3966
select * from t2 order by col1;
 
3967
col1
 
3968
2006-01-17
 
3969
2006-01-25
 
3970
2006-02-03
 
3971
select * from t3 order by col1;
 
3972
col1
 
3973
2006-01-17
 
3974
2006-01-25
 
3975
2006-02-03
 
3976
select * from t4 order by colint;
 
3977
colint  col1
 
3978
1       2006-02-03
 
3979
2       2006-01-17
 
3980
3       2006-01-25
 
3981
4       2006-02-05
 
3982
select * from t5 order by colint;
 
3983
colint  col1
 
3984
1       2006-02-03
 
3985
2       2006-01-17
 
3986
3       2006-01-25
 
3987
4       2006-02-05
 
3988
select * from t6 order by colint;
 
3989
colint  col1
 
3990
1       2006-02-03
 
3991
2       2006-01-17
 
3992
3       2006-01-25
 
3993
4       2006-02-05
 
3994
update t1 set col1='2006-02-05' where col1='2006-02-03';
 
3995
update t2 set col1='2006-02-05' where col1='2006-02-03';
 
3996
update t3 set col1='2006-02-05' where col1='2006-02-03';
 
3997
update t4 set col1='2006-02-05' where col1='2006-02-03';
 
3998
update t5 set col1='2006-02-05' where col1='2006-02-03';
 
3999
update t6 set col1='2006-02-05' where col1='2006-02-03';
 
4000
select * from t1 order by col1;
 
4001
col1
 
4002
2006-01-17
 
4003
2006-02-05
 
4004
select * from t2 order by col1;
 
4005
col1
 
4006
2006-01-17
 
4007
2006-01-25
 
4008
2006-02-05
 
4009
select * from t3 order by col1;
 
4010
col1
 
4011
2006-01-17
 
4012
2006-01-25
 
4013
2006-02-05
 
4014
select * from t4 order by colint;
 
4015
colint  col1
 
4016
1       2006-02-05
 
4017
2       2006-01-17
 
4018
3       2006-01-25
 
4019
4       2006-02-05
 
4020
select * from t5 order by colint;
 
4021
colint  col1
 
4022
1       2006-02-05
 
4023
2       2006-01-17
 
4024
3       2006-01-25
 
4025
4       2006-02-05
 
4026
select * from t6 order by colint;
 
4027
colint  col1
 
4028
1       2006-02-05
 
4029
2       2006-01-17
 
4030
3       2006-01-25
 
4031
4       2006-02-05
 
4032
-------------------------------------------------------------------------
 
4033
---  Alter tables with dayofmonth(col1)
 
4034
-------------------------------------------------------------------------
 
4035
drop table if exists t11 ;
 
4036
drop table if exists t22 ;
 
4037
drop table if exists t33 ;
 
4038
drop table if exists t44 ;
 
4039
drop table if exists t55 ;
 
4040
drop table if exists t66 ;
 
4041
create table t11 engine='INNODB' as select * from t1;
 
4042
create table t22 engine='INNODB' as select * from t2;
 
4043
create table t33 engine='INNODB' as select * from t3;
 
4044
create table t44 engine='INNODB' as select * from t4;
 
4045
create table t55 engine='INNODB' as select * from t5;
 
4046
create table t66 engine='INNODB' as select * from t6;
 
4047
alter table t11
 
4048
partition by range(dayofmonth(col1)) 
 
4049
(partition p0 values less than (15),
 
4050
partition p1 values less than maxvalue);
 
4051
alter table t22
 
4052
partition by list(dayofmonth(col1)) 
 
4053
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
4054
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
4055
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
4056
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
4057
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
4058
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
4059
);
 
4060
alter table t33
 
4061
partition by hash(dayofmonth(col1));
 
4062
alter table t44
 
4063
partition by range(colint) 
 
4064
subpartition by hash(dayofmonth(col1)) subpartitions 2 
 
4065
(partition p0 values less than (15),
 
4066
partition p1 values less than maxvalue);
 
4067
alter table t55
 
4068
partition by list(colint)
 
4069
subpartition by hash(dayofmonth(col1)) subpartitions 2 
 
4070
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
4071
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
4072
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
4073
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
4074
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
4075
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
4076
);
 
4077
alter table t66
 
4078
partition by range(colint) 
 
4079
(partition p0 values less than (dayofmonth('2006-12-24')),
 
4080
partition p1 values less than maxvalue);
 
4081
select * from t11 order by col1;
 
4082
col1
 
4083
2006-01-17
 
4084
2006-02-05
 
4085
select * from t22 order by col1;
 
4086
col1
 
4087
2006-01-17
 
4088
2006-01-25
 
4089
2006-02-05
 
4090
select * from t33 order by col1;
 
4091
col1
 
4092
2006-01-17
 
4093
2006-01-25
 
4094
2006-02-05
 
4095
select * from t44 order by colint;
 
4096
colint  col1
 
4097
1       2006-02-05
 
4098
2       2006-01-17
 
4099
3       2006-01-25
 
4100
4       2006-02-05
 
4101
select * from t55 order by colint;
 
4102
colint  col1
 
4103
1       2006-02-05
 
4104
2       2006-01-17
 
4105
3       2006-01-25
 
4106
4       2006-02-05
 
4107
select * from t66 order by colint;
 
4108
colint  col1
 
4109
1       2006-02-05
 
4110
2       2006-01-17
 
4111
3       2006-01-25
 
4112
4       2006-02-05
 
4113
---------------------------
 
4114
---- some alter table begin
 
4115
---------------------------
 
4116
alter table t11
 
4117
reorganize partition p0,p1 into
 
4118
(partition s1 values less than maxvalue);
 
4119
select * from t11 order by col1;
 
4120
col1
 
4121
2006-01-17
 
4122
2006-02-05
 
4123
alter table t11
 
4124
reorganize partition s1 into
 
4125
(partition p0 values less than (15),
 
4126
partition p1 values less than maxvalue);
 
4127
select * from t11 order by col1;
 
4128
col1
 
4129
2006-01-17
 
4130
2006-02-05
 
4131
alter table t55
 
4132
partition by list(colint)
 
4133
subpartition by hash(dayofmonth(col1)) subpartitions 5 
 
4134
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
4135
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
4136
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
4137
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
4138
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
4139
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
4140
);
 
4141
show create table t55;
 
4142
Table   Create Table
 
4143
t55     CREATE TABLE `t55` (
 
4144
  `colint` int(11) DEFAULT NULL,
 
4145
  `col1` date DEFAULT NULL
 
4146
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
4147
/*!50100 PARTITION BY LIST (colint)
 
4148
SUBPARTITION BY HASH (dayofmonth(col1))
 
4149
SUBPARTITIONS 5
 
4150
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
4151
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
4152
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
4153
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
4154
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
4155
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
4156
select * from t55 order by colint;
 
4157
colint  col1
 
4158
1       2006-02-05
 
4159
2       2006-01-17
 
4160
3       2006-01-25
 
4161
4       2006-02-05
 
4162
alter table t66
 
4163
reorganize partition p0,p1 into
 
4164
(partition s1 values less than maxvalue);
 
4165
select * from t66 order by colint;
 
4166
colint  col1
 
4167
1       2006-02-05
 
4168
2       2006-01-17
 
4169
3       2006-01-25
 
4170
4       2006-02-05
 
4171
alter table t66
 
4172
reorganize partition s1 into
 
4173
(partition p0 values less than (dayofmonth('2006-12-24')),
 
4174
partition p1 values less than maxvalue);
 
4175
select * from t66 order by colint;
 
4176
colint  col1
 
4177
1       2006-02-05
 
4178
2       2006-01-17
 
4179
3       2006-01-25
 
4180
4       2006-02-05
 
4181
alter table t66
 
4182
reorganize partition p0,p1 into
 
4183
(partition s1 values less than maxvalue);
 
4184
select * from t66 order by colint;
 
4185
colint  col1
 
4186
1       2006-02-05
 
4187
2       2006-01-17
 
4188
3       2006-01-25
 
4189
4       2006-02-05
 
4190
alter table t66
 
4191
reorganize partition s1 into
 
4192
(partition p0 values less than (dayofmonth('2006-12-24')),
 
4193
partition p1 values less than maxvalue);
 
4194
select * from t66 order by colint;
 
4195
colint  col1
 
4196
1       2006-02-05
 
4197
2       2006-01-17
 
4198
3       2006-01-25
 
4199
4       2006-02-05
 
4200
-------------------------------------------------------------------------
 
4201
---  Delete rows and partitions of tables with dayofmonth(col1)
 
4202
-------------------------------------------------------------------------
 
4203
delete from t1 where col1='2006-01-17';
 
4204
delete from t2 where col1='2006-01-17';
 
4205
delete from t3 where col1='2006-01-17';
 
4206
delete from t4 where col1='2006-01-17';
 
4207
delete from t5 where col1='2006-01-17';
 
4208
delete from t6 where col1='2006-01-17';
 
4209
select * from t1 order by col1;
 
4210
col1
 
4211
2006-02-05
 
4212
select * from t2 order by col1;
 
4213
col1
 
4214
2006-01-25
 
4215
2006-02-05
 
4216
select * from t3 order by col1;
 
4217
col1
 
4218
2006-01-25
 
4219
2006-02-05
 
4220
select * from t4 order by colint;
 
4221
colint  col1
 
4222
1       2006-02-05
 
4223
3       2006-01-25
 
4224
4       2006-02-05
 
4225
select * from t5 order by colint;
 
4226
colint  col1
 
4227
1       2006-02-05
 
4228
3       2006-01-25
 
4229
4       2006-02-05
 
4230
insert into t1 values ('2006-01-17');
 
4231
insert into t2 values ('2006-01-17');
 
4232
insert into t3 values ('2006-01-17');
 
4233
insert into t4 values (60,'2006-01-17');
 
4234
insert into t5 values (60,'2006-01-17');
 
4235
insert into t6 values (60,'2006-01-17');
 
4236
select * from t1 order by col1;
 
4237
col1
 
4238
2006-01-17
 
4239
2006-02-05
 
4240
select * from t2 order by col1;
 
4241
col1
 
4242
2006-01-17
 
4243
2006-01-25
 
4244
2006-02-05
 
4245
select * from t3 order by col1;
 
4246
col1
 
4247
2006-01-17
 
4248
2006-01-25
 
4249
2006-02-05
 
4250
select * from t4 order by colint;
 
4251
colint  col1
 
4252
1       2006-02-05
 
4253
3       2006-01-25
 
4254
4       2006-02-05
 
4255
60      2006-01-17
 
4256
select * from t5 order by colint;
 
4257
colint  col1
 
4258
1       2006-02-05
 
4259
3       2006-01-25
 
4260
4       2006-02-05
 
4261
60      2006-01-17
 
4262
select * from t6 order by colint;
 
4263
colint  col1
 
4264
1       2006-02-05
 
4265
3       2006-01-25
 
4266
4       2006-02-05
 
4267
60      2006-01-17
 
4268
alter table t1 drop partition p0;
 
4269
alter table t2 drop partition p0;
 
4270
alter table t4 drop partition p0;
 
4271
alter table t5 drop partition p0;
 
4272
alter table t6 drop partition p0;
 
4273
select * from t1 order by col1;
 
4274
col1
 
4275
2006-01-17
 
4276
select * from t2 order by col1;
 
4277
col1
 
4278
2006-01-17
 
4279
2006-01-25
 
4280
select * from t3 order by col1;
 
4281
col1
 
4282
2006-01-17
 
4283
2006-01-25
 
4284
2006-02-05
 
4285
select * from t4 order by colint;
 
4286
colint  col1
 
4287
60      2006-01-17
 
4288
select * from t5 order by colint;
 
4289
colint  col1
 
4290
60      2006-01-17
 
4291
select * from t6 order by colint;
 
4292
colint  col1
 
4293
60      2006-01-17
 
4294
-------------------------------------------------------------------------
 
4295
---  Delete rows and partitions of tables with dayofmonth(col1)
 
4296
-------------------------------------------------------------------------
 
4297
delete from t11 where col1='2006-01-17';
 
4298
delete from t22 where col1='2006-01-17';
 
4299
delete from t33 where col1='2006-01-17';
 
4300
delete from t44 where col1='2006-01-17';
 
4301
delete from t55 where col1='2006-01-17';
 
4302
delete from t66 where col1='2006-01-17';
 
4303
select * from t11 order by col1;
 
4304
col1
 
4305
2006-02-05
 
4306
select * from t22 order by col1;
 
4307
col1
 
4308
2006-01-25
 
4309
2006-02-05
 
4310
select * from t33 order by col1;
 
4311
col1
 
4312
2006-01-25
 
4313
2006-02-05
 
4314
select * from t44 order by colint;
 
4315
colint  col1
 
4316
1       2006-02-05
 
4317
3       2006-01-25
 
4318
4       2006-02-05
 
4319
select * from t55 order by colint;
 
4320
colint  col1
 
4321
1       2006-02-05
 
4322
3       2006-01-25
 
4323
4       2006-02-05
 
4324
insert into t11 values ('2006-01-17');
 
4325
insert into t22 values ('2006-01-17');
 
4326
insert into t33 values ('2006-01-17');
 
4327
insert into t44 values (60,'2006-01-17');
 
4328
insert into t55 values (60,'2006-01-17');
 
4329
insert into t66 values (60,'2006-01-17');
 
4330
select * from t11 order by col1;
 
4331
col1
 
4332
2006-01-17
 
4333
2006-02-05
 
4334
select * from t22 order by col1;
 
4335
col1
 
4336
2006-01-17
 
4337
2006-01-25
 
4338
2006-02-05
 
4339
select * from t33 order by col1;
 
4340
col1
 
4341
2006-01-17
 
4342
2006-01-25
 
4343
2006-02-05
 
4344
select * from t44 order by colint;
 
4345
colint  col1
 
4346
1       2006-02-05
 
4347
3       2006-01-25
 
4348
4       2006-02-05
 
4349
60      2006-01-17
 
4350
select * from t55 order by colint;
 
4351
colint  col1
 
4352
1       2006-02-05
 
4353
3       2006-01-25
 
4354
4       2006-02-05
 
4355
60      2006-01-17
 
4356
select * from t66 order by colint;
 
4357
colint  col1
 
4358
1       2006-02-05
 
4359
3       2006-01-25
 
4360
4       2006-02-05
 
4361
60      2006-01-17
 
4362
alter table t11 drop partition p0;
 
4363
alter table t22 drop partition p0;
 
4364
alter table t44 drop partition p0;
 
4365
alter table t55 drop partition p0;
 
4366
alter table t66 drop partition p0;
 
4367
select * from t11 order by col1;
 
4368
col1
 
4369
2006-01-17
 
4370
select * from t22 order by col1;
 
4371
col1
 
4372
2006-01-17
 
4373
2006-01-25
 
4374
select * from t33 order by col1;
 
4375
col1
 
4376
2006-01-17
 
4377
2006-01-25
 
4378
2006-02-05
 
4379
select * from t44 order by colint;
 
4380
colint  col1
 
4381
60      2006-01-17
 
4382
select * from t55 order by colint;
 
4383
colint  col1
 
4384
60      2006-01-17
 
4385
select * from t66 order by colint;
 
4386
colint  col1
 
4387
60      2006-01-17
 
4388
-------------------------
 
4389
---- some alter table end
 
4390
-------------------------
 
4391
drop table if exists t1 ;
 
4392
drop table if exists t2 ;
 
4393
drop table if exists t3 ;
 
4394
drop table if exists t4 ;
 
4395
drop table if exists t5 ;
 
4396
drop table if exists t6 ;
 
4397
drop table if exists t11 ;
 
4398
drop table if exists t22 ;
 
4399
drop table if exists t33 ;
 
4400
drop table if exists t44 ;
 
4401
drop table if exists t55 ;
 
4402
drop table if exists t66 ;
 
4403
-------------------------------------------------------------------------
 
4404
---  dayofweek(col1)  in partition with coltype  date
 
4405
-------------------------------------------------------------------------
 
4406
drop table if exists t1 ;
 
4407
drop table if exists t2 ;
 
4408
drop table if exists t3 ;
 
4409
drop table if exists t4 ;
 
4410
drop table if exists t5 ;
 
4411
drop table if exists t6 ;
 
4412
-------------------------------------------------------------------------
 
4413
---  Create tables with dayofweek(col1)
 
4414
-------------------------------------------------------------------------
 
4415
create table t1 (col1 date) engine='INNODB' 
 
4416
partition by range(dayofweek(col1)) 
 
4417
(partition p0 values less than (15),
 
4418
partition p1 values less than maxvalue);
 
4419
create table t2 (col1 date) engine='INNODB' 
 
4420
partition by list(dayofweek(col1)) 
 
4421
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
4422
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
4423
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
4424
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
4425
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
4426
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
4427
);
 
4428
create table t3 (col1 date) engine='INNODB' 
 
4429
partition by hash(dayofweek(col1));
 
4430
create table t4 (colint int, col1 date) engine='INNODB' 
 
4431
partition by range(colint) 
 
4432
subpartition by hash(dayofweek(col1)) subpartitions 2 
 
4433
(partition p0 values less than (15),
 
4434
partition p1 values less than maxvalue);
 
4435
create table t5 (colint int, col1 date) engine='INNODB' 
 
4436
partition by list(colint)
 
4437
subpartition by hash(dayofweek(col1)) subpartitions 2 
 
4438
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
4439
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
4440
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
4441
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
4442
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
4443
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
4444
);
 
4445
create table t6 (colint int, col1 date) engine='INNODB' 
 
4446
partition by range(colint) 
 
4447
(partition p0 values less than (dayofweek('2006-12-24')),
 
4448
partition p1 values less than maxvalue);
 
4449
-------------------------------------------------------------------------
 
4450
---  Access tables with dayofweek(col1) 
 
4451
-------------------------------------------------------------------------
 
4452
insert into t1 values ('2006-01-03');
 
4453
insert into t1 values ('2006-02-17');
 
4454
insert into t2 values ('2006-01-03');
 
4455
insert into t2 values ('2006-02-17');
 
4456
insert into t2 values ('2006-01-25');
 
4457
insert into t3 values ('2006-01-03');
 
4458
insert into t3 values ('2006-02-17');
 
4459
insert into t3 values ('2006-01-25');
 
4460
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
 
4461
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
 
4462
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
 
4463
select dayofweek(col1) from t1 order by col1;
 
4464
dayofweek(col1)
 
4465
3
 
4466
6
 
4467
select * from t1 order by col1;
 
4468
col1
 
4469
2006-01-03
 
4470
2006-02-17
 
4471
select * from t2 order by col1;
 
4472
col1
 
4473
2006-01-03
 
4474
2006-01-25
 
4475
2006-02-17
 
4476
select * from t3 order by col1;
 
4477
col1
 
4478
2006-01-03
 
4479
2006-01-25
 
4480
2006-02-17
 
4481
select * from t4 order by colint;
 
4482
colint  col1
 
4483
1       2006-02-03
 
4484
2       2006-01-17
 
4485
3       2006-01-25
 
4486
4       2006-02-05
 
4487
select * from t5 order by colint;
 
4488
colint  col1
 
4489
1       2006-02-03
 
4490
2       2006-01-17
 
4491
3       2006-01-25
 
4492
4       2006-02-05
 
4493
select * from t6 order by colint;
 
4494
colint  col1
 
4495
1       2006-02-03
 
4496
2       2006-01-17
 
4497
3       2006-01-25
 
4498
4       2006-02-05
 
4499
update t1 set col1='2006-02-05' where col1='2006-01-03';
 
4500
update t2 set col1='2006-02-05' where col1='2006-01-03';
 
4501
update t3 set col1='2006-02-05' where col1='2006-01-03';
 
4502
update t4 set col1='2006-02-05' where col1='2006-01-03';
 
4503
update t5 set col1='2006-02-05' where col1='2006-01-03';
 
4504
update t6 set col1='2006-02-05' where col1='2006-01-03';
 
4505
select * from t1 order by col1;
 
4506
col1
 
4507
2006-02-05
 
4508
2006-02-17
 
4509
select * from t2 order by col1;
 
4510
col1
 
4511
2006-01-25
 
4512
2006-02-05
 
4513
2006-02-17
 
4514
select * from t3 order by col1;
 
4515
col1
 
4516
2006-01-25
 
4517
2006-02-05
 
4518
2006-02-17
 
4519
select * from t4 order by colint;
 
4520
colint  col1
 
4521
1       2006-02-03
 
4522
2       2006-01-17
 
4523
3       2006-01-25
 
4524
4       2006-02-05
 
4525
select * from t5 order by colint;
 
4526
colint  col1
 
4527
1       2006-02-03
 
4528
2       2006-01-17
 
4529
3       2006-01-25
 
4530
4       2006-02-05
 
4531
select * from t6 order by colint;
 
4532
colint  col1
 
4533
1       2006-02-03
 
4534
2       2006-01-17
 
4535
3       2006-01-25
 
4536
4       2006-02-05
 
4537
-------------------------------------------------------------------------
 
4538
---  Alter tables with dayofweek(col1)
 
4539
-------------------------------------------------------------------------
 
4540
drop table if exists t11 ;
 
4541
drop table if exists t22 ;
 
4542
drop table if exists t33 ;
 
4543
drop table if exists t44 ;
 
4544
drop table if exists t55 ;
 
4545
drop table if exists t66 ;
 
4546
create table t11 engine='INNODB' as select * from t1;
 
4547
create table t22 engine='INNODB' as select * from t2;
 
4548
create table t33 engine='INNODB' as select * from t3;
 
4549
create table t44 engine='INNODB' as select * from t4;
 
4550
create table t55 engine='INNODB' as select * from t5;
 
4551
create table t66 engine='INNODB' as select * from t6;
 
4552
alter table t11
 
4553
partition by range(dayofweek(col1)) 
 
4554
(partition p0 values less than (15),
 
4555
partition p1 values less than maxvalue);
 
4556
alter table t22
 
4557
partition by list(dayofweek(col1)) 
 
4558
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
4559
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
4560
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
4561
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
4562
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
4563
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
4564
);
 
4565
alter table t33
 
4566
partition by hash(dayofweek(col1));
 
4567
alter table t44
 
4568
partition by range(colint) 
 
4569
subpartition by hash(dayofweek(col1)) subpartitions 2 
 
4570
(partition p0 values less than (15),
 
4571
partition p1 values less than maxvalue);
 
4572
alter table t55
 
4573
partition by list(colint)
 
4574
subpartition by hash(dayofweek(col1)) subpartitions 2 
 
4575
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
4576
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
4577
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
4578
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
4579
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
4580
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
4581
);
 
4582
alter table t66
 
4583
partition by range(colint) 
 
4584
(partition p0 values less than (dayofweek('2006-12-24')),
 
4585
partition p1 values less than maxvalue);
 
4586
select * from t11 order by col1;
 
4587
col1
 
4588
2006-02-05
 
4589
2006-02-17
 
4590
select * from t22 order by col1;
 
4591
col1
 
4592
2006-01-25
 
4593
2006-02-05
 
4594
2006-02-17
 
4595
select * from t33 order by col1;
 
4596
col1
 
4597
2006-01-25
 
4598
2006-02-05
 
4599
2006-02-17
 
4600
select * from t44 order by colint;
 
4601
colint  col1
 
4602
1       2006-02-03
 
4603
2       2006-01-17
 
4604
3       2006-01-25
 
4605
4       2006-02-05
 
4606
select * from t55 order by colint;
 
4607
colint  col1
 
4608
1       2006-02-03
 
4609
2       2006-01-17
 
4610
3       2006-01-25
 
4611
4       2006-02-05
 
4612
select * from t66 order by colint;
 
4613
colint  col1
 
4614
1       2006-02-03
 
4615
2       2006-01-17
 
4616
3       2006-01-25
 
4617
4       2006-02-05
 
4618
---------------------------
 
4619
---- some alter table begin
 
4620
---------------------------
 
4621
alter table t11
 
4622
reorganize partition p0,p1 into
 
4623
(partition s1 values less than maxvalue);
 
4624
select * from t11 order by col1;
 
4625
col1
 
4626
2006-02-05
 
4627
2006-02-17
 
4628
alter table t11
 
4629
reorganize partition s1 into
 
4630
(partition p0 values less than (15),
 
4631
partition p1 values less than maxvalue);
 
4632
select * from t11 order by col1;
 
4633
col1
 
4634
2006-02-05
 
4635
2006-02-17
 
4636
alter table t55
 
4637
partition by list(colint)
 
4638
subpartition by hash(dayofweek(col1)) subpartitions 5 
 
4639
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
4640
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
4641
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
4642
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
4643
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
4644
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
4645
);
 
4646
show create table t55;
 
4647
Table   Create Table
 
4648
t55     CREATE TABLE `t55` (
 
4649
  `colint` int(11) DEFAULT NULL,
 
4650
  `col1` date DEFAULT NULL
 
4651
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
4652
/*!50100 PARTITION BY LIST (colint)
 
4653
SUBPARTITION BY HASH (dayofweek(col1))
 
4654
SUBPARTITIONS 5
 
4655
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
4656
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
4657
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
4658
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
4659
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
4660
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
4661
select * from t55 order by colint;
 
4662
colint  col1
 
4663
1       2006-02-03
 
4664
2       2006-01-17
 
4665
3       2006-01-25
 
4666
4       2006-02-05
 
4667
alter table t66
 
4668
reorganize partition p0,p1 into
 
4669
(partition s1 values less than maxvalue);
 
4670
select * from t66 order by colint;
 
4671
colint  col1
 
4672
1       2006-02-03
 
4673
2       2006-01-17
 
4674
3       2006-01-25
 
4675
4       2006-02-05
 
4676
alter table t66
 
4677
reorganize partition s1 into
 
4678
(partition p0 values less than (dayofweek('2006-12-24')),
 
4679
partition p1 values less than maxvalue);
 
4680
select * from t66 order by colint;
 
4681
colint  col1
 
4682
1       2006-02-03
 
4683
2       2006-01-17
 
4684
3       2006-01-25
 
4685
4       2006-02-05
 
4686
alter table t66
 
4687
reorganize partition p0,p1 into
 
4688
(partition s1 values less than maxvalue);
 
4689
select * from t66 order by colint;
 
4690
colint  col1
 
4691
1       2006-02-03
 
4692
2       2006-01-17
 
4693
3       2006-01-25
 
4694
4       2006-02-05
 
4695
alter table t66
 
4696
reorganize partition s1 into
 
4697
(partition p0 values less than (dayofweek('2006-12-24')),
 
4698
partition p1 values less than maxvalue);
 
4699
select * from t66 order by colint;
 
4700
colint  col1
 
4701
1       2006-02-03
 
4702
2       2006-01-17
 
4703
3       2006-01-25
 
4704
4       2006-02-05
 
4705
-------------------------------------------------------------------------
 
4706
---  Delete rows and partitions of tables with dayofweek(col1)
 
4707
-------------------------------------------------------------------------
 
4708
delete from t1 where col1='2006-02-17';
 
4709
delete from t2 where col1='2006-02-17';
 
4710
delete from t3 where col1='2006-02-17';
 
4711
delete from t4 where col1='2006-02-17';
 
4712
delete from t5 where col1='2006-02-17';
 
4713
delete from t6 where col1='2006-02-17';
 
4714
select * from t1 order by col1;
 
4715
col1
 
4716
2006-02-05
 
4717
select * from t2 order by col1;
 
4718
col1
 
4719
2006-01-25
 
4720
2006-02-05
 
4721
select * from t3 order by col1;
 
4722
col1
 
4723
2006-01-25
 
4724
2006-02-05
 
4725
select * from t4 order by colint;
 
4726
colint  col1
 
4727
1       2006-02-03
 
4728
2       2006-01-17
 
4729
3       2006-01-25
 
4730
4       2006-02-05
 
4731
select * from t5 order by colint;
 
4732
colint  col1
 
4733
1       2006-02-03
 
4734
2       2006-01-17
 
4735
3       2006-01-25
 
4736
4       2006-02-05
 
4737
insert into t1 values ('2006-02-17');
 
4738
insert into t2 values ('2006-02-17');
 
4739
insert into t3 values ('2006-02-17');
 
4740
insert into t4 values (60,'2006-02-17');
 
4741
insert into t5 values (60,'2006-02-17');
 
4742
insert into t6 values (60,'2006-02-17');
 
4743
select * from t1 order by col1;
 
4744
col1
 
4745
2006-02-05
 
4746
2006-02-17
 
4747
select * from t2 order by col1;
 
4748
col1
 
4749
2006-01-25
 
4750
2006-02-05
 
4751
2006-02-17
 
4752
select * from t3 order by col1;
 
4753
col1
 
4754
2006-01-25
 
4755
2006-02-05
 
4756
2006-02-17
 
4757
select * from t4 order by colint;
 
4758
colint  col1
 
4759
1       2006-02-03
 
4760
2       2006-01-17
 
4761
3       2006-01-25
 
4762
4       2006-02-05
 
4763
60      2006-02-17
 
4764
select * from t5 order by colint;
 
4765
colint  col1
 
4766
1       2006-02-03
 
4767
2       2006-01-17
 
4768
3       2006-01-25
 
4769
4       2006-02-05
 
4770
60      2006-02-17
 
4771
select * from t6 order by colint;
 
4772
colint  col1
 
4773
1       2006-02-03
 
4774
2       2006-01-17
 
4775
3       2006-01-25
 
4776
4       2006-02-05
 
4777
60      2006-02-17
 
4778
alter table t1 drop partition p0;
 
4779
alter table t2 drop partition p0;
 
4780
alter table t4 drop partition p0;
 
4781
alter table t5 drop partition p0;
 
4782
alter table t6 drop partition p0;
 
4783
select * from t1 order by col1;
 
4784
col1
 
4785
select * from t2 order by col1;
 
4786
col1
 
4787
select * from t3 order by col1;
 
4788
col1
 
4789
2006-01-25
 
4790
2006-02-05
 
4791
2006-02-17
 
4792
select * from t4 order by colint;
 
4793
colint  col1
 
4794
60      2006-02-17
 
4795
select * from t5 order by colint;
 
4796
colint  col1
 
4797
60      2006-02-17
 
4798
select * from t6 order by colint;
 
4799
colint  col1
 
4800
1       2006-02-03
 
4801
2       2006-01-17
 
4802
3       2006-01-25
 
4803
4       2006-02-05
 
4804
60      2006-02-17
 
4805
-------------------------------------------------------------------------
 
4806
---  Delete rows and partitions of tables with dayofweek(col1)
 
4807
-------------------------------------------------------------------------
 
4808
delete from t11 where col1='2006-02-17';
 
4809
delete from t22 where col1='2006-02-17';
 
4810
delete from t33 where col1='2006-02-17';
 
4811
delete from t44 where col1='2006-02-17';
 
4812
delete from t55 where col1='2006-02-17';
 
4813
delete from t66 where col1='2006-02-17';
 
4814
select * from t11 order by col1;
 
4815
col1
 
4816
2006-02-05
 
4817
select * from t22 order by col1;
 
4818
col1
 
4819
2006-01-25
 
4820
2006-02-05
 
4821
select * from t33 order by col1;
 
4822
col1
 
4823
2006-01-25
 
4824
2006-02-05
 
4825
select * from t44 order by colint;
 
4826
colint  col1
 
4827
1       2006-02-03
 
4828
2       2006-01-17
 
4829
3       2006-01-25
 
4830
4       2006-02-05
 
4831
select * from t55 order by colint;
 
4832
colint  col1
 
4833
1       2006-02-03
 
4834
2       2006-01-17
 
4835
3       2006-01-25
 
4836
4       2006-02-05
 
4837
insert into t11 values ('2006-02-17');
 
4838
insert into t22 values ('2006-02-17');
 
4839
insert into t33 values ('2006-02-17');
 
4840
insert into t44 values (60,'2006-02-17');
 
4841
insert into t55 values (60,'2006-02-17');
 
4842
insert into t66 values (60,'2006-02-17');
 
4843
select * from t11 order by col1;
 
4844
col1
 
4845
2006-02-05
 
4846
2006-02-17
 
4847
select * from t22 order by col1;
 
4848
col1
 
4849
2006-01-25
 
4850
2006-02-05
 
4851
2006-02-17
 
4852
select * from t33 order by col1;
 
4853
col1
 
4854
2006-01-25
 
4855
2006-02-05
 
4856
2006-02-17
 
4857
select * from t44 order by colint;
 
4858
colint  col1
 
4859
1       2006-02-03
 
4860
2       2006-01-17
 
4861
3       2006-01-25
 
4862
4       2006-02-05
 
4863
60      2006-02-17
 
4864
select * from t55 order by colint;
 
4865
colint  col1
 
4866
1       2006-02-03
 
4867
2       2006-01-17
 
4868
3       2006-01-25
 
4869
4       2006-02-05
 
4870
60      2006-02-17
 
4871
select * from t66 order by colint;
 
4872
colint  col1
 
4873
1       2006-02-03
 
4874
2       2006-01-17
 
4875
3       2006-01-25
 
4876
4       2006-02-05
 
4877
60      2006-02-17
 
4878
alter table t11 drop partition p0;
 
4879
alter table t22 drop partition p0;
 
4880
alter table t44 drop partition p0;
 
4881
alter table t55 drop partition p0;
 
4882
alter table t66 drop partition p0;
 
4883
select * from t11 order by col1;
 
4884
col1
 
4885
select * from t22 order by col1;
 
4886
col1
 
4887
select * from t33 order by col1;
 
4888
col1
 
4889
2006-01-25
 
4890
2006-02-05
 
4891
2006-02-17
 
4892
select * from t44 order by colint;
 
4893
colint  col1
 
4894
60      2006-02-17
 
4895
select * from t55 order by colint;
 
4896
colint  col1
 
4897
60      2006-02-17
 
4898
select * from t66 order by colint;
 
4899
colint  col1
 
4900
1       2006-02-03
 
4901
2       2006-01-17
 
4902
3       2006-01-25
 
4903
4       2006-02-05
 
4904
60      2006-02-17
 
4905
-------------------------
 
4906
---- some alter table end
 
4907
-------------------------
 
4908
drop table if exists t1 ;
 
4909
drop table if exists t2 ;
 
4910
drop table if exists t3 ;
 
4911
drop table if exists t4 ;
 
4912
drop table if exists t5 ;
 
4913
drop table if exists t6 ;
 
4914
drop table if exists t11 ;
 
4915
drop table if exists t22 ;
 
4916
drop table if exists t33 ;
 
4917
drop table if exists t44 ;
 
4918
drop table if exists t55 ;
 
4919
drop table if exists t66 ;
 
4920
-------------------------------------------------------------------------
 
4921
---  dayofyear(col1)  in partition with coltype  date
 
4922
-------------------------------------------------------------------------
 
4923
drop table if exists t1 ;
 
4924
drop table if exists t2 ;
 
4925
drop table if exists t3 ;
 
4926
drop table if exists t4 ;
 
4927
drop table if exists t5 ;
 
4928
drop table if exists t6 ;
 
4929
-------------------------------------------------------------------------
 
4930
---  Create tables with dayofyear(col1)
 
4931
-------------------------------------------------------------------------
 
4932
create table t1 (col1 date) engine='INNODB' 
 
4933
partition by range(dayofyear(col1)) 
 
4934
(partition p0 values less than (15),
 
4935
partition p1 values less than maxvalue);
 
4936
create table t2 (col1 date) engine='INNODB' 
 
4937
partition by list(dayofyear(col1)) 
 
4938
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
4939
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
4940
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
4941
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
4942
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
4943
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
4944
);
 
4945
create table t3 (col1 date) engine='INNODB' 
 
4946
partition by hash(dayofyear(col1));
 
4947
create table t4 (colint int, col1 date) engine='INNODB' 
 
4948
partition by range(colint) 
 
4949
subpartition by hash(dayofyear(col1)) subpartitions 2 
 
4950
(partition p0 values less than (15),
 
4951
partition p1 values less than maxvalue);
 
4952
create table t5 (colint int, col1 date) engine='INNODB' 
 
4953
partition by list(colint)
 
4954
subpartition by hash(dayofyear(col1)) subpartitions 2 
 
4955
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
4956
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
4957
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
4958
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
4959
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
4960
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
4961
);
 
4962
create table t6 (colint int, col1 date) engine='INNODB' 
 
4963
partition by range(colint) 
 
4964
(partition p0 values less than (dayofyear('2006-12-25')),
 
4965
partition p1 values less than maxvalue);
 
4966
-------------------------------------------------------------------------
 
4967
---  Access tables with dayofyear(col1) 
 
4968
-------------------------------------------------------------------------
 
4969
insert into t1 values ('2006-01-03');
 
4970
insert into t1 values ('2006-01-17');
 
4971
insert into t2 values ('2006-01-03');
 
4972
insert into t2 values ('2006-01-17');
 
4973
insert into t2 values ('2006-02-25');
 
4974
insert into t3 values ('2006-01-03');
 
4975
insert into t3 values ('2006-01-17');
 
4976
insert into t3 values ('2006-02-25');
 
4977
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
 
4978
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
 
4979
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
 
4980
select dayofyear(col1) from t1 order by col1;
 
4981
dayofyear(col1)
 
4982
3
 
4983
17
 
4984
select * from t1 order by col1;
 
4985
col1
 
4986
2006-01-03
 
4987
2006-01-17
 
4988
select * from t2 order by col1;
 
4989
col1
 
4990
2006-01-03
 
4991
2006-01-17
 
4992
2006-02-25
 
4993
select * from t3 order by col1;
 
4994
col1
 
4995
2006-01-03
 
4996
2006-01-17
 
4997
2006-02-25
 
4998
select * from t4 order by colint;
 
4999
colint  col1
 
5000
1       2006-02-03
 
5001
2       2006-01-17
 
5002
3       2006-01-25
 
5003
4       2006-02-05
 
5004
select * from t5 order by colint;
 
5005
colint  col1
 
5006
1       2006-02-03
 
5007
2       2006-01-17
 
5008
3       2006-01-25
 
5009
4       2006-02-05
 
5010
select * from t6 order by colint;
 
5011
colint  col1
 
5012
1       2006-02-03
 
5013
2       2006-01-17
 
5014
3       2006-01-25
 
5015
4       2006-02-05
 
5016
update t1 set col1='2006-02-05' where col1='2006-01-03';
 
5017
update t2 set col1='2006-02-05' where col1='2006-01-03';
 
5018
update t3 set col1='2006-02-05' where col1='2006-01-03';
 
5019
update t4 set col1='2006-02-05' where col1='2006-01-03';
 
5020
update t5 set col1='2006-02-05' where col1='2006-01-03';
 
5021
update t6 set col1='2006-02-05' where col1='2006-01-03';
 
5022
select * from t1 order by col1;
 
5023
col1
 
5024
2006-01-17
 
5025
2006-02-05
 
5026
select * from t2 order by col1;
 
5027
col1
 
5028
2006-01-17
 
5029
2006-02-05
 
5030
2006-02-25
 
5031
select * from t3 order by col1;
 
5032
col1
 
5033
2006-01-17
 
5034
2006-02-05
 
5035
2006-02-25
 
5036
select * from t4 order by colint;
 
5037
colint  col1
 
5038
1       2006-02-03
 
5039
2       2006-01-17
 
5040
3       2006-01-25
 
5041
4       2006-02-05
 
5042
select * from t5 order by colint;
 
5043
colint  col1
 
5044
1       2006-02-03
 
5045
2       2006-01-17
 
5046
3       2006-01-25
 
5047
4       2006-02-05
 
5048
select * from t6 order by colint;
 
5049
colint  col1
 
5050
1       2006-02-03
 
5051
2       2006-01-17
 
5052
3       2006-01-25
 
5053
4       2006-02-05
 
5054
-------------------------------------------------------------------------
 
5055
---  Alter tables with dayofyear(col1)
 
5056
-------------------------------------------------------------------------
 
5057
drop table if exists t11 ;
 
5058
drop table if exists t22 ;
 
5059
drop table if exists t33 ;
 
5060
drop table if exists t44 ;
 
5061
drop table if exists t55 ;
 
5062
drop table if exists t66 ;
 
5063
create table t11 engine='INNODB' as select * from t1;
 
5064
create table t22 engine='INNODB' as select * from t2;
 
5065
create table t33 engine='INNODB' as select * from t3;
 
5066
create table t44 engine='INNODB' as select * from t4;
 
5067
create table t55 engine='INNODB' as select * from t5;
 
5068
create table t66 engine='INNODB' as select * from t6;
 
5069
alter table t11
 
5070
partition by range(dayofyear(col1)) 
 
5071
(partition p0 values less than (15),
 
5072
partition p1 values less than maxvalue);
 
5073
alter table t22
 
5074
partition by list(dayofyear(col1)) 
 
5075
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
5076
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
5077
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
5078
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
5079
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
5080
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
5081
);
 
5082
alter table t33
 
5083
partition by hash(dayofyear(col1));
 
5084
alter table t44
 
5085
partition by range(colint) 
 
5086
subpartition by hash(dayofyear(col1)) subpartitions 2 
 
5087
(partition p0 values less than (15),
 
5088
partition p1 values less than maxvalue);
 
5089
alter table t55
 
5090
partition by list(colint)
 
5091
subpartition by hash(dayofyear(col1)) subpartitions 2 
 
5092
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
5093
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
5094
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
5095
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
5096
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
5097
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
5098
);
 
5099
alter table t66
 
5100
partition by range(colint) 
 
5101
(partition p0 values less than (dayofyear('2006-12-25')),
 
5102
partition p1 values less than maxvalue);
 
5103
select * from t11 order by col1;
 
5104
col1
 
5105
2006-01-17
 
5106
2006-02-05
 
5107
select * from t22 order by col1;
 
5108
col1
 
5109
2006-01-17
 
5110
2006-02-05
 
5111
2006-02-25
 
5112
select * from t33 order by col1;
 
5113
col1
 
5114
2006-01-17
 
5115
2006-02-05
 
5116
2006-02-25
 
5117
select * from t44 order by colint;
 
5118
colint  col1
 
5119
1       2006-02-03
 
5120
2       2006-01-17
 
5121
3       2006-01-25
 
5122
4       2006-02-05
 
5123
select * from t55 order by colint;
 
5124
colint  col1
 
5125
1       2006-02-03
 
5126
2       2006-01-17
 
5127
3       2006-01-25
 
5128
4       2006-02-05
 
5129
select * from t66 order by colint;
 
5130
colint  col1
 
5131
1       2006-02-03
 
5132
2       2006-01-17
 
5133
3       2006-01-25
 
5134
4       2006-02-05
 
5135
---------------------------
 
5136
---- some alter table begin
 
5137
---------------------------
 
5138
alter table t11
 
5139
reorganize partition p0,p1 into
 
5140
(partition s1 values less than maxvalue);
 
5141
select * from t11 order by col1;
 
5142
col1
 
5143
2006-01-17
 
5144
2006-02-05
 
5145
alter table t11
 
5146
reorganize partition s1 into
 
5147
(partition p0 values less than (15),
 
5148
partition p1 values less than maxvalue);
 
5149
select * from t11 order by col1;
 
5150
col1
 
5151
2006-01-17
 
5152
2006-02-05
 
5153
alter table t55
 
5154
partition by list(colint)
 
5155
subpartition by hash(dayofyear(col1)) subpartitions 5 
 
5156
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
5157
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
5158
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
5159
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
5160
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
5161
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
5162
);
 
5163
show create table t55;
 
5164
Table   Create Table
 
5165
t55     CREATE TABLE `t55` (
 
5166
  `colint` int(11) DEFAULT NULL,
 
5167
  `col1` date DEFAULT NULL
 
5168
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
5169
/*!50100 PARTITION BY LIST (colint)
 
5170
SUBPARTITION BY HASH (dayofyear(col1))
 
5171
SUBPARTITIONS 5
 
5172
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
5173
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
5174
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
5175
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
5176
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
5177
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
5178
select * from t55 order by colint;
 
5179
colint  col1
 
5180
1       2006-02-03
 
5181
2       2006-01-17
 
5182
3       2006-01-25
 
5183
4       2006-02-05
 
5184
alter table t66
 
5185
reorganize partition p0,p1 into
 
5186
(partition s1 values less than maxvalue);
 
5187
select * from t66 order by colint;
 
5188
colint  col1
 
5189
1       2006-02-03
 
5190
2       2006-01-17
 
5191
3       2006-01-25
 
5192
4       2006-02-05
 
5193
alter table t66
 
5194
reorganize partition s1 into
 
5195
(partition p0 values less than (dayofyear('2006-12-25')),
 
5196
partition p1 values less than maxvalue);
 
5197
select * from t66 order by colint;
 
5198
colint  col1
 
5199
1       2006-02-03
 
5200
2       2006-01-17
 
5201
3       2006-01-25
 
5202
4       2006-02-05
 
5203
alter table t66
 
5204
reorganize partition p0,p1 into
 
5205
(partition s1 values less than maxvalue);
 
5206
select * from t66 order by colint;
 
5207
colint  col1
 
5208
1       2006-02-03
 
5209
2       2006-01-17
 
5210
3       2006-01-25
 
5211
4       2006-02-05
 
5212
alter table t66
 
5213
reorganize partition s1 into
 
5214
(partition p0 values less than (dayofyear('2006-12-25')),
 
5215
partition p1 values less than maxvalue);
 
5216
select * from t66 order by colint;
 
5217
colint  col1
 
5218
1       2006-02-03
 
5219
2       2006-01-17
 
5220
3       2006-01-25
 
5221
4       2006-02-05
 
5222
-------------------------------------------------------------------------
 
5223
---  Delete rows and partitions of tables with dayofyear(col1)
 
5224
-------------------------------------------------------------------------
 
5225
delete from t1 where col1='2006-01-17';
 
5226
delete from t2 where col1='2006-01-17';
 
5227
delete from t3 where col1='2006-01-17';
 
5228
delete from t4 where col1='2006-01-17';
 
5229
delete from t5 where col1='2006-01-17';
 
5230
delete from t6 where col1='2006-01-17';
 
5231
select * from t1 order by col1;
 
5232
col1
 
5233
2006-02-05
 
5234
select * from t2 order by col1;
 
5235
col1
 
5236
2006-02-05
 
5237
2006-02-25
 
5238
select * from t3 order by col1;
 
5239
col1
 
5240
2006-02-05
 
5241
2006-02-25
 
5242
select * from t4 order by colint;
 
5243
colint  col1
 
5244
1       2006-02-03
 
5245
3       2006-01-25
 
5246
4       2006-02-05
 
5247
select * from t5 order by colint;
 
5248
colint  col1
 
5249
1       2006-02-03
 
5250
3       2006-01-25
 
5251
4       2006-02-05
 
5252
insert into t1 values ('2006-01-17');
 
5253
insert into t2 values ('2006-01-17');
 
5254
insert into t3 values ('2006-01-17');
 
5255
insert into t4 values (60,'2006-01-17');
 
5256
insert into t5 values (60,'2006-01-17');
 
5257
insert into t6 values (60,'2006-01-17');
 
5258
select * from t1 order by col1;
 
5259
col1
 
5260
2006-01-17
 
5261
2006-02-05
 
5262
select * from t2 order by col1;
 
5263
col1
 
5264
2006-01-17
 
5265
2006-02-05
 
5266
2006-02-25
 
5267
select * from t3 order by col1;
 
5268
col1
 
5269
2006-01-17
 
5270
2006-02-05
 
5271
2006-02-25
 
5272
select * from t4 order by colint;
 
5273
colint  col1
 
5274
1       2006-02-03
 
5275
3       2006-01-25
 
5276
4       2006-02-05
 
5277
60      2006-01-17
 
5278
select * from t5 order by colint;
 
5279
colint  col1
 
5280
1       2006-02-03
 
5281
3       2006-01-25
 
5282
4       2006-02-05
 
5283
60      2006-01-17
 
5284
select * from t6 order by colint;
 
5285
colint  col1
 
5286
1       2006-02-03
 
5287
3       2006-01-25
 
5288
4       2006-02-05
 
5289
60      2006-01-17
 
5290
alter table t1 drop partition p0;
 
5291
alter table t2 drop partition p0;
 
5292
alter table t4 drop partition p0;
 
5293
alter table t5 drop partition p0;
 
5294
alter table t6 drop partition p0;
 
5295
select * from t1 order by col1;
 
5296
col1
 
5297
2006-01-17
 
5298
2006-02-05
 
5299
select * from t2 order by col1;
 
5300
col1
 
5301
2006-01-17
 
5302
2006-02-05
 
5303
2006-02-25
 
5304
select * from t3 order by col1;
 
5305
col1
 
5306
2006-01-17
 
5307
2006-02-05
 
5308
2006-02-25
 
5309
select * from t4 order by colint;
 
5310
colint  col1
 
5311
60      2006-01-17
 
5312
select * from t5 order by colint;
 
5313
colint  col1
 
5314
60      2006-01-17
 
5315
select * from t6 order by colint;
 
5316
colint  col1
 
5317
-------------------------------------------------------------------------
 
5318
---  Delete rows and partitions of tables with dayofyear(col1)
 
5319
-------------------------------------------------------------------------
 
5320
delete from t11 where col1='2006-01-17';
 
5321
delete from t22 where col1='2006-01-17';
 
5322
delete from t33 where col1='2006-01-17';
 
5323
delete from t44 where col1='2006-01-17';
 
5324
delete from t55 where col1='2006-01-17';
 
5325
delete from t66 where col1='2006-01-17';
 
5326
select * from t11 order by col1;
 
5327
col1
 
5328
2006-02-05
 
5329
select * from t22 order by col1;
 
5330
col1
 
5331
2006-02-05
 
5332
2006-02-25
 
5333
select * from t33 order by col1;
 
5334
col1
 
5335
2006-02-05
 
5336
2006-02-25
 
5337
select * from t44 order by colint;
 
5338
colint  col1
 
5339
1       2006-02-03
 
5340
3       2006-01-25
 
5341
4       2006-02-05
 
5342
select * from t55 order by colint;
 
5343
colint  col1
 
5344
1       2006-02-03
 
5345
3       2006-01-25
 
5346
4       2006-02-05
 
5347
insert into t11 values ('2006-01-17');
 
5348
insert into t22 values ('2006-01-17');
 
5349
insert into t33 values ('2006-01-17');
 
5350
insert into t44 values (60,'2006-01-17');
 
5351
insert into t55 values (60,'2006-01-17');
 
5352
insert into t66 values (60,'2006-01-17');
 
5353
select * from t11 order by col1;
 
5354
col1
 
5355
2006-01-17
 
5356
2006-02-05
 
5357
select * from t22 order by col1;
 
5358
col1
 
5359
2006-01-17
 
5360
2006-02-05
 
5361
2006-02-25
 
5362
select * from t33 order by col1;
 
5363
col1
 
5364
2006-01-17
 
5365
2006-02-05
 
5366
2006-02-25
 
5367
select * from t44 order by colint;
 
5368
colint  col1
 
5369
1       2006-02-03
 
5370
3       2006-01-25
 
5371
4       2006-02-05
 
5372
60      2006-01-17
 
5373
select * from t55 order by colint;
 
5374
colint  col1
 
5375
1       2006-02-03
 
5376
3       2006-01-25
 
5377
4       2006-02-05
 
5378
60      2006-01-17
 
5379
select * from t66 order by colint;
 
5380
colint  col1
 
5381
1       2006-02-03
 
5382
3       2006-01-25
 
5383
4       2006-02-05
 
5384
60      2006-01-17
 
5385
alter table t11 drop partition p0;
 
5386
alter table t22 drop partition p0;
 
5387
alter table t44 drop partition p0;
 
5388
alter table t55 drop partition p0;
 
5389
alter table t66 drop partition p0;
 
5390
select * from t11 order by col1;
 
5391
col1
 
5392
2006-01-17
 
5393
2006-02-05
 
5394
select * from t22 order by col1;
 
5395
col1
 
5396
2006-01-17
 
5397
2006-02-05
 
5398
2006-02-25
 
5399
select * from t33 order by col1;
 
5400
col1
 
5401
2006-01-17
 
5402
2006-02-05
 
5403
2006-02-25
 
5404
select * from t44 order by colint;
 
5405
colint  col1
 
5406
60      2006-01-17
 
5407
select * from t55 order by colint;
 
5408
colint  col1
 
5409
60      2006-01-17
 
5410
select * from t66 order by colint;
 
5411
colint  col1
 
5412
-------------------------
 
5413
---- some alter table end
 
5414
-------------------------
 
5415
drop table if exists t1 ;
 
5416
drop table if exists t2 ;
 
5417
drop table if exists t3 ;
 
5418
drop table if exists t4 ;
 
5419
drop table if exists t5 ;
 
5420
drop table if exists t6 ;
 
5421
drop table if exists t11 ;
 
5422
drop table if exists t22 ;
 
5423
drop table if exists t33 ;
 
5424
drop table if exists t44 ;
 
5425
drop table if exists t55 ;
 
5426
drop table if exists t66 ;
 
5427
-------------------------------------------------------------------------
 
5428
---  dayofyear(col1)  in partition with coltype  char(30)
 
5429
-------------------------------------------------------------------------
 
5430
drop table if exists t1 ;
 
5431
drop table if exists t2 ;
 
5432
drop table if exists t3 ;
 
5433
drop table if exists t4 ;
 
5434
drop table if exists t5 ;
 
5435
drop table if exists t6 ;
 
5436
-------------------------------------------------------------------------
 
5437
---  Create tables with dayofyear(col1)
 
5438
-------------------------------------------------------------------------
 
5439
create table t1 (col1 char(30)) engine='INNODB' 
 
5440
partition by range(dayofyear(col1)) 
 
5441
(partition p0 values less than (15),
 
5442
partition p1 values less than maxvalue);
 
5443
create table t2 (col1 char(30)) engine='INNODB' 
 
5444
partition by list(dayofyear(col1)) 
 
5445
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
5446
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
5447
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
5448
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
5449
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
5450
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
5451
);
 
5452
create table t3 (col1 char(30)) engine='INNODB' 
 
5453
partition by hash(dayofyear(col1));
 
5454
create table t4 (colint int, col1 char(30)) engine='INNODB' 
 
5455
partition by range(colint) 
 
5456
subpartition by hash(dayofyear(col1)) subpartitions 2 
 
5457
(partition p0 values less than (15),
 
5458
partition p1 values less than maxvalue);
 
5459
create table t5 (colint int, col1 char(30)) engine='INNODB' 
 
5460
partition by list(colint)
 
5461
subpartition by hash(dayofyear(col1)) subpartitions 2 
 
5462
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
5463
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
5464
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
5465
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
5466
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
5467
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
5468
);
 
5469
create table t6 (colint int, col1 char(30)) engine='INNODB' 
 
5470
partition by range(colint) 
 
5471
(partition p0 values less than (dayofyear('2006-12-25')),
 
5472
partition p1 values less than maxvalue);
 
5473
-------------------------------------------------------------------------
 
5474
---  Access tables with dayofyear(col1) 
 
5475
-------------------------------------------------------------------------
 
5476
insert into t1 values ('2006-01-03');
 
5477
insert into t1 values ('2006-01-17');
 
5478
insert into t2 values ('2006-01-03');
 
5479
insert into t2 values ('2006-01-17');
 
5480
insert into t2 values ('2006-02-25');
 
5481
insert into t3 values ('2006-01-03');
 
5482
insert into t3 values ('2006-01-17');
 
5483
insert into t3 values ('2006-02-25');
 
5484
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
 
5485
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
 
5486
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
 
5487
select dayofyear(col1) from t1 order by col1;
 
5488
dayofyear(col1)
 
5489
3
 
5490
17
 
5491
select * from t1 order by col1;
 
5492
col1
 
5493
2006-01-03
 
5494
2006-01-17
 
5495
select * from t2 order by col1;
 
5496
col1
 
5497
2006-01-03
 
5498
2006-01-17
 
5499
2006-02-25
 
5500
select * from t3 order by col1;
 
5501
col1
 
5502
2006-01-03
 
5503
2006-01-17
 
5504
2006-02-25
 
5505
select * from t4 order by colint;
 
5506
colint  col1
 
5507
1       2006-02-03
 
5508
2       2006-01-17
 
5509
3       2006-01-25
 
5510
4       2006-02-05
 
5511
select * from t5 order by colint;
 
5512
colint  col1
 
5513
1       2006-02-03
 
5514
2       2006-01-17
 
5515
3       2006-01-25
 
5516
4       2006-02-05
 
5517
select * from t6 order by colint;
 
5518
colint  col1
 
5519
1       2006-02-03
 
5520
2       2006-01-17
 
5521
3       2006-01-25
 
5522
4       2006-02-05
 
5523
update t1 set col1='2006-02-05' where col1='2006-01-03';
 
5524
update t2 set col1='2006-02-05' where col1='2006-01-03';
 
5525
update t3 set col1='2006-02-05' where col1='2006-01-03';
 
5526
update t4 set col1='2006-02-05' where col1='2006-01-03';
 
5527
update t5 set col1='2006-02-05' where col1='2006-01-03';
 
5528
update t6 set col1='2006-02-05' where col1='2006-01-03';
 
5529
select * from t1 order by col1;
 
5530
col1
 
5531
2006-01-17
 
5532
2006-02-05
 
5533
select * from t2 order by col1;
 
5534
col1
 
5535
2006-01-17
 
5536
2006-02-05
 
5537
2006-02-25
 
5538
select * from t3 order by col1;
 
5539
col1
 
5540
2006-01-17
 
5541
2006-02-05
 
5542
2006-02-25
 
5543
select * from t4 order by colint;
 
5544
colint  col1
 
5545
1       2006-02-03
 
5546
2       2006-01-17
 
5547
3       2006-01-25
 
5548
4       2006-02-05
 
5549
select * from t5 order by colint;
 
5550
colint  col1
 
5551
1       2006-02-03
 
5552
2       2006-01-17
 
5553
3       2006-01-25
 
5554
4       2006-02-05
 
5555
select * from t6 order by colint;
 
5556
colint  col1
 
5557
1       2006-02-03
 
5558
2       2006-01-17
 
5559
3       2006-01-25
 
5560
4       2006-02-05
 
5561
-------------------------------------------------------------------------
 
5562
---  Alter tables with dayofyear(col1)
 
5563
-------------------------------------------------------------------------
 
5564
drop table if exists t11 ;
 
5565
drop table if exists t22 ;
 
5566
drop table if exists t33 ;
 
5567
drop table if exists t44 ;
 
5568
drop table if exists t55 ;
 
5569
drop table if exists t66 ;
 
5570
create table t11 engine='INNODB' as select * from t1;
 
5571
create table t22 engine='INNODB' as select * from t2;
 
5572
create table t33 engine='INNODB' as select * from t3;
 
5573
create table t44 engine='INNODB' as select * from t4;
 
5574
create table t55 engine='INNODB' as select * from t5;
 
5575
create table t66 engine='INNODB' as select * from t6;
 
5576
alter table t11
 
5577
partition by range(dayofyear(col1)) 
 
5578
(partition p0 values less than (15),
 
5579
partition p1 values less than maxvalue);
 
5580
alter table t22
 
5581
partition by list(dayofyear(col1)) 
 
5582
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
5583
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
5584
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
5585
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
5586
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
5587
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
5588
);
 
5589
alter table t33
 
5590
partition by hash(dayofyear(col1));
 
5591
alter table t44
 
5592
partition by range(colint) 
 
5593
subpartition by hash(dayofyear(col1)) subpartitions 2 
 
5594
(partition p0 values less than (15),
 
5595
partition p1 values less than maxvalue);
 
5596
alter table t55
 
5597
partition by list(colint)
 
5598
subpartition by hash(dayofyear(col1)) subpartitions 2 
 
5599
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
5600
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
5601
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
5602
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
5603
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
5604
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
5605
);
 
5606
alter table t66
 
5607
partition by range(colint) 
 
5608
(partition p0 values less than (dayofyear('2006-12-25')),
 
5609
partition p1 values less than maxvalue);
 
5610
select * from t11 order by col1;
 
5611
col1
 
5612
2006-01-17
 
5613
2006-02-05
 
5614
select * from t22 order by col1;
 
5615
col1
 
5616
2006-01-17
 
5617
2006-02-05
 
5618
2006-02-25
 
5619
select * from t33 order by col1;
 
5620
col1
 
5621
2006-01-17
 
5622
2006-02-05
 
5623
2006-02-25
 
5624
select * from t44 order by colint;
 
5625
colint  col1
 
5626
1       2006-02-03
 
5627
2       2006-01-17
 
5628
3       2006-01-25
 
5629
4       2006-02-05
 
5630
select * from t55 order by colint;
 
5631
colint  col1
 
5632
1       2006-02-03
 
5633
2       2006-01-17
 
5634
3       2006-01-25
 
5635
4       2006-02-05
 
5636
select * from t66 order by colint;
 
5637
colint  col1
 
5638
1       2006-02-03
 
5639
2       2006-01-17
 
5640
3       2006-01-25
 
5641
4       2006-02-05
 
5642
---------------------------
 
5643
---- some alter table begin
 
5644
---------------------------
 
5645
alter table t11
 
5646
reorganize partition p0,p1 into
 
5647
(partition s1 values less than maxvalue);
 
5648
select * from t11 order by col1;
 
5649
col1
 
5650
2006-01-17
 
5651
2006-02-05
 
5652
alter table t11
 
5653
reorganize partition s1 into
 
5654
(partition p0 values less than (15),
 
5655
partition p1 values less than maxvalue);
 
5656
select * from t11 order by col1;
 
5657
col1
 
5658
2006-01-17
 
5659
2006-02-05
 
5660
alter table t55
 
5661
partition by list(colint)
 
5662
subpartition by hash(dayofyear(col1)) subpartitions 5 
 
5663
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
5664
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
5665
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
5666
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
5667
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
5668
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
5669
);
 
5670
show create table t55;
 
5671
Table   Create Table
 
5672
t55     CREATE TABLE `t55` (
 
5673
  `colint` int(11) DEFAULT NULL,
 
5674
  `col1` char(30) DEFAULT NULL
 
5675
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
5676
/*!50100 PARTITION BY LIST (colint)
 
5677
SUBPARTITION BY HASH (dayofyear(col1))
 
5678
SUBPARTITIONS 5
 
5679
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
5680
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
5681
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
5682
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
5683
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
5684
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
5685
select * from t55 order by colint;
 
5686
colint  col1
 
5687
1       2006-02-03
 
5688
2       2006-01-17
 
5689
3       2006-01-25
 
5690
4       2006-02-05
 
5691
alter table t66
 
5692
reorganize partition p0,p1 into
 
5693
(partition s1 values less than maxvalue);
 
5694
select * from t66 order by colint;
 
5695
colint  col1
 
5696
1       2006-02-03
 
5697
2       2006-01-17
 
5698
3       2006-01-25
 
5699
4       2006-02-05
 
5700
alter table t66
 
5701
reorganize partition s1 into
 
5702
(partition p0 values less than (dayofyear('2006-12-25')),
 
5703
partition p1 values less than maxvalue);
 
5704
select * from t66 order by colint;
 
5705
colint  col1
 
5706
1       2006-02-03
 
5707
2       2006-01-17
 
5708
3       2006-01-25
 
5709
4       2006-02-05
 
5710
alter table t66
 
5711
reorganize partition p0,p1 into
 
5712
(partition s1 values less than maxvalue);
 
5713
select * from t66 order by colint;
 
5714
colint  col1
 
5715
1       2006-02-03
 
5716
2       2006-01-17
 
5717
3       2006-01-25
 
5718
4       2006-02-05
 
5719
alter table t66
 
5720
reorganize partition s1 into
 
5721
(partition p0 values less than (dayofyear('2006-12-25')),
 
5722
partition p1 values less than maxvalue);
 
5723
select * from t66 order by colint;
 
5724
colint  col1
 
5725
1       2006-02-03
 
5726
2       2006-01-17
 
5727
3       2006-01-25
 
5728
4       2006-02-05
 
5729
-------------------------------------------------------------------------
 
5730
---  Delete rows and partitions of tables with dayofyear(col1)
 
5731
-------------------------------------------------------------------------
 
5732
delete from t1 where col1='2006-01-17';
 
5733
delete from t2 where col1='2006-01-17';
 
5734
delete from t3 where col1='2006-01-17';
 
5735
delete from t4 where col1='2006-01-17';
 
5736
delete from t5 where col1='2006-01-17';
 
5737
delete from t6 where col1='2006-01-17';
 
5738
select * from t1 order by col1;
 
5739
col1
 
5740
2006-02-05
 
5741
select * from t2 order by col1;
 
5742
col1
 
5743
2006-02-05
 
5744
2006-02-25
 
5745
select * from t3 order by col1;
 
5746
col1
 
5747
2006-02-05
 
5748
2006-02-25
 
5749
select * from t4 order by colint;
 
5750
colint  col1
 
5751
1       2006-02-03
 
5752
3       2006-01-25
 
5753
4       2006-02-05
 
5754
select * from t5 order by colint;
 
5755
colint  col1
 
5756
1       2006-02-03
 
5757
3       2006-01-25
 
5758
4       2006-02-05
 
5759
insert into t1 values ('2006-01-17');
 
5760
insert into t2 values ('2006-01-17');
 
5761
insert into t3 values ('2006-01-17');
 
5762
insert into t4 values (60,'2006-01-17');
 
5763
insert into t5 values (60,'2006-01-17');
 
5764
insert into t6 values (60,'2006-01-17');
 
5765
select * from t1 order by col1;
 
5766
col1
 
5767
2006-01-17
 
5768
2006-02-05
 
5769
select * from t2 order by col1;
 
5770
col1
 
5771
2006-01-17
 
5772
2006-02-05
 
5773
2006-02-25
 
5774
select * from t3 order by col1;
 
5775
col1
 
5776
2006-01-17
 
5777
2006-02-05
 
5778
2006-02-25
 
5779
select * from t4 order by colint;
 
5780
colint  col1
 
5781
1       2006-02-03
 
5782
3       2006-01-25
 
5783
4       2006-02-05
 
5784
60      2006-01-17
 
5785
select * from t5 order by colint;
 
5786
colint  col1
 
5787
1       2006-02-03
 
5788
3       2006-01-25
 
5789
4       2006-02-05
 
5790
60      2006-01-17
 
5791
select * from t6 order by colint;
 
5792
colint  col1
 
5793
1       2006-02-03
 
5794
3       2006-01-25
 
5795
4       2006-02-05
 
5796
60      2006-01-17
 
5797
alter table t1 drop partition p0;
 
5798
alter table t2 drop partition p0;
 
5799
alter table t4 drop partition p0;
 
5800
alter table t5 drop partition p0;
 
5801
alter table t6 drop partition p0;
 
5802
select * from t1 order by col1;
 
5803
col1
 
5804
2006-01-17
 
5805
2006-02-05
 
5806
select * from t2 order by col1;
 
5807
col1
 
5808
2006-01-17
 
5809
2006-02-05
 
5810
2006-02-25
 
5811
select * from t3 order by col1;
 
5812
col1
 
5813
2006-01-17
 
5814
2006-02-05
 
5815
2006-02-25
 
5816
select * from t4 order by colint;
 
5817
colint  col1
 
5818
60      2006-01-17
 
5819
select * from t5 order by colint;
 
5820
colint  col1
 
5821
60      2006-01-17
 
5822
select * from t6 order by colint;
 
5823
colint  col1
 
5824
-------------------------------------------------------------------------
 
5825
---  Delete rows and partitions of tables with dayofyear(col1)
 
5826
-------------------------------------------------------------------------
 
5827
delete from t11 where col1='2006-01-17';
 
5828
delete from t22 where col1='2006-01-17';
 
5829
delete from t33 where col1='2006-01-17';
 
5830
delete from t44 where col1='2006-01-17';
 
5831
delete from t55 where col1='2006-01-17';
 
5832
delete from t66 where col1='2006-01-17';
 
5833
select * from t11 order by col1;
 
5834
col1
 
5835
2006-02-05
 
5836
select * from t22 order by col1;
 
5837
col1
 
5838
2006-02-05
 
5839
2006-02-25
 
5840
select * from t33 order by col1;
 
5841
col1
 
5842
2006-02-05
 
5843
2006-02-25
 
5844
select * from t44 order by colint;
 
5845
colint  col1
 
5846
1       2006-02-03
 
5847
3       2006-01-25
 
5848
4       2006-02-05
 
5849
select * from t55 order by colint;
 
5850
colint  col1
 
5851
1       2006-02-03
 
5852
3       2006-01-25
 
5853
4       2006-02-05
 
5854
insert into t11 values ('2006-01-17');
 
5855
insert into t22 values ('2006-01-17');
 
5856
insert into t33 values ('2006-01-17');
 
5857
insert into t44 values (60,'2006-01-17');
 
5858
insert into t55 values (60,'2006-01-17');
 
5859
insert into t66 values (60,'2006-01-17');
 
5860
select * from t11 order by col1;
 
5861
col1
 
5862
2006-01-17
 
5863
2006-02-05
 
5864
select * from t22 order by col1;
 
5865
col1
 
5866
2006-01-17
 
5867
2006-02-05
 
5868
2006-02-25
 
5869
select * from t33 order by col1;
 
5870
col1
 
5871
2006-01-17
 
5872
2006-02-05
 
5873
2006-02-25
 
5874
select * from t44 order by colint;
 
5875
colint  col1
 
5876
1       2006-02-03
 
5877
3       2006-01-25
 
5878
4       2006-02-05
 
5879
60      2006-01-17
 
5880
select * from t55 order by colint;
 
5881
colint  col1
 
5882
1       2006-02-03
 
5883
3       2006-01-25
 
5884
4       2006-02-05
 
5885
60      2006-01-17
 
5886
select * from t66 order by colint;
 
5887
colint  col1
 
5888
1       2006-02-03
 
5889
3       2006-01-25
 
5890
4       2006-02-05
 
5891
60      2006-01-17
 
5892
alter table t11 drop partition p0;
 
5893
alter table t22 drop partition p0;
 
5894
alter table t44 drop partition p0;
 
5895
alter table t55 drop partition p0;
 
5896
alter table t66 drop partition p0;
 
5897
select * from t11 order by col1;
 
5898
col1
 
5899
2006-01-17
 
5900
2006-02-05
 
5901
select * from t22 order by col1;
 
5902
col1
 
5903
2006-01-17
 
5904
2006-02-05
 
5905
2006-02-25
 
5906
select * from t33 order by col1;
 
5907
col1
 
5908
2006-01-17
 
5909
2006-02-05
 
5910
2006-02-25
 
5911
select * from t44 order by colint;
 
5912
colint  col1
 
5913
60      2006-01-17
 
5914
select * from t55 order by colint;
 
5915
colint  col1
 
5916
60      2006-01-17
 
5917
select * from t66 order by colint;
 
5918
colint  col1
 
5919
-------------------------
 
5920
---- some alter table end
 
5921
-------------------------
 
5922
drop table if exists t1 ;
 
5923
drop table if exists t2 ;
 
5924
drop table if exists t3 ;
 
5925
drop table if exists t4 ;
 
5926
drop table if exists t5 ;
 
5927
drop table if exists t6 ;
 
5928
drop table if exists t11 ;
 
5929
drop table if exists t22 ;
 
5930
drop table if exists t33 ;
 
5931
drop table if exists t44 ;
 
5932
drop table if exists t55 ;
 
5933
drop table if exists t66 ;
 
5934
-------------------------------------------------------------------------
 
5935
---  extract(month from col1)  in partition with coltype  date
 
5936
-------------------------------------------------------------------------
 
5937
drop table if exists t1 ;
 
5938
drop table if exists t2 ;
 
5939
drop table if exists t3 ;
 
5940
drop table if exists t4 ;
 
5941
drop table if exists t5 ;
 
5942
drop table if exists t6 ;
 
5943
-------------------------------------------------------------------------
 
5944
---  Create tables with extract(month from col1)
 
5945
-------------------------------------------------------------------------
 
5946
create table t1 (col1 date) engine='INNODB' 
 
5947
partition by range(extract(month from col1)) 
 
5948
(partition p0 values less than (15),
 
5949
partition p1 values less than maxvalue);
 
5950
create table t2 (col1 date) engine='INNODB' 
 
5951
partition by list(extract(month from col1)) 
 
5952
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
5953
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
5954
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
5955
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
5956
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
5957
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
5958
);
 
5959
create table t3 (col1 date) engine='INNODB' 
 
5960
partition by hash(extract(month from col1));
 
5961
create table t4 (colint int, col1 date) engine='INNODB' 
 
5962
partition by range(colint) 
 
5963
subpartition by hash(extract(month from col1)) subpartitions 2 
 
5964
(partition p0 values less than (15),
 
5965
partition p1 values less than maxvalue);
 
5966
create table t5 (colint int, col1 date) engine='INNODB' 
 
5967
partition by list(colint)
 
5968
subpartition by hash(extract(month from col1)) subpartitions 2 
 
5969
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
5970
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
5971
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
5972
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
5973
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
5974
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
5975
);
 
5976
create table t6 (colint int, col1 date) engine='INNODB' 
 
5977
partition by range(colint) 
 
5978
(partition p0 values less than (extract(year from '1998-11-23')),
 
5979
partition p1 values less than maxvalue);
 
5980
-------------------------------------------------------------------------
 
5981
---  Access tables with extract(month from col1) 
 
5982
-------------------------------------------------------------------------
 
5983
insert into t1 values ('2006-01-03');
 
5984
insert into t1 values ('2006-02-17');
 
5985
insert into t2 values ('2006-01-03');
 
5986
insert into t2 values ('2006-02-17');
 
5987
insert into t2 values ('2006-01-25');
 
5988
insert into t3 values ('2006-01-03');
 
5989
insert into t3 values ('2006-02-17');
 
5990
insert into t3 values ('2006-01-25');
 
5991
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
 
5992
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
 
5993
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
 
5994
select extract(month from col1) from t1 order by col1;
 
5995
extract(month from col1)
 
5996
1
 
5997
2
 
5998
select * from t1 order by col1;
 
5999
col1
 
6000
2006-01-03
 
6001
2006-02-17
 
6002
select * from t2 order by col1;
 
6003
col1
 
6004
2006-01-03
 
6005
2006-01-25
 
6006
2006-02-17
 
6007
select * from t3 order by col1;
 
6008
col1
 
6009
2006-01-03
 
6010
2006-01-25
 
6011
2006-02-17
 
6012
select * from t4 order by colint;
 
6013
colint  col1
 
6014
1       2006-02-03
 
6015
2       2006-01-17
 
6016
3       2006-01-25
 
6017
4       2006-02-05
 
6018
select * from t5 order by colint;
 
6019
colint  col1
 
6020
1       2006-02-03
 
6021
2       2006-01-17
 
6022
3       2006-01-25
 
6023
4       2006-02-05
 
6024
select * from t6 order by colint;
 
6025
colint  col1
 
6026
1       2006-02-03
 
6027
2       2006-01-17
 
6028
3       2006-01-25
 
6029
4       2006-02-05
 
6030
update t1 set col1='2006-02-05' where col1='2006-01-03';
 
6031
update t2 set col1='2006-02-05' where col1='2006-01-03';
 
6032
update t3 set col1='2006-02-05' where col1='2006-01-03';
 
6033
update t4 set col1='2006-02-05' where col1='2006-01-03';
 
6034
update t5 set col1='2006-02-05' where col1='2006-01-03';
 
6035
update t6 set col1='2006-02-05' where col1='2006-01-03';
 
6036
select * from t1 order by col1;
 
6037
col1
 
6038
2006-02-05
 
6039
2006-02-17
 
6040
select * from t2 order by col1;
 
6041
col1
 
6042
2006-01-25
 
6043
2006-02-05
 
6044
2006-02-17
 
6045
select * from t3 order by col1;
 
6046
col1
 
6047
2006-01-25
 
6048
2006-02-05
 
6049
2006-02-17
 
6050
select * from t4 order by colint;
 
6051
colint  col1
 
6052
1       2006-02-03
 
6053
2       2006-01-17
 
6054
3       2006-01-25
 
6055
4       2006-02-05
 
6056
select * from t5 order by colint;
 
6057
colint  col1
 
6058
1       2006-02-03
 
6059
2       2006-01-17
 
6060
3       2006-01-25
 
6061
4       2006-02-05
 
6062
select * from t6 order by colint;
 
6063
colint  col1
 
6064
1       2006-02-03
 
6065
2       2006-01-17
 
6066
3       2006-01-25
 
6067
4       2006-02-05
 
6068
-------------------------------------------------------------------------
 
6069
---  Alter tables with extract(month from col1)
 
6070
-------------------------------------------------------------------------
 
6071
drop table if exists t11 ;
 
6072
drop table if exists t22 ;
 
6073
drop table if exists t33 ;
 
6074
drop table if exists t44 ;
 
6075
drop table if exists t55 ;
 
6076
drop table if exists t66 ;
 
6077
create table t11 engine='INNODB' as select * from t1;
 
6078
create table t22 engine='INNODB' as select * from t2;
 
6079
create table t33 engine='INNODB' as select * from t3;
 
6080
create table t44 engine='INNODB' as select * from t4;
 
6081
create table t55 engine='INNODB' as select * from t5;
 
6082
create table t66 engine='INNODB' as select * from t6;
 
6083
alter table t11
 
6084
partition by range(extract(month from col1)) 
 
6085
(partition p0 values less than (15),
 
6086
partition p1 values less than maxvalue);
 
6087
alter table t22
 
6088
partition by list(extract(month from col1)) 
 
6089
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
6090
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
6091
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
6092
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
6093
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
6094
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
6095
);
 
6096
alter table t33
 
6097
partition by hash(extract(month from col1));
 
6098
alter table t44
 
6099
partition by range(colint) 
 
6100
subpartition by hash(extract(month from col1)) subpartitions 2 
 
6101
(partition p0 values less than (15),
 
6102
partition p1 values less than maxvalue);
 
6103
alter table t55
 
6104
partition by list(colint)
 
6105
subpartition by hash(extract(month from col1)) subpartitions 2 
 
6106
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
6107
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
6108
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
6109
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
6110
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
6111
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
6112
);
 
6113
alter table t66
 
6114
partition by range(colint) 
 
6115
(partition p0 values less than (extract(year from '1998-11-23')),
 
6116
partition p1 values less than maxvalue);
 
6117
select * from t11 order by col1;
 
6118
col1
 
6119
2006-02-05
 
6120
2006-02-17
 
6121
select * from t22 order by col1;
 
6122
col1
 
6123
2006-01-25
 
6124
2006-02-05
 
6125
2006-02-17
 
6126
select * from t33 order by col1;
 
6127
col1
 
6128
2006-01-25
 
6129
2006-02-05
 
6130
2006-02-17
 
6131
select * from t44 order by colint;
 
6132
colint  col1
 
6133
1       2006-02-03
 
6134
2       2006-01-17
 
6135
3       2006-01-25
 
6136
4       2006-02-05
 
6137
select * from t55 order by colint;
 
6138
colint  col1
 
6139
1       2006-02-03
 
6140
2       2006-01-17
 
6141
3       2006-01-25
 
6142
4       2006-02-05
 
6143
select * from t66 order by colint;
 
6144
colint  col1
 
6145
1       2006-02-03
 
6146
2       2006-01-17
 
6147
3       2006-01-25
 
6148
4       2006-02-05
 
6149
---------------------------
 
6150
---- some alter table begin
 
6151
---------------------------
 
6152
alter table t11
 
6153
reorganize partition p0,p1 into
 
6154
(partition s1 values less than maxvalue);
 
6155
select * from t11 order by col1;
 
6156
col1
 
6157
2006-02-05
 
6158
2006-02-17
 
6159
alter table t11
 
6160
reorganize partition s1 into
 
6161
(partition p0 values less than (15),
 
6162
partition p1 values less than maxvalue);
 
6163
select * from t11 order by col1;
 
6164
col1
 
6165
2006-02-05
 
6166
2006-02-17
 
6167
alter table t55
 
6168
partition by list(colint)
 
6169
subpartition by hash(extract(month from col1)) subpartitions 5 
 
6170
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
6171
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
6172
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
6173
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
6174
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
6175
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
6176
);
 
6177
show create table t55;
 
6178
Table   Create Table
 
6179
t55     CREATE TABLE `t55` (
 
6180
  `colint` int(11) DEFAULT NULL,
 
6181
  `col1` date DEFAULT NULL
 
6182
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
6183
/*!50100 PARTITION BY LIST (colint)
 
6184
SUBPARTITION BY HASH (extract(month from col1))
 
6185
SUBPARTITIONS 5
 
6186
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
6187
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
6188
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
6189
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
6190
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
6191
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
6192
select * from t55 order by colint;
 
6193
colint  col1
 
6194
1       2006-02-03
 
6195
2       2006-01-17
 
6196
3       2006-01-25
 
6197
4       2006-02-05
 
6198
alter table t66
 
6199
reorganize partition p0,p1 into
 
6200
(partition s1 values less than maxvalue);
 
6201
select * from t66 order by colint;
 
6202
colint  col1
 
6203
1       2006-02-03
 
6204
2       2006-01-17
 
6205
3       2006-01-25
 
6206
4       2006-02-05
 
6207
alter table t66
 
6208
reorganize partition s1 into
 
6209
(partition p0 values less than (extract(year from '1998-11-23')),
 
6210
partition p1 values less than maxvalue);
 
6211
select * from t66 order by colint;
 
6212
colint  col1
 
6213
1       2006-02-03
 
6214
2       2006-01-17
 
6215
3       2006-01-25
 
6216
4       2006-02-05
 
6217
alter table t66
 
6218
reorganize partition p0,p1 into
 
6219
(partition s1 values less than maxvalue);
 
6220
select * from t66 order by colint;
 
6221
colint  col1
 
6222
1       2006-02-03
 
6223
2       2006-01-17
 
6224
3       2006-01-25
 
6225
4       2006-02-05
 
6226
alter table t66
 
6227
reorganize partition s1 into
 
6228
(partition p0 values less than (extract(year from '1998-11-23')),
 
6229
partition p1 values less than maxvalue);
 
6230
select * from t66 order by colint;
 
6231
colint  col1
 
6232
1       2006-02-03
 
6233
2       2006-01-17
 
6234
3       2006-01-25
 
6235
4       2006-02-05
 
6236
-------------------------------------------------------------------------
 
6237
---  Delete rows and partitions of tables with extract(month from col1)
 
6238
-------------------------------------------------------------------------
 
6239
delete from t1 where col1='2006-02-17';
 
6240
delete from t2 where col1='2006-02-17';
 
6241
delete from t3 where col1='2006-02-17';
 
6242
delete from t4 where col1='2006-02-17';
 
6243
delete from t5 where col1='2006-02-17';
 
6244
delete from t6 where col1='2006-02-17';
 
6245
select * from t1 order by col1;
 
6246
col1
 
6247
2006-02-05
 
6248
select * from t2 order by col1;
 
6249
col1
 
6250
2006-01-25
 
6251
2006-02-05
 
6252
select * from t3 order by col1;
 
6253
col1
 
6254
2006-01-25
 
6255
2006-02-05
 
6256
select * from t4 order by colint;
 
6257
colint  col1
 
6258
1       2006-02-03
 
6259
2       2006-01-17
 
6260
3       2006-01-25
 
6261
4       2006-02-05
 
6262
select * from t5 order by colint;
 
6263
colint  col1
 
6264
1       2006-02-03
 
6265
2       2006-01-17
 
6266
3       2006-01-25
 
6267
4       2006-02-05
 
6268
insert into t1 values ('2006-02-17');
 
6269
insert into t2 values ('2006-02-17');
 
6270
insert into t3 values ('2006-02-17');
 
6271
insert into t4 values (60,'2006-02-17');
 
6272
insert into t5 values (60,'2006-02-17');
 
6273
insert into t6 values (60,'2006-02-17');
 
6274
select * from t1 order by col1;
 
6275
col1
 
6276
2006-02-05
 
6277
2006-02-17
 
6278
select * from t2 order by col1;
 
6279
col1
 
6280
2006-01-25
 
6281
2006-02-05
 
6282
2006-02-17
 
6283
select * from t3 order by col1;
 
6284
col1
 
6285
2006-01-25
 
6286
2006-02-05
 
6287
2006-02-17
 
6288
select * from t4 order by colint;
 
6289
colint  col1
 
6290
1       2006-02-03
 
6291
2       2006-01-17
 
6292
3       2006-01-25
 
6293
4       2006-02-05
 
6294
60      2006-02-17
 
6295
select * from t5 order by colint;
 
6296
colint  col1
 
6297
1       2006-02-03
 
6298
2       2006-01-17
 
6299
3       2006-01-25
 
6300
4       2006-02-05
 
6301
60      2006-02-17
 
6302
select * from t6 order by colint;
 
6303
colint  col1
 
6304
1       2006-02-03
 
6305
2       2006-01-17
 
6306
3       2006-01-25
 
6307
4       2006-02-05
 
6308
60      2006-02-17
 
6309
alter table t1 drop partition p0;
 
6310
alter table t2 drop partition p0;
 
6311
alter table t4 drop partition p0;
 
6312
alter table t5 drop partition p0;
 
6313
alter table t6 drop partition p0;
 
6314
select * from t1 order by col1;
 
6315
col1
 
6316
select * from t2 order by col1;
 
6317
col1
 
6318
select * from t3 order by col1;
 
6319
col1
 
6320
2006-01-25
 
6321
2006-02-05
 
6322
2006-02-17
 
6323
select * from t4 order by colint;
 
6324
colint  col1
 
6325
60      2006-02-17
 
6326
select * from t5 order by colint;
 
6327
colint  col1
 
6328
60      2006-02-17
 
6329
select * from t6 order by colint;
 
6330
colint  col1
 
6331
-------------------------------------------------------------------------
 
6332
---  Delete rows and partitions of tables with extract(month from col1)
 
6333
-------------------------------------------------------------------------
 
6334
delete from t11 where col1='2006-02-17';
 
6335
delete from t22 where col1='2006-02-17';
 
6336
delete from t33 where col1='2006-02-17';
 
6337
delete from t44 where col1='2006-02-17';
 
6338
delete from t55 where col1='2006-02-17';
 
6339
delete from t66 where col1='2006-02-17';
 
6340
select * from t11 order by col1;
 
6341
col1
 
6342
2006-02-05
 
6343
select * from t22 order by col1;
 
6344
col1
 
6345
2006-01-25
 
6346
2006-02-05
 
6347
select * from t33 order by col1;
 
6348
col1
 
6349
2006-01-25
 
6350
2006-02-05
 
6351
select * from t44 order by colint;
 
6352
colint  col1
 
6353
1       2006-02-03
 
6354
2       2006-01-17
 
6355
3       2006-01-25
 
6356
4       2006-02-05
 
6357
select * from t55 order by colint;
 
6358
colint  col1
 
6359
1       2006-02-03
 
6360
2       2006-01-17
 
6361
3       2006-01-25
 
6362
4       2006-02-05
 
6363
insert into t11 values ('2006-02-17');
 
6364
insert into t22 values ('2006-02-17');
 
6365
insert into t33 values ('2006-02-17');
 
6366
insert into t44 values (60,'2006-02-17');
 
6367
insert into t55 values (60,'2006-02-17');
 
6368
insert into t66 values (60,'2006-02-17');
 
6369
select * from t11 order by col1;
 
6370
col1
 
6371
2006-02-05
 
6372
2006-02-17
 
6373
select * from t22 order by col1;
 
6374
col1
 
6375
2006-01-25
 
6376
2006-02-05
 
6377
2006-02-17
 
6378
select * from t33 order by col1;
 
6379
col1
 
6380
2006-01-25
 
6381
2006-02-05
 
6382
2006-02-17
 
6383
select * from t44 order by colint;
 
6384
colint  col1
 
6385
1       2006-02-03
 
6386
2       2006-01-17
 
6387
3       2006-01-25
 
6388
4       2006-02-05
 
6389
60      2006-02-17
 
6390
select * from t55 order by colint;
 
6391
colint  col1
 
6392
1       2006-02-03
 
6393
2       2006-01-17
 
6394
3       2006-01-25
 
6395
4       2006-02-05
 
6396
60      2006-02-17
 
6397
select * from t66 order by colint;
 
6398
colint  col1
 
6399
1       2006-02-03
 
6400
2       2006-01-17
 
6401
3       2006-01-25
 
6402
4       2006-02-05
 
6403
60      2006-02-17
 
6404
alter table t11 drop partition p0;
 
6405
alter table t22 drop partition p0;
 
6406
alter table t44 drop partition p0;
 
6407
alter table t55 drop partition p0;
 
6408
alter table t66 drop partition p0;
 
6409
select * from t11 order by col1;
 
6410
col1
 
6411
select * from t22 order by col1;
 
6412
col1
 
6413
select * from t33 order by col1;
 
6414
col1
 
6415
2006-01-25
 
6416
2006-02-05
 
6417
2006-02-17
 
6418
select * from t44 order by colint;
 
6419
colint  col1
 
6420
60      2006-02-17
 
6421
select * from t55 order by colint;
 
6422
colint  col1
 
6423
60      2006-02-17
 
6424
select * from t66 order by colint;
 
6425
colint  col1
 
6426
-------------------------
 
6427
---- some alter table end
 
6428
-------------------------
 
6429
drop table if exists t1 ;
 
6430
drop table if exists t2 ;
 
6431
drop table if exists t3 ;
 
6432
drop table if exists t4 ;
 
6433
drop table if exists t5 ;
 
6434
drop table if exists t6 ;
 
6435
drop table if exists t11 ;
 
6436
drop table if exists t22 ;
 
6437
drop table if exists t33 ;
 
6438
drop table if exists t44 ;
 
6439
drop table if exists t55 ;
 
6440
drop table if exists t66 ;
 
6441
-------------------------------------------------------------------------
 
6442
---  hour(col1)  in partition with coltype  time
 
6443
-------------------------------------------------------------------------
 
6444
drop table if exists t1 ;
 
6445
drop table if exists t2 ;
 
6446
drop table if exists t3 ;
 
6447
drop table if exists t4 ;
 
6448
drop table if exists t5 ;
 
6449
drop table if exists t6 ;
 
6450
-------------------------------------------------------------------------
 
6451
---  Create tables with hour(col1)
 
6452
-------------------------------------------------------------------------
 
6453
create table t1 (col1 time) engine='INNODB' 
 
6454
partition by range(hour(col1)) 
 
6455
(partition p0 values less than (15),
 
6456
partition p1 values less than maxvalue);
 
6457
create table t2 (col1 time) engine='INNODB' 
 
6458
partition by list(hour(col1)) 
 
6459
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
6460
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
6461
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
6462
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
6463
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
6464
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
6465
);
 
6466
create table t3 (col1 time) engine='INNODB' 
 
6467
partition by hash(hour(col1));
 
6468
create table t4 (colint int, col1 time) engine='INNODB' 
 
6469
partition by range(colint) 
 
6470
subpartition by hash(hour(col1)) subpartitions 2 
 
6471
(partition p0 values less than (15),
 
6472
partition p1 values less than maxvalue);
 
6473
create table t5 (colint int, col1 time) engine='INNODB' 
 
6474
partition by list(colint)
 
6475
subpartition by hash(hour(col1)) subpartitions 2 
 
6476
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
6477
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
6478
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
6479
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
6480
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
6481
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
6482
);
 
6483
create table t6 (colint int, col1 time) engine='INNODB' 
 
6484
partition by range(colint) 
 
6485
(partition p0 values less than (hour('18:30')),
 
6486
partition p1 values less than maxvalue);
 
6487
-------------------------------------------------------------------------
 
6488
---  Access tables with hour(col1) 
 
6489
-------------------------------------------------------------------------
 
6490
insert into t1 values ('09:09');
 
6491
insert into t1 values ('14:30');
 
6492
insert into t2 values ('09:09');
 
6493
insert into t2 values ('14:30');
 
6494
insert into t2 values ('21:59');
 
6495
insert into t3 values ('09:09');
 
6496
insert into t3 values ('14:30');
 
6497
insert into t3 values ('21:59');
 
6498
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
 
6499
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
 
6500
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
 
6501
select hour(col1) from t1 order by col1;
 
6502
hour(col1)
 
6503
9
 
6504
14
 
6505
select * from t1 order by col1;
 
6506
col1
 
6507
09:09:00
 
6508
14:30:00
 
6509
select * from t2 order by col1;
 
6510
col1
 
6511
09:09:00
 
6512
14:30:00
 
6513
21:59:00
 
6514
select * from t3 order by col1;
 
6515
col1
 
6516
09:09:00
 
6517
14:30:00
 
6518
21:59:00
 
6519
select * from t4 order by colint;
 
6520
colint  col1
 
6521
1       09:09:15
 
6522
2       04:30:01
 
6523
3       00:59:22
 
6524
4       05:30:34
 
6525
select * from t5 order by colint;
 
6526
colint  col1
 
6527
1       09:09:15
 
6528
2       04:30:01
 
6529
3       00:59:22
 
6530
4       05:30:34
 
6531
select * from t6 order by colint;
 
6532
colint  col1
 
6533
1       09:09:15
 
6534
2       04:30:01
 
6535
3       00:59:22
 
6536
4       05:30:34
 
6537
update t1 set col1='10:30' where col1='09:09';
 
6538
update t2 set col1='10:30' where col1='09:09';
 
6539
update t3 set col1='10:30' where col1='09:09';
 
6540
update t4 set col1='10:30' where col1='09:09';
 
6541
update t5 set col1='10:30' where col1='09:09';
 
6542
update t6 set col1='10:30' where col1='09:09';
 
6543
select * from t1 order by col1;
 
6544
col1
 
6545
10:30:00
 
6546
14:30:00
 
6547
select * from t2 order by col1;
 
6548
col1
 
6549
10:30:00
 
6550
14:30:00
 
6551
21:59:00
 
6552
select * from t3 order by col1;
 
6553
col1
 
6554
10:30:00
 
6555
14:30:00
 
6556
21:59:00
 
6557
select * from t4 order by colint;
 
6558
colint  col1
 
6559
1       09:09:15
 
6560
2       04:30:01
 
6561
3       00:59:22
 
6562
4       05:30:34
 
6563
select * from t5 order by colint;
 
6564
colint  col1
 
6565
1       09:09:15
 
6566
2       04:30:01
 
6567
3       00:59:22
 
6568
4       05:30:34
 
6569
select * from t6 order by colint;
 
6570
colint  col1
 
6571
1       09:09:15
 
6572
2       04:30:01
 
6573
3       00:59:22
 
6574
4       05:30:34
 
6575
-------------------------------------------------------------------------
 
6576
---  Alter tables with hour(col1)
 
6577
-------------------------------------------------------------------------
 
6578
drop table if exists t11 ;
 
6579
drop table if exists t22 ;
 
6580
drop table if exists t33 ;
 
6581
drop table if exists t44 ;
 
6582
drop table if exists t55 ;
 
6583
drop table if exists t66 ;
 
6584
create table t11 engine='INNODB' as select * from t1;
 
6585
create table t22 engine='INNODB' as select * from t2;
 
6586
create table t33 engine='INNODB' as select * from t3;
 
6587
create table t44 engine='INNODB' as select * from t4;
 
6588
create table t55 engine='INNODB' as select * from t5;
 
6589
create table t66 engine='INNODB' as select * from t6;
 
6590
alter table t11
 
6591
partition by range(hour(col1)) 
 
6592
(partition p0 values less than (15),
 
6593
partition p1 values less than maxvalue);
 
6594
alter table t22
 
6595
partition by list(hour(col1)) 
 
6596
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
6597
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
6598
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
6599
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
6600
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
6601
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
6602
);
 
6603
alter table t33
 
6604
partition by hash(hour(col1));
 
6605
alter table t44
 
6606
partition by range(colint) 
 
6607
subpartition by hash(hour(col1)) subpartitions 2 
 
6608
(partition p0 values less than (15),
 
6609
partition p1 values less than maxvalue);
 
6610
alter table t55
 
6611
partition by list(colint)
 
6612
subpartition by hash(hour(col1)) subpartitions 2 
 
6613
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
6614
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
6615
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
6616
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
6617
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
6618
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
6619
);
 
6620
alter table t66
 
6621
partition by range(colint) 
 
6622
(partition p0 values less than (hour('18:30')),
 
6623
partition p1 values less than maxvalue);
 
6624
select * from t11 order by col1;
 
6625
col1
 
6626
10:30:00
 
6627
14:30:00
 
6628
select * from t22 order by col1;
 
6629
col1
 
6630
10:30:00
 
6631
14:30:00
 
6632
21:59:00
 
6633
select * from t33 order by col1;
 
6634
col1
 
6635
10:30:00
 
6636
14:30:00
 
6637
21:59:00
 
6638
select * from t44 order by colint;
 
6639
colint  col1
 
6640
1       09:09:15
 
6641
2       04:30:01
 
6642
3       00:59:22
 
6643
4       05:30:34
 
6644
select * from t55 order by colint;
 
6645
colint  col1
 
6646
1       09:09:15
 
6647
2       04:30:01
 
6648
3       00:59:22
 
6649
4       05:30:34
 
6650
select * from t66 order by colint;
 
6651
colint  col1
 
6652
1       09:09:15
 
6653
2       04:30:01
 
6654
3       00:59:22
 
6655
4       05:30:34
 
6656
---------------------------
 
6657
---- some alter table begin
 
6658
---------------------------
 
6659
alter table t11
 
6660
reorganize partition p0,p1 into
 
6661
(partition s1 values less than maxvalue);
 
6662
select * from t11 order by col1;
 
6663
col1
 
6664
10:30:00
 
6665
14:30:00
 
6666
alter table t11
 
6667
reorganize partition s1 into
 
6668
(partition p0 values less than (15),
 
6669
partition p1 values less than maxvalue);
 
6670
select * from t11 order by col1;
 
6671
col1
 
6672
10:30:00
 
6673
14:30:00
 
6674
alter table t55
 
6675
partition by list(colint)
 
6676
subpartition by hash(hour(col1)) subpartitions 5 
 
6677
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
6678
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
6679
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
6680
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
6681
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
6682
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
6683
);
 
6684
show create table t55;
 
6685
Table   Create Table
 
6686
t55     CREATE TABLE `t55` (
 
6687
  `colint` int(11) DEFAULT NULL,
 
6688
  `col1` time DEFAULT NULL
 
6689
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
6690
/*!50100 PARTITION BY LIST (colint)
 
6691
SUBPARTITION BY HASH (hour(col1))
 
6692
SUBPARTITIONS 5
 
6693
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
6694
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
6695
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
6696
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
6697
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
6698
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
6699
select * from t55 order by colint;
 
6700
colint  col1
 
6701
1       09:09:15
 
6702
2       04:30:01
 
6703
3       00:59:22
 
6704
4       05:30:34
 
6705
alter table t66
 
6706
reorganize partition p0,p1 into
 
6707
(partition s1 values less than maxvalue);
 
6708
select * from t66 order by colint;
 
6709
colint  col1
 
6710
1       09:09:15
 
6711
2       04:30:01
 
6712
3       00:59:22
 
6713
4       05:30:34
 
6714
alter table t66
 
6715
reorganize partition s1 into
 
6716
(partition p0 values less than (hour('18:30')),
 
6717
partition p1 values less than maxvalue);
 
6718
select * from t66 order by colint;
 
6719
colint  col1
 
6720
1       09:09:15
 
6721
2       04:30:01
 
6722
3       00:59:22
 
6723
4       05:30:34
 
6724
alter table t66
 
6725
reorganize partition p0,p1 into
 
6726
(partition s1 values less than maxvalue);
 
6727
select * from t66 order by colint;
 
6728
colint  col1
 
6729
1       09:09:15
 
6730
2       04:30:01
 
6731
3       00:59:22
 
6732
4       05:30:34
 
6733
alter table t66
 
6734
reorganize partition s1 into
 
6735
(partition p0 values less than (hour('18:30')),
 
6736
partition p1 values less than maxvalue);
 
6737
select * from t66 order by colint;
 
6738
colint  col1
 
6739
1       09:09:15
 
6740
2       04:30:01
 
6741
3       00:59:22
 
6742
4       05:30:34
 
6743
-------------------------------------------------------------------------
 
6744
---  Delete rows and partitions of tables with hour(col1)
 
6745
-------------------------------------------------------------------------
 
6746
delete from t1 where col1='14:30';
 
6747
delete from t2 where col1='14:30';
 
6748
delete from t3 where col1='14:30';
 
6749
delete from t4 where col1='14:30';
 
6750
delete from t5 where col1='14:30';
 
6751
delete from t6 where col1='14:30';
 
6752
select * from t1 order by col1;
 
6753
col1
 
6754
10:30:00
 
6755
select * from t2 order by col1;
 
6756
col1
 
6757
10:30:00
 
6758
21:59:00
 
6759
select * from t3 order by col1;
 
6760
col1
 
6761
10:30:00
 
6762
21:59:00
 
6763
select * from t4 order by colint;
 
6764
colint  col1
 
6765
1       09:09:15
 
6766
2       04:30:01
 
6767
3       00:59:22
 
6768
4       05:30:34
 
6769
select * from t5 order by colint;
 
6770
colint  col1
 
6771
1       09:09:15
 
6772
2       04:30:01
 
6773
3       00:59:22
 
6774
4       05:30:34
 
6775
insert into t1 values ('14:30');
 
6776
insert into t2 values ('14:30');
 
6777
insert into t3 values ('14:30');
 
6778
insert into t4 values (60,'14:30');
 
6779
insert into t5 values (60,'14:30');
 
6780
insert into t6 values (60,'14:30');
 
6781
select * from t1 order by col1;
 
6782
col1
 
6783
10:30:00
 
6784
14:30:00
 
6785
select * from t2 order by col1;
 
6786
col1
 
6787
10:30:00
 
6788
14:30:00
 
6789
21:59:00
 
6790
select * from t3 order by col1;
 
6791
col1
 
6792
10:30:00
 
6793
14:30:00
 
6794
21:59:00
 
6795
select * from t4 order by colint;
 
6796
colint  col1
 
6797
1       09:09:15
 
6798
2       04:30:01
 
6799
3       00:59:22
 
6800
4       05:30:34
 
6801
60      14:30:00
 
6802
select * from t5 order by colint;
 
6803
colint  col1
 
6804
1       09:09:15
 
6805
2       04:30:01
 
6806
3       00:59:22
 
6807
4       05:30:34
 
6808
60      14:30:00
 
6809
select * from t6 order by colint;
 
6810
colint  col1
 
6811
1       09:09:15
 
6812
2       04:30:01
 
6813
3       00:59:22
 
6814
4       05:30:34
 
6815
60      14:30:00
 
6816
alter table t1 drop partition p0;
 
6817
alter table t2 drop partition p0;
 
6818
alter table t4 drop partition p0;
 
6819
alter table t5 drop partition p0;
 
6820
alter table t6 drop partition p0;
 
6821
select * from t1 order by col1;
 
6822
col1
 
6823
select * from t2 order by col1;
 
6824
col1
 
6825
14:30:00
 
6826
21:59:00
 
6827
select * from t3 order by col1;
 
6828
col1
 
6829
10:30:00
 
6830
14:30:00
 
6831
21:59:00
 
6832
select * from t4 order by colint;
 
6833
colint  col1
 
6834
60      14:30:00
 
6835
select * from t5 order by colint;
 
6836
colint  col1
 
6837
60      14:30:00
 
6838
select * from t6 order by colint;
 
6839
colint  col1
 
6840
60      14:30:00
 
6841
-------------------------------------------------------------------------
 
6842
---  Delete rows and partitions of tables with hour(col1)
 
6843
-------------------------------------------------------------------------
 
6844
delete from t11 where col1='14:30';
 
6845
delete from t22 where col1='14:30';
 
6846
delete from t33 where col1='14:30';
 
6847
delete from t44 where col1='14:30';
 
6848
delete from t55 where col1='14:30';
 
6849
delete from t66 where col1='14:30';
 
6850
select * from t11 order by col1;
 
6851
col1
 
6852
10:30:00
 
6853
select * from t22 order by col1;
 
6854
col1
 
6855
10:30:00
 
6856
21:59:00
 
6857
select * from t33 order by col1;
 
6858
col1
 
6859
10:30:00
 
6860
21:59:00
 
6861
select * from t44 order by colint;
 
6862
colint  col1
 
6863
1       09:09:15
 
6864
2       04:30:01
 
6865
3       00:59:22
 
6866
4       05:30:34
 
6867
select * from t55 order by colint;
 
6868
colint  col1
 
6869
1       09:09:15
 
6870
2       04:30:01
 
6871
3       00:59:22
 
6872
4       05:30:34
 
6873
insert into t11 values ('14:30');
 
6874
insert into t22 values ('14:30');
 
6875
insert into t33 values ('14:30');
 
6876
insert into t44 values (60,'14:30');
 
6877
insert into t55 values (60,'14:30');
 
6878
insert into t66 values (60,'14:30');
 
6879
select * from t11 order by col1;
 
6880
col1
 
6881
10:30:00
 
6882
14:30:00
 
6883
select * from t22 order by col1;
 
6884
col1
 
6885
10:30:00
 
6886
14:30:00
 
6887
21:59:00
 
6888
select * from t33 order by col1;
 
6889
col1
 
6890
10:30:00
 
6891
14:30:00
 
6892
21:59:00
 
6893
select * from t44 order by colint;
 
6894
colint  col1
 
6895
1       09:09:15
 
6896
2       04:30:01
 
6897
3       00:59:22
 
6898
4       05:30:34
 
6899
60      14:30:00
 
6900
select * from t55 order by colint;
 
6901
colint  col1
 
6902
1       09:09:15
 
6903
2       04:30:01
 
6904
3       00:59:22
 
6905
4       05:30:34
 
6906
60      14:30:00
 
6907
select * from t66 order by colint;
 
6908
colint  col1
 
6909
1       09:09:15
 
6910
2       04:30:01
 
6911
3       00:59:22
 
6912
4       05:30:34
 
6913
60      14:30:00
 
6914
alter table t11 drop partition p0;
 
6915
alter table t22 drop partition p0;
 
6916
alter table t44 drop partition p0;
 
6917
alter table t55 drop partition p0;
 
6918
alter table t66 drop partition p0;
 
6919
select * from t11 order by col1;
 
6920
col1
 
6921
select * from t22 order by col1;
 
6922
col1
 
6923
14:30:00
 
6924
21:59:00
 
6925
select * from t33 order by col1;
 
6926
col1
 
6927
10:30:00
 
6928
14:30:00
 
6929
21:59:00
 
6930
select * from t44 order by colint;
 
6931
colint  col1
 
6932
60      14:30:00
 
6933
select * from t55 order by colint;
 
6934
colint  col1
 
6935
60      14:30:00
 
6936
select * from t66 order by colint;
 
6937
colint  col1
 
6938
60      14:30:00
 
6939
-------------------------
 
6940
---- some alter table end
 
6941
-------------------------
 
6942
drop table if exists t1 ;
 
6943
drop table if exists t2 ;
 
6944
drop table if exists t3 ;
 
6945
drop table if exists t4 ;
 
6946
drop table if exists t5 ;
 
6947
drop table if exists t6 ;
 
6948
drop table if exists t11 ;
 
6949
drop table if exists t22 ;
 
6950
drop table if exists t33 ;
 
6951
drop table if exists t44 ;
 
6952
drop table if exists t55 ;
 
6953
drop table if exists t66 ;
 
6954
-------------------------------------------------------------------------
 
6955
---  microsecond(col1)  in partition with coltype  time
 
6956
-------------------------------------------------------------------------
 
6957
drop table if exists t1 ;
 
6958
drop table if exists t2 ;
 
6959
drop table if exists t3 ;
 
6960
drop table if exists t4 ;
 
6961
drop table if exists t5 ;
 
6962
drop table if exists t6 ;
 
6963
-------------------------------------------------------------------------
 
6964
---  Create tables with microsecond(col1)
 
6965
-------------------------------------------------------------------------
 
6966
create table t1 (col1 time) engine='INNODB' 
 
6967
partition by range(microsecond(col1)) 
 
6968
(partition p0 values less than (15),
 
6969
partition p1 values less than maxvalue);
 
6970
create table t2 (col1 time) engine='INNODB' 
 
6971
partition by list(microsecond(col1)) 
 
6972
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
6973
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
6974
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
6975
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
6976
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
6977
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
6978
);
 
6979
create table t3 (col1 time) engine='INNODB' 
 
6980
partition by hash(microsecond(col1));
 
6981
create table t4 (colint int, col1 time) engine='INNODB' 
 
6982
partition by range(colint) 
 
6983
subpartition by hash(microsecond(col1)) subpartitions 2 
 
6984
(partition p0 values less than (15),
 
6985
partition p1 values less than maxvalue);
 
6986
create table t5 (colint int, col1 time) engine='INNODB' 
 
6987
partition by list(colint)
 
6988
subpartition by hash(microsecond(col1)) subpartitions 2 
 
6989
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
6990
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
6991
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
6992
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
6993
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
6994
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
6995
);
 
6996
create table t6 (colint int, col1 time) engine='INNODB' 
 
6997
partition by range(colint) 
 
6998
(partition p0 values less than (microsecond('10:30:10.000010')),
 
6999
partition p1 values less than maxvalue);
 
7000
-------------------------------------------------------------------------
 
7001
---  Access tables with microsecond(col1) 
 
7002
-------------------------------------------------------------------------
 
7003
insert into t1 values ('09:09:15.000002');
 
7004
insert into t1 values ('04:30:01.000018');
 
7005
insert into t2 values ('09:09:15.000002');
 
7006
insert into t2 values ('04:30:01.000018');
 
7007
insert into t2 values ('00:59:22.000024');
 
7008
insert into t3 values ('09:09:15.000002');
 
7009
insert into t3 values ('04:30:01.000018');
 
7010
insert into t3 values ('00:59:22.000024');
 
7011
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
 
7012
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
 
7013
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
 
7014
select microsecond(col1) from t1 order by col1;
 
7015
microsecond(col1)
 
7016
0
 
7017
0
 
7018
select * from t1 order by col1;
 
7019
col1
 
7020
04:30:01
 
7021
09:09:15
 
7022
select * from t2 order by col1;
 
7023
col1
 
7024
00:59:22
 
7025
04:30:01
 
7026
09:09:15
 
7027
select * from t3 order by col1;
 
7028
col1
 
7029
00:59:22
 
7030
04:30:01
 
7031
09:09:15
 
7032
select * from t4 order by colint;
 
7033
colint  col1
 
7034
1       09:09:15
 
7035
2       04:30:01
 
7036
3       00:59:22
 
7037
4       05:30:34
 
7038
select * from t5 order by colint;
 
7039
colint  col1
 
7040
1       09:09:15
 
7041
2       04:30:01
 
7042
3       00:59:22
 
7043
4       05:30:34
 
7044
select * from t6 order by colint;
 
7045
colint  col1
 
7046
1       09:09:15
 
7047
2       04:30:01
 
7048
3       00:59:22
 
7049
4       05:30:34
 
7050
update t1 set col1='05:30:34.000037' where col1='09:09:15.000002';
 
7051
update t2 set col1='05:30:34.000037' where col1='09:09:15.000002';
 
7052
update t3 set col1='05:30:34.000037' where col1='09:09:15.000002';
 
7053
update t4 set col1='05:30:34.000037' where col1='09:09:15.000002';
 
7054
update t5 set col1='05:30:34.000037' where col1='09:09:15.000002';
 
7055
update t6 set col1='05:30:34.000037' where col1='09:09:15.000002';
 
7056
select * from t1 order by col1;
 
7057
col1
 
7058
04:30:01
 
7059
05:30:34
 
7060
select * from t2 order by col1;
 
7061
col1
 
7062
00:59:22
 
7063
04:30:01
 
7064
05:30:34
 
7065
select * from t3 order by col1;
 
7066
col1
 
7067
00:59:22
 
7068
04:30:01
 
7069
05:30:34
 
7070
select * from t4 order by colint;
 
7071
colint  col1
 
7072
1       05:30:34
 
7073
2       04:30:01
 
7074
3       00:59:22
 
7075
4       05:30:34
 
7076
select * from t5 order by colint;
 
7077
colint  col1
 
7078
1       05:30:34
 
7079
2       04:30:01
 
7080
3       00:59:22
 
7081
4       05:30:34
 
7082
select * from t6 order by colint;
 
7083
colint  col1
 
7084
1       05:30:34
 
7085
2       04:30:01
 
7086
3       00:59:22
 
7087
4       05:30:34
 
7088
-------------------------------------------------------------------------
 
7089
---  Alter tables with microsecond(col1)
 
7090
-------------------------------------------------------------------------
 
7091
drop table if exists t11 ;
 
7092
drop table if exists t22 ;
 
7093
drop table if exists t33 ;
 
7094
drop table if exists t44 ;
 
7095
drop table if exists t55 ;
 
7096
drop table if exists t66 ;
 
7097
create table t11 engine='INNODB' as select * from t1;
 
7098
create table t22 engine='INNODB' as select * from t2;
 
7099
create table t33 engine='INNODB' as select * from t3;
 
7100
create table t44 engine='INNODB' as select * from t4;
 
7101
create table t55 engine='INNODB' as select * from t5;
 
7102
create table t66 engine='INNODB' as select * from t6;
 
7103
alter table t11
 
7104
partition by range(microsecond(col1)) 
 
7105
(partition p0 values less than (15),
 
7106
partition p1 values less than maxvalue);
 
7107
alter table t22
 
7108
partition by list(microsecond(col1)) 
 
7109
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
7110
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
7111
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
7112
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
7113
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
7114
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
7115
);
 
7116
alter table t33
 
7117
partition by hash(microsecond(col1));
 
7118
alter table t44
 
7119
partition by range(colint) 
 
7120
subpartition by hash(microsecond(col1)) subpartitions 2 
 
7121
(partition p0 values less than (15),
 
7122
partition p1 values less than maxvalue);
 
7123
alter table t55
 
7124
partition by list(colint)
 
7125
subpartition by hash(microsecond(col1)) subpartitions 2 
 
7126
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
7127
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
7128
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
7129
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
7130
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
7131
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
7132
);
 
7133
alter table t66
 
7134
partition by range(colint) 
 
7135
(partition p0 values less than (microsecond('10:30:10.000010')),
 
7136
partition p1 values less than maxvalue);
 
7137
select * from t11 order by col1;
 
7138
col1
 
7139
04:30:01
 
7140
05:30:34
 
7141
select * from t22 order by col1;
 
7142
col1
 
7143
00:59:22
 
7144
04:30:01
 
7145
05:30:34
 
7146
select * from t33 order by col1;
 
7147
col1
 
7148
00:59:22
 
7149
04:30:01
 
7150
05:30:34
 
7151
select * from t44 order by colint;
 
7152
colint  col1
 
7153
1       05:30:34
 
7154
2       04:30:01
 
7155
3       00:59:22
 
7156
4       05:30:34
 
7157
select * from t55 order by colint;
 
7158
colint  col1
 
7159
1       05:30:34
 
7160
2       04:30:01
 
7161
3       00:59:22
 
7162
4       05:30:34
 
7163
select * from t66 order by colint;
 
7164
colint  col1
 
7165
1       05:30:34
 
7166
2       04:30:01
 
7167
3       00:59:22
 
7168
4       05:30:34
 
7169
---------------------------
 
7170
---- some alter table begin
 
7171
---------------------------
 
7172
alter table t11
 
7173
reorganize partition p0,p1 into
 
7174
(partition s1 values less than maxvalue);
 
7175
select * from t11 order by col1;
 
7176
col1
 
7177
04:30:01
 
7178
05:30:34
 
7179
alter table t11
 
7180
reorganize partition s1 into
 
7181
(partition p0 values less than (15),
 
7182
partition p1 values less than maxvalue);
 
7183
select * from t11 order by col1;
 
7184
col1
 
7185
04:30:01
 
7186
05:30:34
 
7187
alter table t55
 
7188
partition by list(colint)
 
7189
subpartition by hash(microsecond(col1)) subpartitions 5 
 
7190
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
7191
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
7192
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
7193
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
7194
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
7195
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
7196
);
 
7197
show create table t55;
 
7198
Table   Create Table
 
7199
t55     CREATE TABLE `t55` (
 
7200
  `colint` int(11) DEFAULT NULL,
 
7201
  `col1` time DEFAULT NULL
 
7202
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
7203
/*!50100 PARTITION BY LIST (colint)
 
7204
SUBPARTITION BY HASH (microsecond(col1))
 
7205
SUBPARTITIONS 5
 
7206
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
7207
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
7208
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
7209
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
7210
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
7211
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
7212
select * from t55 order by colint;
 
7213
colint  col1
 
7214
1       05:30:34
 
7215
2       04:30:01
 
7216
3       00:59:22
 
7217
4       05:30:34
 
7218
alter table t66
 
7219
reorganize partition p0,p1 into
 
7220
(partition s1 values less than maxvalue);
 
7221
select * from t66 order by colint;
 
7222
colint  col1
 
7223
1       05:30:34
 
7224
2       04:30:01
 
7225
3       00:59:22
 
7226
4       05:30:34
 
7227
alter table t66
 
7228
reorganize partition s1 into
 
7229
(partition p0 values less than (microsecond('10:30:10.000010')),
 
7230
partition p1 values less than maxvalue);
 
7231
select * from t66 order by colint;
 
7232
colint  col1
 
7233
1       05:30:34
 
7234
2       04:30:01
 
7235
3       00:59:22
 
7236
4       05:30:34
 
7237
alter table t66
 
7238
reorganize partition p0,p1 into
 
7239
(partition s1 values less than maxvalue);
 
7240
select * from t66 order by colint;
 
7241
colint  col1
 
7242
1       05:30:34
 
7243
2       04:30:01
 
7244
3       00:59:22
 
7245
4       05:30:34
 
7246
alter table t66
 
7247
reorganize partition s1 into
 
7248
(partition p0 values less than (microsecond('10:30:10.000010')),
 
7249
partition p1 values less than maxvalue);
 
7250
select * from t66 order by colint;
 
7251
colint  col1
 
7252
1       05:30:34
 
7253
2       04:30:01
 
7254
3       00:59:22
 
7255
4       05:30:34
 
7256
-------------------------------------------------------------------------
 
7257
---  Delete rows and partitions of tables with microsecond(col1)
 
7258
-------------------------------------------------------------------------
 
7259
delete from t1 where col1='04:30:01.000018';
 
7260
delete from t2 where col1='04:30:01.000018';
 
7261
delete from t3 where col1='04:30:01.000018';
 
7262
delete from t4 where col1='04:30:01.000018';
 
7263
delete from t5 where col1='04:30:01.000018';
 
7264
delete from t6 where col1='04:30:01.000018';
 
7265
select * from t1 order by col1;
 
7266
col1
 
7267
05:30:34
 
7268
select * from t2 order by col1;
 
7269
col1
 
7270
00:59:22
 
7271
05:30:34
 
7272
select * from t3 order by col1;
 
7273
col1
 
7274
00:59:22
 
7275
05:30:34
 
7276
select * from t4 order by colint;
 
7277
colint  col1
 
7278
1       05:30:34
 
7279
3       00:59:22
 
7280
4       05:30:34
 
7281
select * from t5 order by colint;
 
7282
colint  col1
 
7283
1       05:30:34
 
7284
3       00:59:22
 
7285
4       05:30:34
 
7286
insert into t1 values ('04:30:01.000018');
 
7287
insert into t2 values ('04:30:01.000018');
 
7288
insert into t3 values ('04:30:01.000018');
 
7289
insert into t4 values (60,'04:30:01.000018');
 
7290
insert into t5 values (60,'04:30:01.000018');
 
7291
insert into t6 values (60,'04:30:01.000018');
 
7292
select * from t1 order by col1;
 
7293
col1
 
7294
04:30:01
 
7295
05:30:34
 
7296
select * from t2 order by col1;
 
7297
col1
 
7298
00:59:22
 
7299
04:30:01
 
7300
05:30:34
 
7301
select * from t3 order by col1;
 
7302
col1
 
7303
00:59:22
 
7304
04:30:01
 
7305
05:30:34
 
7306
select * from t4 order by colint;
 
7307
colint  col1
 
7308
1       05:30:34
 
7309
3       00:59:22
 
7310
4       05:30:34
 
7311
60      04:30:01
 
7312
select * from t5 order by colint;
 
7313
colint  col1
 
7314
1       05:30:34
 
7315
3       00:59:22
 
7316
4       05:30:34
 
7317
60      04:30:01
 
7318
select * from t6 order by colint;
 
7319
colint  col1
 
7320
1       05:30:34
 
7321
3       00:59:22
 
7322
4       05:30:34
 
7323
60      04:30:01
 
7324
alter table t1 drop partition p0;
 
7325
alter table t2 drop partition p0;
 
7326
alter table t4 drop partition p0;
 
7327
alter table t5 drop partition p0;
 
7328
alter table t6 drop partition p0;
 
7329
select * from t1 order by col1;
 
7330
col1
 
7331
select * from t2 order by col1;
 
7332
col1
 
7333
select * from t3 order by col1;
 
7334
col1
 
7335
00:59:22
 
7336
04:30:01
 
7337
05:30:34
 
7338
select * from t4 order by colint;
 
7339
colint  col1
 
7340
60      04:30:01
 
7341
select * from t5 order by colint;
 
7342
colint  col1
 
7343
60      04:30:01
 
7344
select * from t6 order by colint;
 
7345
colint  col1
 
7346
60      04:30:01
 
7347
-------------------------------------------------------------------------
 
7348
---  Delete rows and partitions of tables with microsecond(col1)
 
7349
-------------------------------------------------------------------------
 
7350
delete from t11 where col1='04:30:01.000018';
 
7351
delete from t22 where col1='04:30:01.000018';
 
7352
delete from t33 where col1='04:30:01.000018';
 
7353
delete from t44 where col1='04:30:01.000018';
 
7354
delete from t55 where col1='04:30:01.000018';
 
7355
delete from t66 where col1='04:30:01.000018';
 
7356
select * from t11 order by col1;
 
7357
col1
 
7358
05:30:34
 
7359
select * from t22 order by col1;
 
7360
col1
 
7361
00:59:22
 
7362
05:30:34
 
7363
select * from t33 order by col1;
 
7364
col1
 
7365
00:59:22
 
7366
05:30:34
 
7367
select * from t44 order by colint;
 
7368
colint  col1
 
7369
1       05:30:34
 
7370
3       00:59:22
 
7371
4       05:30:34
 
7372
select * from t55 order by colint;
 
7373
colint  col1
 
7374
1       05:30:34
 
7375
3       00:59:22
 
7376
4       05:30:34
 
7377
insert into t11 values ('04:30:01.000018');
 
7378
insert into t22 values ('04:30:01.000018');
 
7379
insert into t33 values ('04:30:01.000018');
 
7380
insert into t44 values (60,'04:30:01.000018');
 
7381
insert into t55 values (60,'04:30:01.000018');
 
7382
insert into t66 values (60,'04:30:01.000018');
 
7383
select * from t11 order by col1;
 
7384
col1
 
7385
04:30:01
 
7386
05:30:34
 
7387
select * from t22 order by col1;
 
7388
col1
 
7389
00:59:22
 
7390
04:30:01
 
7391
05:30:34
 
7392
select * from t33 order by col1;
 
7393
col1
 
7394
00:59:22
 
7395
04:30:01
 
7396
05:30:34
 
7397
select * from t44 order by colint;
 
7398
colint  col1
 
7399
1       05:30:34
 
7400
3       00:59:22
 
7401
4       05:30:34
 
7402
60      04:30:01
 
7403
select * from t55 order by colint;
 
7404
colint  col1
 
7405
1       05:30:34
 
7406
3       00:59:22
 
7407
4       05:30:34
 
7408
60      04:30:01
 
7409
select * from t66 order by colint;
 
7410
colint  col1
 
7411
1       05:30:34
 
7412
3       00:59:22
 
7413
4       05:30:34
 
7414
60      04:30:01
 
7415
alter table t11 drop partition p0;
 
7416
alter table t22 drop partition p0;
 
7417
alter table t44 drop partition p0;
 
7418
alter table t55 drop partition p0;
 
7419
alter table t66 drop partition p0;
 
7420
select * from t11 order by col1;
 
7421
col1
 
7422
select * from t22 order by col1;
 
7423
col1
 
7424
select * from t33 order by col1;
 
7425
col1
 
7426
00:59:22
 
7427
04:30:01
 
7428
05:30:34
 
7429
select * from t44 order by colint;
 
7430
colint  col1
 
7431
60      04:30:01
 
7432
select * from t55 order by colint;
 
7433
colint  col1
 
7434
60      04:30:01
 
7435
select * from t66 order by colint;
 
7436
colint  col1
 
7437
60      04:30:01
 
7438
-------------------------
 
7439
---- some alter table end
 
7440
-------------------------
 
7441
drop table if exists t1 ;
 
7442
drop table if exists t2 ;
 
7443
drop table if exists t3 ;
 
7444
drop table if exists t4 ;
 
7445
drop table if exists t5 ;
 
7446
drop table if exists t6 ;
 
7447
drop table if exists t11 ;
 
7448
drop table if exists t22 ;
 
7449
drop table if exists t33 ;
 
7450
drop table if exists t44 ;
 
7451
drop table if exists t55 ;
 
7452
drop table if exists t66 ;
 
7453
-------------------------------------------------------------------------
 
7454
---  minute(col1)  in partition with coltype  time
 
7455
-------------------------------------------------------------------------
 
7456
drop table if exists t1 ;
 
7457
drop table if exists t2 ;
 
7458
drop table if exists t3 ;
 
7459
drop table if exists t4 ;
 
7460
drop table if exists t5 ;
 
7461
drop table if exists t6 ;
 
7462
-------------------------------------------------------------------------
 
7463
---  Create tables with minute(col1)
 
7464
-------------------------------------------------------------------------
 
7465
create table t1 (col1 time) engine='INNODB' 
 
7466
partition by range(minute(col1)) 
 
7467
(partition p0 values less than (15),
 
7468
partition p1 values less than maxvalue);
 
7469
create table t2 (col1 time) engine='INNODB' 
 
7470
partition by list(minute(col1)) 
 
7471
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
7472
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
7473
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
7474
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
7475
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
7476
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
7477
);
 
7478
create table t3 (col1 time) engine='INNODB' 
 
7479
partition by hash(minute(col1));
 
7480
create table t4 (colint int, col1 time) engine='INNODB' 
 
7481
partition by range(colint) 
 
7482
subpartition by hash(minute(col1)) subpartitions 2 
 
7483
(partition p0 values less than (15),
 
7484
partition p1 values less than maxvalue);
 
7485
create table t5 (colint int, col1 time) engine='INNODB' 
 
7486
partition by list(colint)
 
7487
subpartition by hash(minute(col1)) subpartitions 2 
 
7488
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
7489
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
7490
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
7491
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
7492
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
7493
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
7494
);
 
7495
create table t6 (colint int, col1 time) engine='INNODB' 
 
7496
partition by range(colint) 
 
7497
(partition p0 values less than (minute('18:30')),
 
7498
partition p1 values less than maxvalue);
 
7499
-------------------------------------------------------------------------
 
7500
---  Access tables with minute(col1) 
 
7501
-------------------------------------------------------------------------
 
7502
insert into t1 values ('09:09:15');
 
7503
insert into t1 values ('14:30:45');
 
7504
insert into t2 values ('09:09:15');
 
7505
insert into t2 values ('14:30:45');
 
7506
insert into t2 values ('21:59:22');
 
7507
insert into t3 values ('09:09:15');
 
7508
insert into t3 values ('14:30:45');
 
7509
insert into t3 values ('21:59:22');
 
7510
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
 
7511
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
 
7512
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
 
7513
select minute(col1) from t1 order by col1;
 
7514
minute(col1)
 
7515
9
 
7516
30
 
7517
select * from t1 order by col1;
 
7518
col1
 
7519
09:09:15
 
7520
14:30:45
 
7521
select * from t2 order by col1;
 
7522
col1
 
7523
09:09:15
 
7524
14:30:45
 
7525
21:59:22
 
7526
select * from t3 order by col1;
 
7527
col1
 
7528
09:09:15
 
7529
14:30:45
 
7530
21:59:22
 
7531
select * from t4 order by colint;
 
7532
colint  col1
 
7533
1       09:09:15
 
7534
2       04:30:01
 
7535
3       00:59:22
 
7536
4       05:30:34
 
7537
select * from t5 order by colint;
 
7538
colint  col1
 
7539
1       09:09:15
 
7540
2       04:30:01
 
7541
3       00:59:22
 
7542
4       05:30:34
 
7543
select * from t6 order by colint;
 
7544
colint  col1
 
7545
1       09:09:15
 
7546
2       04:30:01
 
7547
3       00:59:22
 
7548
4       05:30:34
 
7549
update t1 set col1='10:24:23' where col1='09:09:15';
 
7550
update t2 set col1='10:24:23' where col1='09:09:15';
 
7551
update t3 set col1='10:24:23' where col1='09:09:15';
 
7552
update t4 set col1='10:24:23' where col1='09:09:15';
 
7553
update t5 set col1='10:24:23' where col1='09:09:15';
 
7554
update t6 set col1='10:24:23' where col1='09:09:15';
 
7555
select * from t1 order by col1;
 
7556
col1
 
7557
10:24:23
 
7558
14:30:45
 
7559
select * from t2 order by col1;
 
7560
col1
 
7561
10:24:23
 
7562
14:30:45
 
7563
21:59:22
 
7564
select * from t3 order by col1;
 
7565
col1
 
7566
10:24:23
 
7567
14:30:45
 
7568
21:59:22
 
7569
select * from t4 order by colint;
 
7570
colint  col1
 
7571
1       10:24:23
 
7572
2       04:30:01
 
7573
3       00:59:22
 
7574
4       05:30:34
 
7575
select * from t5 order by colint;
 
7576
colint  col1
 
7577
1       10:24:23
 
7578
2       04:30:01
 
7579
3       00:59:22
 
7580
4       05:30:34
 
7581
select * from t6 order by colint;
 
7582
colint  col1
 
7583
1       10:24:23
 
7584
2       04:30:01
 
7585
3       00:59:22
 
7586
4       05:30:34
 
7587
-------------------------------------------------------------------------
 
7588
---  Alter tables with minute(col1)
 
7589
-------------------------------------------------------------------------
 
7590
drop table if exists t11 ;
 
7591
drop table if exists t22 ;
 
7592
drop table if exists t33 ;
 
7593
drop table if exists t44 ;
 
7594
drop table if exists t55 ;
 
7595
drop table if exists t66 ;
 
7596
create table t11 engine='INNODB' as select * from t1;
 
7597
create table t22 engine='INNODB' as select * from t2;
 
7598
create table t33 engine='INNODB' as select * from t3;
 
7599
create table t44 engine='INNODB' as select * from t4;
 
7600
create table t55 engine='INNODB' as select * from t5;
 
7601
create table t66 engine='INNODB' as select * from t6;
 
7602
alter table t11
 
7603
partition by range(minute(col1)) 
 
7604
(partition p0 values less than (15),
 
7605
partition p1 values less than maxvalue);
 
7606
alter table t22
 
7607
partition by list(minute(col1)) 
 
7608
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
7609
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
7610
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
7611
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
7612
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
7613
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
7614
);
 
7615
alter table t33
 
7616
partition by hash(minute(col1));
 
7617
alter table t44
 
7618
partition by range(colint) 
 
7619
subpartition by hash(minute(col1)) subpartitions 2 
 
7620
(partition p0 values less than (15),
 
7621
partition p1 values less than maxvalue);
 
7622
alter table t55
 
7623
partition by list(colint)
 
7624
subpartition by hash(minute(col1)) subpartitions 2 
 
7625
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
7626
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
7627
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
7628
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
7629
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
7630
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
7631
);
 
7632
alter table t66
 
7633
partition by range(colint) 
 
7634
(partition p0 values less than (minute('18:30')),
 
7635
partition p1 values less than maxvalue);
 
7636
select * from t11 order by col1;
 
7637
col1
 
7638
10:24:23
 
7639
14:30:45
 
7640
select * from t22 order by col1;
 
7641
col1
 
7642
10:24:23
 
7643
14:30:45
 
7644
21:59:22
 
7645
select * from t33 order by col1;
 
7646
col1
 
7647
10:24:23
 
7648
14:30:45
 
7649
21:59:22
 
7650
select * from t44 order by colint;
 
7651
colint  col1
 
7652
1       10:24:23
 
7653
2       04:30:01
 
7654
3       00:59:22
 
7655
4       05:30:34
 
7656
select * from t55 order by colint;
 
7657
colint  col1
 
7658
1       10:24:23
 
7659
2       04:30:01
 
7660
3       00:59:22
 
7661
4       05:30:34
 
7662
select * from t66 order by colint;
 
7663
colint  col1
 
7664
1       10:24:23
 
7665
2       04:30:01
 
7666
3       00:59:22
 
7667
4       05:30:34
 
7668
---------------------------
 
7669
---- some alter table begin
 
7670
---------------------------
 
7671
alter table t11
 
7672
reorganize partition p0,p1 into
 
7673
(partition s1 values less than maxvalue);
 
7674
select * from t11 order by col1;
 
7675
col1
 
7676
10:24:23
 
7677
14:30:45
 
7678
alter table t11
 
7679
reorganize partition s1 into
 
7680
(partition p0 values less than (15),
 
7681
partition p1 values less than maxvalue);
 
7682
select * from t11 order by col1;
 
7683
col1
 
7684
10:24:23
 
7685
14:30:45
 
7686
alter table t55
 
7687
partition by list(colint)
 
7688
subpartition by hash(minute(col1)) subpartitions 5 
 
7689
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
7690
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
7691
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
7692
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
7693
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
7694
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
7695
);
 
7696
show create table t55;
 
7697
Table   Create Table
 
7698
t55     CREATE TABLE `t55` (
 
7699
  `colint` int(11) DEFAULT NULL,
 
7700
  `col1` time DEFAULT NULL
 
7701
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
7702
/*!50100 PARTITION BY LIST (colint)
 
7703
SUBPARTITION BY HASH (minute(col1))
 
7704
SUBPARTITIONS 5
 
7705
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
7706
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
7707
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
7708
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
7709
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
7710
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
7711
select * from t55 order by colint;
 
7712
colint  col1
 
7713
1       10:24:23
 
7714
2       04:30:01
 
7715
3       00:59:22
 
7716
4       05:30:34
 
7717
alter table t66
 
7718
reorganize partition p0,p1 into
 
7719
(partition s1 values less than maxvalue);
 
7720
select * from t66 order by colint;
 
7721
colint  col1
 
7722
1       10:24:23
 
7723
2       04:30:01
 
7724
3       00:59:22
 
7725
4       05:30:34
 
7726
alter table t66
 
7727
reorganize partition s1 into
 
7728
(partition p0 values less than (minute('18:30')),
 
7729
partition p1 values less than maxvalue);
 
7730
select * from t66 order by colint;
 
7731
colint  col1
 
7732
1       10:24:23
 
7733
2       04:30:01
 
7734
3       00:59:22
 
7735
4       05:30:34
 
7736
alter table t66
 
7737
reorganize partition p0,p1 into
 
7738
(partition s1 values less than maxvalue);
 
7739
select * from t66 order by colint;
 
7740
colint  col1
 
7741
1       10:24:23
 
7742
2       04:30:01
 
7743
3       00:59:22
 
7744
4       05:30:34
 
7745
alter table t66
 
7746
reorganize partition s1 into
 
7747
(partition p0 values less than (minute('18:30')),
 
7748
partition p1 values less than maxvalue);
 
7749
select * from t66 order by colint;
 
7750
colint  col1
 
7751
1       10:24:23
 
7752
2       04:30:01
 
7753
3       00:59:22
 
7754
4       05:30:34
 
7755
-------------------------------------------------------------------------
 
7756
---  Delete rows and partitions of tables with minute(col1)
 
7757
-------------------------------------------------------------------------
 
7758
delete from t1 where col1='14:30:45';
 
7759
delete from t2 where col1='14:30:45';
 
7760
delete from t3 where col1='14:30:45';
 
7761
delete from t4 where col1='14:30:45';
 
7762
delete from t5 where col1='14:30:45';
 
7763
delete from t6 where col1='14:30:45';
 
7764
select * from t1 order by col1;
 
7765
col1
 
7766
10:24:23
 
7767
select * from t2 order by col1;
 
7768
col1
 
7769
10:24:23
 
7770
21:59:22
 
7771
select * from t3 order by col1;
 
7772
col1
 
7773
10:24:23
 
7774
21:59:22
 
7775
select * from t4 order by colint;
 
7776
colint  col1
 
7777
1       10:24:23
 
7778
2       04:30:01
 
7779
3       00:59:22
 
7780
4       05:30:34
 
7781
select * from t5 order by colint;
 
7782
colint  col1
 
7783
1       10:24:23
 
7784
2       04:30:01
 
7785
3       00:59:22
 
7786
4       05:30:34
 
7787
insert into t1 values ('14:30:45');
 
7788
insert into t2 values ('14:30:45');
 
7789
insert into t3 values ('14:30:45');
 
7790
insert into t4 values (60,'14:30:45');
 
7791
insert into t5 values (60,'14:30:45');
 
7792
insert into t6 values (60,'14:30:45');
 
7793
select * from t1 order by col1;
 
7794
col1
 
7795
10:24:23
 
7796
14:30:45
 
7797
select * from t2 order by col1;
 
7798
col1
 
7799
10:24:23
 
7800
14:30:45
 
7801
21:59:22
 
7802
select * from t3 order by col1;
 
7803
col1
 
7804
10:24:23
 
7805
14:30:45
 
7806
21:59:22
 
7807
select * from t4 order by colint;
 
7808
colint  col1
 
7809
1       10:24:23
 
7810
2       04:30:01
 
7811
3       00:59:22
 
7812
4       05:30:34
 
7813
60      14:30:45
 
7814
select * from t5 order by colint;
 
7815
colint  col1
 
7816
1       10:24:23
 
7817
2       04:30:01
 
7818
3       00:59:22
 
7819
4       05:30:34
 
7820
60      14:30:45
 
7821
select * from t6 order by colint;
 
7822
colint  col1
 
7823
1       10:24:23
 
7824
2       04:30:01
 
7825
3       00:59:22
 
7826
4       05:30:34
 
7827
60      14:30:45
 
7828
alter table t1 drop partition p0;
 
7829
alter table t2 drop partition p0;
 
7830
alter table t4 drop partition p0;
 
7831
alter table t5 drop partition p0;
 
7832
alter table t6 drop partition p0;
 
7833
select * from t1 order by col1;
 
7834
col1
 
7835
10:24:23
 
7836
14:30:45
 
7837
select * from t2 order by col1;
 
7838
col1
 
7839
10:24:23
 
7840
14:30:45
 
7841
21:59:22
 
7842
select * from t3 order by col1;
 
7843
col1
 
7844
10:24:23
 
7845
14:30:45
 
7846
21:59:22
 
7847
select * from t4 order by colint;
 
7848
colint  col1
 
7849
60      14:30:45
 
7850
select * from t5 order by colint;
 
7851
colint  col1
 
7852
60      14:30:45
 
7853
select * from t6 order by colint;
 
7854
colint  col1
 
7855
60      14:30:45
 
7856
-------------------------------------------------------------------------
 
7857
---  Delete rows and partitions of tables with minute(col1)
 
7858
-------------------------------------------------------------------------
 
7859
delete from t11 where col1='14:30:45';
 
7860
delete from t22 where col1='14:30:45';
 
7861
delete from t33 where col1='14:30:45';
 
7862
delete from t44 where col1='14:30:45';
 
7863
delete from t55 where col1='14:30:45';
 
7864
delete from t66 where col1='14:30:45';
 
7865
select * from t11 order by col1;
 
7866
col1
 
7867
10:24:23
 
7868
select * from t22 order by col1;
 
7869
col1
 
7870
10:24:23
 
7871
21:59:22
 
7872
select * from t33 order by col1;
 
7873
col1
 
7874
10:24:23
 
7875
21:59:22
 
7876
select * from t44 order by colint;
 
7877
colint  col1
 
7878
1       10:24:23
 
7879
2       04:30:01
 
7880
3       00:59:22
 
7881
4       05:30:34
 
7882
select * from t55 order by colint;
 
7883
colint  col1
 
7884
1       10:24:23
 
7885
2       04:30:01
 
7886
3       00:59:22
 
7887
4       05:30:34
 
7888
insert into t11 values ('14:30:45');
 
7889
insert into t22 values ('14:30:45');
 
7890
insert into t33 values ('14:30:45');
 
7891
insert into t44 values (60,'14:30:45');
 
7892
insert into t55 values (60,'14:30:45');
 
7893
insert into t66 values (60,'14:30:45');
 
7894
select * from t11 order by col1;
 
7895
col1
 
7896
10:24:23
 
7897
14:30:45
 
7898
select * from t22 order by col1;
 
7899
col1
 
7900
10:24:23
 
7901
14:30:45
 
7902
21:59:22
 
7903
select * from t33 order by col1;
 
7904
col1
 
7905
10:24:23
 
7906
14:30:45
 
7907
21:59:22
 
7908
select * from t44 order by colint;
 
7909
colint  col1
 
7910
1       10:24:23
 
7911
2       04:30:01
 
7912
3       00:59:22
 
7913
4       05:30:34
 
7914
60      14:30:45
 
7915
select * from t55 order by colint;
 
7916
colint  col1
 
7917
1       10:24:23
 
7918
2       04:30:01
 
7919
3       00:59:22
 
7920
4       05:30:34
 
7921
60      14:30:45
 
7922
select * from t66 order by colint;
 
7923
colint  col1
 
7924
1       10:24:23
 
7925
2       04:30:01
 
7926
3       00:59:22
 
7927
4       05:30:34
 
7928
60      14:30:45
 
7929
alter table t11 drop partition p0;
 
7930
alter table t22 drop partition p0;
 
7931
alter table t44 drop partition p0;
 
7932
alter table t55 drop partition p0;
 
7933
alter table t66 drop partition p0;
 
7934
select * from t11 order by col1;
 
7935
col1
 
7936
10:24:23
 
7937
14:30:45
 
7938
select * from t22 order by col1;
 
7939
col1
 
7940
10:24:23
 
7941
14:30:45
 
7942
21:59:22
 
7943
select * from t33 order by col1;
 
7944
col1
 
7945
10:24:23
 
7946
14:30:45
 
7947
21:59:22
 
7948
select * from t44 order by colint;
 
7949
colint  col1
 
7950
60      14:30:45
 
7951
select * from t55 order by colint;
 
7952
colint  col1
 
7953
60      14:30:45
 
7954
select * from t66 order by colint;
 
7955
colint  col1
 
7956
60      14:30:45
 
7957
-------------------------
 
7958
---- some alter table end
 
7959
-------------------------
 
7960
drop table if exists t1 ;
 
7961
drop table if exists t2 ;
 
7962
drop table if exists t3 ;
 
7963
drop table if exists t4 ;
 
7964
drop table if exists t5 ;
 
7965
drop table if exists t6 ;
 
7966
drop table if exists t11 ;
 
7967
drop table if exists t22 ;
 
7968
drop table if exists t33 ;
 
7969
drop table if exists t44 ;
 
7970
drop table if exists t55 ;
 
7971
drop table if exists t66 ;
 
7972
-------------------------------------------------------------------------
 
7973
---  second(col1)  in partition with coltype  time
 
7974
-------------------------------------------------------------------------
 
7975
drop table if exists t1 ;
 
7976
drop table if exists t2 ;
 
7977
drop table if exists t3 ;
 
7978
drop table if exists t4 ;
 
7979
drop table if exists t5 ;
 
7980
drop table if exists t6 ;
 
7981
-------------------------------------------------------------------------
 
7982
---  Create tables with second(col1)
 
7983
-------------------------------------------------------------------------
 
7984
create table t1 (col1 time) engine='INNODB' 
 
7985
partition by range(second(col1)) 
 
7986
(partition p0 values less than (15),
 
7987
partition p1 values less than maxvalue);
 
7988
create table t2 (col1 time) engine='INNODB' 
 
7989
partition by list(second(col1)) 
 
7990
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
7991
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
7992
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
7993
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
7994
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
7995
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
7996
);
 
7997
create table t3 (col1 time) engine='INNODB' 
 
7998
partition by hash(second(col1));
 
7999
create table t4 (colint int, col1 time) engine='INNODB' 
 
8000
partition by range(colint) 
 
8001
subpartition by hash(second(col1)) subpartitions 2 
 
8002
(partition p0 values less than (15),
 
8003
partition p1 values less than maxvalue);
 
8004
create table t5 (colint int, col1 time) engine='INNODB' 
 
8005
partition by list(colint)
 
8006
subpartition by hash(second(col1)) subpartitions 2 
 
8007
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
8008
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
8009
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
8010
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
8011
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
8012
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
8013
);
 
8014
create table t6 (colint int, col1 time) engine='INNODB' 
 
8015
partition by range(colint) 
 
8016
(partition p0 values less than (second('18:30:14')),
 
8017
partition p1 values less than maxvalue);
 
8018
-------------------------------------------------------------------------
 
8019
---  Access tables with second(col1) 
 
8020
-------------------------------------------------------------------------
 
8021
insert into t1 values ('09:09:09');
 
8022
insert into t1 values ('14:30:20');
 
8023
insert into t2 values ('09:09:09');
 
8024
insert into t2 values ('14:30:20');
 
8025
insert into t2 values ('21:59:22');
 
8026
insert into t3 values ('09:09:09');
 
8027
insert into t3 values ('14:30:20');
 
8028
insert into t3 values ('21:59:22');
 
8029
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
 
8030
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
 
8031
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
 
8032
select second(col1) from t1 order by col1;
 
8033
second(col1)
 
8034
9
 
8035
20
 
8036
select * from t1 order by col1;
 
8037
col1
 
8038
09:09:09
 
8039
14:30:20
 
8040
select * from t2 order by col1;
 
8041
col1
 
8042
09:09:09
 
8043
14:30:20
 
8044
21:59:22
 
8045
select * from t3 order by col1;
 
8046
col1
 
8047
09:09:09
 
8048
14:30:20
 
8049
21:59:22
 
8050
select * from t4 order by colint;
 
8051
colint  col1
 
8052
1       09:09:15
 
8053
2       04:30:01
 
8054
3       00:59:22
 
8055
4       05:30:34
 
8056
select * from t5 order by colint;
 
8057
colint  col1
 
8058
1       09:09:15
 
8059
2       04:30:01
 
8060
3       00:59:22
 
8061
4       05:30:34
 
8062
select * from t6 order by colint;
 
8063
colint  col1
 
8064
1       09:09:15
 
8065
2       04:30:01
 
8066
3       00:59:22
 
8067
4       05:30:34
 
8068
update t1 set col1='10:22:33' where col1='09:09:09';
 
8069
update t2 set col1='10:22:33' where col1='09:09:09';
 
8070
update t3 set col1='10:22:33' where col1='09:09:09';
 
8071
update t4 set col1='10:22:33' where col1='09:09:09';
 
8072
update t5 set col1='10:22:33' where col1='09:09:09';
 
8073
update t6 set col1='10:22:33' where col1='09:09:09';
 
8074
select * from t1 order by col1;
 
8075
col1
 
8076
10:22:33
 
8077
14:30:20
 
8078
select * from t2 order by col1;
 
8079
col1
 
8080
10:22:33
 
8081
14:30:20
 
8082
21:59:22
 
8083
select * from t3 order by col1;
 
8084
col1
 
8085
10:22:33
 
8086
14:30:20
 
8087
21:59:22
 
8088
select * from t4 order by colint;
 
8089
colint  col1
 
8090
1       09:09:15
 
8091
2       04:30:01
 
8092
3       00:59:22
 
8093
4       05:30:34
 
8094
select * from t5 order by colint;
 
8095
colint  col1
 
8096
1       09:09:15
 
8097
2       04:30:01
 
8098
3       00:59:22
 
8099
4       05:30:34
 
8100
select * from t6 order by colint;
 
8101
colint  col1
 
8102
1       09:09:15
 
8103
2       04:30:01
 
8104
3       00:59:22
 
8105
4       05:30:34
 
8106
-------------------------------------------------------------------------
 
8107
---  Alter tables with second(col1)
 
8108
-------------------------------------------------------------------------
 
8109
drop table if exists t11 ;
 
8110
drop table if exists t22 ;
 
8111
drop table if exists t33 ;
 
8112
drop table if exists t44 ;
 
8113
drop table if exists t55 ;
 
8114
drop table if exists t66 ;
 
8115
create table t11 engine='INNODB' as select * from t1;
 
8116
create table t22 engine='INNODB' as select * from t2;
 
8117
create table t33 engine='INNODB' as select * from t3;
 
8118
create table t44 engine='INNODB' as select * from t4;
 
8119
create table t55 engine='INNODB' as select * from t5;
 
8120
create table t66 engine='INNODB' as select * from t6;
 
8121
alter table t11
 
8122
partition by range(second(col1)) 
 
8123
(partition p0 values less than (15),
 
8124
partition p1 values less than maxvalue);
 
8125
alter table t22
 
8126
partition by list(second(col1)) 
 
8127
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
8128
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
8129
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
8130
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
8131
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
8132
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
8133
);
 
8134
alter table t33
 
8135
partition by hash(second(col1));
 
8136
alter table t44
 
8137
partition by range(colint) 
 
8138
subpartition by hash(second(col1)) subpartitions 2 
 
8139
(partition p0 values less than (15),
 
8140
partition p1 values less than maxvalue);
 
8141
alter table t55
 
8142
partition by list(colint)
 
8143
subpartition by hash(second(col1)) subpartitions 2 
 
8144
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
8145
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
8146
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
8147
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
8148
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
8149
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
8150
);
 
8151
alter table t66
 
8152
partition by range(colint) 
 
8153
(partition p0 values less than (second('18:30:14')),
 
8154
partition p1 values less than maxvalue);
 
8155
select * from t11 order by col1;
 
8156
col1
 
8157
10:22:33
 
8158
14:30:20
 
8159
select * from t22 order by col1;
 
8160
col1
 
8161
10:22:33
 
8162
14:30:20
 
8163
21:59:22
 
8164
select * from t33 order by col1;
 
8165
col1
 
8166
10:22:33
 
8167
14:30:20
 
8168
21:59:22
 
8169
select * from t44 order by colint;
 
8170
colint  col1
 
8171
1       09:09:15
 
8172
2       04:30:01
 
8173
3       00:59:22
 
8174
4       05:30:34
 
8175
select * from t55 order by colint;
 
8176
colint  col1
 
8177
1       09:09:15
 
8178
2       04:30:01
 
8179
3       00:59:22
 
8180
4       05:30:34
 
8181
select * from t66 order by colint;
 
8182
colint  col1
 
8183
1       09:09:15
 
8184
2       04:30:01
 
8185
3       00:59:22
 
8186
4       05:30:34
 
8187
---------------------------
 
8188
---- some alter table begin
 
8189
---------------------------
 
8190
alter table t11
 
8191
reorganize partition p0,p1 into
 
8192
(partition s1 values less than maxvalue);
 
8193
select * from t11 order by col1;
 
8194
col1
 
8195
10:22:33
 
8196
14:30:20
 
8197
alter table t11
 
8198
reorganize partition s1 into
 
8199
(partition p0 values less than (15),
 
8200
partition p1 values less than maxvalue);
 
8201
select * from t11 order by col1;
 
8202
col1
 
8203
10:22:33
 
8204
14:30:20
 
8205
alter table t55
 
8206
partition by list(colint)
 
8207
subpartition by hash(second(col1)) subpartitions 5 
 
8208
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
8209
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
8210
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
8211
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
8212
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
8213
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
8214
);
 
8215
show create table t55;
 
8216
Table   Create Table
 
8217
t55     CREATE TABLE `t55` (
 
8218
  `colint` int(11) DEFAULT NULL,
 
8219
  `col1` time DEFAULT NULL
 
8220
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
8221
/*!50100 PARTITION BY LIST (colint)
 
8222
SUBPARTITION BY HASH (second(col1))
 
8223
SUBPARTITIONS 5
 
8224
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
8225
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
8226
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
8227
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
8228
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
8229
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
8230
select * from t55 order by colint;
 
8231
colint  col1
 
8232
1       09:09:15
 
8233
2       04:30:01
 
8234
3       00:59:22
 
8235
4       05:30:34
 
8236
alter table t66
 
8237
reorganize partition p0,p1 into
 
8238
(partition s1 values less than maxvalue);
 
8239
select * from t66 order by colint;
 
8240
colint  col1
 
8241
1       09:09:15
 
8242
2       04:30:01
 
8243
3       00:59:22
 
8244
4       05:30:34
 
8245
alter table t66
 
8246
reorganize partition s1 into
 
8247
(partition p0 values less than (second('18:30:14')),
 
8248
partition p1 values less than maxvalue);
 
8249
select * from t66 order by colint;
 
8250
colint  col1
 
8251
1       09:09:15
 
8252
2       04:30:01
 
8253
3       00:59:22
 
8254
4       05:30:34
 
8255
alter table t66
 
8256
reorganize partition p0,p1 into
 
8257
(partition s1 values less than maxvalue);
 
8258
select * from t66 order by colint;
 
8259
colint  col1
 
8260
1       09:09:15
 
8261
2       04:30:01
 
8262
3       00:59:22
 
8263
4       05:30:34
 
8264
alter table t66
 
8265
reorganize partition s1 into
 
8266
(partition p0 values less than (second('18:30:14')),
 
8267
partition p1 values less than maxvalue);
 
8268
select * from t66 order by colint;
 
8269
colint  col1
 
8270
1       09:09:15
 
8271
2       04:30:01
 
8272
3       00:59:22
 
8273
4       05:30:34
 
8274
-------------------------------------------------------------------------
 
8275
---  Delete rows and partitions of tables with second(col1)
 
8276
-------------------------------------------------------------------------
 
8277
delete from t1 where col1='14:30:20';
 
8278
delete from t2 where col1='14:30:20';
 
8279
delete from t3 where col1='14:30:20';
 
8280
delete from t4 where col1='14:30:20';
 
8281
delete from t5 where col1='14:30:20';
 
8282
delete from t6 where col1='14:30:20';
 
8283
select * from t1 order by col1;
 
8284
col1
 
8285
10:22:33
 
8286
select * from t2 order by col1;
 
8287
col1
 
8288
10:22:33
 
8289
21:59:22
 
8290
select * from t3 order by col1;
 
8291
col1
 
8292
10:22:33
 
8293
21:59:22
 
8294
select * from t4 order by colint;
 
8295
colint  col1
 
8296
1       09:09:15
 
8297
2       04:30:01
 
8298
3       00:59:22
 
8299
4       05:30:34
 
8300
select * from t5 order by colint;
 
8301
colint  col1
 
8302
1       09:09:15
 
8303
2       04:30:01
 
8304
3       00:59:22
 
8305
4       05:30:34
 
8306
insert into t1 values ('14:30:20');
 
8307
insert into t2 values ('14:30:20');
 
8308
insert into t3 values ('14:30:20');
 
8309
insert into t4 values (60,'14:30:20');
 
8310
insert into t5 values (60,'14:30:20');
 
8311
insert into t6 values (60,'14:30:20');
 
8312
select * from t1 order by col1;
 
8313
col1
 
8314
10:22:33
 
8315
14:30:20
 
8316
select * from t2 order by col1;
 
8317
col1
 
8318
10:22:33
 
8319
14:30:20
 
8320
21:59:22
 
8321
select * from t3 order by col1;
 
8322
col1
 
8323
10:22:33
 
8324
14:30:20
 
8325
21:59:22
 
8326
select * from t4 order by colint;
 
8327
colint  col1
 
8328
1       09:09:15
 
8329
2       04:30:01
 
8330
3       00:59:22
 
8331
4       05:30:34
 
8332
60      14:30:20
 
8333
select * from t5 order by colint;
 
8334
colint  col1
 
8335
1       09:09:15
 
8336
2       04:30:01
 
8337
3       00:59:22
 
8338
4       05:30:34
 
8339
60      14:30:20
 
8340
select * from t6 order by colint;
 
8341
colint  col1
 
8342
1       09:09:15
 
8343
2       04:30:01
 
8344
3       00:59:22
 
8345
4       05:30:34
 
8346
60      14:30:20
 
8347
alter table t1 drop partition p0;
 
8348
alter table t2 drop partition p0;
 
8349
alter table t4 drop partition p0;
 
8350
alter table t5 drop partition p0;
 
8351
alter table t6 drop partition p0;
 
8352
select * from t1 order by col1;
 
8353
col1
 
8354
10:22:33
 
8355
14:30:20
 
8356
select * from t2 order by col1;
 
8357
col1
 
8358
10:22:33
 
8359
14:30:20
 
8360
21:59:22
 
8361
select * from t3 order by col1;
 
8362
col1
 
8363
10:22:33
 
8364
14:30:20
 
8365
21:59:22
 
8366
select * from t4 order by colint;
 
8367
colint  col1
 
8368
60      14:30:20
 
8369
select * from t5 order by colint;
 
8370
colint  col1
 
8371
60      14:30:20
 
8372
select * from t6 order by colint;
 
8373
colint  col1
 
8374
60      14:30:20
 
8375
-------------------------------------------------------------------------
 
8376
---  Delete rows and partitions of tables with second(col1)
 
8377
-------------------------------------------------------------------------
 
8378
delete from t11 where col1='14:30:20';
 
8379
delete from t22 where col1='14:30:20';
 
8380
delete from t33 where col1='14:30:20';
 
8381
delete from t44 where col1='14:30:20';
 
8382
delete from t55 where col1='14:30:20';
 
8383
delete from t66 where col1='14:30:20';
 
8384
select * from t11 order by col1;
 
8385
col1
 
8386
10:22:33
 
8387
select * from t22 order by col1;
 
8388
col1
 
8389
10:22:33
 
8390
21:59:22
 
8391
select * from t33 order by col1;
 
8392
col1
 
8393
10:22:33
 
8394
21:59:22
 
8395
select * from t44 order by colint;
 
8396
colint  col1
 
8397
1       09:09:15
 
8398
2       04:30:01
 
8399
3       00:59:22
 
8400
4       05:30:34
 
8401
select * from t55 order by colint;
 
8402
colint  col1
 
8403
1       09:09:15
 
8404
2       04:30:01
 
8405
3       00:59:22
 
8406
4       05:30:34
 
8407
insert into t11 values ('14:30:20');
 
8408
insert into t22 values ('14:30:20');
 
8409
insert into t33 values ('14:30:20');
 
8410
insert into t44 values (60,'14:30:20');
 
8411
insert into t55 values (60,'14:30:20');
 
8412
insert into t66 values (60,'14:30:20');
 
8413
select * from t11 order by col1;
 
8414
col1
 
8415
10:22:33
 
8416
14:30:20
 
8417
select * from t22 order by col1;
 
8418
col1
 
8419
10:22:33
 
8420
14:30:20
 
8421
21:59:22
 
8422
select * from t33 order by col1;
 
8423
col1
 
8424
10:22:33
 
8425
14:30:20
 
8426
21:59:22
 
8427
select * from t44 order by colint;
 
8428
colint  col1
 
8429
1       09:09:15
 
8430
2       04:30:01
 
8431
3       00:59:22
 
8432
4       05:30:34
 
8433
60      14:30:20
 
8434
select * from t55 order by colint;
 
8435
colint  col1
 
8436
1       09:09:15
 
8437
2       04:30:01
 
8438
3       00:59:22
 
8439
4       05:30:34
 
8440
60      14:30:20
 
8441
select * from t66 order by colint;
 
8442
colint  col1
 
8443
1       09:09:15
 
8444
2       04:30:01
 
8445
3       00:59:22
 
8446
4       05:30:34
 
8447
60      14:30:20
 
8448
alter table t11 drop partition p0;
 
8449
alter table t22 drop partition p0;
 
8450
alter table t44 drop partition p0;
 
8451
alter table t55 drop partition p0;
 
8452
alter table t66 drop partition p0;
 
8453
select * from t11 order by col1;
 
8454
col1
 
8455
10:22:33
 
8456
14:30:20
 
8457
select * from t22 order by col1;
 
8458
col1
 
8459
10:22:33
 
8460
14:30:20
 
8461
21:59:22
 
8462
select * from t33 order by col1;
 
8463
col1
 
8464
10:22:33
 
8465
14:30:20
 
8466
21:59:22
 
8467
select * from t44 order by colint;
 
8468
colint  col1
 
8469
60      14:30:20
 
8470
select * from t55 order by colint;
 
8471
colint  col1
 
8472
60      14:30:20
 
8473
select * from t66 order by colint;
 
8474
colint  col1
 
8475
60      14:30:20
 
8476
-------------------------
 
8477
---- some alter table end
 
8478
-------------------------
 
8479
drop table if exists t1 ;
 
8480
drop table if exists t2 ;
 
8481
drop table if exists t3 ;
 
8482
drop table if exists t4 ;
 
8483
drop table if exists t5 ;
 
8484
drop table if exists t6 ;
 
8485
drop table if exists t11 ;
 
8486
drop table if exists t22 ;
 
8487
drop table if exists t33 ;
 
8488
drop table if exists t44 ;
 
8489
drop table if exists t55 ;
 
8490
drop table if exists t66 ;
 
8491
-------------------------------------------------------------------------
 
8492
---  second(col1)  in partition with coltype  char(30)
 
8493
-------------------------------------------------------------------------
 
8494
drop table if exists t1 ;
 
8495
drop table if exists t2 ;
 
8496
drop table if exists t3 ;
 
8497
drop table if exists t4 ;
 
8498
drop table if exists t5 ;
 
8499
drop table if exists t6 ;
 
8500
-------------------------------------------------------------------------
 
8501
---  Create tables with second(col1)
 
8502
-------------------------------------------------------------------------
 
8503
create table t1 (col1 char(30)) engine='INNODB' 
 
8504
partition by range(second(col1)) 
 
8505
(partition p0 values less than (15),
 
8506
partition p1 values less than maxvalue);
 
8507
create table t2 (col1 char(30)) engine='INNODB' 
 
8508
partition by list(second(col1)) 
 
8509
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
8510
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
8511
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
8512
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
8513
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
8514
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
8515
);
 
8516
create table t3 (col1 char(30)) engine='INNODB' 
 
8517
partition by hash(second(col1));
 
8518
create table t4 (colint int, col1 char(30)) engine='INNODB' 
 
8519
partition by range(colint) 
 
8520
subpartition by hash(second(col1)) subpartitions 2 
 
8521
(partition p0 values less than (15),
 
8522
partition p1 values less than maxvalue);
 
8523
create table t5 (colint int, col1 char(30)) engine='INNODB' 
 
8524
partition by list(colint)
 
8525
subpartition by hash(second(col1)) subpartitions 2 
 
8526
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
8527
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
8528
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
8529
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
8530
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
8531
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
8532
);
 
8533
create table t6 (colint int, col1 char(30)) engine='INNODB' 
 
8534
partition by range(colint) 
 
8535
(partition p0 values less than (second('18:30:14')),
 
8536
partition p1 values less than maxvalue);
 
8537
-------------------------------------------------------------------------
 
8538
---  Access tables with second(col1) 
 
8539
-------------------------------------------------------------------------
 
8540
insert into t1 values ('09:09:09');
 
8541
insert into t1 values ('14:30:20');
 
8542
insert into t2 values ('09:09:09');
 
8543
insert into t2 values ('14:30:20');
 
8544
insert into t2 values ('21:59:22');
 
8545
insert into t3 values ('09:09:09');
 
8546
insert into t3 values ('14:30:20');
 
8547
insert into t3 values ('21:59:22');
 
8548
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
 
8549
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
 
8550
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
 
8551
select second(col1) from t1 order by col1;
 
8552
second(col1)
 
8553
9
 
8554
20
 
8555
select * from t1 order by col1;
 
8556
col1
 
8557
09:09:09
 
8558
14:30:20
 
8559
select * from t2 order by col1;
 
8560
col1
 
8561
09:09:09
 
8562
14:30:20
 
8563
21:59:22
 
8564
select * from t3 order by col1;
 
8565
col1
 
8566
09:09:09
 
8567
14:30:20
 
8568
21:59:22
 
8569
select * from t4 order by colint;
 
8570
colint  col1
 
8571
1       09:09:15.000002
 
8572
2       04:30:01.000018
 
8573
3       00:59:22.000024
 
8574
4       05:30:34.000037
 
8575
select * from t5 order by colint;
 
8576
colint  col1
 
8577
1       09:09:15.000002
 
8578
2       04:30:01.000018
 
8579
3       00:59:22.000024
 
8580
4       05:30:34.000037
 
8581
select * from t6 order by colint;
 
8582
colint  col1
 
8583
1       09:09:15.000002
 
8584
2       04:30:01.000018
 
8585
3       00:59:22.000024
 
8586
4       05:30:34.000037
 
8587
update t1 set col1='10:22:33' where col1='09:09:09';
 
8588
update t2 set col1='10:22:33' where col1='09:09:09';
 
8589
update t3 set col1='10:22:33' where col1='09:09:09';
 
8590
update t4 set col1='10:22:33' where col1='09:09:09';
 
8591
update t5 set col1='10:22:33' where col1='09:09:09';
 
8592
update t6 set col1='10:22:33' where col1='09:09:09';
 
8593
select * from t1 order by col1;
 
8594
col1
 
8595
10:22:33
 
8596
14:30:20
 
8597
select * from t2 order by col1;
 
8598
col1
 
8599
10:22:33
 
8600
14:30:20
 
8601
21:59:22
 
8602
select * from t3 order by col1;
 
8603
col1
 
8604
10:22:33
 
8605
14:30:20
 
8606
21:59:22
 
8607
select * from t4 order by colint;
 
8608
colint  col1
 
8609
1       09:09:15.000002
 
8610
2       04:30:01.000018
 
8611
3       00:59:22.000024
 
8612
4       05:30:34.000037
 
8613
select * from t5 order by colint;
 
8614
colint  col1
 
8615
1       09:09:15.000002
 
8616
2       04:30:01.000018
 
8617
3       00:59:22.000024
 
8618
4       05:30:34.000037
 
8619
select * from t6 order by colint;
 
8620
colint  col1
 
8621
1       09:09:15.000002
 
8622
2       04:30:01.000018
 
8623
3       00:59:22.000024
 
8624
4       05:30:34.000037
 
8625
-------------------------------------------------------------------------
 
8626
---  Alter tables with second(col1)
 
8627
-------------------------------------------------------------------------
 
8628
drop table if exists t11 ;
 
8629
drop table if exists t22 ;
 
8630
drop table if exists t33 ;
 
8631
drop table if exists t44 ;
 
8632
drop table if exists t55 ;
 
8633
drop table if exists t66 ;
 
8634
create table t11 engine='INNODB' as select * from t1;
 
8635
create table t22 engine='INNODB' as select * from t2;
 
8636
create table t33 engine='INNODB' as select * from t3;
 
8637
create table t44 engine='INNODB' as select * from t4;
 
8638
create table t55 engine='INNODB' as select * from t5;
 
8639
create table t66 engine='INNODB' as select * from t6;
 
8640
alter table t11
 
8641
partition by range(second(col1)) 
 
8642
(partition p0 values less than (15),
 
8643
partition p1 values less than maxvalue);
 
8644
alter table t22
 
8645
partition by list(second(col1)) 
 
8646
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
8647
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
8648
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
8649
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
8650
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
8651
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
8652
);
 
8653
alter table t33
 
8654
partition by hash(second(col1));
 
8655
alter table t44
 
8656
partition by range(colint) 
 
8657
subpartition by hash(second(col1)) subpartitions 2 
 
8658
(partition p0 values less than (15),
 
8659
partition p1 values less than maxvalue);
 
8660
alter table t55
 
8661
partition by list(colint)
 
8662
subpartition by hash(second(col1)) subpartitions 2 
 
8663
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
8664
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
8665
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
8666
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
8667
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
8668
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
8669
);
 
8670
alter table t66
 
8671
partition by range(colint) 
 
8672
(partition p0 values less than (second('18:30:14')),
 
8673
partition p1 values less than maxvalue);
 
8674
select * from t11 order by col1;
 
8675
col1
 
8676
10:22:33
 
8677
14:30:20
 
8678
select * from t22 order by col1;
 
8679
col1
 
8680
10:22:33
 
8681
14:30:20
 
8682
21:59:22
 
8683
select * from t33 order by col1;
 
8684
col1
 
8685
10:22:33
 
8686
14:30:20
 
8687
21:59:22
 
8688
select * from t44 order by colint;
 
8689
colint  col1
 
8690
1       09:09:15.000002
 
8691
2       04:30:01.000018
 
8692
3       00:59:22.000024
 
8693
4       05:30:34.000037
 
8694
select * from t55 order by colint;
 
8695
colint  col1
 
8696
1       09:09:15.000002
 
8697
2       04:30:01.000018
 
8698
3       00:59:22.000024
 
8699
4       05:30:34.000037
 
8700
select * from t66 order by colint;
 
8701
colint  col1
 
8702
1       09:09:15.000002
 
8703
2       04:30:01.000018
 
8704
3       00:59:22.000024
 
8705
4       05:30:34.000037
 
8706
---------------------------
 
8707
---- some alter table begin
 
8708
---------------------------
 
8709
alter table t11
 
8710
reorganize partition p0,p1 into
 
8711
(partition s1 values less than maxvalue);
 
8712
select * from t11 order by col1;
 
8713
col1
 
8714
10:22:33
 
8715
14:30:20
 
8716
alter table t11
 
8717
reorganize partition s1 into
 
8718
(partition p0 values less than (15),
 
8719
partition p1 values less than maxvalue);
 
8720
select * from t11 order by col1;
 
8721
col1
 
8722
10:22:33
 
8723
14:30:20
 
8724
alter table t55
 
8725
partition by list(colint)
 
8726
subpartition by hash(second(col1)) subpartitions 5 
 
8727
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
8728
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
8729
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
8730
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
8731
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
8732
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
8733
);
 
8734
show create table t55;
 
8735
Table   Create Table
 
8736
t55     CREATE TABLE `t55` (
 
8737
  `colint` int(11) DEFAULT NULL,
 
8738
  `col1` char(30) DEFAULT NULL
 
8739
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
8740
/*!50100 PARTITION BY LIST (colint)
 
8741
SUBPARTITION BY HASH (second(col1))
 
8742
SUBPARTITIONS 5
 
8743
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
8744
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
8745
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
8746
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
8747
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
8748
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
8749
select * from t55 order by colint;
 
8750
colint  col1
 
8751
1       09:09:15.000002
 
8752
2       04:30:01.000018
 
8753
3       00:59:22.000024
 
8754
4       05:30:34.000037
 
8755
alter table t66
 
8756
reorganize partition p0,p1 into
 
8757
(partition s1 values less than maxvalue);
 
8758
select * from t66 order by colint;
 
8759
colint  col1
 
8760
1       09:09:15.000002
 
8761
2       04:30:01.000018
 
8762
3       00:59:22.000024
 
8763
4       05:30:34.000037
 
8764
alter table t66
 
8765
reorganize partition s1 into
 
8766
(partition p0 values less than (second('18:30:14')),
 
8767
partition p1 values less than maxvalue);
 
8768
select * from t66 order by colint;
 
8769
colint  col1
 
8770
1       09:09:15.000002
 
8771
2       04:30:01.000018
 
8772
3       00:59:22.000024
 
8773
4       05:30:34.000037
 
8774
alter table t66
 
8775
reorganize partition p0,p1 into
 
8776
(partition s1 values less than maxvalue);
 
8777
select * from t66 order by colint;
 
8778
colint  col1
 
8779
1       09:09:15.000002
 
8780
2       04:30:01.000018
 
8781
3       00:59:22.000024
 
8782
4       05:30:34.000037
 
8783
alter table t66
 
8784
reorganize partition s1 into
 
8785
(partition p0 values less than (second('18:30:14')),
 
8786
partition p1 values less than maxvalue);
 
8787
select * from t66 order by colint;
 
8788
colint  col1
 
8789
1       09:09:15.000002
 
8790
2       04:30:01.000018
 
8791
3       00:59:22.000024
 
8792
4       05:30:34.000037
 
8793
-------------------------------------------------------------------------
 
8794
---  Delete rows and partitions of tables with second(col1)
 
8795
-------------------------------------------------------------------------
 
8796
delete from t1 where col1='14:30:20';
 
8797
delete from t2 where col1='14:30:20';
 
8798
delete from t3 where col1='14:30:20';
 
8799
delete from t4 where col1='14:30:20';
 
8800
delete from t5 where col1='14:30:20';
 
8801
delete from t6 where col1='14:30:20';
 
8802
select * from t1 order by col1;
 
8803
col1
 
8804
10:22:33
 
8805
select * from t2 order by col1;
 
8806
col1
 
8807
10:22:33
 
8808
21:59:22
 
8809
select * from t3 order by col1;
 
8810
col1
 
8811
10:22:33
 
8812
21:59:22
 
8813
select * from t4 order by colint;
 
8814
colint  col1
 
8815
1       09:09:15.000002
 
8816
2       04:30:01.000018
 
8817
3       00:59:22.000024
 
8818
4       05:30:34.000037
 
8819
select * from t5 order by colint;
 
8820
colint  col1
 
8821
1       09:09:15.000002
 
8822
2       04:30:01.000018
 
8823
3       00:59:22.000024
 
8824
4       05:30:34.000037
 
8825
insert into t1 values ('14:30:20');
 
8826
insert into t2 values ('14:30:20');
 
8827
insert into t3 values ('14:30:20');
 
8828
insert into t4 values (60,'14:30:20');
 
8829
insert into t5 values (60,'14:30:20');
 
8830
insert into t6 values (60,'14:30:20');
 
8831
select * from t1 order by col1;
 
8832
col1
 
8833
10:22:33
 
8834
14:30:20
 
8835
select * from t2 order by col1;
 
8836
col1
 
8837
10:22:33
 
8838
14:30:20
 
8839
21:59:22
 
8840
select * from t3 order by col1;
 
8841
col1
 
8842
10:22:33
 
8843
14:30:20
 
8844
21:59:22
 
8845
select * from t4 order by colint;
 
8846
colint  col1
 
8847
1       09:09:15.000002
 
8848
2       04:30:01.000018
 
8849
3       00:59:22.000024
 
8850
4       05:30:34.000037
 
8851
60      14:30:20
 
8852
select * from t5 order by colint;
 
8853
colint  col1
 
8854
1       09:09:15.000002
 
8855
2       04:30:01.000018
 
8856
3       00:59:22.000024
 
8857
4       05:30:34.000037
 
8858
60      14:30:20
 
8859
select * from t6 order by colint;
 
8860
colint  col1
 
8861
1       09:09:15.000002
 
8862
2       04:30:01.000018
 
8863
3       00:59:22.000024
 
8864
4       05:30:34.000037
 
8865
60      14:30:20
 
8866
alter table t1 drop partition p0;
 
8867
alter table t2 drop partition p0;
 
8868
alter table t4 drop partition p0;
 
8869
alter table t5 drop partition p0;
 
8870
alter table t6 drop partition p0;
 
8871
select * from t1 order by col1;
 
8872
col1
 
8873
10:22:33
 
8874
14:30:20
 
8875
select * from t2 order by col1;
 
8876
col1
 
8877
10:22:33
 
8878
14:30:20
 
8879
21:59:22
 
8880
select * from t3 order by col1;
 
8881
col1
 
8882
10:22:33
 
8883
14:30:20
 
8884
21:59:22
 
8885
select * from t4 order by colint;
 
8886
colint  col1
 
8887
60      14:30:20
 
8888
select * from t5 order by colint;
 
8889
colint  col1
 
8890
60      14:30:20
 
8891
select * from t6 order by colint;
 
8892
colint  col1
 
8893
60      14:30:20
 
8894
-------------------------------------------------------------------------
 
8895
---  Delete rows and partitions of tables with second(col1)
 
8896
-------------------------------------------------------------------------
 
8897
delete from t11 where col1='14:30:20';
 
8898
delete from t22 where col1='14:30:20';
 
8899
delete from t33 where col1='14:30:20';
 
8900
delete from t44 where col1='14:30:20';
 
8901
delete from t55 where col1='14:30:20';
 
8902
delete from t66 where col1='14:30:20';
 
8903
select * from t11 order by col1;
 
8904
col1
 
8905
10:22:33
 
8906
select * from t22 order by col1;
 
8907
col1
 
8908
10:22:33
 
8909
21:59:22
 
8910
select * from t33 order by col1;
 
8911
col1
 
8912
10:22:33
 
8913
21:59:22
 
8914
select * from t44 order by colint;
 
8915
colint  col1
 
8916
1       09:09:15.000002
 
8917
2       04:30:01.000018
 
8918
3       00:59:22.000024
 
8919
4       05:30:34.000037
 
8920
select * from t55 order by colint;
 
8921
colint  col1
 
8922
1       09:09:15.000002
 
8923
2       04:30:01.000018
 
8924
3       00:59:22.000024
 
8925
4       05:30:34.000037
 
8926
insert into t11 values ('14:30:20');
 
8927
insert into t22 values ('14:30:20');
 
8928
insert into t33 values ('14:30:20');
 
8929
insert into t44 values (60,'14:30:20');
 
8930
insert into t55 values (60,'14:30:20');
 
8931
insert into t66 values (60,'14:30:20');
 
8932
select * from t11 order by col1;
 
8933
col1
 
8934
10:22:33
 
8935
14:30:20
 
8936
select * from t22 order by col1;
 
8937
col1
 
8938
10:22:33
 
8939
14:30:20
 
8940
21:59:22
 
8941
select * from t33 order by col1;
 
8942
col1
 
8943
10:22:33
 
8944
14:30:20
 
8945
21:59:22
 
8946
select * from t44 order by colint;
 
8947
colint  col1
 
8948
1       09:09:15.000002
 
8949
2       04:30:01.000018
 
8950
3       00:59:22.000024
 
8951
4       05:30:34.000037
 
8952
60      14:30:20
 
8953
select * from t55 order by colint;
 
8954
colint  col1
 
8955
1       09:09:15.000002
 
8956
2       04:30:01.000018
 
8957
3       00:59:22.000024
 
8958
4       05:30:34.000037
 
8959
60      14:30:20
 
8960
select * from t66 order by colint;
 
8961
colint  col1
 
8962
1       09:09:15.000002
 
8963
2       04:30:01.000018
 
8964
3       00:59:22.000024
 
8965
4       05:30:34.000037
 
8966
60      14:30:20
 
8967
alter table t11 drop partition p0;
 
8968
alter table t22 drop partition p0;
 
8969
alter table t44 drop partition p0;
 
8970
alter table t55 drop partition p0;
 
8971
alter table t66 drop partition p0;
 
8972
select * from t11 order by col1;
 
8973
col1
 
8974
10:22:33
 
8975
14:30:20
 
8976
select * from t22 order by col1;
 
8977
col1
 
8978
10:22:33
 
8979
14:30:20
 
8980
21:59:22
 
8981
select * from t33 order by col1;
 
8982
col1
 
8983
10:22:33
 
8984
14:30:20
 
8985
21:59:22
 
8986
select * from t44 order by colint;
 
8987
colint  col1
 
8988
60      14:30:20
 
8989
select * from t55 order by colint;
 
8990
colint  col1
 
8991
60      14:30:20
 
8992
select * from t66 order by colint;
 
8993
colint  col1
 
8994
60      14:30:20
 
8995
-------------------------
 
8996
---- some alter table end
 
8997
-------------------------
 
8998
drop table if exists t1 ;
 
8999
drop table if exists t2 ;
 
9000
drop table if exists t3 ;
 
9001
drop table if exists t4 ;
 
9002
drop table if exists t5 ;
 
9003
drop table if exists t6 ;
 
9004
drop table if exists t11 ;
 
9005
drop table if exists t22 ;
 
9006
drop table if exists t33 ;
 
9007
drop table if exists t44 ;
 
9008
drop table if exists t55 ;
 
9009
drop table if exists t66 ;
 
9010
-------------------------------------------------------------------------
 
9011
---  month(col1)  in partition with coltype  date
 
9012
-------------------------------------------------------------------------
 
9013
drop table if exists t1 ;
 
9014
drop table if exists t2 ;
 
9015
drop table if exists t3 ;
 
9016
drop table if exists t4 ;
 
9017
drop table if exists t5 ;
 
9018
drop table if exists t6 ;
 
9019
-------------------------------------------------------------------------
 
9020
---  Create tables with month(col1)
 
9021
-------------------------------------------------------------------------
 
9022
create table t1 (col1 date) engine='INNODB' 
 
9023
partition by range(month(col1)) 
 
9024
(partition p0 values less than (15),
 
9025
partition p1 values less than maxvalue);
 
9026
create table t2 (col1 date) engine='INNODB' 
 
9027
partition by list(month(col1)) 
 
9028
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
9029
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
9030
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
9031
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
9032
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
9033
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
9034
);
 
9035
create table t3 (col1 date) engine='INNODB' 
 
9036
partition by hash(month(col1));
 
9037
create table t4 (colint int, col1 date) engine='INNODB' 
 
9038
partition by range(colint) 
 
9039
subpartition by hash(month(col1)) subpartitions 2 
 
9040
(partition p0 values less than (15),
 
9041
partition p1 values less than maxvalue);
 
9042
create table t5 (colint int, col1 date) engine='INNODB' 
 
9043
partition by list(colint)
 
9044
subpartition by hash(month(col1)) subpartitions 2 
 
9045
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
9046
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
9047
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
9048
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
9049
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
9050
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
9051
);
 
9052
create table t6 (colint int, col1 date) engine='INNODB' 
 
9053
partition by range(colint) 
 
9054
(partition p0 values less than (month('2006-10-14')),
 
9055
partition p1 values less than maxvalue);
 
9056
-------------------------------------------------------------------------
 
9057
---  Access tables with month(col1) 
 
9058
-------------------------------------------------------------------------
 
9059
insert into t1 values ('2006-01-03');
 
9060
insert into t1 values ('2006-12-17');
 
9061
insert into t2 values ('2006-01-03');
 
9062
insert into t2 values ('2006-12-17');
 
9063
insert into t2 values ('2006-05-25');
 
9064
insert into t3 values ('2006-01-03');
 
9065
insert into t3 values ('2006-12-17');
 
9066
insert into t3 values ('2006-05-25');
 
9067
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
 
9068
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
 
9069
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
 
9070
select month(col1) from t1 order by col1;
 
9071
month(col1)
 
9072
1
 
9073
12
 
9074
select * from t1 order by col1;
 
9075
col1
 
9076
2006-01-03
 
9077
2006-12-17
 
9078
select * from t2 order by col1;
 
9079
col1
 
9080
2006-01-03
 
9081
2006-05-25
 
9082
2006-12-17
 
9083
select * from t3 order by col1;
 
9084
col1
 
9085
2006-01-03
 
9086
2006-05-25
 
9087
2006-12-17
 
9088
select * from t4 order by colint;
 
9089
colint  col1
 
9090
1       2006-02-03
 
9091
2       2006-01-17
 
9092
3       2006-01-25
 
9093
4       2006-02-05
 
9094
select * from t5 order by colint;
 
9095
colint  col1
 
9096
1       2006-02-03
 
9097
2       2006-01-17
 
9098
3       2006-01-25
 
9099
4       2006-02-05
 
9100
select * from t6 order by colint;
 
9101
colint  col1
 
9102
1       2006-02-03
 
9103
2       2006-01-17
 
9104
3       2006-01-25
 
9105
4       2006-02-05
 
9106
update t1 set col1='2006-11-06' where col1='2006-01-03';
 
9107
update t2 set col1='2006-11-06' where col1='2006-01-03';
 
9108
update t3 set col1='2006-11-06' where col1='2006-01-03';
 
9109
update t4 set col1='2006-11-06' where col1='2006-01-03';
 
9110
update t5 set col1='2006-11-06' where col1='2006-01-03';
 
9111
update t6 set col1='2006-11-06' where col1='2006-01-03';
 
9112
select * from t1 order by col1;
 
9113
col1
 
9114
2006-11-06
 
9115
2006-12-17
 
9116
select * from t2 order by col1;
 
9117
col1
 
9118
2006-05-25
 
9119
2006-11-06
 
9120
2006-12-17
 
9121
select * from t3 order by col1;
 
9122
col1
 
9123
2006-05-25
 
9124
2006-11-06
 
9125
2006-12-17
 
9126
select * from t4 order by colint;
 
9127
colint  col1
 
9128
1       2006-02-03
 
9129
2       2006-01-17
 
9130
3       2006-01-25
 
9131
4       2006-02-05
 
9132
select * from t5 order by colint;
 
9133
colint  col1
 
9134
1       2006-02-03
 
9135
2       2006-01-17
 
9136
3       2006-01-25
 
9137
4       2006-02-05
 
9138
select * from t6 order by colint;
 
9139
colint  col1
 
9140
1       2006-02-03
 
9141
2       2006-01-17
 
9142
3       2006-01-25
 
9143
4       2006-02-05
 
9144
-------------------------------------------------------------------------
 
9145
---  Alter tables with month(col1)
 
9146
-------------------------------------------------------------------------
 
9147
drop table if exists t11 ;
 
9148
drop table if exists t22 ;
 
9149
drop table if exists t33 ;
 
9150
drop table if exists t44 ;
 
9151
drop table if exists t55 ;
 
9152
drop table if exists t66 ;
 
9153
create table t11 engine='INNODB' as select * from t1;
 
9154
create table t22 engine='INNODB' as select * from t2;
 
9155
create table t33 engine='INNODB' as select * from t3;
 
9156
create table t44 engine='INNODB' as select * from t4;
 
9157
create table t55 engine='INNODB' as select * from t5;
 
9158
create table t66 engine='INNODB' as select * from t6;
 
9159
alter table t11
 
9160
partition by range(month(col1)) 
 
9161
(partition p0 values less than (15),
 
9162
partition p1 values less than maxvalue);
 
9163
alter table t22
 
9164
partition by list(month(col1)) 
 
9165
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
9166
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
9167
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
9168
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
9169
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
9170
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
9171
);
 
9172
alter table t33
 
9173
partition by hash(month(col1));
 
9174
alter table t44
 
9175
partition by range(colint) 
 
9176
subpartition by hash(month(col1)) subpartitions 2 
 
9177
(partition p0 values less than (15),
 
9178
partition p1 values less than maxvalue);
 
9179
alter table t55
 
9180
partition by list(colint)
 
9181
subpartition by hash(month(col1)) subpartitions 2 
 
9182
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
9183
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
9184
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
9185
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
9186
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
9187
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
9188
);
 
9189
alter table t66
 
9190
partition by range(colint) 
 
9191
(partition p0 values less than (month('2006-10-14')),
 
9192
partition p1 values less than maxvalue);
 
9193
select * from t11 order by col1;
 
9194
col1
 
9195
2006-11-06
 
9196
2006-12-17
 
9197
select * from t22 order by col1;
 
9198
col1
 
9199
2006-05-25
 
9200
2006-11-06
 
9201
2006-12-17
 
9202
select * from t33 order by col1;
 
9203
col1
 
9204
2006-05-25
 
9205
2006-11-06
 
9206
2006-12-17
 
9207
select * from t44 order by colint;
 
9208
colint  col1
 
9209
1       2006-02-03
 
9210
2       2006-01-17
 
9211
3       2006-01-25
 
9212
4       2006-02-05
 
9213
select * from t55 order by colint;
 
9214
colint  col1
 
9215
1       2006-02-03
 
9216
2       2006-01-17
 
9217
3       2006-01-25
 
9218
4       2006-02-05
 
9219
select * from t66 order by colint;
 
9220
colint  col1
 
9221
1       2006-02-03
 
9222
2       2006-01-17
 
9223
3       2006-01-25
 
9224
4       2006-02-05
 
9225
---------------------------
 
9226
---- some alter table begin
 
9227
---------------------------
 
9228
alter table t11
 
9229
reorganize partition p0,p1 into
 
9230
(partition s1 values less than maxvalue);
 
9231
select * from t11 order by col1;
 
9232
col1
 
9233
2006-11-06
 
9234
2006-12-17
 
9235
alter table t11
 
9236
reorganize partition s1 into
 
9237
(partition p0 values less than (15),
 
9238
partition p1 values less than maxvalue);
 
9239
select * from t11 order by col1;
 
9240
col1
 
9241
2006-11-06
 
9242
2006-12-17
 
9243
alter table t55
 
9244
partition by list(colint)
 
9245
subpartition by hash(month(col1)) subpartitions 5 
 
9246
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
9247
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
9248
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
9249
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
9250
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
9251
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
9252
);
 
9253
show create table t55;
 
9254
Table   Create Table
 
9255
t55     CREATE TABLE `t55` (
 
9256
  `colint` int(11) DEFAULT NULL,
 
9257
  `col1` date DEFAULT NULL
 
9258
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
9259
/*!50100 PARTITION BY LIST (colint)
 
9260
SUBPARTITION BY HASH (month(col1))
 
9261
SUBPARTITIONS 5
 
9262
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
9263
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
9264
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
9265
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
9266
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
9267
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
9268
select * from t55 order by colint;
 
9269
colint  col1
 
9270
1       2006-02-03
 
9271
2       2006-01-17
 
9272
3       2006-01-25
 
9273
4       2006-02-05
 
9274
alter table t66
 
9275
reorganize partition p0,p1 into
 
9276
(partition s1 values less than maxvalue);
 
9277
select * from t66 order by colint;
 
9278
colint  col1
 
9279
1       2006-02-03
 
9280
2       2006-01-17
 
9281
3       2006-01-25
 
9282
4       2006-02-05
 
9283
alter table t66
 
9284
reorganize partition s1 into
 
9285
(partition p0 values less than (month('2006-10-14')),
 
9286
partition p1 values less than maxvalue);
 
9287
select * from t66 order by colint;
 
9288
colint  col1
 
9289
1       2006-02-03
 
9290
2       2006-01-17
 
9291
3       2006-01-25
 
9292
4       2006-02-05
 
9293
alter table t66
 
9294
reorganize partition p0,p1 into
 
9295
(partition s1 values less than maxvalue);
 
9296
select * from t66 order by colint;
 
9297
colint  col1
 
9298
1       2006-02-03
 
9299
2       2006-01-17
 
9300
3       2006-01-25
 
9301
4       2006-02-05
 
9302
alter table t66
 
9303
reorganize partition s1 into
 
9304
(partition p0 values less than (month('2006-10-14')),
 
9305
partition p1 values less than maxvalue);
 
9306
select * from t66 order by colint;
 
9307
colint  col1
 
9308
1       2006-02-03
 
9309
2       2006-01-17
 
9310
3       2006-01-25
 
9311
4       2006-02-05
 
9312
-------------------------------------------------------------------------
 
9313
---  Delete rows and partitions of tables with month(col1)
 
9314
-------------------------------------------------------------------------
 
9315
delete from t1 where col1='2006-12-17';
 
9316
delete from t2 where col1='2006-12-17';
 
9317
delete from t3 where col1='2006-12-17';
 
9318
delete from t4 where col1='2006-12-17';
 
9319
delete from t5 where col1='2006-12-17';
 
9320
delete from t6 where col1='2006-12-17';
 
9321
select * from t1 order by col1;
 
9322
col1
 
9323
2006-11-06
 
9324
select * from t2 order by col1;
 
9325
col1
 
9326
2006-05-25
 
9327
2006-11-06
 
9328
select * from t3 order by col1;
 
9329
col1
 
9330
2006-05-25
 
9331
2006-11-06
 
9332
select * from t4 order by colint;
 
9333
colint  col1
 
9334
1       2006-02-03
 
9335
2       2006-01-17
 
9336
3       2006-01-25
 
9337
4       2006-02-05
 
9338
select * from t5 order by colint;
 
9339
colint  col1
 
9340
1       2006-02-03
 
9341
2       2006-01-17
 
9342
3       2006-01-25
 
9343
4       2006-02-05
 
9344
insert into t1 values ('2006-12-17');
 
9345
insert into t2 values ('2006-12-17');
 
9346
insert into t3 values ('2006-12-17');
 
9347
insert into t4 values (60,'2006-12-17');
 
9348
insert into t5 values (60,'2006-12-17');
 
9349
insert into t6 values (60,'2006-12-17');
 
9350
select * from t1 order by col1;
 
9351
col1
 
9352
2006-11-06
 
9353
2006-12-17
 
9354
select * from t2 order by col1;
 
9355
col1
 
9356
2006-05-25
 
9357
2006-11-06
 
9358
2006-12-17
 
9359
select * from t3 order by col1;
 
9360
col1
 
9361
2006-05-25
 
9362
2006-11-06
 
9363
2006-12-17
 
9364
select * from t4 order by colint;
 
9365
colint  col1
 
9366
1       2006-02-03
 
9367
2       2006-01-17
 
9368
3       2006-01-25
 
9369
4       2006-02-05
 
9370
60      2006-12-17
 
9371
select * from t5 order by colint;
 
9372
colint  col1
 
9373
1       2006-02-03
 
9374
2       2006-01-17
 
9375
3       2006-01-25
 
9376
4       2006-02-05
 
9377
60      2006-12-17
 
9378
select * from t6 order by colint;
 
9379
colint  col1
 
9380
1       2006-02-03
 
9381
2       2006-01-17
 
9382
3       2006-01-25
 
9383
4       2006-02-05
 
9384
60      2006-12-17
 
9385
alter table t1 drop partition p0;
 
9386
alter table t2 drop partition p0;
 
9387
alter table t4 drop partition p0;
 
9388
alter table t5 drop partition p0;
 
9389
alter table t6 drop partition p0;
 
9390
select * from t1 order by col1;
 
9391
col1
 
9392
select * from t2 order by col1;
 
9393
col1
 
9394
2006-11-06
 
9395
2006-12-17
 
9396
select * from t3 order by col1;
 
9397
col1
 
9398
2006-05-25
 
9399
2006-11-06
 
9400
2006-12-17
 
9401
select * from t4 order by colint;
 
9402
colint  col1
 
9403
60      2006-12-17
 
9404
select * from t5 order by colint;
 
9405
colint  col1
 
9406
60      2006-12-17
 
9407
select * from t6 order by colint;
 
9408
colint  col1
 
9409
60      2006-12-17
 
9410
-------------------------------------------------------------------------
 
9411
---  Delete rows and partitions of tables with month(col1)
 
9412
-------------------------------------------------------------------------
 
9413
delete from t11 where col1='2006-12-17';
 
9414
delete from t22 where col1='2006-12-17';
 
9415
delete from t33 where col1='2006-12-17';
 
9416
delete from t44 where col1='2006-12-17';
 
9417
delete from t55 where col1='2006-12-17';
 
9418
delete from t66 where col1='2006-12-17';
 
9419
select * from t11 order by col1;
 
9420
col1
 
9421
2006-11-06
 
9422
select * from t22 order by col1;
 
9423
col1
 
9424
2006-05-25
 
9425
2006-11-06
 
9426
select * from t33 order by col1;
 
9427
col1
 
9428
2006-05-25
 
9429
2006-11-06
 
9430
select * from t44 order by colint;
 
9431
colint  col1
 
9432
1       2006-02-03
 
9433
2       2006-01-17
 
9434
3       2006-01-25
 
9435
4       2006-02-05
 
9436
select * from t55 order by colint;
 
9437
colint  col1
 
9438
1       2006-02-03
 
9439
2       2006-01-17
 
9440
3       2006-01-25
 
9441
4       2006-02-05
 
9442
insert into t11 values ('2006-12-17');
 
9443
insert into t22 values ('2006-12-17');
 
9444
insert into t33 values ('2006-12-17');
 
9445
insert into t44 values (60,'2006-12-17');
 
9446
insert into t55 values (60,'2006-12-17');
 
9447
insert into t66 values (60,'2006-12-17');
 
9448
select * from t11 order by col1;
 
9449
col1
 
9450
2006-11-06
 
9451
2006-12-17
 
9452
select * from t22 order by col1;
 
9453
col1
 
9454
2006-05-25
 
9455
2006-11-06
 
9456
2006-12-17
 
9457
select * from t33 order by col1;
 
9458
col1
 
9459
2006-05-25
 
9460
2006-11-06
 
9461
2006-12-17
 
9462
select * from t44 order by colint;
 
9463
colint  col1
 
9464
1       2006-02-03
 
9465
2       2006-01-17
 
9466
3       2006-01-25
 
9467
4       2006-02-05
 
9468
60      2006-12-17
 
9469
select * from t55 order by colint;
 
9470
colint  col1
 
9471
1       2006-02-03
 
9472
2       2006-01-17
 
9473
3       2006-01-25
 
9474
4       2006-02-05
 
9475
60      2006-12-17
 
9476
select * from t66 order by colint;
 
9477
colint  col1
 
9478
1       2006-02-03
 
9479
2       2006-01-17
 
9480
3       2006-01-25
 
9481
4       2006-02-05
 
9482
60      2006-12-17
 
9483
alter table t11 drop partition p0;
 
9484
alter table t22 drop partition p0;
 
9485
alter table t44 drop partition p0;
 
9486
alter table t55 drop partition p0;
 
9487
alter table t66 drop partition p0;
 
9488
select * from t11 order by col1;
 
9489
col1
 
9490
select * from t22 order by col1;
 
9491
col1
 
9492
2006-11-06
 
9493
2006-12-17
 
9494
select * from t33 order by col1;
 
9495
col1
 
9496
2006-05-25
 
9497
2006-11-06
 
9498
2006-12-17
 
9499
select * from t44 order by colint;
 
9500
colint  col1
 
9501
60      2006-12-17
 
9502
select * from t55 order by colint;
 
9503
colint  col1
 
9504
60      2006-12-17
 
9505
select * from t66 order by colint;
 
9506
colint  col1
 
9507
60      2006-12-17
 
9508
-------------------------
 
9509
---- some alter table end
 
9510
-------------------------
 
9511
drop table if exists t1 ;
 
9512
drop table if exists t2 ;
 
9513
drop table if exists t3 ;
 
9514
drop table if exists t4 ;
 
9515
drop table if exists t5 ;
 
9516
drop table if exists t6 ;
 
9517
drop table if exists t11 ;
 
9518
drop table if exists t22 ;
 
9519
drop table if exists t33 ;
 
9520
drop table if exists t44 ;
 
9521
drop table if exists t55 ;
 
9522
drop table if exists t66 ;
 
9523
-------------------------------------------------------------------------
 
9524
---  quarter(col1)  in partition with coltype  date
 
9525
-------------------------------------------------------------------------
 
9526
drop table if exists t1 ;
 
9527
drop table if exists t2 ;
 
9528
drop table if exists t3 ;
 
9529
drop table if exists t4 ;
 
9530
drop table if exists t5 ;
 
9531
drop table if exists t6 ;
 
9532
-------------------------------------------------------------------------
 
9533
---  Create tables with quarter(col1)
 
9534
-------------------------------------------------------------------------
 
9535
create table t1 (col1 date) engine='INNODB' 
 
9536
partition by range(quarter(col1)) 
 
9537
(partition p0 values less than (15),
 
9538
partition p1 values less than maxvalue);
 
9539
create table t2 (col1 date) engine='INNODB' 
 
9540
partition by list(quarter(col1)) 
 
9541
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
9542
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
9543
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
9544
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
9545
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
9546
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
9547
);
 
9548
create table t3 (col1 date) engine='INNODB' 
 
9549
partition by hash(quarter(col1));
 
9550
create table t4 (colint int, col1 date) engine='INNODB' 
 
9551
partition by range(colint) 
 
9552
subpartition by hash(quarter(col1)) subpartitions 2 
 
9553
(partition p0 values less than (15),
 
9554
partition p1 values less than maxvalue);
 
9555
create table t5 (colint int, col1 date) engine='INNODB' 
 
9556
partition by list(colint)
 
9557
subpartition by hash(quarter(col1)) subpartitions 2 
 
9558
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
9559
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
9560
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
9561
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
9562
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
9563
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
9564
);
 
9565
create table t6 (colint int, col1 date) engine='INNODB' 
 
9566
partition by range(colint) 
 
9567
(partition p0 values less than (quarter('2006-10-14')),
 
9568
partition p1 values less than maxvalue);
 
9569
-------------------------------------------------------------------------
 
9570
---  Access tables with quarter(col1) 
 
9571
-------------------------------------------------------------------------
 
9572
insert into t1 values ('2006-01-03');
 
9573
insert into t1 values ('2006-12-17');
 
9574
insert into t2 values ('2006-01-03');
 
9575
insert into t2 values ('2006-12-17');
 
9576
insert into t2 values ('2006-09-25');
 
9577
insert into t3 values ('2006-01-03');
 
9578
insert into t3 values ('2006-12-17');
 
9579
insert into t3 values ('2006-09-25');
 
9580
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
 
9581
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
 
9582
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
 
9583
select quarter(col1) from t1 order by col1;
 
9584
quarter(col1)
 
9585
1
 
9586
4
 
9587
select * from t1 order by col1;
 
9588
col1
 
9589
2006-01-03
 
9590
2006-12-17
 
9591
select * from t2 order by col1;
 
9592
col1
 
9593
2006-01-03
 
9594
2006-09-25
 
9595
2006-12-17
 
9596
select * from t3 order by col1;
 
9597
col1
 
9598
2006-01-03
 
9599
2006-09-25
 
9600
2006-12-17
 
9601
select * from t4 order by colint;
 
9602
colint  col1
 
9603
1       2006-02-03
 
9604
2       2006-01-17
 
9605
3       2006-01-25
 
9606
4       2006-02-05
 
9607
select * from t5 order by colint;
 
9608
colint  col1
 
9609
1       2006-02-03
 
9610
2       2006-01-17
 
9611
3       2006-01-25
 
9612
4       2006-02-05
 
9613
select * from t6 order by colint;
 
9614
colint  col1
 
9615
1       2006-02-03
 
9616
2       2006-01-17
 
9617
3       2006-01-25
 
9618
4       2006-02-05
 
9619
update t1 set col1='2006-07-30' where col1='2006-01-03';
 
9620
update t2 set col1='2006-07-30' where col1='2006-01-03';
 
9621
update t3 set col1='2006-07-30' where col1='2006-01-03';
 
9622
update t4 set col1='2006-07-30' where col1='2006-01-03';
 
9623
update t5 set col1='2006-07-30' where col1='2006-01-03';
 
9624
update t6 set col1='2006-07-30' where col1='2006-01-03';
 
9625
select * from t1 order by col1;
 
9626
col1
 
9627
2006-07-30
 
9628
2006-12-17
 
9629
select * from t2 order by col1;
 
9630
col1
 
9631
2006-07-30
 
9632
2006-09-25
 
9633
2006-12-17
 
9634
select * from t3 order by col1;
 
9635
col1
 
9636
2006-07-30
 
9637
2006-09-25
 
9638
2006-12-17
 
9639
select * from t4 order by colint;
 
9640
colint  col1
 
9641
1       2006-02-03
 
9642
2       2006-01-17
 
9643
3       2006-01-25
 
9644
4       2006-02-05
 
9645
select * from t5 order by colint;
 
9646
colint  col1
 
9647
1       2006-02-03
 
9648
2       2006-01-17
 
9649
3       2006-01-25
 
9650
4       2006-02-05
 
9651
select * from t6 order by colint;
 
9652
colint  col1
 
9653
1       2006-02-03
 
9654
2       2006-01-17
 
9655
3       2006-01-25
 
9656
4       2006-02-05
 
9657
-------------------------------------------------------------------------
 
9658
---  Alter tables with quarter(col1)
 
9659
-------------------------------------------------------------------------
 
9660
drop table if exists t11 ;
 
9661
drop table if exists t22 ;
 
9662
drop table if exists t33 ;
 
9663
drop table if exists t44 ;
 
9664
drop table if exists t55 ;
 
9665
drop table if exists t66 ;
 
9666
create table t11 engine='INNODB' as select * from t1;
 
9667
create table t22 engine='INNODB' as select * from t2;
 
9668
create table t33 engine='INNODB' as select * from t3;
 
9669
create table t44 engine='INNODB' as select * from t4;
 
9670
create table t55 engine='INNODB' as select * from t5;
 
9671
create table t66 engine='INNODB' as select * from t6;
 
9672
alter table t11
 
9673
partition by range(quarter(col1)) 
 
9674
(partition p0 values less than (15),
 
9675
partition p1 values less than maxvalue);
 
9676
alter table t22
 
9677
partition by list(quarter(col1)) 
 
9678
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
9679
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
9680
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
9681
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
9682
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
9683
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
9684
);
 
9685
alter table t33
 
9686
partition by hash(quarter(col1));
 
9687
alter table t44
 
9688
partition by range(colint) 
 
9689
subpartition by hash(quarter(col1)) subpartitions 2 
 
9690
(partition p0 values less than (15),
 
9691
partition p1 values less than maxvalue);
 
9692
alter table t55
 
9693
partition by list(colint)
 
9694
subpartition by hash(quarter(col1)) subpartitions 2 
 
9695
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
9696
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
9697
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
9698
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
9699
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
9700
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
9701
);
 
9702
alter table t66
 
9703
partition by range(colint) 
 
9704
(partition p0 values less than (quarter('2006-10-14')),
 
9705
partition p1 values less than maxvalue);
 
9706
select * from t11 order by col1;
 
9707
col1
 
9708
2006-07-30
 
9709
2006-12-17
 
9710
select * from t22 order by col1;
 
9711
col1
 
9712
2006-07-30
 
9713
2006-09-25
 
9714
2006-12-17
 
9715
select * from t33 order by col1;
 
9716
col1
 
9717
2006-07-30
 
9718
2006-09-25
 
9719
2006-12-17
 
9720
select * from t44 order by colint;
 
9721
colint  col1
 
9722
1       2006-02-03
 
9723
2       2006-01-17
 
9724
3       2006-01-25
 
9725
4       2006-02-05
 
9726
select * from t55 order by colint;
 
9727
colint  col1
 
9728
1       2006-02-03
 
9729
2       2006-01-17
 
9730
3       2006-01-25
 
9731
4       2006-02-05
 
9732
select * from t66 order by colint;
 
9733
colint  col1
 
9734
1       2006-02-03
 
9735
2       2006-01-17
 
9736
3       2006-01-25
 
9737
4       2006-02-05
 
9738
---------------------------
 
9739
---- some alter table begin
 
9740
---------------------------
 
9741
alter table t11
 
9742
reorganize partition p0,p1 into
 
9743
(partition s1 values less than maxvalue);
 
9744
select * from t11 order by col1;
 
9745
col1
 
9746
2006-07-30
 
9747
2006-12-17
 
9748
alter table t11
 
9749
reorganize partition s1 into
 
9750
(partition p0 values less than (15),
 
9751
partition p1 values less than maxvalue);
 
9752
select * from t11 order by col1;
 
9753
col1
 
9754
2006-07-30
 
9755
2006-12-17
 
9756
alter table t55
 
9757
partition by list(colint)
 
9758
subpartition by hash(quarter(col1)) subpartitions 5 
 
9759
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
9760
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
9761
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
9762
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
9763
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
9764
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
9765
);
 
9766
show create table t55;
 
9767
Table   Create Table
 
9768
t55     CREATE TABLE `t55` (
 
9769
  `colint` int(11) DEFAULT NULL,
 
9770
  `col1` date DEFAULT NULL
 
9771
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
9772
/*!50100 PARTITION BY LIST (colint)
 
9773
SUBPARTITION BY HASH (quarter(col1))
 
9774
SUBPARTITIONS 5
 
9775
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
9776
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
9777
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
9778
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
9779
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
9780
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
9781
select * from t55 order by colint;
 
9782
colint  col1
 
9783
1       2006-02-03
 
9784
2       2006-01-17
 
9785
3       2006-01-25
 
9786
4       2006-02-05
 
9787
alter table t66
 
9788
reorganize partition p0,p1 into
 
9789
(partition s1 values less than maxvalue);
 
9790
select * from t66 order by colint;
 
9791
colint  col1
 
9792
1       2006-02-03
 
9793
2       2006-01-17
 
9794
3       2006-01-25
 
9795
4       2006-02-05
 
9796
alter table t66
 
9797
reorganize partition s1 into
 
9798
(partition p0 values less than (quarter('2006-10-14')),
 
9799
partition p1 values less than maxvalue);
 
9800
select * from t66 order by colint;
 
9801
colint  col1
 
9802
1       2006-02-03
 
9803
2       2006-01-17
 
9804
3       2006-01-25
 
9805
4       2006-02-05
 
9806
alter table t66
 
9807
reorganize partition p0,p1 into
 
9808
(partition s1 values less than maxvalue);
 
9809
select * from t66 order by colint;
 
9810
colint  col1
 
9811
1       2006-02-03
 
9812
2       2006-01-17
 
9813
3       2006-01-25
 
9814
4       2006-02-05
 
9815
alter table t66
 
9816
reorganize partition s1 into
 
9817
(partition p0 values less than (quarter('2006-10-14')),
 
9818
partition p1 values less than maxvalue);
 
9819
select * from t66 order by colint;
 
9820
colint  col1
 
9821
1       2006-02-03
 
9822
2       2006-01-17
 
9823
3       2006-01-25
 
9824
4       2006-02-05
 
9825
-------------------------------------------------------------------------
 
9826
---  Delete rows and partitions of tables with quarter(col1)
 
9827
-------------------------------------------------------------------------
 
9828
delete from t1 where col1='2006-12-17';
 
9829
delete from t2 where col1='2006-12-17';
 
9830
delete from t3 where col1='2006-12-17';
 
9831
delete from t4 where col1='2006-12-17';
 
9832
delete from t5 where col1='2006-12-17';
 
9833
delete from t6 where col1='2006-12-17';
 
9834
select * from t1 order by col1;
 
9835
col1
 
9836
2006-07-30
 
9837
select * from t2 order by col1;
 
9838
col1
 
9839
2006-07-30
 
9840
2006-09-25
 
9841
select * from t3 order by col1;
 
9842
col1
 
9843
2006-07-30
 
9844
2006-09-25
 
9845
select * from t4 order by colint;
 
9846
colint  col1
 
9847
1       2006-02-03
 
9848
2       2006-01-17
 
9849
3       2006-01-25
 
9850
4       2006-02-05
 
9851
select * from t5 order by colint;
 
9852
colint  col1
 
9853
1       2006-02-03
 
9854
2       2006-01-17
 
9855
3       2006-01-25
 
9856
4       2006-02-05
 
9857
insert into t1 values ('2006-12-17');
 
9858
insert into t2 values ('2006-12-17');
 
9859
insert into t3 values ('2006-12-17');
 
9860
insert into t4 values (60,'2006-12-17');
 
9861
insert into t5 values (60,'2006-12-17');
 
9862
insert into t6 values (60,'2006-12-17');
 
9863
select * from t1 order by col1;
 
9864
col1
 
9865
2006-07-30
 
9866
2006-12-17
 
9867
select * from t2 order by col1;
 
9868
col1
 
9869
2006-07-30
 
9870
2006-09-25
 
9871
2006-12-17
 
9872
select * from t3 order by col1;
 
9873
col1
 
9874
2006-07-30
 
9875
2006-09-25
 
9876
2006-12-17
 
9877
select * from t4 order by colint;
 
9878
colint  col1
 
9879
1       2006-02-03
 
9880
2       2006-01-17
 
9881
3       2006-01-25
 
9882
4       2006-02-05
 
9883
60      2006-12-17
 
9884
select * from t5 order by colint;
 
9885
colint  col1
 
9886
1       2006-02-03
 
9887
2       2006-01-17
 
9888
3       2006-01-25
 
9889
4       2006-02-05
 
9890
60      2006-12-17
 
9891
select * from t6 order by colint;
 
9892
colint  col1
 
9893
1       2006-02-03
 
9894
2       2006-01-17
 
9895
3       2006-01-25
 
9896
4       2006-02-05
 
9897
60      2006-12-17
 
9898
alter table t1 drop partition p0;
 
9899
alter table t2 drop partition p0;
 
9900
alter table t4 drop partition p0;
 
9901
alter table t5 drop partition p0;
 
9902
alter table t6 drop partition p0;
 
9903
select * from t1 order by col1;
 
9904
col1
 
9905
select * from t2 order by col1;
 
9906
col1
 
9907
select * from t3 order by col1;
 
9908
col1
 
9909
2006-07-30
 
9910
2006-09-25
 
9911
2006-12-17
 
9912
select * from t4 order by colint;
 
9913
colint  col1
 
9914
60      2006-12-17
 
9915
select * from t5 order by colint;
 
9916
colint  col1
 
9917
60      2006-12-17
 
9918
select * from t6 order by colint;
 
9919
colint  col1
 
9920
4       2006-02-05
 
9921
60      2006-12-17
 
9922
-------------------------------------------------------------------------
 
9923
---  Delete rows and partitions of tables with quarter(col1)
 
9924
-------------------------------------------------------------------------
 
9925
delete from t11 where col1='2006-12-17';
 
9926
delete from t22 where col1='2006-12-17';
 
9927
delete from t33 where col1='2006-12-17';
 
9928
delete from t44 where col1='2006-12-17';
 
9929
delete from t55 where col1='2006-12-17';
 
9930
delete from t66 where col1='2006-12-17';
 
9931
select * from t11 order by col1;
 
9932
col1
 
9933
2006-07-30
 
9934
select * from t22 order by col1;
 
9935
col1
 
9936
2006-07-30
 
9937
2006-09-25
 
9938
select * from t33 order by col1;
 
9939
col1
 
9940
2006-07-30
 
9941
2006-09-25
 
9942
select * from t44 order by colint;
 
9943
colint  col1
 
9944
1       2006-02-03
 
9945
2       2006-01-17
 
9946
3       2006-01-25
 
9947
4       2006-02-05
 
9948
select * from t55 order by colint;
 
9949
colint  col1
 
9950
1       2006-02-03
 
9951
2       2006-01-17
 
9952
3       2006-01-25
 
9953
4       2006-02-05
 
9954
insert into t11 values ('2006-12-17');
 
9955
insert into t22 values ('2006-12-17');
 
9956
insert into t33 values ('2006-12-17');
 
9957
insert into t44 values (60,'2006-12-17');
 
9958
insert into t55 values (60,'2006-12-17');
 
9959
insert into t66 values (60,'2006-12-17');
 
9960
select * from t11 order by col1;
 
9961
col1
 
9962
2006-07-30
 
9963
2006-12-17
 
9964
select * from t22 order by col1;
 
9965
col1
 
9966
2006-07-30
 
9967
2006-09-25
 
9968
2006-12-17
 
9969
select * from t33 order by col1;
 
9970
col1
 
9971
2006-07-30
 
9972
2006-09-25
 
9973
2006-12-17
 
9974
select * from t44 order by colint;
 
9975
colint  col1
 
9976
1       2006-02-03
 
9977
2       2006-01-17
 
9978
3       2006-01-25
 
9979
4       2006-02-05
 
9980
60      2006-12-17
 
9981
select * from t55 order by colint;
 
9982
colint  col1
 
9983
1       2006-02-03
 
9984
2       2006-01-17
 
9985
3       2006-01-25
 
9986
4       2006-02-05
 
9987
60      2006-12-17
 
9988
select * from t66 order by colint;
 
9989
colint  col1
 
9990
1       2006-02-03
 
9991
2       2006-01-17
 
9992
3       2006-01-25
 
9993
4       2006-02-05
 
9994
60      2006-12-17
 
9995
alter table t11 drop partition p0;
 
9996
alter table t22 drop partition p0;
 
9997
alter table t44 drop partition p0;
 
9998
alter table t55 drop partition p0;
 
9999
alter table t66 drop partition p0;
 
10000
select * from t11 order by col1;
 
10001
col1
 
10002
select * from t22 order by col1;
 
10003
col1
 
10004
select * from t33 order by col1;
 
10005
col1
 
10006
2006-07-30
 
10007
2006-09-25
 
10008
2006-12-17
 
10009
select * from t44 order by colint;
 
10010
colint  col1
 
10011
60      2006-12-17
 
10012
select * from t55 order by colint;
 
10013
colint  col1
 
10014
60      2006-12-17
 
10015
select * from t66 order by colint;
 
10016
colint  col1
 
10017
4       2006-02-05
 
10018
60      2006-12-17
 
10019
-------------------------
 
10020
---- some alter table end
 
10021
-------------------------
 
10022
drop table if exists t1 ;
 
10023
drop table if exists t2 ;
 
10024
drop table if exists t3 ;
 
10025
drop table if exists t4 ;
 
10026
drop table if exists t5 ;
 
10027
drop table if exists t6 ;
 
10028
drop table if exists t11 ;
 
10029
drop table if exists t22 ;
 
10030
drop table if exists t33 ;
 
10031
drop table if exists t44 ;
 
10032
drop table if exists t55 ;
 
10033
drop table if exists t66 ;
 
10034
-------------------------------------------------------------------------
 
10035
---  time_to_sec(col1)-(time_to_sec(col1)-20)  in partition with coltype  time
 
10036
-------------------------------------------------------------------------
 
10037
drop table if exists t1 ;
 
10038
drop table if exists t2 ;
 
10039
drop table if exists t3 ;
 
10040
drop table if exists t4 ;
 
10041
drop table if exists t5 ;
 
10042
drop table if exists t6 ;
 
10043
-------------------------------------------------------------------------
 
10044
---  Create tables with time_to_sec(col1)-(time_to_sec(col1)-20)
 
10045
-------------------------------------------------------------------------
 
10046
create table t1 (col1 time) engine='INNODB' 
 
10047
partition by range(time_to_sec(col1)-(time_to_sec(col1)-20)) 
 
10048
(partition p0 values less than (15),
 
10049
partition p1 values less than maxvalue);
 
10050
create table t2 (col1 time) engine='INNODB' 
 
10051
partition by list(time_to_sec(col1)-(time_to_sec(col1)-20)) 
 
10052
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
10053
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
10054
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
10055
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
10056
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
10057
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
10058
);
 
10059
create table t3 (col1 time) engine='INNODB' 
 
10060
partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20));
 
10061
create table t4 (colint int, col1 time) engine='INNODB' 
 
10062
partition by range(colint) 
 
10063
subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 
 
10064
(partition p0 values less than (15),
 
10065
partition p1 values less than maxvalue);
 
10066
create table t5 (colint int, col1 time) engine='INNODB' 
 
10067
partition by list(colint)
 
10068
subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 
 
10069
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
10070
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
10071
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
10072
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
10073
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
10074
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
10075
);
 
10076
create table t6 (colint int, col1 time) engine='INNODB' 
 
10077
partition by range(colint) 
 
10078
(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))),
 
10079
partition p1 values less than maxvalue);
 
10080
-------------------------------------------------------------------------
 
10081
---  Access tables with time_to_sec(col1)-(time_to_sec(col1)-20) 
 
10082
-------------------------------------------------------------------------
 
10083
insert into t1 values ('09:09:15');
 
10084
insert into t1 values ('14:30:45');
 
10085
insert into t2 values ('09:09:15');
 
10086
insert into t2 values ('14:30:45');
 
10087
insert into t2 values ('21:59:22');
 
10088
insert into t3 values ('09:09:15');
 
10089
insert into t3 values ('14:30:45');
 
10090
insert into t3 values ('21:59:22');
 
10091
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4;
 
10092
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5;
 
10093
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6;
 
10094
select time_to_sec(col1)-(time_to_sec(col1)-20) from t1 order by col1;
 
10095
time_to_sec(col1)-(time_to_sec(col1)-20)
 
10096
20
 
10097
20
 
10098
select * from t1 order by col1;
 
10099
col1
 
10100
09:09:15
 
10101
14:30:45
 
10102
select * from t2 order by col1;
 
10103
col1
 
10104
09:09:15
 
10105
14:30:45
 
10106
21:59:22
 
10107
select * from t3 order by col1;
 
10108
col1
 
10109
09:09:15
 
10110
14:30:45
 
10111
21:59:22
 
10112
select * from t4 order by colint;
 
10113
colint  col1
 
10114
1       09:09:15
 
10115
2       04:30:01
 
10116
3       00:59:22
 
10117
4       05:30:34
 
10118
select * from t5 order by colint;
 
10119
colint  col1
 
10120
1       09:09:15
 
10121
2       04:30:01
 
10122
3       00:59:22
 
10123
4       05:30:34
 
10124
select * from t6 order by colint;
 
10125
colint  col1
 
10126
1       09:09:15
 
10127
2       04:30:01
 
10128
3       00:59:22
 
10129
4       05:30:34
 
10130
update t1 set col1='10:33:11' where col1='09:09:15';
 
10131
update t2 set col1='10:33:11' where col1='09:09:15';
 
10132
update t3 set col1='10:33:11' where col1='09:09:15';
 
10133
update t4 set col1='10:33:11' where col1='09:09:15';
 
10134
update t5 set col1='10:33:11' where col1='09:09:15';
 
10135
update t6 set col1='10:33:11' where col1='09:09:15';
 
10136
select * from t1 order by col1;
 
10137
col1
 
10138
10:33:11
 
10139
14:30:45
 
10140
select * from t2 order by col1;
 
10141
col1
 
10142
10:33:11
 
10143
14:30:45
 
10144
21:59:22
 
10145
select * from t3 order by col1;
 
10146
col1
 
10147
10:33:11
 
10148
14:30:45
 
10149
21:59:22
 
10150
select * from t4 order by colint;
 
10151
colint  col1
 
10152
1       10:33:11
 
10153
2       04:30:01
 
10154
3       00:59:22
 
10155
4       05:30:34
 
10156
select * from t5 order by colint;
 
10157
colint  col1
 
10158
1       10:33:11
 
10159
2       04:30:01
 
10160
3       00:59:22
 
10161
4       05:30:34
 
10162
select * from t6 order by colint;
 
10163
colint  col1
 
10164
1       10:33:11
 
10165
2       04:30:01
 
10166
3       00:59:22
 
10167
4       05:30:34
 
10168
-------------------------------------------------------------------------
 
10169
---  Alter tables with time_to_sec(col1)-(time_to_sec(col1)-20)
 
10170
-------------------------------------------------------------------------
 
10171
drop table if exists t11 ;
 
10172
drop table if exists t22 ;
 
10173
drop table if exists t33 ;
 
10174
drop table if exists t44 ;
 
10175
drop table if exists t55 ;
 
10176
drop table if exists t66 ;
 
10177
create table t11 engine='INNODB' as select * from t1;
 
10178
create table t22 engine='INNODB' as select * from t2;
 
10179
create table t33 engine='INNODB' as select * from t3;
 
10180
create table t44 engine='INNODB' as select * from t4;
 
10181
create table t55 engine='INNODB' as select * from t5;
 
10182
create table t66 engine='INNODB' as select * from t6;
 
10183
alter table t11
 
10184
partition by range(time_to_sec(col1)-(time_to_sec(col1)-20)) 
 
10185
(partition p0 values less than (15),
 
10186
partition p1 values less than maxvalue);
 
10187
alter table t22
 
10188
partition by list(time_to_sec(col1)-(time_to_sec(col1)-20)) 
 
10189
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
10190
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
10191
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
10192
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
10193
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
10194
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
10195
);
 
10196
alter table t33
 
10197
partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20));
 
10198
alter table t44
 
10199
partition by range(colint) 
 
10200
subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 
 
10201
(partition p0 values less than (15),
 
10202
partition p1 values less than maxvalue);
 
10203
alter table t55
 
10204
partition by list(colint)
 
10205
subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 
 
10206
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
10207
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
10208
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
10209
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
10210
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
10211
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
10212
);
 
10213
alter table t66
 
10214
partition by range(colint) 
 
10215
(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))),
 
10216
partition p1 values less than maxvalue);
 
10217
select * from t11 order by col1;
 
10218
col1
 
10219
10:33:11
 
10220
14:30:45
 
10221
select * from t22 order by col1;
 
10222
col1
 
10223
10:33:11
 
10224
14:30:45
 
10225
21:59:22
 
10226
select * from t33 order by col1;
 
10227
col1
 
10228
10:33:11
 
10229
14:30:45
 
10230
21:59:22
 
10231
select * from t44 order by colint;
 
10232
colint  col1
 
10233
1       10:33:11
 
10234
2       04:30:01
 
10235
3       00:59:22
 
10236
4       05:30:34
 
10237
select * from t55 order by colint;
 
10238
colint  col1
 
10239
1       10:33:11
 
10240
2       04:30:01
 
10241
3       00:59:22
 
10242
4       05:30:34
 
10243
select * from t66 order by colint;
 
10244
colint  col1
 
10245
1       10:33:11
 
10246
2       04:30:01
 
10247
3       00:59:22
 
10248
4       05:30:34
 
10249
---------------------------
 
10250
---- some alter table begin
 
10251
---------------------------
 
10252
alter table t11
 
10253
reorganize partition p0,p1 into
 
10254
(partition s1 values less than maxvalue);
 
10255
select * from t11 order by col1;
 
10256
col1
 
10257
10:33:11
 
10258
14:30:45
 
10259
alter table t11
 
10260
reorganize partition s1 into
 
10261
(partition p0 values less than (15),
 
10262
partition p1 values less than maxvalue);
 
10263
select * from t11 order by col1;
 
10264
col1
 
10265
10:33:11
 
10266
14:30:45
 
10267
alter table t55
 
10268
partition by list(colint)
 
10269
subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 5 
 
10270
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
10271
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
10272
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
10273
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
10274
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
10275
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
10276
);
 
10277
show create table t55;
 
10278
Table   Create Table
 
10279
t55     CREATE TABLE `t55` (
 
10280
  `colint` int(11) DEFAULT NULL,
 
10281
  `col1` time DEFAULT NULL
 
10282
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
10283
/*!50100 PARTITION BY LIST (colint)
 
10284
SUBPARTITION BY HASH (time_to_sec(col1)-(time_to_sec(col1)-20))
 
10285
SUBPARTITIONS 5
 
10286
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
10287
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
10288
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
10289
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
10290
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
10291
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
10292
select * from t55 order by colint;
 
10293
colint  col1
 
10294
1       10:33:11
 
10295
2       04:30:01
 
10296
3       00:59:22
 
10297
4       05:30:34
 
10298
alter table t66
 
10299
reorganize partition p0,p1 into
 
10300
(partition s1 values less than maxvalue);
 
10301
select * from t66 order by colint;
 
10302
colint  col1
 
10303
1       10:33:11
 
10304
2       04:30:01
 
10305
3       00:59:22
 
10306
4       05:30:34
 
10307
alter table t66
 
10308
reorganize partition s1 into
 
10309
(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))),
 
10310
partition p1 values less than maxvalue);
 
10311
select * from t66 order by colint;
 
10312
colint  col1
 
10313
1       10:33:11
 
10314
2       04:30:01
 
10315
3       00:59:22
 
10316
4       05:30:34
 
10317
alter table t66
 
10318
reorganize partition p0,p1 into
 
10319
(partition s1 values less than maxvalue);
 
10320
select * from t66 order by colint;
 
10321
colint  col1
 
10322
1       10:33:11
 
10323
2       04:30:01
 
10324
3       00:59:22
 
10325
4       05:30:34
 
10326
alter table t66
 
10327
reorganize partition s1 into
 
10328
(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))),
 
10329
partition p1 values less than maxvalue);
 
10330
select * from t66 order by colint;
 
10331
colint  col1
 
10332
1       10:33:11
 
10333
2       04:30:01
 
10334
3       00:59:22
 
10335
4       05:30:34
 
10336
-------------------------------------------------------------------------
 
10337
---  Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20)
 
10338
-------------------------------------------------------------------------
 
10339
delete from t1 where col1='14:30:45';
 
10340
delete from t2 where col1='14:30:45';
 
10341
delete from t3 where col1='14:30:45';
 
10342
delete from t4 where col1='14:30:45';
 
10343
delete from t5 where col1='14:30:45';
 
10344
delete from t6 where col1='14:30:45';
 
10345
select * from t1 order by col1;
 
10346
col1
 
10347
10:33:11
 
10348
select * from t2 order by col1;
 
10349
col1
 
10350
10:33:11
 
10351
21:59:22
 
10352
select * from t3 order by col1;
 
10353
col1
 
10354
10:33:11
 
10355
21:59:22
 
10356
select * from t4 order by colint;
 
10357
colint  col1
 
10358
1       10:33:11
 
10359
2       04:30:01
 
10360
3       00:59:22
 
10361
4       05:30:34
 
10362
select * from t5 order by colint;
 
10363
colint  col1
 
10364
1       10:33:11
 
10365
2       04:30:01
 
10366
3       00:59:22
 
10367
4       05:30:34
 
10368
insert into t1 values ('14:30:45');
 
10369
insert into t2 values ('14:30:45');
 
10370
insert into t3 values ('14:30:45');
 
10371
insert into t4 values (60,'14:30:45');
 
10372
insert into t5 values (60,'14:30:45');
 
10373
insert into t6 values (60,'14:30:45');
 
10374
select * from t1 order by col1;
 
10375
col1
 
10376
10:33:11
 
10377
14:30:45
 
10378
select * from t2 order by col1;
 
10379
col1
 
10380
10:33:11
 
10381
14:30:45
 
10382
21:59:22
 
10383
select * from t3 order by col1;
 
10384
col1
 
10385
10:33:11
 
10386
14:30:45
 
10387
21:59:22
 
10388
select * from t4 order by colint;
 
10389
colint  col1
 
10390
1       10:33:11
 
10391
2       04:30:01
 
10392
3       00:59:22
 
10393
4       05:30:34
 
10394
60      14:30:45
 
10395
select * from t5 order by colint;
 
10396
colint  col1
 
10397
1       10:33:11
 
10398
2       04:30:01
 
10399
3       00:59:22
 
10400
4       05:30:34
 
10401
60      14:30:45
 
10402
select * from t6 order by colint;
 
10403
colint  col1
 
10404
1       10:33:11
 
10405
2       04:30:01
 
10406
3       00:59:22
 
10407
4       05:30:34
 
10408
60      14:30:45
 
10409
alter table t1 drop partition p0;
 
10410
alter table t2 drop partition p0;
 
10411
alter table t4 drop partition p0;
 
10412
alter table t5 drop partition p0;
 
10413
alter table t6 drop partition p0;
 
10414
select * from t1 order by col1;
 
10415
col1
 
10416
10:33:11
 
10417
14:30:45
 
10418
select * from t2 order by col1;
 
10419
col1
 
10420
10:33:11
 
10421
14:30:45
 
10422
21:59:22
 
10423
select * from t3 order by col1;
 
10424
col1
 
10425
10:33:11
 
10426
14:30:45
 
10427
21:59:22
 
10428
select * from t4 order by colint;
 
10429
colint  col1
 
10430
60      14:30:45
 
10431
select * from t5 order by colint;
 
10432
colint  col1
 
10433
60      14:30:45
 
10434
select * from t6 order by colint;
 
10435
colint  col1
 
10436
-------------------------------------------------------------------------
 
10437
---  Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20)
 
10438
-------------------------------------------------------------------------
 
10439
delete from t11 where col1='14:30:45';
 
10440
delete from t22 where col1='14:30:45';
 
10441
delete from t33 where col1='14:30:45';
 
10442
delete from t44 where col1='14:30:45';
 
10443
delete from t55 where col1='14:30:45';
 
10444
delete from t66 where col1='14:30:45';
 
10445
select * from t11 order by col1;
 
10446
col1
 
10447
10:33:11
 
10448
select * from t22 order by col1;
 
10449
col1
 
10450
10:33:11
 
10451
21:59:22
 
10452
select * from t33 order by col1;
 
10453
col1
 
10454
10:33:11
 
10455
21:59:22
 
10456
select * from t44 order by colint;
 
10457
colint  col1
 
10458
1       10:33:11
 
10459
2       04:30:01
 
10460
3       00:59:22
 
10461
4       05:30:34
 
10462
select * from t55 order by colint;
 
10463
colint  col1
 
10464
1       10:33:11
 
10465
2       04:30:01
 
10466
3       00:59:22
 
10467
4       05:30:34
 
10468
insert into t11 values ('14:30:45');
 
10469
insert into t22 values ('14:30:45');
 
10470
insert into t33 values ('14:30:45');
 
10471
insert into t44 values (60,'14:30:45');
 
10472
insert into t55 values (60,'14:30:45');
 
10473
insert into t66 values (60,'14:30:45');
 
10474
select * from t11 order by col1;
 
10475
col1
 
10476
10:33:11
 
10477
14:30:45
 
10478
select * from t22 order by col1;
 
10479
col1
 
10480
10:33:11
 
10481
14:30:45
 
10482
21:59:22
 
10483
select * from t33 order by col1;
 
10484
col1
 
10485
10:33:11
 
10486
14:30:45
 
10487
21:59:22
 
10488
select * from t44 order by colint;
 
10489
colint  col1
 
10490
1       10:33:11
 
10491
2       04:30:01
 
10492
3       00:59:22
 
10493
4       05:30:34
 
10494
60      14:30:45
 
10495
select * from t55 order by colint;
 
10496
colint  col1
 
10497
1       10:33:11
 
10498
2       04:30:01
 
10499
3       00:59:22
 
10500
4       05:30:34
 
10501
60      14:30:45
 
10502
select * from t66 order by colint;
 
10503
colint  col1
 
10504
1       10:33:11
 
10505
2       04:30:01
 
10506
3       00:59:22
 
10507
4       05:30:34
 
10508
60      14:30:45
 
10509
alter table t11 drop partition p0;
 
10510
alter table t22 drop partition p0;
 
10511
alter table t44 drop partition p0;
 
10512
alter table t55 drop partition p0;
 
10513
alter table t66 drop partition p0;
 
10514
select * from t11 order by col1;
 
10515
col1
 
10516
10:33:11
 
10517
14:30:45
 
10518
select * from t22 order by col1;
 
10519
col1
 
10520
10:33:11
 
10521
14:30:45
 
10522
21:59:22
 
10523
select * from t33 order by col1;
 
10524
col1
 
10525
10:33:11
 
10526
14:30:45
 
10527
21:59:22
 
10528
select * from t44 order by colint;
 
10529
colint  col1
 
10530
60      14:30:45
 
10531
select * from t55 order by colint;
 
10532
colint  col1
 
10533
60      14:30:45
 
10534
select * from t66 order by colint;
 
10535
colint  col1
 
10536
-------------------------
 
10537
---- some alter table end
 
10538
-------------------------
 
10539
drop table if exists t1 ;
 
10540
drop table if exists t2 ;
 
10541
drop table if exists t3 ;
 
10542
drop table if exists t4 ;
 
10543
drop table if exists t5 ;
 
10544
drop table if exists t6 ;
 
10545
drop table if exists t11 ;
 
10546
drop table if exists t22 ;
 
10547
drop table if exists t33 ;
 
10548
drop table if exists t44 ;
 
10549
drop table if exists t55 ;
 
10550
drop table if exists t66 ;
 
10551
-------------------------------------------------------------------------
 
10552
---  to_days(col1)-to_days('2006-01-01')  in partition with coltype  date
 
10553
-------------------------------------------------------------------------
 
10554
drop table if exists t1 ;
 
10555
drop table if exists t2 ;
 
10556
drop table if exists t3 ;
 
10557
drop table if exists t4 ;
 
10558
drop table if exists t5 ;
 
10559
drop table if exists t6 ;
 
10560
-------------------------------------------------------------------------
 
10561
---  Create tables with to_days(col1)-to_days('2006-01-01')
 
10562
-------------------------------------------------------------------------
 
10563
create table t1 (col1 date) engine='INNODB' 
 
10564
partition by range(to_days(col1)-to_days('2006-01-01')) 
 
10565
(partition p0 values less than (15),
 
10566
partition p1 values less than maxvalue);
 
10567
create table t2 (col1 date) engine='INNODB' 
 
10568
partition by list(to_days(col1)-to_days('2006-01-01')) 
 
10569
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
10570
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
10571
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
10572
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
10573
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
10574
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
10575
);
 
10576
create table t3 (col1 date) engine='INNODB' 
 
10577
partition by hash(to_days(col1)-to_days('2006-01-01'));
 
10578
create table t4 (colint int, col1 date) engine='INNODB' 
 
10579
partition by range(colint) 
 
10580
subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 2 
 
10581
(partition p0 values less than (15),
 
10582
partition p1 values less than maxvalue);
 
10583
create table t5 (colint int, col1 date) engine='INNODB' 
 
10584
partition by list(colint)
 
10585
subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 2 
 
10586
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
10587
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
10588
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
10589
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
10590
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
10591
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
10592
);
 
10593
create table t6 (colint int, col1 date) engine='INNODB' 
 
10594
partition by range(colint) 
 
10595
(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')),
 
10596
partition p1 values less than maxvalue);
 
10597
-------------------------------------------------------------------------
 
10598
---  Access tables with to_days(col1)-to_days('2006-01-01') 
 
10599
-------------------------------------------------------------------------
 
10600
insert into t1 values ('2006-02-03');
 
10601
insert into t1 values ('2006-01-17');
 
10602
insert into t2 values ('2006-02-03');
 
10603
insert into t2 values ('2006-01-17');
 
10604
insert into t2 values ('2006-01-25');
 
10605
insert into t3 values ('2006-02-03');
 
10606
insert into t3 values ('2006-01-17');
 
10607
insert into t3 values ('2006-01-25');
 
10608
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
 
10609
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
 
10610
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
 
10611
select to_days(col1)-to_days('2006-01-01') from t1 order by col1;
 
10612
to_days(col1)-to_days('2006-01-01')
 
10613
16
 
10614
33
 
10615
select * from t1 order by col1;
 
10616
col1
 
10617
2006-01-17
 
10618
2006-02-03
 
10619
select * from t2 order by col1;
 
10620
col1
 
10621
2006-01-17
 
10622
2006-01-25
 
10623
2006-02-03
 
10624
select * from t3 order by col1;
 
10625
col1
 
10626
2006-01-17
 
10627
2006-01-25
 
10628
2006-02-03
 
10629
select * from t4 order by colint;
 
10630
colint  col1
 
10631
1       2006-02-03
 
10632
2       2006-01-17
 
10633
3       2006-01-25
 
10634
4       2006-02-05
 
10635
select * from t5 order by colint;
 
10636
colint  col1
 
10637
1       2006-02-03
 
10638
2       2006-01-17
 
10639
3       2006-01-25
 
10640
4       2006-02-05
 
10641
select * from t6 order by colint;
 
10642
colint  col1
 
10643
1       2006-02-03
 
10644
2       2006-01-17
 
10645
3       2006-01-25
 
10646
4       2006-02-05
 
10647
update t1 set col1='2006-02-06' where col1='2006-02-03';
 
10648
update t2 set col1='2006-02-06' where col1='2006-02-03';
 
10649
update t3 set col1='2006-02-06' where col1='2006-02-03';
 
10650
update t4 set col1='2006-02-06' where col1='2006-02-03';
 
10651
update t5 set col1='2006-02-06' where col1='2006-02-03';
 
10652
update t6 set col1='2006-02-06' where col1='2006-02-03';
 
10653
select * from t1 order by col1;
 
10654
col1
 
10655
2006-01-17
 
10656
2006-02-06
 
10657
select * from t2 order by col1;
 
10658
col1
 
10659
2006-01-17
 
10660
2006-01-25
 
10661
2006-02-06
 
10662
select * from t3 order by col1;
 
10663
col1
 
10664
2006-01-17
 
10665
2006-01-25
 
10666
2006-02-06
 
10667
select * from t4 order by colint;
 
10668
colint  col1
 
10669
1       2006-02-06
 
10670
2       2006-01-17
 
10671
3       2006-01-25
 
10672
4       2006-02-05
 
10673
select * from t5 order by colint;
 
10674
colint  col1
 
10675
1       2006-02-06
 
10676
2       2006-01-17
 
10677
3       2006-01-25
 
10678
4       2006-02-05
 
10679
select * from t6 order by colint;
 
10680
colint  col1
 
10681
1       2006-02-06
 
10682
2       2006-01-17
 
10683
3       2006-01-25
 
10684
4       2006-02-05
 
10685
-------------------------------------------------------------------------
 
10686
---  Alter tables with to_days(col1)-to_days('2006-01-01')
 
10687
-------------------------------------------------------------------------
 
10688
drop table if exists t11 ;
 
10689
drop table if exists t22 ;
 
10690
drop table if exists t33 ;
 
10691
drop table if exists t44 ;
 
10692
drop table if exists t55 ;
 
10693
drop table if exists t66 ;
 
10694
create table t11 engine='INNODB' as select * from t1;
 
10695
create table t22 engine='INNODB' as select * from t2;
 
10696
create table t33 engine='INNODB' as select * from t3;
 
10697
create table t44 engine='INNODB' as select * from t4;
 
10698
create table t55 engine='INNODB' as select * from t5;
 
10699
create table t66 engine='INNODB' as select * from t6;
 
10700
alter table t11
 
10701
partition by range(to_days(col1)-to_days('2006-01-01')) 
 
10702
(partition p0 values less than (15),
 
10703
partition p1 values less than maxvalue);
 
10704
alter table t22
 
10705
partition by list(to_days(col1)-to_days('2006-01-01')) 
 
10706
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
10707
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
10708
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
10709
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
10710
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
10711
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
10712
);
 
10713
alter table t33
 
10714
partition by hash(to_days(col1)-to_days('2006-01-01'));
 
10715
alter table t44
 
10716
partition by range(colint) 
 
10717
subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 2 
 
10718
(partition p0 values less than (15),
 
10719
partition p1 values less than maxvalue);
 
10720
alter table t55
 
10721
partition by list(colint)
 
10722
subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 2 
 
10723
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
10724
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
10725
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
10726
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
10727
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
10728
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
10729
);
 
10730
alter table t66
 
10731
partition by range(colint) 
 
10732
(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')),
 
10733
partition p1 values less than maxvalue);
 
10734
select * from t11 order by col1;
 
10735
col1
 
10736
2006-01-17
 
10737
2006-02-06
 
10738
select * from t22 order by col1;
 
10739
col1
 
10740
2006-01-17
 
10741
2006-01-25
 
10742
2006-02-06
 
10743
select * from t33 order by col1;
 
10744
col1
 
10745
2006-01-17
 
10746
2006-01-25
 
10747
2006-02-06
 
10748
select * from t44 order by colint;
 
10749
colint  col1
 
10750
1       2006-02-06
 
10751
2       2006-01-17
 
10752
3       2006-01-25
 
10753
4       2006-02-05
 
10754
select * from t55 order by colint;
 
10755
colint  col1
 
10756
1       2006-02-06
 
10757
2       2006-01-17
 
10758
3       2006-01-25
 
10759
4       2006-02-05
 
10760
select * from t66 order by colint;
 
10761
colint  col1
 
10762
1       2006-02-06
 
10763
2       2006-01-17
 
10764
3       2006-01-25
 
10765
4       2006-02-05
 
10766
---------------------------
 
10767
---- some alter table begin
 
10768
---------------------------
 
10769
alter table t11
 
10770
reorganize partition p0,p1 into
 
10771
(partition s1 values less than maxvalue);
 
10772
select * from t11 order by col1;
 
10773
col1
 
10774
2006-01-17
 
10775
2006-02-06
 
10776
alter table t11
 
10777
reorganize partition s1 into
 
10778
(partition p0 values less than (15),
 
10779
partition p1 values less than maxvalue);
 
10780
select * from t11 order by col1;
 
10781
col1
 
10782
2006-01-17
 
10783
2006-02-06
 
10784
alter table t55
 
10785
partition by list(colint)
 
10786
subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 5 
 
10787
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
10788
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
10789
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
10790
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
10791
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
10792
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
10793
);
 
10794
show create table t55;
 
10795
Table   Create Table
 
10796
t55     CREATE TABLE `t55` (
 
10797
  `colint` int(11) DEFAULT NULL,
 
10798
  `col1` date DEFAULT NULL
 
10799
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
10800
/*!50100 PARTITION BY LIST (colint)
 
10801
SUBPARTITION BY HASH (to_days(col1)-to_days('2006-01-01'))
 
10802
SUBPARTITIONS 5
 
10803
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
10804
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
10805
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
10806
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
10807
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
10808
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
10809
select * from t55 order by colint;
 
10810
colint  col1
 
10811
1       2006-02-06
 
10812
2       2006-01-17
 
10813
3       2006-01-25
 
10814
4       2006-02-05
 
10815
alter table t66
 
10816
reorganize partition p0,p1 into
 
10817
(partition s1 values less than maxvalue);
 
10818
select * from t66 order by colint;
 
10819
colint  col1
 
10820
1       2006-02-06
 
10821
2       2006-01-17
 
10822
3       2006-01-25
 
10823
4       2006-02-05
 
10824
alter table t66
 
10825
reorganize partition s1 into
 
10826
(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')),
 
10827
partition p1 values less than maxvalue);
 
10828
select * from t66 order by colint;
 
10829
colint  col1
 
10830
1       2006-02-06
 
10831
2       2006-01-17
 
10832
3       2006-01-25
 
10833
4       2006-02-05
 
10834
alter table t66
 
10835
reorganize partition p0,p1 into
 
10836
(partition s1 values less than maxvalue);
 
10837
select * from t66 order by colint;
 
10838
colint  col1
 
10839
1       2006-02-06
 
10840
2       2006-01-17
 
10841
3       2006-01-25
 
10842
4       2006-02-05
 
10843
alter table t66
 
10844
reorganize partition s1 into
 
10845
(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')),
 
10846
partition p1 values less than maxvalue);
 
10847
select * from t66 order by colint;
 
10848
colint  col1
 
10849
1       2006-02-06
 
10850
2       2006-01-17
 
10851
3       2006-01-25
 
10852
4       2006-02-05
 
10853
-------------------------------------------------------------------------
 
10854
---  Delete rows and partitions of tables with to_days(col1)-to_days('2006-01-01')
 
10855
-------------------------------------------------------------------------
 
10856
delete from t1 where col1='2006-01-17';
 
10857
delete from t2 where col1='2006-01-17';
 
10858
delete from t3 where col1='2006-01-17';
 
10859
delete from t4 where col1='2006-01-17';
 
10860
delete from t5 where col1='2006-01-17';
 
10861
delete from t6 where col1='2006-01-17';
 
10862
select * from t1 order by col1;
 
10863
col1
 
10864
2006-02-06
 
10865
select * from t2 order by col1;
 
10866
col1
 
10867
2006-01-25
 
10868
2006-02-06
 
10869
select * from t3 order by col1;
 
10870
col1
 
10871
2006-01-25
 
10872
2006-02-06
 
10873
select * from t4 order by colint;
 
10874
colint  col1
 
10875
1       2006-02-06
 
10876
3       2006-01-25
 
10877
4       2006-02-05
 
10878
select * from t5 order by colint;
 
10879
colint  col1
 
10880
1       2006-02-06
 
10881
3       2006-01-25
 
10882
4       2006-02-05
 
10883
insert into t1 values ('2006-01-17');
 
10884
insert into t2 values ('2006-01-17');
 
10885
insert into t3 values ('2006-01-17');
 
10886
insert into t4 values (60,'2006-01-17');
 
10887
insert into t5 values (60,'2006-01-17');
 
10888
insert into t6 values (60,'2006-01-17');
 
10889
select * from t1 order by col1;
 
10890
col1
 
10891
2006-01-17
 
10892
2006-02-06
 
10893
select * from t2 order by col1;
 
10894
col1
 
10895
2006-01-17
 
10896
2006-01-25
 
10897
2006-02-06
 
10898
select * from t3 order by col1;
 
10899
col1
 
10900
2006-01-17
 
10901
2006-01-25
 
10902
2006-02-06
 
10903
select * from t4 order by colint;
 
10904
colint  col1
 
10905
1       2006-02-06
 
10906
3       2006-01-25
 
10907
4       2006-02-05
 
10908
60      2006-01-17
 
10909
select * from t5 order by colint;
 
10910
colint  col1
 
10911
1       2006-02-06
 
10912
3       2006-01-25
 
10913
4       2006-02-05
 
10914
60      2006-01-17
 
10915
select * from t6 order by colint;
 
10916
colint  col1
 
10917
1       2006-02-06
 
10918
3       2006-01-25
 
10919
4       2006-02-05
 
10920
60      2006-01-17
 
10921
alter table t1 drop partition p0;
 
10922
alter table t2 drop partition p0;
 
10923
alter table t4 drop partition p0;
 
10924
alter table t5 drop partition p0;
 
10925
alter table t6 drop partition p0;
 
10926
select * from t1 order by col1;
 
10927
col1
 
10928
2006-01-17
 
10929
2006-02-06
 
10930
select * from t2 order by col1;
 
10931
col1
 
10932
2006-01-17
 
10933
2006-01-25
 
10934
2006-02-06
 
10935
select * from t3 order by col1;
 
10936
col1
 
10937
2006-01-17
 
10938
2006-01-25
 
10939
2006-02-06
 
10940
select * from t4 order by colint;
 
10941
colint  col1
 
10942
60      2006-01-17
 
10943
select * from t5 order by colint;
 
10944
colint  col1
 
10945
60      2006-01-17
 
10946
select * from t6 order by colint;
 
10947
colint  col1
 
10948
60      2006-01-17
 
10949
-------------------------------------------------------------------------
 
10950
---  Delete rows and partitions of tables with to_days(col1)-to_days('2006-01-01')
 
10951
-------------------------------------------------------------------------
 
10952
delete from t11 where col1='2006-01-17';
 
10953
delete from t22 where col1='2006-01-17';
 
10954
delete from t33 where col1='2006-01-17';
 
10955
delete from t44 where col1='2006-01-17';
 
10956
delete from t55 where col1='2006-01-17';
 
10957
delete from t66 where col1='2006-01-17';
 
10958
select * from t11 order by col1;
 
10959
col1
 
10960
2006-02-06
 
10961
select * from t22 order by col1;
 
10962
col1
 
10963
2006-01-25
 
10964
2006-02-06
 
10965
select * from t33 order by col1;
 
10966
col1
 
10967
2006-01-25
 
10968
2006-02-06
 
10969
select * from t44 order by colint;
 
10970
colint  col1
 
10971
1       2006-02-06
 
10972
3       2006-01-25
 
10973
4       2006-02-05
 
10974
select * from t55 order by colint;
 
10975
colint  col1
 
10976
1       2006-02-06
 
10977
3       2006-01-25
 
10978
4       2006-02-05
 
10979
insert into t11 values ('2006-01-17');
 
10980
insert into t22 values ('2006-01-17');
 
10981
insert into t33 values ('2006-01-17');
 
10982
insert into t44 values (60,'2006-01-17');
 
10983
insert into t55 values (60,'2006-01-17');
 
10984
insert into t66 values (60,'2006-01-17');
 
10985
select * from t11 order by col1;
 
10986
col1
 
10987
2006-01-17
 
10988
2006-02-06
 
10989
select * from t22 order by col1;
 
10990
col1
 
10991
2006-01-17
 
10992
2006-01-25
 
10993
2006-02-06
 
10994
select * from t33 order by col1;
 
10995
col1
 
10996
2006-01-17
 
10997
2006-01-25
 
10998
2006-02-06
 
10999
select * from t44 order by colint;
 
11000
colint  col1
 
11001
1       2006-02-06
 
11002
3       2006-01-25
 
11003
4       2006-02-05
 
11004
60      2006-01-17
 
11005
select * from t55 order by colint;
 
11006
colint  col1
 
11007
1       2006-02-06
 
11008
3       2006-01-25
 
11009
4       2006-02-05
 
11010
60      2006-01-17
 
11011
select * from t66 order by colint;
 
11012
colint  col1
 
11013
1       2006-02-06
 
11014
3       2006-01-25
 
11015
4       2006-02-05
 
11016
60      2006-01-17
 
11017
alter table t11 drop partition p0;
 
11018
alter table t22 drop partition p0;
 
11019
alter table t44 drop partition p0;
 
11020
alter table t55 drop partition p0;
 
11021
alter table t66 drop partition p0;
 
11022
select * from t11 order by col1;
 
11023
col1
 
11024
2006-01-17
 
11025
2006-02-06
 
11026
select * from t22 order by col1;
 
11027
col1
 
11028
2006-01-17
 
11029
2006-01-25
 
11030
2006-02-06
 
11031
select * from t33 order by col1;
 
11032
col1
 
11033
2006-01-17
 
11034
2006-01-25
 
11035
2006-02-06
 
11036
select * from t44 order by colint;
 
11037
colint  col1
 
11038
60      2006-01-17
 
11039
select * from t55 order by colint;
 
11040
colint  col1
 
11041
60      2006-01-17
 
11042
select * from t66 order by colint;
 
11043
colint  col1
 
11044
60      2006-01-17
 
11045
-------------------------
 
11046
---- some alter table end
 
11047
-------------------------
 
11048
drop table if exists t1 ;
 
11049
drop table if exists t2 ;
 
11050
drop table if exists t3 ;
 
11051
drop table if exists t4 ;
 
11052
drop table if exists t5 ;
 
11053
drop table if exists t6 ;
 
11054
drop table if exists t11 ;
 
11055
drop table if exists t22 ;
 
11056
drop table if exists t33 ;
 
11057
drop table if exists t44 ;
 
11058
drop table if exists t55 ;
 
11059
drop table if exists t66 ;
 
11060
-------------------------------------------------------------------------
 
11061
---  datediff(col1, '2006-01-01')  in partition with coltype  date
 
11062
-------------------------------------------------------------------------
 
11063
drop table if exists t1 ;
 
11064
drop table if exists t2 ;
 
11065
drop table if exists t3 ;
 
11066
drop table if exists t4 ;
 
11067
drop table if exists t5 ;
 
11068
drop table if exists t6 ;
 
11069
-------------------------------------------------------------------------
 
11070
---  Create tables with datediff(col1, '2006-01-01')
 
11071
-------------------------------------------------------------------------
 
11072
create table t1 (col1 date) engine='INNODB' 
 
11073
partition by range(datediff(col1, '2006-01-01')) 
 
11074
(partition p0 values less than (15),
 
11075
partition p1 values less than maxvalue);
 
11076
create table t2 (col1 date) engine='INNODB' 
 
11077
partition by list(datediff(col1, '2006-01-01')) 
 
11078
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
11079
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
11080
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
11081
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
11082
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
11083
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
11084
);
 
11085
create table t3 (col1 date) engine='INNODB' 
 
11086
partition by hash(datediff(col1, '2006-01-01'));
 
11087
create table t4 (colint int, col1 date) engine='INNODB' 
 
11088
partition by range(colint) 
 
11089
subpartition by hash(datediff(col1, '2006-01-01')) subpartitions 2 
 
11090
(partition p0 values less than (15),
 
11091
partition p1 values less than maxvalue);
 
11092
create table t5 (colint int, col1 date) engine='INNODB' 
 
11093
partition by list(colint)
 
11094
subpartition by hash(datediff(col1, '2006-01-01')) subpartitions 2 
 
11095
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
11096
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
11097
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
11098
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
11099
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
11100
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
11101
);
 
11102
create table t6 (colint int, col1 date) engine='INNODB' 
 
11103
partition by range(colint) 
 
11104
(partition p0 values less than (datediff('2006-02-02', '2006-01-01')),
 
11105
partition p1 values less than maxvalue);
 
11106
-------------------------------------------------------------------------
 
11107
---  Access tables with datediff(col1, '2006-01-01') 
 
11108
-------------------------------------------------------------------------
 
11109
insert into t1 values ('2006-02-03');
 
11110
insert into t1 values ('2006-01-17');
 
11111
insert into t2 values ('2006-02-03');
 
11112
insert into t2 values ('2006-01-17');
 
11113
insert into t2 values ('2006-01-25');
 
11114
insert into t3 values ('2006-02-03');
 
11115
insert into t3 values ('2006-01-17');
 
11116
insert into t3 values ('2006-01-25');
 
11117
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
 
11118
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
 
11119
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
 
11120
select datediff(col1, '2006-01-01') from t1 order by col1;
 
11121
datediff(col1, '2006-01-01')
 
11122
16
 
11123
33
 
11124
select * from t1 order by col1;
 
11125
col1
 
11126
2006-01-17
 
11127
2006-02-03
 
11128
select * from t2 order by col1;
 
11129
col1
 
11130
2006-01-17
 
11131
2006-01-25
 
11132
2006-02-03
 
11133
select * from t3 order by col1;
 
11134
col1
 
11135
2006-01-17
 
11136
2006-01-25
 
11137
2006-02-03
 
11138
select * from t4 order by colint;
 
11139
colint  col1
 
11140
1       2006-02-03
 
11141
2       2006-01-17
 
11142
3       2006-01-25
 
11143
4       2006-02-05
 
11144
select * from t5 order by colint;
 
11145
colint  col1
 
11146
1       2006-02-03
 
11147
2       2006-01-17
 
11148
3       2006-01-25
 
11149
4       2006-02-05
 
11150
select * from t6 order by colint;
 
11151
colint  col1
 
11152
1       2006-02-03
 
11153
2       2006-01-17
 
11154
3       2006-01-25
 
11155
4       2006-02-05
 
11156
update t1 set col1='2006-02-06' where col1='2006-02-03';
 
11157
update t2 set col1='2006-02-06' where col1='2006-02-03';
 
11158
update t3 set col1='2006-02-06' where col1='2006-02-03';
 
11159
update t4 set col1='2006-02-06' where col1='2006-02-03';
 
11160
update t5 set col1='2006-02-06' where col1='2006-02-03';
 
11161
update t6 set col1='2006-02-06' where col1='2006-02-03';
 
11162
select * from t1 order by col1;
 
11163
col1
 
11164
2006-01-17
 
11165
2006-02-06
 
11166
select * from t2 order by col1;
 
11167
col1
 
11168
2006-01-17
 
11169
2006-01-25
 
11170
2006-02-06
 
11171
select * from t3 order by col1;
 
11172
col1
 
11173
2006-01-17
 
11174
2006-01-25
 
11175
2006-02-06
 
11176
select * from t4 order by colint;
 
11177
colint  col1
 
11178
1       2006-02-06
 
11179
2       2006-01-17
 
11180
3       2006-01-25
 
11181
4       2006-02-05
 
11182
select * from t5 order by colint;
 
11183
colint  col1
 
11184
1       2006-02-06
 
11185
2       2006-01-17
 
11186
3       2006-01-25
 
11187
4       2006-02-05
 
11188
select * from t6 order by colint;
 
11189
colint  col1
 
11190
1       2006-02-06
 
11191
2       2006-01-17
 
11192
3       2006-01-25
 
11193
4       2006-02-05
 
11194
-------------------------------------------------------------------------
 
11195
---  Alter tables with datediff(col1, '2006-01-01')
 
11196
-------------------------------------------------------------------------
 
11197
drop table if exists t11 ;
 
11198
drop table if exists t22 ;
 
11199
drop table if exists t33 ;
 
11200
drop table if exists t44 ;
 
11201
drop table if exists t55 ;
 
11202
drop table if exists t66 ;
 
11203
create table t11 engine='INNODB' as select * from t1;
 
11204
create table t22 engine='INNODB' as select * from t2;
 
11205
create table t33 engine='INNODB' as select * from t3;
 
11206
create table t44 engine='INNODB' as select * from t4;
 
11207
create table t55 engine='INNODB' as select * from t5;
 
11208
create table t66 engine='INNODB' as select * from t6;
 
11209
alter table t11
 
11210
partition by range(datediff(col1, '2006-01-01')) 
 
11211
(partition p0 values less than (15),
 
11212
partition p1 values less than maxvalue);
 
11213
alter table t22
 
11214
partition by list(datediff(col1, '2006-01-01')) 
 
11215
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
11216
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
11217
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
11218
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
11219
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
11220
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
11221
);
 
11222
alter table t33
 
11223
partition by hash(datediff(col1, '2006-01-01'));
 
11224
alter table t44
 
11225
partition by range(colint) 
 
11226
subpartition by hash(datediff(col1, '2006-01-01')) subpartitions 2 
 
11227
(partition p0 values less than (15),
 
11228
partition p1 values less than maxvalue);
 
11229
alter table t55
 
11230
partition by list(colint)
 
11231
subpartition by hash(datediff(col1, '2006-01-01')) subpartitions 2 
 
11232
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
11233
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
11234
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
11235
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
11236
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
11237
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
11238
);
 
11239
alter table t66
 
11240
partition by range(colint) 
 
11241
(partition p0 values less than (datediff('2006-02-02', '2006-01-01')),
 
11242
partition p1 values less than maxvalue);
 
11243
select * from t11 order by col1;
 
11244
col1
 
11245
2006-01-17
 
11246
2006-02-06
 
11247
select * from t22 order by col1;
 
11248
col1
 
11249
2006-01-17
 
11250
2006-01-25
 
11251
2006-02-06
 
11252
select * from t33 order by col1;
 
11253
col1
 
11254
2006-01-17
 
11255
2006-01-25
 
11256
2006-02-06
 
11257
select * from t44 order by colint;
 
11258
colint  col1
 
11259
1       2006-02-06
 
11260
2       2006-01-17
 
11261
3       2006-01-25
 
11262
4       2006-02-05
 
11263
select * from t55 order by colint;
 
11264
colint  col1
 
11265
1       2006-02-06
 
11266
2       2006-01-17
 
11267
3       2006-01-25
 
11268
4       2006-02-05
 
11269
select * from t66 order by colint;
 
11270
colint  col1
 
11271
1       2006-02-06
 
11272
2       2006-01-17
 
11273
3       2006-01-25
 
11274
4       2006-02-05
 
11275
---------------------------
 
11276
---- some alter table begin
 
11277
---------------------------
 
11278
alter table t11
 
11279
reorganize partition p0,p1 into
 
11280
(partition s1 values less than maxvalue);
 
11281
select * from t11 order by col1;
 
11282
col1
 
11283
2006-01-17
 
11284
2006-02-06
 
11285
alter table t11
 
11286
reorganize partition s1 into
 
11287
(partition p0 values less than (15),
 
11288
partition p1 values less than maxvalue);
 
11289
select * from t11 order by col1;
 
11290
col1
 
11291
2006-01-17
 
11292
2006-02-06
 
11293
alter table t55
 
11294
partition by list(colint)
 
11295
subpartition by hash(datediff(col1, '2006-01-01')) subpartitions 5 
 
11296
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
11297
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
11298
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
11299
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
11300
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
11301
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
11302
);
 
11303
show create table t55;
 
11304
Table   Create Table
 
11305
t55     CREATE TABLE `t55` (
 
11306
  `colint` int(11) DEFAULT NULL,
 
11307
  `col1` date DEFAULT NULL
 
11308
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
11309
/*!50100 PARTITION BY LIST (colint)
 
11310
SUBPARTITION BY HASH (datediff(col1, '2006-01-01'))
 
11311
SUBPARTITIONS 5
 
11312
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
11313
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
11314
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
11315
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
11316
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
11317
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
11318
select * from t55 order by colint;
 
11319
colint  col1
 
11320
1       2006-02-06
 
11321
2       2006-01-17
 
11322
3       2006-01-25
 
11323
4       2006-02-05
 
11324
alter table t66
 
11325
reorganize partition p0,p1 into
 
11326
(partition s1 values less than maxvalue);
 
11327
select * from t66 order by colint;
 
11328
colint  col1
 
11329
1       2006-02-06
 
11330
2       2006-01-17
 
11331
3       2006-01-25
 
11332
4       2006-02-05
 
11333
alter table t66
 
11334
reorganize partition s1 into
 
11335
(partition p0 values less than (datediff('2006-02-02', '2006-01-01')),
 
11336
partition p1 values less than maxvalue);
 
11337
select * from t66 order by colint;
 
11338
colint  col1
 
11339
1       2006-02-06
 
11340
2       2006-01-17
 
11341
3       2006-01-25
 
11342
4       2006-02-05
 
11343
alter table t66
 
11344
reorganize partition p0,p1 into
 
11345
(partition s1 values less than maxvalue);
 
11346
select * from t66 order by colint;
 
11347
colint  col1
 
11348
1       2006-02-06
 
11349
2       2006-01-17
 
11350
3       2006-01-25
 
11351
4       2006-02-05
 
11352
alter table t66
 
11353
reorganize partition s1 into
 
11354
(partition p0 values less than (datediff('2006-02-02', '2006-01-01')),
 
11355
partition p1 values less than maxvalue);
 
11356
select * from t66 order by colint;
 
11357
colint  col1
 
11358
1       2006-02-06
 
11359
2       2006-01-17
 
11360
3       2006-01-25
 
11361
4       2006-02-05
 
11362
-------------------------------------------------------------------------
 
11363
---  Delete rows and partitions of tables with datediff(col1, '2006-01-01')
 
11364
-------------------------------------------------------------------------
 
11365
delete from t1 where col1='2006-01-17';
 
11366
delete from t2 where col1='2006-01-17';
 
11367
delete from t3 where col1='2006-01-17';
 
11368
delete from t4 where col1='2006-01-17';
 
11369
delete from t5 where col1='2006-01-17';
 
11370
delete from t6 where col1='2006-01-17';
 
11371
select * from t1 order by col1;
 
11372
col1
 
11373
2006-02-06
 
11374
select * from t2 order by col1;
 
11375
col1
 
11376
2006-01-25
 
11377
2006-02-06
 
11378
select * from t3 order by col1;
 
11379
col1
 
11380
2006-01-25
 
11381
2006-02-06
 
11382
select * from t4 order by colint;
 
11383
colint  col1
 
11384
1       2006-02-06
 
11385
3       2006-01-25
 
11386
4       2006-02-05
 
11387
select * from t5 order by colint;
 
11388
colint  col1
 
11389
1       2006-02-06
 
11390
3       2006-01-25
 
11391
4       2006-02-05
 
11392
insert into t1 values ('2006-01-17');
 
11393
insert into t2 values ('2006-01-17');
 
11394
insert into t3 values ('2006-01-17');
 
11395
insert into t4 values (60,'2006-01-17');
 
11396
insert into t5 values (60,'2006-01-17');
 
11397
insert into t6 values (60,'2006-01-17');
 
11398
select * from t1 order by col1;
 
11399
col1
 
11400
2006-01-17
 
11401
2006-02-06
 
11402
select * from t2 order by col1;
 
11403
col1
 
11404
2006-01-17
 
11405
2006-01-25
 
11406
2006-02-06
 
11407
select * from t3 order by col1;
 
11408
col1
 
11409
2006-01-17
 
11410
2006-01-25
 
11411
2006-02-06
 
11412
select * from t4 order by colint;
 
11413
colint  col1
 
11414
1       2006-02-06
 
11415
3       2006-01-25
 
11416
4       2006-02-05
 
11417
60      2006-01-17
 
11418
select * from t5 order by colint;
 
11419
colint  col1
 
11420
1       2006-02-06
 
11421
3       2006-01-25
 
11422
4       2006-02-05
 
11423
60      2006-01-17
 
11424
select * from t6 order by colint;
 
11425
colint  col1
 
11426
1       2006-02-06
 
11427
3       2006-01-25
 
11428
4       2006-02-05
 
11429
60      2006-01-17
 
11430
alter table t1 drop partition p0;
 
11431
alter table t2 drop partition p0;
 
11432
alter table t4 drop partition p0;
 
11433
alter table t5 drop partition p0;
 
11434
alter table t6 drop partition p0;
 
11435
select * from t1 order by col1;
 
11436
col1
 
11437
2006-01-17
 
11438
2006-02-06
 
11439
select * from t2 order by col1;
 
11440
col1
 
11441
2006-01-17
 
11442
2006-01-25
 
11443
2006-02-06
 
11444
select * from t3 order by col1;
 
11445
col1
 
11446
2006-01-17
 
11447
2006-01-25
 
11448
2006-02-06
 
11449
select * from t4 order by colint;
 
11450
colint  col1
 
11451
60      2006-01-17
 
11452
select * from t5 order by colint;
 
11453
colint  col1
 
11454
60      2006-01-17
 
11455
select * from t6 order by colint;
 
11456
colint  col1
 
11457
60      2006-01-17
 
11458
-------------------------------------------------------------------------
 
11459
---  Delete rows and partitions of tables with datediff(col1, '2006-01-01')
 
11460
-------------------------------------------------------------------------
 
11461
delete from t11 where col1='2006-01-17';
 
11462
delete from t22 where col1='2006-01-17';
 
11463
delete from t33 where col1='2006-01-17';
 
11464
delete from t44 where col1='2006-01-17';
 
11465
delete from t55 where col1='2006-01-17';
 
11466
delete from t66 where col1='2006-01-17';
 
11467
select * from t11 order by col1;
 
11468
col1
 
11469
2006-02-06
 
11470
select * from t22 order by col1;
 
11471
col1
 
11472
2006-01-25
 
11473
2006-02-06
 
11474
select * from t33 order by col1;
 
11475
col1
 
11476
2006-01-25
 
11477
2006-02-06
 
11478
select * from t44 order by colint;
 
11479
colint  col1
 
11480
1       2006-02-06
 
11481
3       2006-01-25
 
11482
4       2006-02-05
 
11483
select * from t55 order by colint;
 
11484
colint  col1
 
11485
1       2006-02-06
 
11486
3       2006-01-25
 
11487
4       2006-02-05
 
11488
insert into t11 values ('2006-01-17');
 
11489
insert into t22 values ('2006-01-17');
 
11490
insert into t33 values ('2006-01-17');
 
11491
insert into t44 values (60,'2006-01-17');
 
11492
insert into t55 values (60,'2006-01-17');
 
11493
insert into t66 values (60,'2006-01-17');
 
11494
select * from t11 order by col1;
 
11495
col1
 
11496
2006-01-17
 
11497
2006-02-06
 
11498
select * from t22 order by col1;
 
11499
col1
 
11500
2006-01-17
 
11501
2006-01-25
 
11502
2006-02-06
 
11503
select * from t33 order by col1;
 
11504
col1
 
11505
2006-01-17
 
11506
2006-01-25
 
11507
2006-02-06
 
11508
select * from t44 order by colint;
 
11509
colint  col1
 
11510
1       2006-02-06
 
11511
3       2006-01-25
 
11512
4       2006-02-05
 
11513
60      2006-01-17
 
11514
select * from t55 order by colint;
 
11515
colint  col1
 
11516
1       2006-02-06
 
11517
3       2006-01-25
 
11518
4       2006-02-05
 
11519
60      2006-01-17
 
11520
select * from t66 order by colint;
 
11521
colint  col1
 
11522
1       2006-02-06
 
11523
3       2006-01-25
 
11524
4       2006-02-05
 
11525
60      2006-01-17
 
11526
alter table t11 drop partition p0;
 
11527
alter table t22 drop partition p0;
 
11528
alter table t44 drop partition p0;
 
11529
alter table t55 drop partition p0;
 
11530
alter table t66 drop partition p0;
 
11531
select * from t11 order by col1;
 
11532
col1
 
11533
2006-01-17
 
11534
2006-02-06
 
11535
select * from t22 order by col1;
 
11536
col1
 
11537
2006-01-17
 
11538
2006-01-25
 
11539
2006-02-06
 
11540
select * from t33 order by col1;
 
11541
col1
 
11542
2006-01-17
 
11543
2006-01-25
 
11544
2006-02-06
 
11545
select * from t44 order by colint;
 
11546
colint  col1
 
11547
60      2006-01-17
 
11548
select * from t55 order by colint;
 
11549
colint  col1
 
11550
60      2006-01-17
 
11551
select * from t66 order by colint;
 
11552
colint  col1
 
11553
60      2006-01-17
 
11554
-------------------------
 
11555
---- some alter table end
 
11556
-------------------------
 
11557
drop table if exists t1 ;
 
11558
drop table if exists t2 ;
 
11559
drop table if exists t3 ;
 
11560
drop table if exists t4 ;
 
11561
drop table if exists t5 ;
 
11562
drop table if exists t6 ;
 
11563
drop table if exists t11 ;
 
11564
drop table if exists t22 ;
 
11565
drop table if exists t33 ;
 
11566
drop table if exists t44 ;
 
11567
drop table if exists t55 ;
 
11568
drop table if exists t66 ;
 
11569
-------------------------------------------------------------------------
 
11570
---  weekday(col1)  in partition with coltype  date
 
11571
-------------------------------------------------------------------------
 
11572
drop table if exists t1 ;
 
11573
drop table if exists t2 ;
 
11574
drop table if exists t3 ;
 
11575
drop table if exists t4 ;
 
11576
drop table if exists t5 ;
 
11577
drop table if exists t6 ;
 
11578
-------------------------------------------------------------------------
 
11579
---  Create tables with weekday(col1)
 
11580
-------------------------------------------------------------------------
 
11581
create table t1 (col1 date) engine='INNODB' 
 
11582
partition by range(weekday(col1)) 
 
11583
(partition p0 values less than (15),
 
11584
partition p1 values less than maxvalue);
 
11585
create table t2 (col1 date) engine='INNODB' 
 
11586
partition by list(weekday(col1)) 
 
11587
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
11588
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
11589
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
11590
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
11591
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
11592
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
11593
);
 
11594
create table t3 (col1 date) engine='INNODB' 
 
11595
partition by hash(weekday(col1));
 
11596
create table t4 (colint int, col1 date) engine='INNODB' 
 
11597
partition by range(colint) 
 
11598
subpartition by hash(weekday(col1)) subpartitions 2 
 
11599
(partition p0 values less than (15),
 
11600
partition p1 values less than maxvalue);
 
11601
create table t5 (colint int, col1 date) engine='INNODB' 
 
11602
partition by list(colint)
 
11603
subpartition by hash(weekday(col1)) subpartitions 2 
 
11604
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
11605
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
11606
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
11607
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
11608
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
11609
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
11610
);
 
11611
create table t6 (colint int, col1 date) engine='INNODB' 
 
11612
partition by range(colint) 
 
11613
(partition p0 values less than (weekday('2006-10-14')),
 
11614
partition p1 values less than maxvalue);
 
11615
-------------------------------------------------------------------------
 
11616
---  Access tables with weekday(col1) 
 
11617
-------------------------------------------------------------------------
 
11618
insert into t1 values ('2006-12-03');
 
11619
insert into t1 values ('2006-11-17');
 
11620
insert into t2 values ('2006-12-03');
 
11621
insert into t2 values ('2006-11-17');
 
11622
insert into t2 values ('2006-05-25');
 
11623
insert into t3 values ('2006-12-03');
 
11624
insert into t3 values ('2006-11-17');
 
11625
insert into t3 values ('2006-05-25');
 
11626
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
 
11627
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
 
11628
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
 
11629
select weekday(col1) from t1 order by col1;
 
11630
weekday(col1)
 
11631
4
 
11632
6
 
11633
select * from t1 order by col1;
 
11634
col1
 
11635
2006-11-17
 
11636
2006-12-03
 
11637
select * from t2 order by col1;
 
11638
col1
 
11639
2006-05-25
 
11640
2006-11-17
 
11641
2006-12-03
 
11642
select * from t3 order by col1;
 
11643
col1
 
11644
2006-05-25
 
11645
2006-11-17
 
11646
2006-12-03
 
11647
select * from t4 order by colint;
 
11648
colint  col1
 
11649
1       2006-02-03
 
11650
2       2006-01-17
 
11651
3       2006-01-25
 
11652
4       2006-02-05
 
11653
select * from t5 order by colint;
 
11654
colint  col1
 
11655
1       2006-02-03
 
11656
2       2006-01-17
 
11657
3       2006-01-25
 
11658
4       2006-02-05
 
11659
select * from t6 order by colint;
 
11660
colint  col1
 
11661
1       2006-02-03
 
11662
2       2006-01-17
 
11663
3       2006-01-25
 
11664
4       2006-02-05
 
11665
update t1 set col1='2006-02-06' where col1='2006-12-03';
 
11666
update t2 set col1='2006-02-06' where col1='2006-12-03';
 
11667
update t3 set col1='2006-02-06' where col1='2006-12-03';
 
11668
update t4 set col1='2006-02-06' where col1='2006-12-03';
 
11669
update t5 set col1='2006-02-06' where col1='2006-12-03';
 
11670
update t6 set col1='2006-02-06' where col1='2006-12-03';
 
11671
select * from t1 order by col1;
 
11672
col1
 
11673
2006-02-06
 
11674
2006-11-17
 
11675
select * from t2 order by col1;
 
11676
col1
 
11677
2006-02-06
 
11678
2006-05-25
 
11679
2006-11-17
 
11680
select * from t3 order by col1;
 
11681
col1
 
11682
2006-02-06
 
11683
2006-05-25
 
11684
2006-11-17
 
11685
select * from t4 order by colint;
 
11686
colint  col1
 
11687
1       2006-02-03
 
11688
2       2006-01-17
 
11689
3       2006-01-25
 
11690
4       2006-02-05
 
11691
select * from t5 order by colint;
 
11692
colint  col1
 
11693
1       2006-02-03
 
11694
2       2006-01-17
 
11695
3       2006-01-25
 
11696
4       2006-02-05
 
11697
select * from t6 order by colint;
 
11698
colint  col1
 
11699
1       2006-02-03
 
11700
2       2006-01-17
 
11701
3       2006-01-25
 
11702
4       2006-02-05
 
11703
-------------------------------------------------------------------------
 
11704
---  Alter tables with weekday(col1)
 
11705
-------------------------------------------------------------------------
 
11706
drop table if exists t11 ;
 
11707
drop table if exists t22 ;
 
11708
drop table if exists t33 ;
 
11709
drop table if exists t44 ;
 
11710
drop table if exists t55 ;
 
11711
drop table if exists t66 ;
 
11712
create table t11 engine='INNODB' as select * from t1;
 
11713
create table t22 engine='INNODB' as select * from t2;
 
11714
create table t33 engine='INNODB' as select * from t3;
 
11715
create table t44 engine='INNODB' as select * from t4;
 
11716
create table t55 engine='INNODB' as select * from t5;
 
11717
create table t66 engine='INNODB' as select * from t6;
 
11718
alter table t11
 
11719
partition by range(weekday(col1)) 
 
11720
(partition p0 values less than (15),
 
11721
partition p1 values less than maxvalue);
 
11722
alter table t22
 
11723
partition by list(weekday(col1)) 
 
11724
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
11725
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
11726
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
11727
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
11728
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
11729
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
11730
);
 
11731
alter table t33
 
11732
partition by hash(weekday(col1));
 
11733
alter table t44
 
11734
partition by range(colint) 
 
11735
subpartition by hash(weekday(col1)) subpartitions 2 
 
11736
(partition p0 values less than (15),
 
11737
partition p1 values less than maxvalue);
 
11738
alter table t55
 
11739
partition by list(colint)
 
11740
subpartition by hash(weekday(col1)) subpartitions 2 
 
11741
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
11742
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
11743
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
11744
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
11745
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
11746
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
11747
);
 
11748
alter table t66
 
11749
partition by range(colint) 
 
11750
(partition p0 values less than (weekday('2006-10-14')),
 
11751
partition p1 values less than maxvalue);
 
11752
select * from t11 order by col1;
 
11753
col1
 
11754
2006-02-06
 
11755
2006-11-17
 
11756
select * from t22 order by col1;
 
11757
col1
 
11758
2006-02-06
 
11759
2006-05-25
 
11760
2006-11-17
 
11761
select * from t33 order by col1;
 
11762
col1
 
11763
2006-02-06
 
11764
2006-05-25
 
11765
2006-11-17
 
11766
select * from t44 order by colint;
 
11767
colint  col1
 
11768
1       2006-02-03
 
11769
2       2006-01-17
 
11770
3       2006-01-25
 
11771
4       2006-02-05
 
11772
select * from t55 order by colint;
 
11773
colint  col1
 
11774
1       2006-02-03
 
11775
2       2006-01-17
 
11776
3       2006-01-25
 
11777
4       2006-02-05
 
11778
select * from t66 order by colint;
 
11779
colint  col1
 
11780
1       2006-02-03
 
11781
2       2006-01-17
 
11782
3       2006-01-25
 
11783
4       2006-02-05
 
11784
---------------------------
 
11785
---- some alter table begin
 
11786
---------------------------
 
11787
alter table t11
 
11788
reorganize partition p0,p1 into
 
11789
(partition s1 values less than maxvalue);
 
11790
select * from t11 order by col1;
 
11791
col1
 
11792
2006-02-06
 
11793
2006-11-17
 
11794
alter table t11
 
11795
reorganize partition s1 into
 
11796
(partition p0 values less than (15),
 
11797
partition p1 values less than maxvalue);
 
11798
select * from t11 order by col1;
 
11799
col1
 
11800
2006-02-06
 
11801
2006-11-17
 
11802
alter table t55
 
11803
partition by list(colint)
 
11804
subpartition by hash(weekday(col1)) subpartitions 5 
 
11805
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
11806
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
11807
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
11808
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
11809
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
11810
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
11811
);
 
11812
show create table t55;
 
11813
Table   Create Table
 
11814
t55     CREATE TABLE `t55` (
 
11815
  `colint` int(11) DEFAULT NULL,
 
11816
  `col1` date DEFAULT NULL
 
11817
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
11818
/*!50100 PARTITION BY LIST (colint)
 
11819
SUBPARTITION BY HASH (weekday(col1))
 
11820
SUBPARTITIONS 5
 
11821
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
11822
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
11823
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
11824
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
11825
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
11826
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
11827
select * from t55 order by colint;
 
11828
colint  col1
 
11829
1       2006-02-03
 
11830
2       2006-01-17
 
11831
3       2006-01-25
 
11832
4       2006-02-05
 
11833
alter table t66
 
11834
reorganize partition p0,p1 into
 
11835
(partition s1 values less than maxvalue);
 
11836
select * from t66 order by colint;
 
11837
colint  col1
 
11838
1       2006-02-03
 
11839
2       2006-01-17
 
11840
3       2006-01-25
 
11841
4       2006-02-05
 
11842
alter table t66
 
11843
reorganize partition s1 into
 
11844
(partition p0 values less than (weekday('2006-10-14')),
 
11845
partition p1 values less than maxvalue);
 
11846
select * from t66 order by colint;
 
11847
colint  col1
 
11848
1       2006-02-03
 
11849
2       2006-01-17
 
11850
3       2006-01-25
 
11851
4       2006-02-05
 
11852
alter table t66
 
11853
reorganize partition p0,p1 into
 
11854
(partition s1 values less than maxvalue);
 
11855
select * from t66 order by colint;
 
11856
colint  col1
 
11857
1       2006-02-03
 
11858
2       2006-01-17
 
11859
3       2006-01-25
 
11860
4       2006-02-05
 
11861
alter table t66
 
11862
reorganize partition s1 into
 
11863
(partition p0 values less than (weekday('2006-10-14')),
 
11864
partition p1 values less than maxvalue);
 
11865
select * from t66 order by colint;
 
11866
colint  col1
 
11867
1       2006-02-03
 
11868
2       2006-01-17
 
11869
3       2006-01-25
 
11870
4       2006-02-05
 
11871
-------------------------------------------------------------------------
 
11872
---  Delete rows and partitions of tables with weekday(col1)
 
11873
-------------------------------------------------------------------------
 
11874
delete from t1 where col1='2006-11-17';
 
11875
delete from t2 where col1='2006-11-17';
 
11876
delete from t3 where col1='2006-11-17';
 
11877
delete from t4 where col1='2006-11-17';
 
11878
delete from t5 where col1='2006-11-17';
 
11879
delete from t6 where col1='2006-11-17';
 
11880
select * from t1 order by col1;
 
11881
col1
 
11882
2006-02-06
 
11883
select * from t2 order by col1;
 
11884
col1
 
11885
2006-02-06
 
11886
2006-05-25
 
11887
select * from t3 order by col1;
 
11888
col1
 
11889
2006-02-06
 
11890
2006-05-25
 
11891
select * from t4 order by colint;
 
11892
colint  col1
 
11893
1       2006-02-03
 
11894
2       2006-01-17
 
11895
3       2006-01-25
 
11896
4       2006-02-05
 
11897
select * from t5 order by colint;
 
11898
colint  col1
 
11899
1       2006-02-03
 
11900
2       2006-01-17
 
11901
3       2006-01-25
 
11902
4       2006-02-05
 
11903
insert into t1 values ('2006-11-17');
 
11904
insert into t2 values ('2006-11-17');
 
11905
insert into t3 values ('2006-11-17');
 
11906
insert into t4 values (60,'2006-11-17');
 
11907
insert into t5 values (60,'2006-11-17');
 
11908
insert into t6 values (60,'2006-11-17');
 
11909
select * from t1 order by col1;
 
11910
col1
 
11911
2006-02-06
 
11912
2006-11-17
 
11913
select * from t2 order by col1;
 
11914
col1
 
11915
2006-02-06
 
11916
2006-05-25
 
11917
2006-11-17
 
11918
select * from t3 order by col1;
 
11919
col1
 
11920
2006-02-06
 
11921
2006-05-25
 
11922
2006-11-17
 
11923
select * from t4 order by colint;
 
11924
colint  col1
 
11925
1       2006-02-03
 
11926
2       2006-01-17
 
11927
3       2006-01-25
 
11928
4       2006-02-05
 
11929
60      2006-11-17
 
11930
select * from t5 order by colint;
 
11931
colint  col1
 
11932
1       2006-02-03
 
11933
2       2006-01-17
 
11934
3       2006-01-25
 
11935
4       2006-02-05
 
11936
60      2006-11-17
 
11937
select * from t6 order by colint;
 
11938
colint  col1
 
11939
1       2006-02-03
 
11940
2       2006-01-17
 
11941
3       2006-01-25
 
11942
4       2006-02-05
 
11943
60      2006-11-17
 
11944
alter table t1 drop partition p0;
 
11945
alter table t2 drop partition p0;
 
11946
alter table t4 drop partition p0;
 
11947
alter table t5 drop partition p0;
 
11948
alter table t6 drop partition p0;
 
11949
select * from t1 order by col1;
 
11950
col1
 
11951
select * from t2 order by col1;
 
11952
col1
 
11953
select * from t3 order by col1;
 
11954
col1
 
11955
2006-02-06
 
11956
2006-05-25
 
11957
2006-11-17
 
11958
select * from t4 order by colint;
 
11959
colint  col1
 
11960
60      2006-11-17
 
11961
select * from t5 order by colint;
 
11962
colint  col1
 
11963
60      2006-11-17
 
11964
select * from t6 order by colint;
 
11965
colint  col1
 
11966
60      2006-11-17
 
11967
-------------------------------------------------------------------------
 
11968
---  Delete rows and partitions of tables with weekday(col1)
 
11969
-------------------------------------------------------------------------
 
11970
delete from t11 where col1='2006-11-17';
 
11971
delete from t22 where col1='2006-11-17';
 
11972
delete from t33 where col1='2006-11-17';
 
11973
delete from t44 where col1='2006-11-17';
 
11974
delete from t55 where col1='2006-11-17';
 
11975
delete from t66 where col1='2006-11-17';
 
11976
select * from t11 order by col1;
 
11977
col1
 
11978
2006-02-06
 
11979
select * from t22 order by col1;
 
11980
col1
 
11981
2006-02-06
 
11982
2006-05-25
 
11983
select * from t33 order by col1;
 
11984
col1
 
11985
2006-02-06
 
11986
2006-05-25
 
11987
select * from t44 order by colint;
 
11988
colint  col1
 
11989
1       2006-02-03
 
11990
2       2006-01-17
 
11991
3       2006-01-25
 
11992
4       2006-02-05
 
11993
select * from t55 order by colint;
 
11994
colint  col1
 
11995
1       2006-02-03
 
11996
2       2006-01-17
 
11997
3       2006-01-25
 
11998
4       2006-02-05
 
11999
insert into t11 values ('2006-11-17');
 
12000
insert into t22 values ('2006-11-17');
 
12001
insert into t33 values ('2006-11-17');
 
12002
insert into t44 values (60,'2006-11-17');
 
12003
insert into t55 values (60,'2006-11-17');
 
12004
insert into t66 values (60,'2006-11-17');
 
12005
select * from t11 order by col1;
 
12006
col1
 
12007
2006-02-06
 
12008
2006-11-17
 
12009
select * from t22 order by col1;
 
12010
col1
 
12011
2006-02-06
 
12012
2006-05-25
 
12013
2006-11-17
 
12014
select * from t33 order by col1;
 
12015
col1
 
12016
2006-02-06
 
12017
2006-05-25
 
12018
2006-11-17
 
12019
select * from t44 order by colint;
 
12020
colint  col1
 
12021
1       2006-02-03
 
12022
2       2006-01-17
 
12023
3       2006-01-25
 
12024
4       2006-02-05
 
12025
60      2006-11-17
 
12026
select * from t55 order by colint;
 
12027
colint  col1
 
12028
1       2006-02-03
 
12029
2       2006-01-17
 
12030
3       2006-01-25
 
12031
4       2006-02-05
 
12032
60      2006-11-17
 
12033
select * from t66 order by colint;
 
12034
colint  col1
 
12035
1       2006-02-03
 
12036
2       2006-01-17
 
12037
3       2006-01-25
 
12038
4       2006-02-05
 
12039
60      2006-11-17
 
12040
alter table t11 drop partition p0;
 
12041
alter table t22 drop partition p0;
 
12042
alter table t44 drop partition p0;
 
12043
alter table t55 drop partition p0;
 
12044
alter table t66 drop partition p0;
 
12045
select * from t11 order by col1;
 
12046
col1
 
12047
select * from t22 order by col1;
 
12048
col1
 
12049
select * from t33 order by col1;
 
12050
col1
 
12051
2006-02-06
 
12052
2006-05-25
 
12053
2006-11-17
 
12054
select * from t44 order by colint;
 
12055
colint  col1
 
12056
60      2006-11-17
 
12057
select * from t55 order by colint;
 
12058
colint  col1
 
12059
60      2006-11-17
 
12060
select * from t66 order by colint;
 
12061
colint  col1
 
12062
60      2006-11-17
 
12063
-------------------------
 
12064
---- some alter table end
 
12065
-------------------------
 
12066
drop table if exists t1 ;
 
12067
drop table if exists t2 ;
 
12068
drop table if exists t3 ;
 
12069
drop table if exists t4 ;
 
12070
drop table if exists t5 ;
 
12071
drop table if exists t6 ;
 
12072
drop table if exists t11 ;
 
12073
drop table if exists t22 ;
 
12074
drop table if exists t33 ;
 
12075
drop table if exists t44 ;
 
12076
drop table if exists t55 ;
 
12077
drop table if exists t66 ;
 
12078
-------------------------------------------------------------------------
 
12079
---  year(col1)-1990  in partition with coltype  date
 
12080
-------------------------------------------------------------------------
 
12081
drop table if exists t1 ;
 
12082
drop table if exists t2 ;
 
12083
drop table if exists t3 ;
 
12084
drop table if exists t4 ;
 
12085
drop table if exists t5 ;
 
12086
drop table if exists t6 ;
 
12087
-------------------------------------------------------------------------
 
12088
---  Create tables with year(col1)-1990
 
12089
-------------------------------------------------------------------------
 
12090
create table t1 (col1 date) engine='INNODB' 
 
12091
partition by range(year(col1)-1990) 
 
12092
(partition p0 values less than (15),
 
12093
partition p1 values less than maxvalue);
 
12094
create table t2 (col1 date) engine='INNODB' 
 
12095
partition by list(year(col1)-1990) 
 
12096
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
12097
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
12098
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
12099
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
12100
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
12101
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
12102
);
 
12103
create table t3 (col1 date) engine='INNODB' 
 
12104
partition by hash(year(col1)-1990);
 
12105
create table t4 (colint int, col1 date) engine='INNODB' 
 
12106
partition by range(colint) 
 
12107
subpartition by hash(year(col1)-1990) subpartitions 2 
 
12108
(partition p0 values less than (15),
 
12109
partition p1 values less than maxvalue);
 
12110
create table t5 (colint int, col1 date) engine='INNODB' 
 
12111
partition by list(colint)
 
12112
subpartition by hash(year(col1)-1990) subpartitions 2 
 
12113
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
12114
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
12115
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
12116
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
12117
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
12118
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
12119
);
 
12120
create table t6 (colint int, col1 date) engine='INNODB' 
 
12121
partition by range(colint) 
 
12122
(partition p0 values less than (year('2005-10-14')-1990),
 
12123
partition p1 values less than maxvalue);
 
12124
-------------------------------------------------------------------------
 
12125
---  Access tables with year(col1)-1990 
 
12126
-------------------------------------------------------------------------
 
12127
insert into t1 values ('1996-01-03');
 
12128
insert into t1 values ('2000-02-17');
 
12129
insert into t2 values ('1996-01-03');
 
12130
insert into t2 values ('2000-02-17');
 
12131
insert into t2 values ('2004-05-25');
 
12132
insert into t3 values ('1996-01-03');
 
12133
insert into t3 values ('2000-02-17');
 
12134
insert into t3 values ('2004-05-25');
 
12135
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
 
12136
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
 
12137
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
 
12138
select year(col1)-1990 from t1 order by col1;
 
12139
year(col1)-1990
 
12140
6
 
12141
10
 
12142
select * from t1 order by col1;
 
12143
col1
 
12144
1996-01-03
 
12145
2000-02-17
 
12146
select * from t2 order by col1;
 
12147
col1
 
12148
1996-01-03
 
12149
2000-02-17
 
12150
2004-05-25
 
12151
select * from t3 order by col1;
 
12152
col1
 
12153
1996-01-03
 
12154
2000-02-17
 
12155
2004-05-25
 
12156
select * from t4 order by colint;
 
12157
colint  col1
 
12158
1       2006-02-03
 
12159
2       2006-01-17
 
12160
3       2006-01-25
 
12161
4       2006-02-05
 
12162
select * from t5 order by colint;
 
12163
colint  col1
 
12164
1       2006-02-03
 
12165
2       2006-01-17
 
12166
3       2006-01-25
 
12167
4       2006-02-05
 
12168
select * from t6 order by colint;
 
12169
colint  col1
 
12170
1       2006-02-03
 
12171
2       2006-01-17
 
12172
3       2006-01-25
 
12173
4       2006-02-05
 
12174
update t1 set col1='2002-02-15' where col1='1996-01-03';
 
12175
update t2 set col1='2002-02-15' where col1='1996-01-03';
 
12176
update t3 set col1='2002-02-15' where col1='1996-01-03';
 
12177
update t4 set col1='2002-02-15' where col1='1996-01-03';
 
12178
update t5 set col1='2002-02-15' where col1='1996-01-03';
 
12179
update t6 set col1='2002-02-15' where col1='1996-01-03';
 
12180
select * from t1 order by col1;
 
12181
col1
 
12182
2000-02-17
 
12183
2002-02-15
 
12184
select * from t2 order by col1;
 
12185
col1
 
12186
2000-02-17
 
12187
2002-02-15
 
12188
2004-05-25
 
12189
select * from t3 order by col1;
 
12190
col1
 
12191
2000-02-17
 
12192
2002-02-15
 
12193
2004-05-25
 
12194
select * from t4 order by colint;
 
12195
colint  col1
 
12196
1       2006-02-03
 
12197
2       2006-01-17
 
12198
3       2006-01-25
 
12199
4       2006-02-05
 
12200
select * from t5 order by colint;
 
12201
colint  col1
 
12202
1       2006-02-03
 
12203
2       2006-01-17
 
12204
3       2006-01-25
 
12205
4       2006-02-05
 
12206
select * from t6 order by colint;
 
12207
colint  col1
 
12208
1       2006-02-03
 
12209
2       2006-01-17
 
12210
3       2006-01-25
 
12211
4       2006-02-05
 
12212
-------------------------------------------------------------------------
 
12213
---  Alter tables with year(col1)-1990
 
12214
-------------------------------------------------------------------------
 
12215
drop table if exists t11 ;
 
12216
drop table if exists t22 ;
 
12217
drop table if exists t33 ;
 
12218
drop table if exists t44 ;
 
12219
drop table if exists t55 ;
 
12220
drop table if exists t66 ;
 
12221
create table t11 engine='INNODB' as select * from t1;
 
12222
create table t22 engine='INNODB' as select * from t2;
 
12223
create table t33 engine='INNODB' as select * from t3;
 
12224
create table t44 engine='INNODB' as select * from t4;
 
12225
create table t55 engine='INNODB' as select * from t5;
 
12226
create table t66 engine='INNODB' as select * from t6;
 
12227
alter table t11
 
12228
partition by range(year(col1)-1990) 
 
12229
(partition p0 values less than (15),
 
12230
partition p1 values less than maxvalue);
 
12231
alter table t22
 
12232
partition by list(year(col1)-1990) 
 
12233
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
12234
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
12235
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
12236
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
12237
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
12238
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
12239
);
 
12240
alter table t33
 
12241
partition by hash(year(col1)-1990);
 
12242
alter table t44
 
12243
partition by range(colint) 
 
12244
subpartition by hash(year(col1)-1990) subpartitions 2 
 
12245
(partition p0 values less than (15),
 
12246
partition p1 values less than maxvalue);
 
12247
alter table t55
 
12248
partition by list(colint)
 
12249
subpartition by hash(year(col1)-1990) subpartitions 2 
 
12250
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
12251
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
12252
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
12253
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
12254
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
12255
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
12256
);
 
12257
alter table t66
 
12258
partition by range(colint) 
 
12259
(partition p0 values less than (year('2005-10-14')-1990),
 
12260
partition p1 values less than maxvalue);
 
12261
select * from t11 order by col1;
 
12262
col1
 
12263
2000-02-17
 
12264
2002-02-15
 
12265
select * from t22 order by col1;
 
12266
col1
 
12267
2000-02-17
 
12268
2002-02-15
 
12269
2004-05-25
 
12270
select * from t33 order by col1;
 
12271
col1
 
12272
2000-02-17
 
12273
2002-02-15
 
12274
2004-05-25
 
12275
select * from t44 order by colint;
 
12276
colint  col1
 
12277
1       2006-02-03
 
12278
2       2006-01-17
 
12279
3       2006-01-25
 
12280
4       2006-02-05
 
12281
select * from t55 order by colint;
 
12282
colint  col1
 
12283
1       2006-02-03
 
12284
2       2006-01-17
 
12285
3       2006-01-25
 
12286
4       2006-02-05
 
12287
select * from t66 order by colint;
 
12288
colint  col1
 
12289
1       2006-02-03
 
12290
2       2006-01-17
 
12291
3       2006-01-25
 
12292
4       2006-02-05
 
12293
---------------------------
 
12294
---- some alter table begin
 
12295
---------------------------
 
12296
alter table t11
 
12297
reorganize partition p0,p1 into
 
12298
(partition s1 values less than maxvalue);
 
12299
select * from t11 order by col1;
 
12300
col1
 
12301
2000-02-17
 
12302
2002-02-15
 
12303
alter table t11
 
12304
reorganize partition s1 into
 
12305
(partition p0 values less than (15),
 
12306
partition p1 values less than maxvalue);
 
12307
select * from t11 order by col1;
 
12308
col1
 
12309
2000-02-17
 
12310
2002-02-15
 
12311
alter table t55
 
12312
partition by list(colint)
 
12313
subpartition by hash(year(col1)-1990) subpartitions 5 
 
12314
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
12315
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
12316
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
12317
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
12318
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
12319
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
12320
);
 
12321
show create table t55;
 
12322
Table   Create Table
 
12323
t55     CREATE TABLE `t55` (
 
12324
  `colint` int(11) DEFAULT NULL,
 
12325
  `col1` date DEFAULT NULL
 
12326
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
12327
/*!50100 PARTITION BY LIST (colint)
 
12328
SUBPARTITION BY HASH (year(col1)-1990)
 
12329
SUBPARTITIONS 5
 
12330
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
12331
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
12332
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
12333
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
12334
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
12335
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
12336
select * from t55 order by colint;
 
12337
colint  col1
 
12338
1       2006-02-03
 
12339
2       2006-01-17
 
12340
3       2006-01-25
 
12341
4       2006-02-05
 
12342
alter table t66
 
12343
reorganize partition p0,p1 into
 
12344
(partition s1 values less than maxvalue);
 
12345
select * from t66 order by colint;
 
12346
colint  col1
 
12347
1       2006-02-03
 
12348
2       2006-01-17
 
12349
3       2006-01-25
 
12350
4       2006-02-05
 
12351
alter table t66
 
12352
reorganize partition s1 into
 
12353
(partition p0 values less than (year('2005-10-14')-1990),
 
12354
partition p1 values less than maxvalue);
 
12355
select * from t66 order by colint;
 
12356
colint  col1
 
12357
1       2006-02-03
 
12358
2       2006-01-17
 
12359
3       2006-01-25
 
12360
4       2006-02-05
 
12361
alter table t66
 
12362
reorganize partition p0,p1 into
 
12363
(partition s1 values less than maxvalue);
 
12364
select * from t66 order by colint;
 
12365
colint  col1
 
12366
1       2006-02-03
 
12367
2       2006-01-17
 
12368
3       2006-01-25
 
12369
4       2006-02-05
 
12370
alter table t66
 
12371
reorganize partition s1 into
 
12372
(partition p0 values less than (year('2005-10-14')-1990),
 
12373
partition p1 values less than maxvalue);
 
12374
select * from t66 order by colint;
 
12375
colint  col1
 
12376
1       2006-02-03
 
12377
2       2006-01-17
 
12378
3       2006-01-25
 
12379
4       2006-02-05
 
12380
-------------------------------------------------------------------------
 
12381
---  Delete rows and partitions of tables with year(col1)-1990
 
12382
-------------------------------------------------------------------------
 
12383
delete from t1 where col1='2000-02-17';
 
12384
delete from t2 where col1='2000-02-17';
 
12385
delete from t3 where col1='2000-02-17';
 
12386
delete from t4 where col1='2000-02-17';
 
12387
delete from t5 where col1='2000-02-17';
 
12388
delete from t6 where col1='2000-02-17';
 
12389
select * from t1 order by col1;
 
12390
col1
 
12391
2002-02-15
 
12392
select * from t2 order by col1;
 
12393
col1
 
12394
2002-02-15
 
12395
2004-05-25
 
12396
select * from t3 order by col1;
 
12397
col1
 
12398
2002-02-15
 
12399
2004-05-25
 
12400
select * from t4 order by colint;
 
12401
colint  col1
 
12402
1       2006-02-03
 
12403
2       2006-01-17
 
12404
3       2006-01-25
 
12405
4       2006-02-05
 
12406
select * from t5 order by colint;
 
12407
colint  col1
 
12408
1       2006-02-03
 
12409
2       2006-01-17
 
12410
3       2006-01-25
 
12411
4       2006-02-05
 
12412
insert into t1 values ('2000-02-17');
 
12413
insert into t2 values ('2000-02-17');
 
12414
insert into t3 values ('2000-02-17');
 
12415
insert into t4 values (60,'2000-02-17');
 
12416
insert into t5 values (60,'2000-02-17');
 
12417
insert into t6 values (60,'2000-02-17');
 
12418
select * from t1 order by col1;
 
12419
col1
 
12420
2000-02-17
 
12421
2002-02-15
 
12422
select * from t2 order by col1;
 
12423
col1
 
12424
2000-02-17
 
12425
2002-02-15
 
12426
2004-05-25
 
12427
select * from t3 order by col1;
 
12428
col1
 
12429
2000-02-17
 
12430
2002-02-15
 
12431
2004-05-25
 
12432
select * from t4 order by colint;
 
12433
colint  col1
 
12434
1       2006-02-03
 
12435
2       2006-01-17
 
12436
3       2006-01-25
 
12437
4       2006-02-05
 
12438
60      2000-02-17
 
12439
select * from t5 order by colint;
 
12440
colint  col1
 
12441
1       2006-02-03
 
12442
2       2006-01-17
 
12443
3       2006-01-25
 
12444
4       2006-02-05
 
12445
60      2000-02-17
 
12446
select * from t6 order by colint;
 
12447
colint  col1
 
12448
1       2006-02-03
 
12449
2       2006-01-17
 
12450
3       2006-01-25
 
12451
4       2006-02-05
 
12452
60      2000-02-17
 
12453
alter table t1 drop partition p0;
 
12454
alter table t2 drop partition p0;
 
12455
alter table t4 drop partition p0;
 
12456
alter table t5 drop partition p0;
 
12457
alter table t6 drop partition p0;
 
12458
select * from t1 order by col1;
 
12459
col1
 
12460
select * from t2 order by col1;
 
12461
col1
 
12462
2002-02-15
 
12463
2004-05-25
 
12464
select * from t3 order by col1;
 
12465
col1
 
12466
2000-02-17
 
12467
2002-02-15
 
12468
2004-05-25
 
12469
select * from t4 order by colint;
 
12470
colint  col1
 
12471
60      2000-02-17
 
12472
select * from t5 order by colint;
 
12473
colint  col1
 
12474
60      2000-02-17
 
12475
select * from t6 order by colint;
 
12476
colint  col1
 
12477
60      2000-02-17
 
12478
-------------------------------------------------------------------------
 
12479
---  Delete rows and partitions of tables with year(col1)-1990
 
12480
-------------------------------------------------------------------------
 
12481
delete from t11 where col1='2000-02-17';
 
12482
delete from t22 where col1='2000-02-17';
 
12483
delete from t33 where col1='2000-02-17';
 
12484
delete from t44 where col1='2000-02-17';
 
12485
delete from t55 where col1='2000-02-17';
 
12486
delete from t66 where col1='2000-02-17';
 
12487
select * from t11 order by col1;
 
12488
col1
 
12489
2002-02-15
 
12490
select * from t22 order by col1;
 
12491
col1
 
12492
2002-02-15
 
12493
2004-05-25
 
12494
select * from t33 order by col1;
 
12495
col1
 
12496
2002-02-15
 
12497
2004-05-25
 
12498
select * from t44 order by colint;
 
12499
colint  col1
 
12500
1       2006-02-03
 
12501
2       2006-01-17
 
12502
3       2006-01-25
 
12503
4       2006-02-05
 
12504
select * from t55 order by colint;
 
12505
colint  col1
 
12506
1       2006-02-03
 
12507
2       2006-01-17
 
12508
3       2006-01-25
 
12509
4       2006-02-05
 
12510
insert into t11 values ('2000-02-17');
 
12511
insert into t22 values ('2000-02-17');
 
12512
insert into t33 values ('2000-02-17');
 
12513
insert into t44 values (60,'2000-02-17');
 
12514
insert into t55 values (60,'2000-02-17');
 
12515
insert into t66 values (60,'2000-02-17');
 
12516
select * from t11 order by col1;
 
12517
col1
 
12518
2000-02-17
 
12519
2002-02-15
 
12520
select * from t22 order by col1;
 
12521
col1
 
12522
2000-02-17
 
12523
2002-02-15
 
12524
2004-05-25
 
12525
select * from t33 order by col1;
 
12526
col1
 
12527
2000-02-17
 
12528
2002-02-15
 
12529
2004-05-25
 
12530
select * from t44 order by colint;
 
12531
colint  col1
 
12532
1       2006-02-03
 
12533
2       2006-01-17
 
12534
3       2006-01-25
 
12535
4       2006-02-05
 
12536
60      2000-02-17
 
12537
select * from t55 order by colint;
 
12538
colint  col1
 
12539
1       2006-02-03
 
12540
2       2006-01-17
 
12541
3       2006-01-25
 
12542
4       2006-02-05
 
12543
60      2000-02-17
 
12544
select * from t66 order by colint;
 
12545
colint  col1
 
12546
1       2006-02-03
 
12547
2       2006-01-17
 
12548
3       2006-01-25
 
12549
4       2006-02-05
 
12550
60      2000-02-17
 
12551
alter table t11 drop partition p0;
 
12552
alter table t22 drop partition p0;
 
12553
alter table t44 drop partition p0;
 
12554
alter table t55 drop partition p0;
 
12555
alter table t66 drop partition p0;
 
12556
select * from t11 order by col1;
 
12557
col1
 
12558
select * from t22 order by col1;
 
12559
col1
 
12560
2002-02-15
 
12561
2004-05-25
 
12562
select * from t33 order by col1;
 
12563
col1
 
12564
2000-02-17
 
12565
2002-02-15
 
12566
2004-05-25
 
12567
select * from t44 order by colint;
 
12568
colint  col1
 
12569
60      2000-02-17
 
12570
select * from t55 order by colint;
 
12571
colint  col1
 
12572
60      2000-02-17
 
12573
select * from t66 order by colint;
 
12574
colint  col1
 
12575
60      2000-02-17
 
12576
-------------------------
 
12577
---- some alter table end
 
12578
-------------------------
 
12579
drop table if exists t1 ;
 
12580
drop table if exists t2 ;
 
12581
drop table if exists t3 ;
 
12582
drop table if exists t4 ;
 
12583
drop table if exists t5 ;
 
12584
drop table if exists t6 ;
 
12585
drop table if exists t11 ;
 
12586
drop table if exists t22 ;
 
12587
drop table if exists t33 ;
 
12588
drop table if exists t44 ;
 
12589
drop table if exists t55 ;
 
12590
drop table if exists t66 ;
 
12591
-------------------------------------------------------------------------
 
12592
---  yearweek(col1)-200600  in partition with coltype  date
 
12593
-------------------------------------------------------------------------
 
12594
drop table if exists t1 ;
 
12595
drop table if exists t2 ;
 
12596
drop table if exists t3 ;
 
12597
drop table if exists t4 ;
 
12598
drop table if exists t5 ;
 
12599
drop table if exists t6 ;
 
12600
-------------------------------------------------------------------------
 
12601
---  Create tables with yearweek(col1)-200600
 
12602
-------------------------------------------------------------------------
 
12603
create table t1 (col1 date) engine='INNODB' 
 
12604
partition by range(yearweek(col1)-200600) 
 
12605
(partition p0 values less than (15),
 
12606
partition p1 values less than maxvalue);
 
12607
create table t2 (col1 date) engine='INNODB' 
 
12608
partition by list(yearweek(col1)-200600) 
 
12609
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
12610
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
12611
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
12612
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
12613
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
12614
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
12615
);
 
12616
create table t3 (col1 date) engine='INNODB' 
 
12617
partition by hash(yearweek(col1)-200600);
 
12618
create table t4 (colint int, col1 date) engine='INNODB' 
 
12619
partition by range(colint) 
 
12620
subpartition by hash(yearweek(col1)-200600) subpartitions 2 
 
12621
(partition p0 values less than (15),
 
12622
partition p1 values less than maxvalue);
 
12623
create table t5 (colint int, col1 date) engine='INNODB' 
 
12624
partition by list(colint)
 
12625
subpartition by hash(yearweek(col1)-200600) subpartitions 2 
 
12626
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
12627
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
12628
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
12629
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
12630
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
12631
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
12632
);
 
12633
create table t6 (colint int, col1 date) engine='INNODB' 
 
12634
partition by range(colint) 
 
12635
(partition p0 values less than (yearweek('2006-10-14')-200600),
 
12636
partition p1 values less than maxvalue);
 
12637
-------------------------------------------------------------------------
 
12638
---  Access tables with yearweek(col1)-200600 
 
12639
-------------------------------------------------------------------------
 
12640
insert into t1 values ('2006-01-03');
 
12641
insert into t1 values ('2006-08-17');
 
12642
insert into t2 values ('2006-01-03');
 
12643
insert into t2 values ('2006-08-17');
 
12644
insert into t2 values ('2006-03-25');
 
12645
insert into t3 values ('2006-01-03');
 
12646
insert into t3 values ('2006-08-17');
 
12647
insert into t3 values ('2006-03-25');
 
12648
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4;
 
12649
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5;
 
12650
load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6;
 
12651
select yearweek(col1)-200600 from t1 order by col1;
 
12652
yearweek(col1)-200600
 
12653
1
 
12654
33
 
12655
select * from t1 order by col1;
 
12656
col1
 
12657
2006-01-03
 
12658
2006-08-17
 
12659
select * from t2 order by col1;
 
12660
col1
 
12661
2006-01-03
 
12662
2006-03-25
 
12663
2006-08-17
 
12664
select * from t3 order by col1;
 
12665
col1
 
12666
2006-01-03
 
12667
2006-03-25
 
12668
2006-08-17
 
12669
select * from t4 order by colint;
 
12670
colint  col1
 
12671
1       2006-02-03
 
12672
2       2006-01-17
 
12673
3       2006-01-25
 
12674
4       2006-02-05
 
12675
select * from t5 order by colint;
 
12676
colint  col1
 
12677
1       2006-02-03
 
12678
2       2006-01-17
 
12679
3       2006-01-25
 
12680
4       2006-02-05
 
12681
select * from t6 order by colint;
 
12682
colint  col1
 
12683
1       2006-02-03
 
12684
2       2006-01-17
 
12685
3       2006-01-25
 
12686
4       2006-02-05
 
12687
update t1 set col1='2006-11-15' where col1='2006-01-03';
 
12688
update t2 set col1='2006-11-15' where col1='2006-01-03';
 
12689
update t3 set col1='2006-11-15' where col1='2006-01-03';
 
12690
update t4 set col1='2006-11-15' where col1='2006-01-03';
 
12691
update t5 set col1='2006-11-15' where col1='2006-01-03';
 
12692
update t6 set col1='2006-11-15' where col1='2006-01-03';
 
12693
select * from t1 order by col1;
 
12694
col1
 
12695
2006-08-17
 
12696
2006-11-15
 
12697
select * from t2 order by col1;
 
12698
col1
 
12699
2006-03-25
 
12700
2006-08-17
 
12701
2006-11-15
 
12702
select * from t3 order by col1;
 
12703
col1
 
12704
2006-03-25
 
12705
2006-08-17
 
12706
2006-11-15
 
12707
select * from t4 order by colint;
 
12708
colint  col1
 
12709
1       2006-02-03
 
12710
2       2006-01-17
 
12711
3       2006-01-25
 
12712
4       2006-02-05
 
12713
select * from t5 order by colint;
 
12714
colint  col1
 
12715
1       2006-02-03
 
12716
2       2006-01-17
 
12717
3       2006-01-25
 
12718
4       2006-02-05
 
12719
select * from t6 order by colint;
 
12720
colint  col1
 
12721
1       2006-02-03
 
12722
2       2006-01-17
 
12723
3       2006-01-25
 
12724
4       2006-02-05
 
12725
-------------------------------------------------------------------------
 
12726
---  Alter tables with yearweek(col1)-200600
 
12727
-------------------------------------------------------------------------
 
12728
drop table if exists t11 ;
 
12729
drop table if exists t22 ;
 
12730
drop table if exists t33 ;
 
12731
drop table if exists t44 ;
 
12732
drop table if exists t55 ;
 
12733
drop table if exists t66 ;
 
12734
create table t11 engine='INNODB' as select * from t1;
 
12735
create table t22 engine='INNODB' as select * from t2;
 
12736
create table t33 engine='INNODB' as select * from t3;
 
12737
create table t44 engine='INNODB' as select * from t4;
 
12738
create table t55 engine='INNODB' as select * from t5;
 
12739
create table t66 engine='INNODB' as select * from t6;
 
12740
alter table t11
 
12741
partition by range(yearweek(col1)-200600) 
 
12742
(partition p0 values less than (15),
 
12743
partition p1 values less than maxvalue);
 
12744
alter table t22
 
12745
partition by list(yearweek(col1)-200600) 
 
12746
(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10),
 
12747
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
12748
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
12749
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
12750
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
12751
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
12752
);
 
12753
alter table t33
 
12754
partition by hash(yearweek(col1)-200600);
 
12755
alter table t44
 
12756
partition by range(colint) 
 
12757
subpartition by hash(yearweek(col1)-200600) subpartitions 2 
 
12758
(partition p0 values less than (15),
 
12759
partition p1 values less than maxvalue);
 
12760
alter table t55
 
12761
partition by list(colint)
 
12762
subpartition by hash(yearweek(col1)-200600) subpartitions 2 
 
12763
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
12764
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
12765
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
12766
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
12767
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
12768
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
12769
);
 
12770
alter table t66
 
12771
partition by range(colint) 
 
12772
(partition p0 values less than (yearweek('2006-10-14')-200600),
 
12773
partition p1 values less than maxvalue);
 
12774
select * from t11 order by col1;
 
12775
col1
 
12776
2006-08-17
 
12777
2006-11-15
 
12778
select * from t22 order by col1;
 
12779
col1
 
12780
2006-03-25
 
12781
2006-08-17
 
12782
2006-11-15
 
12783
select * from t33 order by col1;
 
12784
col1
 
12785
2006-03-25
 
12786
2006-08-17
 
12787
2006-11-15
 
12788
select * from t44 order by colint;
 
12789
colint  col1
 
12790
1       2006-02-03
 
12791
2       2006-01-17
 
12792
3       2006-01-25
 
12793
4       2006-02-05
 
12794
select * from t55 order by colint;
 
12795
colint  col1
 
12796
1       2006-02-03
 
12797
2       2006-01-17
 
12798
3       2006-01-25
 
12799
4       2006-02-05
 
12800
select * from t66 order by colint;
 
12801
colint  col1
 
12802
1       2006-02-03
 
12803
2       2006-01-17
 
12804
3       2006-01-25
 
12805
4       2006-02-05
 
12806
---------------------------
 
12807
---- some alter table begin
 
12808
---------------------------
 
12809
alter table t11
 
12810
reorganize partition p0,p1 into
 
12811
(partition s1 values less than maxvalue);
 
12812
select * from t11 order by col1;
 
12813
col1
 
12814
2006-08-17
 
12815
2006-11-15
 
12816
alter table t11
 
12817
reorganize partition s1 into
 
12818
(partition p0 values less than (15),
 
12819
partition p1 values less than maxvalue);
 
12820
select * from t11 order by col1;
 
12821
col1
 
12822
2006-08-17
 
12823
2006-11-15
 
12824
alter table t55
 
12825
partition by list(colint)
 
12826
subpartition by hash(yearweek(col1)-200600) subpartitions 5 
 
12827
(partition p0 values in (1,2,3,4,5,6,7,8,9,10),
 
12828
partition p1 values in (11,12,13,14,15,16,17,18,19,20),
 
12829
partition p2 values in (21,22,23,24,25,26,27,28,29,30),
 
12830
partition p3 values in (31,32,33,34,35,36,37,38,39,40),
 
12831
partition p4 values in (41,42,43,44,45,46,47,48,49,50),
 
12832
partition p5 values in (51,52,53,54,55,56,57,58,59,60)
 
12833
);
 
12834
show create table t55;
 
12835
Table   Create Table
 
12836
t55     CREATE TABLE `t55` (
 
12837
  `colint` int(11) DEFAULT NULL,
 
12838
  `col1` date DEFAULT NULL
 
12839
) ENGINE=InnoDB DEFAULT CHARSET=latin1
 
12840
/*!50100 PARTITION BY LIST (colint)
 
12841
SUBPARTITION BY HASH (yearweek(col1)-200600)
 
12842
SUBPARTITIONS 5
 
12843
(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB,
 
12844
 PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB,
 
12845
 PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB,
 
12846
 PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB,
 
12847
 PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB,
 
12848
 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
 
12849
select * from t55 order by colint;
 
12850
colint  col1
 
12851
1       2006-02-03
 
12852
2       2006-01-17
 
12853
3       2006-01-25
 
12854
4       2006-02-05
 
12855
alter table t66
 
12856
reorganize partition p0,p1 into
 
12857
(partition s1 values less than maxvalue);
 
12858
select * from t66 order by colint;
 
12859
colint  col1
 
12860
1       2006-02-03
 
12861
2       2006-01-17
 
12862
3       2006-01-25
 
12863
4       2006-02-05
 
12864
alter table t66
 
12865
reorganize partition s1 into
 
12866
(partition p0 values less than (yearweek('2006-10-14')-200600),
 
12867
partition p1 values less than maxvalue);
 
12868
select * from t66 order by colint;
 
12869
colint  col1
 
12870
1       2006-02-03
 
12871
2       2006-01-17
 
12872
3       2006-01-25
 
12873
4       2006-02-05
 
12874
alter table t66
 
12875
reorganize partition p0,p1 into
 
12876
(partition s1 values less than maxvalue);
 
12877
select * from t66 order by colint;
 
12878
colint  col1
 
12879
1       2006-02-03
 
12880
2       2006-01-17
 
12881
3       2006-01-25
 
12882
4       2006-02-05
 
12883
alter table t66
 
12884
reorganize partition s1 into
 
12885
(partition p0 values less than (yearweek('2006-10-14')-200600),
 
12886
partition p1 values less than maxvalue);
 
12887
select * from t66 order by colint;
 
12888
colint  col1
 
12889
1       2006-02-03
 
12890
2       2006-01-17
 
12891
3       2006-01-25
 
12892
4       2006-02-05
 
12893
-------------------------------------------------------------------------
 
12894
---  Delete rows and partitions of tables with yearweek(col1)-200600
 
12895
-------------------------------------------------------------------------
 
12896
delete from t1 where col1='2006-08-17';
 
12897
delete from t2 where col1='2006-08-17';
 
12898
delete from t3 where col1='2006-08-17';
 
12899
delete from t4 where col1='2006-08-17';
 
12900
delete from t5 where col1='2006-08-17';
 
12901
delete from t6 where col1='2006-08-17';
 
12902
select * from t1 order by col1;
 
12903
col1
 
12904
2006-11-15
 
12905
select * from t2 order by col1;
 
12906
col1
 
12907
2006-03-25
 
12908
2006-11-15
 
12909
select * from t3 order by col1;
 
12910
col1
 
12911
2006-03-25
 
12912
2006-11-15
 
12913
select * from t4 order by colint;
 
12914
colint  col1
 
12915
1       2006-02-03
 
12916
2       2006-01-17
 
12917
3       2006-01-25
 
12918
4       2006-02-05
 
12919
select * from t5 order by colint;
 
12920
colint  col1
 
12921
1       2006-02-03
 
12922
2       2006-01-17
 
12923
3       2006-01-25
 
12924
4       2006-02-05
 
12925
insert into t1 values ('2006-08-17');
 
12926
insert into t2 values ('2006-08-17');
 
12927
insert into t3 values ('2006-08-17');
 
12928
insert into t4 values (60,'2006-08-17');
 
12929
insert into t5 values (60,'2006-08-17');
 
12930
insert into t6 values (60,'2006-08-17');
 
12931
select * from t1 order by col1;
 
12932
col1
 
12933
2006-08-17
 
12934
2006-11-15
 
12935
select * from t2 order by col1;
 
12936
col1
 
12937
2006-03-25
 
12938
2006-08-17
 
12939
2006-11-15
 
12940
select * from t3 order by col1;
 
12941
col1
 
12942
2006-03-25
 
12943
2006-08-17
 
12944
2006-11-15
 
12945
select * from t4 order by colint;
 
12946
colint  col1
 
12947
1       2006-02-03
 
12948
2       2006-01-17
 
12949
3       2006-01-25
 
12950
4       2006-02-05
 
12951
60      2006-08-17
 
12952
select * from t5 order by colint;
 
12953
colint  col1
 
12954
1       2006-02-03
 
12955
2       2006-01-17
 
12956
3       2006-01-25
 
12957
4       2006-02-05
 
12958
60      2006-08-17
 
12959
select * from t6 order by colint;
 
12960
colint  col1
 
12961
1       2006-02-03
 
12962
2       2006-01-17
 
12963
3       2006-01-25
 
12964
4       2006-02-05
 
12965
60      2006-08-17
 
12966
alter table t1 drop partition p0;
 
12967
alter table t2 drop partition p0;
 
12968
alter table t4 drop partition p0;
 
12969
alter table t5 drop partition p0;
 
12970
alter table t6 drop partition p0;
 
12971
select * from t1 order by col1;
 
12972
col1
 
12973
2006-08-17
 
12974
2006-11-15
 
12975
select * from t2 order by col1;
 
12976
col1
 
12977
2006-03-25
 
12978
2006-08-17
 
12979
2006-11-15
 
12980
select * from t3 order by col1;
 
12981
col1
 
12982
2006-03-25
 
12983
2006-08-17
 
12984
2006-11-15
 
12985
select * from t4 order by colint;
 
12986
colint  col1
 
12987
60      2006-08-17
 
12988
select * from t5 order by colint;
 
12989
colint  col1
 
12990
60      2006-08-17
 
12991
select * from t6 order by colint;
 
12992
colint  col1
 
12993
60      2006-08-17
 
12994
-------------------------------------------------------------------------
 
12995
---  Delete rows and partitions of tables with yearweek(col1)-200600
 
12996
-------------------------------------------------------------------------
 
12997
delete from t11 where col1='2006-08-17';
 
12998
delete from t22 where col1='2006-08-17';
 
12999
delete from t33 where col1='2006-08-17';
 
13000
delete from t44 where col1='2006-08-17';
 
13001
delete from t55 where col1='2006-08-17';
 
13002
delete from t66 where col1='2006-08-17';
 
13003
select * from t11 order by col1;
 
13004
col1
 
13005
2006-11-15
 
13006
select * from t22 order by col1;
 
13007
col1
 
13008
2006-03-25
 
13009
2006-11-15
 
13010
select * from t33 order by col1;
 
13011
col1
 
13012
2006-03-25
 
13013
2006-11-15
 
13014
select * from t44 order by colint;
 
13015
colint  col1
 
13016
1       2006-02-03
 
13017
2       2006-01-17
 
13018
3       2006-01-25
 
13019
4       2006-02-05
 
13020
select * from t55 order by colint;
 
13021
colint  col1
 
13022
1       2006-02-03
 
13023
2       2006-01-17
 
13024
3       2006-01-25
 
13025
4       2006-02-05
 
13026
insert into t11 values ('2006-08-17');
 
13027
insert into t22 values ('2006-08-17');
 
13028
insert into t33 values ('2006-08-17');
 
13029
insert into t44 values (60,'2006-08-17');
 
13030
insert into t55 values (60,'2006-08-17');
 
13031
insert into t66 values (60,'2006-08-17');
 
13032
select * from t11 order by col1;
 
13033
col1
 
13034
2006-08-17
 
13035
2006-11-15
 
13036
select * from t22 order by col1;
 
13037
col1
 
13038
2006-03-25
 
13039
2006-08-17
 
13040
2006-11-15
 
13041
select * from t33 order by col1;
 
13042
col1
 
13043
2006-03-25
 
13044
2006-08-17
 
13045
2006-11-15
 
13046
select * from t44 order by colint;
 
13047
colint  col1
 
13048
1       2006-02-03
 
13049
2       2006-01-17
 
13050
3       2006-01-25
 
13051
4       2006-02-05
 
13052
60      2006-08-17
 
13053
select * from t55 order by colint;
 
13054
colint  col1
 
13055
1       2006-02-03
 
13056
2       2006-01-17
 
13057
3       2006-01-25
 
13058
4       2006-02-05
 
13059
60      2006-08-17
 
13060
select * from t66 order by colint;
 
13061
colint  col1
 
13062
1       2006-02-03
 
13063
2       2006-01-17
 
13064
3       2006-01-25
 
13065
4       2006-02-05
 
13066
60      2006-08-17
 
13067
alter table t11 drop partition p0;
 
13068
alter table t22 drop partition p0;
 
13069
alter table t44 drop partition p0;
 
13070
alter table t55 drop partition p0;
 
13071
alter table t66 drop partition p0;
 
13072
select * from t11 order by col1;
 
13073
col1
 
13074
2006-08-17
 
13075
2006-11-15
 
13076
select * from t22 order by col1;
 
13077
col1
 
13078
2006-03-25
 
13079
2006-08-17
 
13080
2006-11-15
 
13081
select * from t33 order by col1;
 
13082
col1
 
13083
2006-03-25
 
13084
2006-08-17
 
13085
2006-11-15
 
13086
select * from t44 order by colint;
 
13087
colint  col1
 
13088
60      2006-08-17
 
13089
select * from t55 order by colint;
 
13090
colint  col1
 
13091
60      2006-08-17
 
13092
select * from t66 order by colint;
 
13093
colint  col1
 
13094
60      2006-08-17
 
13095
-------------------------
 
13096
---- some alter table end
 
13097
-------------------------
 
13098
drop table if exists t1 ;
 
13099
drop table if exists t2 ;
 
13100
drop table if exists t3 ;
 
13101
drop table if exists t4 ;
 
13102
drop table if exists t5 ;
 
13103
drop table if exists t6 ;
 
13104
drop table if exists t11 ;
 
13105
drop table if exists t22 ;
 
13106
drop table if exists t33 ;
 
13107
drop table if exists t44 ;
 
13108
drop table if exists t55 ;
 
13109
drop table if exists t66 ;