MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
partition_enum.inc
1 --echo ---- Partitioning and enum data type
2 
3 eval create table t1 (a enum('A','B','C','D','E','F','G','H','I','J','K','L') not null, primary key(a)) engine=$engine
4 partition by key (a) (
5 partition pa1 max_rows=20 min_rows=2,
6 partition pa2 max_rows=30 min_rows=3,
7 partition pa3 max_rows=30 min_rows=4,
8 partition pa4 max_rows=40 min_rows=2);
9 show create table t1;
10 insert into t1 values ('A'),('D'),('L'),('G');
11 select * from t1;
12 select * from t1 where a='A';
13 update t1 set a='E' where a='L';
14 select * from t1;
15 delete from t1 where a='E';
16 select * from t1;
17 drop table t1;
18 
19 eval create table t2 (a enum (
20 '1','2','3','4','5','6','7','8','9','0',
21 'A','B','C','D','E','F','G','H','I','J','K','L',
22 'M','N','O','P','Q','R','S','T','U','V','W','X',
23 'Y','Z'
24 ) not null, primary key(a)) engine=$engine
25 partition by key (a) partitions 27;
26 show create table t2;
27 let $letter=26;
28 --echo $count inserts;
29 #--disable_query_log
30 while ($letter)
31 {
32 eval insert into t2 values (char(ascii('A')+$letter));
33 dec $letter;
34 }
35 insert into t2 values ('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'),('0');
36 select count(*) from t2;
37 select * from t2;
38 drop table t2;
39 
40 # mleich: Several partitioning functions are no more allowed.
41 if (0)
42 {
43 eval create table t3 (a enum (
44 '1','2','3','4','5','6','7','8','9','0',
45 'A','B','C','D','E','F','G','H','I','J','K','L',
46 'M','N','O','P','Q','R','S','T','U','V','W','X',
47 'Y','Z'
48 ) not null, primary key(a)) engine=$engine
49 partition by range (a) subpartition by key (a) subpartitions 3 (
50 partition pa9 values less than (10),
51 partition pa18 values less than (19),
52 partition pa27 values less than (28),
53 partition pa36 values less than (37)
54 );
55 show create table t3;
56 let $letter=36;
57 --echo $count inserts;
58 #--disable_query_log
59 while ($letter)
60 {
61 #eval insert into t3 values ($letter);
62 dec $letter;
63 }
64 select count(*) from t3;
65 select * from t3;
66 drop table t3;
67 }
68 # End of tests with disallowed partitioning functions.