MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
partition_syntax_1.inc
1 ################################################################################
2 # inc/partition_syntax_1.inc #
3 # #
4 # Purpose: #
5 # Auxiliary script, only useful when sourced by inc/partition_syntax.inc #
6 # #
7 # Try to create a table with number of partitions/subpartitions #
8 # = $part_number. Print the layout of the table and drop it. #
9 # #
10 # The parameter $part_number must be set before sourcing this script. #
11 # #
12 #------------------------------------------------------------------------------#
13 # Original Author: mleich #
14 # Original Date: 2006-03-05 #
15 # Change Author: mleich #
16 # Change Date: 2007-10-08 #
17 # Change: Fix for #
18 # Bug#31481 test suite parts: Many tests fail because of #
19 # changed server error codes #
20 ################################################################################
21 
22 --disable_abort_on_error
23 eval CREATE TABLE t1 (
24 $column_list
25 )
26 PARTITION BY HASH(f_int1) PARTITIONS $part_number;
27 --enable_abort_on_error
28 --disable_query_log
29 eval SET @my_errno= $mysql_errno ;
30 let $run= `SELECT @my_errno = 0`;
31 # Expected error codes are
32 # 0, ER_PARSE_ERROR (Reason: assign -1 partitions), ER_TOO_MANY_PARTITIONS_ERROR
33 # and ER_NO_PARTS_ERROR
34 if (`SELECT @my_errno NOT IN (0,$ER_PARSE_ERROR,$ER_TOO_MANY_PARTITIONS_ERROR,
35  $ER_NO_PARTS_ERROR)`)
36 {
37  --echo # The last command got an unexepected error response.
38  --echo # Expected/handled SQL codes are 0,$ER_PARSE_ERROR,$ER_TOO_MANY_PARTITIONS_ERROR,$ER_NO_PARTS_ERROR
39  SELECT '# SQL code we got was: ' AS "", @my_errno AS "";
40  --echo # Sorry, have to abort.
41  exit;
42  --echo
43 }
44 --enable_query_log
45 #
46 # If this operation was successfull, print layout + drop this table
47 if ($run)
48 {
49  --source suite/parts/inc/partition_layout_check1.inc
50  eval DROP TABLE t1;
51 }
52 #### Try to create a table with the given subpartition number
53 --disable_abort_on_error
54 eval CREATE TABLE t1 (
55 $column_list
56 )
57 PARTITION BY RANGE(f_int1) SUBPARTITION BY HASH(f_int1)
58 SUBPARTITIONS $part_number
59 (PARTITION part1 VALUES LESS THAN ($max_row_div2),
60  PARTITION part2 VALUES LESS THAN $MAX_VALUE);
61 --enable_abort_on_error
62 --disable_query_log
63 eval SET @my_errno= $mysql_errno ;
64 let $run= `SELECT @my_errno = 0`;
65 # Expected error codes are
66 # 0, ER_PARSE_ERROR (Reason: assign -1 partitions), ER_TOO_MANY_PARTITIONS_ERROR
67 # and ER_NO_PARTS_ERROR
68 if (`SELECT @my_errno NOT IN (0,$ER_PARSE_ERROR,$ER_TOO_MANY_PARTITIONS_ERROR,
69  $ER_NO_PARTS_ERROR)`)
70 {
71  --echo # The last command got an unexepected error response.
72  --echo # Expected/handled SQL codes are 0,$ER_PARSE_ERROR,$ER_TOO_MANY_PARTITIONS_ERROR,$ER_NO_PARTS_ERROR
73  SELECT '# SQL code we got was: ' AS "", @my_errno AS "";
74  --echo # Sorry, have to abort.
75  exit;
76  --echo
77 }
78 --enable_query_log
79 #
80 # If this operation was successfull, print layout + drop this table
81 if ($run)
82 {
83  --source suite/parts/inc/partition_layout_check1.inc
84  eval DROP TABLE t1;
85 }