MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
partition_max_sub_parts_key_list.inc
1 # Need more as 16k open files per process (ulimit -n) on Unix systems.
2 --source include/have_partition_open_file_limit.inc
3 # Create a list partitioned table with 8192 partitions.
4 # The CREATE will be written into a temporary file ($MYSQL_TMP_DIR/part_list_elem.inc).
5 # After inserting the content of the file it will be removed.
6 perl;
7  use strict;
8  use warnings;
9  my $fname= "$ENV{'MYSQL_TMP_DIR'}/part_list_elem.inc";
10  my @wrlines;
11  push (@wrlines, "eval create table t2 (a int not null, primary key(a)) engine=\$engine\n");
12  push (@wrlines, " partition by list (a)\n");
13  push (@wrlines, " subpartition by key (a)");
14  push (@wrlines, " subpartitions 2 (\n");
15  for(my $i=0; $i<4096; $i++)
16  {
17  my $j= $i*4;
18  if ($i<4095)
19  {
20  my $pattern= " PARTITION p$i VALUES IN (".$j++.",".$j++.",".$j++.",".$j++."),\n";
21  push(@wrlines,$pattern);
22  }
23  else
24  {
25  my $last_pattern= " PARTITION p$i VALUES IN (".$j++.",".$j++.",".$j++.",".$j++.")\n";
26  push(@wrlines,$last_pattern);
27  }
28 
29  }
30  push (@wrlines, " );\n");
31  open(FILE, ">", $fname) or die;
32  print FILE @wrlines;
33  close FILE;
34 EOF
35 
36 source $MYSQL_TMP_DIR/part_list_elem.inc;
37 #remove_file $MYSQL_TMP_DIR/part_list_elem.inc;
38 
39 let $count= 16383;
40 --echo $count inserts;
41 --disable_query_log
42 while ($count)
43 {
44 eval insert into t2 values ($count);
45 dec $count;
46 }
47 --enable_query_log
48 select count(*) from t2;
49 select count(*) from t2 partition (p0);
50 select count(*) from t2 partition (p10);
51 select count(*) from t2 partition (p100);
52 select count(*) from t2 partition (p1000);
53 select count(*) from t2 partition (p4000);
54 select count(*) from t2 partition (p4095);
55 
56 select * from t2 partition (p0);
57 select * from t2 partition (p10);
58 select * from t2 partition (p100);
59 select * from t2 partition (p1000);
60 select * from t2 partition (p4000);
61 select * from t2 partition (p4095);
62 
63 delete from t2 partition (p4095);
64 select * from t2 partition (p4095);
65 insert into t2 partition (p4095) values (16382),(16383);
66 select * from t2 partition (p4095);
67 update t2 partition (p4095) set a=16381 where a= 16382;
68 select * from t2 partition (p4095);
69 
70 write_file $MYSQL_TMP_DIR/data01;
71 16380,
72 16382,
73 EOF
74 replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR;
75 eval load data infile '$MYSQL_TMP_DIR/data01' into table t2 partition (p4095) fields terminated by ',';
76 remove_file $MYSQL_TMP_DIR/data01;
77 select * from t2 partition (p4095);
78 
79 error ER_TOO_MANY_PARTITIONS_ERROR;
80 alter table t2 add partition (partition p4096 values in (16384,16385,16386,16387));
81 
82 drop table t2;
83