Debian Codegraph @

mysql-test/suite/parts/inc/partition_date.inc

raw
1 eval create table t1 (a date not null, primary key(a)) engine=$engine
2 partition by key (a) (
3 partition pa1 max_rows=20 min_rows=2,
4 partition pa2 max_rows=30 min_rows=3,
5 partition pa3 max_rows=30 min_rows=4,
6 partition pa4 max_rows=40 min_rows=2);
7 show create table t1;
8 insert into t1 values ('1975-01-01'), ('2020-12-31'), ('1980-10-14'), ('2000-06-15');
9 select * from t1;
10 select * from t1 where a=19801014;
11 delete from t1 where a=19801014;
12 select * from t1;
13 drop table t1;
14
15 eval create table t2 (a date not null, primary key(a)) engine=$engine
16 partition by key (a) partitions 12;
17 show create table t2;
18 insert into t2 values ('1975-01-01'), ('2020-12-31'), ('1980-10-14'), ('2000-06-15');
19 select * from t2;
20 select * from t2 where a='1980-10-14';
21 delete from t2 where a='1980-10-14';
22 select * from t2;
23 delete from t2;
24 let $count=28;
25 --echo $count inserts;
26 --disable_query_log
27 begin;
28 while ($count)
29 {
30 eval insert into t2 values (19700101+$count-1);
31 eval insert into t2 values (19700201+$count-1);
32 eval insert into t2 values (19700301+$count-1);
33 dec $count;
34 }
35 commit;
36 --enable_query_log
37 select count(*) from t2;
38 select * from t2;
39 drop table t2;
40
41 eval create table t3 (a date not null, primary key(a)) engine=$engine
42 partition by range (month(a)) subpartition by key (a)
43 subpartitions 3 (
44 partition quarter1 values less than (4),
45 partition quarter2 values less than (7),
46 partition quarter3 values less than (10),
47 partition quarter4 values less than (13)
48 );
49 show create table t3;
50 let $count=12;
51 --echo $count inserts;
52 --disable_query_log
53 begin;
54 while ($count)
55 {
56 eval insert into t3 values (adddate(19700101,interval $count-1 month));
57 dec $count;
58 }
59 commit;
60 --enable_query_log
61 select count(*) from t3;
62 select * from t3;
63 drop table t3;
64
65 eval create table t4 (a date not null, primary key(a)) engine=$engine
66 partition by list (month(a)) subpartition by key (a)
67 subpartitions 3 (
68 partition quarter1 values in (1,2,3),
69 partition quarter2 values in (4,5,6),
70 partition quarter3 values in (7,8,9),
71 partition quarter4 values in (10,11,12)
72 );
73 show create table t4;
74 let $count=12;
75 --echo $count inserts;
76 --disable_query_log
77 begin;
78 while ($count)
79 {
80 eval insert into t4 values (adddate(19700101,interval $count-1 month));
81 dec $count;
82 }
83 commit;
84 --enable_query_log
85 select count(*) from t4;
86 select * from t4;
87 drop table t4;