MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
partition_max_sub_parts_range.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 ##### max rows to be inserted
4 let $maxrows=32767;
5 
6 # The CREATE will be written into a temporary file ($MYSQL_TMP_DIR/part_list_elem.inc).
7 # After inserting the content of the file it will be removed.
8 perl;
9  use strict;
10  use warnings;
11  my $fname= "$ENV{'MYSQL_TMP_DIR'}/part_list_elem.inc";
12  my @wrlines;
13  push (@wrlines, "eval create table t2 (a int) engine=\$engine\n");
14  push (@wrlines, " partition by range (a) \n");
15  push (@wrlines, " subpartition by hash (a) \n");
16  push (@wrlines, " subpartitions 2 (\n");
17  for(my $i=0; $i<4096; $i++)
18  {
19  my $j= ($i+1)* 8;
20  my $pattern= " PARTITION p$i VALUES LESS THAN ($j),\n";
21  my $last_pattern= " PARTITION p$i VALUES LESS THAN ($j)\n";
22  if ($i<4095)
23  {
24  push(@wrlines,$pattern);
25  }
26  else
27  {
28  push(@wrlines,$last_pattern);
29  }
30 
31  }
32  push (@wrlines, " );\n");
33  open(FILE, ">", $fname) or die;
34  print FILE @wrlines;
35  close FILE;
36 EOF
37 
38 source $MYSQL_TMP_DIR/part_list_elem.inc;
39 #remove_file $MYSQL_TMP_DIR/part_list_elem.inc;
40 
41 let $count= $maxrows;
42 --echo $count inserts;
43 --disable_query_log
44 while ($count)
45 {
46 eval insert into t2 values ($count);
47 dec $count;
48 }
49 --enable_query_log
50 select count(*) from t2;
51 select count(*) from t2 partition (p0);
52 select count(*) from t2 partition (p10);
53 select count(*) from t2 partition (p100);
54 select count(*) from t2 partition (p1000);
55 select count(*) from t2 partition (p4000);
56 select count(*) from t2 partition (p4095);
57 
58 select * from t2 partition (p0);
59 select * from t2 partition (p10);
60 select * from t2 partition (p100);
61 select * from t2 partition (p1000);
62 select * from t2 partition (p4000);
63 select * from t2 partition (p4095);
64 
65 delete from t2 partition (p4095);
66 select * from t2 partition (p4095);
67 insert into t2 partition (p4095) values (32766), (32767);
68 select * from t2 partition (p4095);
69 update t2 partition (p4095) set a=32765 where a= 32767;
70 select * from t2 partition (p4095);
71 
72 write_file $MYSQL_TMP_DIR/data01;
73 32766,
74 32764,
75 EOF
76 replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR;
77 eval load data infile '$MYSQL_TMP_DIR/data01' into table t2 partition (p4095) fields terminated by ',';
78 remove_file $MYSQL_TMP_DIR/data01;
79 select * from t2 partition (p4095);
80 
81 error ER_TOO_MANY_PARTITIONS_ERROR;
82 alter table t2 add partition (partition p4096 values less than (32775));
83 
84 drop table t2;
85