1 ################################################################################ 
    2 # inc/partition_engine.inc                                                     # 
    5 #   Tests around Create/Alter partitioned tables and storage engine settings   # 
    6 #   at different places within the statement.                                  # 
    7 #   This routine is only useful for the partition_<feature>_<engine> tests.    # 
    9 # Note: There were some problems in history.                                   # 
   10 #    It looks like a table holds informations about the storage engine         # 
   12 #      "the whole table" -> in statement after column list before partitioning # 
   13 #      a partition       -> in statement after definition of partition         # 
   14 #      a subpartition    -> in statement after definition of subpartition      # 
   15 #    If there is a CREATE TABLE statement where not at all of these place      # 
   16 #    a storage engine is assigned, the server must decide by itself whic       # 
   17 #    storage engine to use.                                                    # 
   19 #------------------------------------------------------------------------------# 
   20 # Original Author: mleich                                                      # 
   21 # Original Date: 2006-03-05                                                    # 
   25 ################################################################################ 
   28 --echo #========================================================================
 
   29 --echo # Checks where the engine is assigned on all supported (CREATE 
TABLE 
   30 --echo # 
statement) positions + basic operations on the tables
 
   31 --echo #        Storage engine mixups are currently (2005-12-23) not supported
 
   32 --echo 
#======================================================================== 
   34 DROP 
TABLE IF EXISTS t1;
 
   38 --echo #------------------------------------------------------------------------
 
   39 --echo # 1 Assignment of storage engine just after column list only
 
   40 --echo #------------------------------------------------------------------------
 
   41 eval CREATE 
TABLE t1 (
 
   44      PARTITION BY 
HASH(f_int1) PARTITIONS 2;
 
   45 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
 
   46 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
 
   47 --source suite/parts/inc/partition_check.inc
 
   50 --echo #------------------------------------------------------------------------
 
   51 --echo # 2 Assignment of storage engine just after partition or subpartition
 
   53 --echo #------------------------------------------------------------------------
 
   54 eval CREATE 
TABLE t1 (
 
   57 PARTITION BY 
HASH(f_int1)
 
   58 ( PARTITION part1 STORAGE ENGINE = $engine,
 
   59   PARTITION part2 STORAGE ENGINE = $engine
 
   61 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
 
   62 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
 
   63 --source suite/parts/inc/partition_check.inc
 
   65 eval CREATE 
TABLE t1 (
 
   68 PARTITION BY RANGE(f_int1)
 
   69 SUBPARTITION BY 
HASH(f_int1)
 
   70 ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
 
   71      (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
 
   72       SUBPARTITION subpart12 STORAGE ENGINE = $engine),
 
   73   PARTITION part2 VALUES LESS THAN $MAX_VALUE
 
   74      (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
 
   75       SUBPARTITION subpart22 STORAGE ENGINE = $engine)
 
   77 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
 
   78 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
 
   79 --source suite/parts/inc/partition_check.inc
 
   82 --echo #------------------------------------------------------------------------
 
   83 --echo # 3 Some but not all named partitions or subpartitions 
get a storage
 
   84 --echo #   engine assigned
 
   85 --echo #------------------------------------------------------------------------
 
   86 --error ER_MIX_HANDLER_ERROR
 
   87 eval CREATE 
TABLE t1 (
 
   90 PARTITION BY 
HASH(f_int1)
 
   91 ( PARTITION part1 STORAGE ENGINE = $engine,
 
   94 --error ER_MIX_HANDLER_ERROR
 
   95 eval CREATE 
TABLE t1 (
 
   98 PARTITION BY 
HASH(f_int1)
 
  100   PARTITION part2 STORAGE ENGINE = $engine
 
  102 --error ER_MIX_HANDLER_ERROR
 
  103 eval CREATE 
TABLE t1 (
 
  106 PARTITION BY RANGE(f_int1)
 
  107 SUBPARTITION BY 
HASH(f_int1)
 
  108 ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
 
  109      (SUBPARTITION subpart11,
 
  110       SUBPARTITION subpart12 STORAGE ENGINE = $engine),
 
  111   PARTITION part2 VALUES LESS THAN $MAX_VALUE
 
  112      (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
 
  113       SUBPARTITION subpart22 STORAGE ENGINE = $engine)
 
  115 --error ER_MIX_HANDLER_ERROR
 
  116 eval CREATE 
TABLE t1 (
 
  119 PARTITION BY RANGE(f_int1)
 
  120 SUBPARTITION BY 
HASH(f_int1)
 
  121 ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
 
  122      (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
 
  123       SUBPARTITION subpart12 STORAGE ENGINE = $engine),
 
  124   PARTITION part2 VALUES LESS THAN $MAX_VALUE
 
  125      (SUBPARTITION subpart21,
 
  126       SUBPARTITION subpart22 )
 
  128 eval CREATE 
TABLE t1 (
 
  132 PARTITION BY RANGE(f_int1)
 
  133 SUBPARTITION BY 
HASH(f_int1)
 
  134 ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
 
  135      (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
 
  136       SUBPARTITION subpart12 STORAGE ENGINE = $engine),
 
  137   PARTITION part2 VALUES LESS THAN $MAX_VALUE
 
  138      (SUBPARTITION subpart21,
 
  139       SUBPARTITION subpart22 )
 
  141 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
 
  142 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
 
  143 --source suite/parts/inc/partition_check.inc
 
  146 --echo #------------------------------------------------------------------------
 
  147 --echo # 4 Storage engine assignment after partition 
name + after 
name of
 
  148 --echo #   subpartitions belonging 
to another partition
 
  149 --echo #------------------------------------------------------------------------
 
  150 --error ER_MIX_HANDLER_ERROR
 
  151 eval CREATE 
TABLE t1 (
 
  154 PARTITION BY RANGE(f_int1)
 
  155 SUBPARTITION BY 
HASH(f_int1)
 
  156 ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
 
  157      (SUBPARTITION subpart11,
 
  158       SUBPARTITION subpart12),
 
  159   PARTITION part2 VALUES LESS THAN $MAX_VALUE
 
  160      (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
 
  161       SUBPARTITION subpart22 STORAGE ENGINE = $engine)
 
  163 eval CREATE 
TABLE t1 (
 
  167 PARTITION BY RANGE(f_int1)
 
  168 SUBPARTITION BY 
HASH(f_int1)
 
  169 ( PARTITION part1 VALUES LESS THAN ($max_row_div2) ENGINE = $engine
 
  170      (SUBPARTITION subpart11,
 
  171       SUBPARTITION subpart12),
 
  172   PARTITION part2 VALUES LESS THAN $MAX_VALUE
 
  173      (SUBPARTITION subpart21,
 
  174       SUBPARTITION subpart22 STORAGE ENGINE = $engine)
 
  177 eval CREATE 
TABLE t1 (
 
  180 PARTITION BY RANGE(f_int1)
 
  181 SUBPARTITION BY 
HASH(f_int1)
 
  182 ( PARTITION part1 VALUES LESS THAN ($max_row_div2) ENGINE = $engine
 
  183      (SUBPARTITION subpart11,
 
  184       SUBPARTITION subpart12),
 
  185   PARTITION part2 VALUES LESS THAN $MAX_VALUE
 
  186      (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
 
  187       SUBPARTITION subpart22 STORAGE ENGINE = $engine)
 
  189 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
 
  190 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
 
  191 --source suite/parts/inc/partition_check.inc
 
  193 eval CREATE 
TABLE t1 (
 
  196 PARTITION BY RANGE(f_int1)
 
  197 SUBPARTITION BY 
HASH(f_int1)
 
  198 ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
 
  199      (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
 
  200       SUBPARTITION subpart12 STORAGE ENGINE = $engine),
 
  201   PARTITION part2 VALUES LESS THAN $MAX_VALUE ENGINE = $engine
 
  202      (SUBPARTITION subpart21 ENGINE = $engine,
 
  203       SUBPARTITION subpart22)
 
  205 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
 
  206 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
 
  207 --source suite/parts/inc/partition_check.inc
 
  210 --echo #------------------------------------------------------------------------
 
  211 --echo # 5 Precedence of storage engine assignments (
if there is any)
 
  212 --echo #------------------------------------------------------------------------
 
  213 --echo # 5.1 Storage engine assignment after column list + after partition
 
  214 --echo #     or subpartition 
name 
  215 eval CREATE 
TABLE t1 (
 
  218 PARTITION BY 
HASH(f_int1)
 
  219 ( PARTITION part1 STORAGE ENGINE = $engine,
 
  220   PARTITION part2 STORAGE ENGINE = $engine
 
  222 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
 
  223 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
 
  224 --source suite/parts/inc/partition_check.inc
 
  226 eval CREATE 
TABLE t1 (
 
  229 PARTITION BY RANGE(f_int1)
 
  230 SUBPARTITION BY 
HASH(f_int1)
 
  231 ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
 
  232      (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
 
  233       SUBPARTITION subpart12 STORAGE ENGINE = $engine),
 
  234   PARTITION part2 VALUES LESS THAN $MAX_VALUE
 
  235      (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
 
  236       SUBPARTITION subpart22 STORAGE ENGINE = $engine)
 
  238 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
 
  239 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
 
  240 --source suite/parts/inc/partition_check.inc
 
  242 --echo 
# 6.2 Storage engine assignment after partition name + after 
  243 --echo #     subpartition 
name 
  244 --echo #     in partition part + in sub partition part
 
  245 eval CREATE 
TABLE t1 (
 
  248 PARTITION BY RANGE(f_int1)
 
  249 SUBPARTITION BY 
HASH(f_int1)
 
  250 ( PARTITION part1 VALUES LESS THAN ($max_row_div2) STORAGE ENGINE = $engine
 
  251      (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
 
  252       SUBPARTITION subpart12 STORAGE ENGINE = $engine),
 
  253   PARTITION part2 VALUES LESS THAN $MAX_VALUE
 
  254      (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
 
  255       SUBPARTITION subpart22 STORAGE ENGINE = $engine)
 
  257 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
 
  258 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
 
  259 --source suite/parts/inc/partition_check.inc
 
  262 --echo 
#------------------------------------------------------------------------ 
  263 --echo # 6 Session 
default engine differs from engine used within create 
table 
  264 --echo #------------------------------------------------------------------------
 
  265 eval SET SESSION default_storage_engine=$engine_other;
 
  266 # Bug#16775 Partitions: strange effects on subpartitioned tables, mixed storage engines 
  267 # Bug#15966 Partitions: crash if session default engine <> engine used in create table 
  268 eval CREATE 
TABLE t1 (
 
  271 PARTITION BY 
HASH(f_int1) ( PARTITION part1 ENGINE = $engine);
 
  272 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
 
  273 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
 
  274 --source suite/parts/inc/partition_check.inc
 
  276 # Bug#15966 Partitions: crash if session default engine <> engine used in create table 
  277 eval CREATE 
TABLE t1 (
 
  280 PARTITION BY RANGE(f_int1)
 
  281 SUBPARTITION BY 
HASH(f_int1)
 
  282 ( PARTITION part1 VALUES LESS THAN (1000)
 
  283      (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
 
  284       SUBPARTITION subpart12 STORAGE ENGINE = $engine));
 
  285 INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
 
  286 SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
 
  287 --source suite/parts/inc/partition_check.inc
 
  289 eval SET SESSION default_storage_engine=$engine;