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