SET SESSION storage_engine='MYISAM'; SET @max_row = 200; SET AUTOCOMMIT= 1; #------------------------------------------------------------------------ # There are several testcases disabled because ouf the open bugs # #15407 , #15408 , #15890 , #15961 , #13447 , #15966 , #15968, #16370 #------------------------------------------------------------------------ #------------------------------------------------------------------------ # 0. Setting of auxiliary variables + Creation of an auxiliary table # needed in all testcases #------------------------------------------------------------------------ DROP TABLE IF EXISTS t0_template; CREATE TABLE t0_template ( f1 INTEGER, f2 char(20), PRIMARY KEY(f1)) ENGINE = MEMORY; # Logging of <max_row> INSERTs into t0_template suppressed #------------------------------------------------------------------------ # 1. Some syntax checks #------------------------------------------------------------------------ # 1.1 Subpartioned table without subpartitioning rule must be rejected DROP TABLE IF EXISTS t1; # FIXME Implement testcases, where it is checked that all create and # alter table statements # - with missing mandatory parameters are rejected # - with optional parameters are accepted # - with wrong combinations of optional parameters are rejected # - ............ #------------------------------------------------------------------------ # 2. Checks where the engine is assigned on all supported (CREATE TABLE # statement) positions + basic operations on the tables # Storage engine mixups are currently (2005-12-23) not supported #------------------------------------------------------------------------ DROP TABLE IF EXISTS t1; # 2.1 non partitioned table (for comparison) CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) ENGINE = 'MYISAM'; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; # 2.2 Assignment of storage engine just after column list only CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) ENGINE = 'MYISAM' PARTITION BY HASH(f1) PARTITIONS 2; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) PARTITIONS 2 SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; # 2.3 Assignment of storage engine just after partition or subpartition # name only CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) ( PARTITION part1 STORAGE ENGINE = 'MYISAM', PARTITION part2 STORAGE ENGINE = 'MYISAM' ); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = MyISAM, PARTITION part2 ENGINE = MyISAM) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) ( PARTITION part1 VALUES LESS THAN (100) (SUBPARTITION subpart11 STORAGE ENGINE = 'MYISAM', SUBPARTITION subpart12 STORAGE ENGINE = 'MYISAM'), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 STORAGE ENGINE = 'MYISAM', SUBPARTITION subpart22 STORAGE ENGINE = 'MYISAM') ); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (100) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 ENGINE = MyISAM, SUBPARTITION subpart22 ENGINE = MyISAM)) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; # 2.4 Some but not all named partitions or subpartitions get a storage # engine assigned CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) ( PARTITION part1 STORAGE ENGINE = 'MYISAM', PARTITION part2 ); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = MyISAM, PARTITION part2 ENGINE = MyISAM) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) ( PARTITION part1 , PARTITION part2 STORAGE ENGINE = 'MYISAM' ); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = MyISAM, PARTITION part2 ENGINE = MyISAM) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) ( PARTITION part1 VALUES LESS THAN (100) (SUBPARTITION subpart11, SUBPARTITION subpart12 STORAGE ENGINE = 'MYISAM'), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 STORAGE ENGINE = 'MYISAM', SUBPARTITION subpart22 STORAGE ENGINE = 'MYISAM') ); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (100) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 ENGINE = MyISAM, SUBPARTITION subpart22 ENGINE = MyISAM)) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) ( PARTITION part1 VALUES LESS THAN (100) (SUBPARTITION subpart11 STORAGE ENGINE = 'MYISAM', SUBPARTITION subpart12 STORAGE ENGINE = 'MYISAM'), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21, SUBPARTITION subpart22 ) ); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (100) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 ENGINE = MyISAM, SUBPARTITION subpart22 ENGINE = MyISAM)) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; # 2.5 Storage engine assignment after partition name + after name of # subpartitions belonging to another partition CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) ( PARTITION part1 VALUES LESS THAN (100) ENGINE = 'MYISAM' (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 STORAGE ENGINE = 'MYISAM', SUBPARTITION subpart22 STORAGE ENGINE = 'MYISAM') ); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (100) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 ENGINE = MyISAM, SUBPARTITION subpart22 ENGINE = MyISAM)) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) ( PARTITION part1 VALUES LESS THAN (100) (SUBPARTITION subpart11 STORAGE ENGINE = 'MYISAM', SUBPARTITION subpart12 STORAGE ENGINE = 'MYISAM'), PARTITION part2 VALUES LESS THAN (2147483647) ENGINE = 'MYISAM' (SUBPARTITION subpart21, SUBPARTITION subpart22) ); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (100) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 ENGINE = MyISAM, SUBPARTITION subpart22 ENGINE = MyISAM)) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; # 2.6 Precedence of storage engine assignments # 2.6.1 Storage engine assignment after column list + after partition # or subpartition name CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) ENGINE = 'MYISAM' PARTITION BY HASH(f1) ( PARTITION part1 STORAGE ENGINE = 'MYISAM', PARTITION part2 STORAGE ENGINE = 'MYISAM' ); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = MyISAM, PARTITION part2 ENGINE = MyISAM) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) ENGINE = 'MYISAM' PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) ( PARTITION part1 VALUES LESS THAN (100) (SUBPARTITION subpart11 STORAGE ENGINE = 'MYISAM', SUBPARTITION subpart12 STORAGE ENGINE = 'MYISAM'), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 STORAGE ENGINE = 'MYISAM', SUBPARTITION subpart22 STORAGE ENGINE = 'MYISAM') ); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (100) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 ENGINE = MyISAM, SUBPARTITION subpart22 ENGINE = MyISAM)) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; # 2.6.2 Storage engine assignment after partition name + after # subpartition name CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) ( PARTITION part1 VALUES LESS THAN (100) STORAGE ENGINE = 'MYISAM' (SUBPARTITION subpart11 STORAGE ENGINE = 'MYISAM', SUBPARTITION subpart12 STORAGE ENGINE = 'MYISAM'), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 STORAGE ENGINE = 'MYISAM', SUBPARTITION subpart22 STORAGE ENGINE = 'MYISAM') ); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (100) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 ENGINE = MyISAM, SUBPARTITION subpart22 ENGINE = MyISAM)) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; # 2.7 Session default engine differs from engine used within create table SET SESSION storage_engine='MEMORY'; SET SESSION storage_engine='MYISAM'; #------------------------------------------------------------------------ # 3. Check assigning the number of partitions and subpartitions # with and without named partitions/subpartitions #------------------------------------------------------------------------ DROP TABLE IF EXISTS t1; # 3.1 (positive) without partition/subpartition number assignment # 3.1.1 no partition number, no named partitions CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; # 3.1.2 no partition number, named partitions CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) (PARTITION part1, PARTITION part2); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = MyISAM, PARTITION part2 ENGINE = MyISAM) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; # 3.1.3 variations on no partition/subpartition number, named partitions, # different subpartitions are/are not named CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (200), PARTITION part3 VALUES LESS THAN (2147483647)) ; DROP TABLE t1; CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) (PARTITION part1 VALUES LESS THAN (100) (SUBPARTITION subpart11 , SUBPARTITION subpart12 ), PARTITION part2 VALUES LESS THAN (200) (SUBPARTITION subpart21 , SUBPARTITION subpart22 ), PARTITION part3 VALUES LESS THAN (2147483647) (SUBPARTITION subpart31 , SUBPARTITION subpart32 )) ; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (100) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), PARTITION part2 VALUES LESS THAN (200) (SUBPARTITION subpart21 ENGINE = MyISAM, SUBPARTITION subpart22 ENGINE = MyISAM), PARTITION part3 VALUES LESS THAN (2147483647) (SUBPARTITION subpart31 ENGINE = MyISAM, SUBPARTITION subpart32 ENGINE = MyISAM)) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; # 3.2 partition/subpartition numbers good and bad values and notations DROP TABLE IF EXISTS t1; # 3.2.1 partition/subpartition numbers INTEGER notation CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS 2; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) PARTITIONS 2 SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS 2 (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) SUBPARTITIONS 2 (PARTITION part1 VALUES LESS THAN (100) , PARTITION part2 VALUES LESS THAN (2147483647) ) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS 1; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) PARTITIONS 1 SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS 1 (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) SUBPARTITIONS 1 (PARTITION part1 VALUES LESS THAN (100) , PARTITION part2 VALUES LESS THAN (2147483647) ) SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS 0; ERROR HY000: Number of partitions = 0 is not an allowed value CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS 0 (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR HY000: Number of subpartitions = 0 is not an allowed value CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS -1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS -1 (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1 (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (21' at line 3 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS 1000000; ERROR HY000: Too many partitions (including subpartitions) were defined CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS 1000000 (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR HY000: Too many partitions (including subpartitions) were defined # 3.2.4 partition/subpartition numbers STRING notation CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS '2'; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2'' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS '2' (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2' (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2' at line 3 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS '2.0'; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2.0'' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS '2.0' (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2.0' (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN ' at line 3 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS '0.2E+1'; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0.2E+1'' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS '0.2E+1' (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0.2E+1' (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS TH' at line 3 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS '2A'; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2A'' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS '2A' (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2A' (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (' at line 3 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS 'A2'; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''A2'' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS 'A2' (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''A2' (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (' at line 3 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS ''; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '''' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS '' (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (21' at line 3 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS 'GARBAGE'; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''GARBAGE'' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS 'GARBAGE' (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''GARBAGE' (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS T' at line 3 # 3.2.5 partition/subpartition numbers other notations CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS 2A; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2A' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS 2A (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2A (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (21' at line 3 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS A2; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'A2' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS A2 (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'A2 (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (21' at line 3 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS GARBAGE; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GARBAGE' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS GARBAGE (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GARBAGE (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THA' at line 3 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS "2"; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"2"' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS "2" (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"2" (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2' at line 3 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS "2A"; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"2A"' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS "2A" (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"2A" (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (' at line 3 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS "A2"; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"A2"' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS "A2" (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"A2" (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (' at line 3 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS "GARBAGE"; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"GARBAGE"' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS "GARBAGE" (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS THAN (2147483647)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"GARBAGE" (PARTITION part1 VALUES LESS THAN (100), PARTITION part2 VALUES LESS T' at line 3 # 3.3 Mixups of assigned partition/subpartition numbers and names # 3.3.1 (positive) number of partition/subpartition # = number of named partition/subpartition CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS 2 ( PARTITION part1, PARTITION part2 ) ; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = MyISAM, PARTITION part2 ENGINE = MyISAM) DROP TABLE t1; CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) PARTITIONS 2 SUBPARTITION BY HASH(f1) SUBPARTITIONS 2 ( PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21, SUBPARTITION subpart22) ); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11 ENGINE = MyISAM, SUBPARTITION subpart12 ENGINE = MyISAM), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 ENGINE = MyISAM, SUBPARTITION subpart22 ENGINE = MyISAM)) DROP TABLE t1; # 3.3.2 (positive) number of partition/subpartition , # 0 (= no) named partition/subpartition # already checked above # 3.3.3 (negative) number of partitions/subpartitions # > number of named partitions/subpartitions CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS 2 ( PARTITION part1 ) ; ERROR 42000: Wrong number of partitions defined, mismatch with previous setting near ')' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS 2 ( PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11 ), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21, SUBPARTITION subpart22) ); ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near '), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21, SUBPAR' at line 5 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS 2 ( PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part2 VALUES LESS THAN (2000) (SUBPARTITION subpart21 ), PARTITION part3 VALUES LESS THAN (2147483647) (SUBPARTITION subpart31, SUBPARTITION subpart32) ); ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near '), PARTITION part3 VALUES LESS THAN (2147483647) (SUBPARTITION subpart31, SUBPAR' at line 7 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) PARTITIONS 2 SUBPARTITION BY HASH(f1) SUBPARTITIONS 2 ( PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 ) ); ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near ') )' at line 7 # 3.3.4 (negative) number of partitions < number of named partitions CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) PARTITIONS 1 ( PARTITION part1, PARTITION part2 ) ; ERROR 42000: Wrong number of partitions defined, mismatch with previous setting near ')' at line 2 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS 1 ( PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21, SUBPARTITION subpart22) ); ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near '), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21, SUBPAR' at line 5 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS 1 ( PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part2 VALUES LESS THAN (2000) (SUBPARTITION subpart21 ), PARTITION part3 VALUES LESS THAN (2147483647) (SUBPARTITION subpart31, SUBPARTITION subpart32) ); ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near '), PARTITION part2 VALUES LESS THAN (2000) (SUBPARTITION subpart21 ' at line 5 CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) SUBPARTITIONS 1 ( PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11, SUBPARTITION subpart12), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21, SUBPARTITION subpart22) ); ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near '), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21, SUBPAR' at line 5 #------------------------------------------------------------------------ # 4. Checks of logical partition/subpartition name # file name clashes during CREATE TABLE #------------------------------------------------------------------------ DROP TABLE IF EXISTS t1; # 4.1 (negative) A partition name used more than once CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) (PARTITION part1, PARTITION part1); ERROR HY000: Duplicate partition name part1 # FIXME Implement testcases with filename problems # existing file of other table --- partition/subpartition file name # partition/subpartition file name --- file of the same table #------------------------------------------------------------------------ # 5. Alter table experiments #------------------------------------------------------------------------ DROP TABLE IF EXISTS t1; # 5.1 alter table add partition # 5.1.1 (negative) add partition to non partitioned table CREATE TABLE t1 ( f1 INTEGER, f2 char(20)); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ALTER TABLE t1 ADD PARTITION (PARTITION part1); Got one of the listed errors SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; # 5.1.2 Add one partition to a table with one partition CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 100 - 1; ALTER TABLE t1 ADD PARTITION (PARTITION part1); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION p0 ENGINE = MyISAM, PARTITION part1 ENGINE = MyISAM) INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 100 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; # 5.1.3 Several times add one partition to a table with some partitions CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) (PARTITION part1, PARTITION part3); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = MyISAM, PARTITION part3 ENGINE = MyISAM) INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 100 - 1; ALTER TABLE t1 ADD PARTITION (PARTITION part0); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = MyISAM, PARTITION part3 ENGINE = MyISAM, PARTITION part0 ENGINE = MyISAM) INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 100 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DELETE FROM t1; INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 100 - 1; ALTER TABLE t1 ADD PARTITION (PARTITION part2); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = MyISAM, PARTITION part3 ENGINE = MyISAM, PARTITION part0 ENGINE = MyISAM, PARTITION part2 ENGINE = MyISAM) INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 100 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DELETE FROM t1; INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 100 - 1; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = MyISAM, PARTITION part3 ENGINE = MyISAM, PARTITION part0 ENGINE = MyISAM, PARTITION part2 ENGINE = MyISAM) INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 100 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; # 5.1.4 Add several partitions to a table with some partitions CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) (PARTITION part1, PARTITION part3); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = MyISAM, PARTITION part3 ENGINE = MyISAM) INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 100 - 1; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `f1` int(11) DEFAULT NULL, `f2` char(20) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = MyISAM, PARTITION part3 ENGINE = MyISAM) INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 100 AND 200; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 UPDATE t1 SET f1 = f1 + 200 WHERE f1 BETWEEN 100 - 50 AND 100 + 50; SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) AS my_value FROM t1; my_value 1 DELETE FROM t1 WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) AS my_value FROM t1; my_value 1 INSERT INTO t1 SET f1 = 0 , f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; my_value 1 INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; my_value 1 UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' WHERE f1 = 0 AND f2 = '#######'; SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; my_value 1 DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; my_value 1 TRUNCATE t1; SELECT COUNT(*) = 0 AS my_value FROM t1; my_value 1 DROP TABLE t1; # 5.1.5 (negative) Add partitions to a table with some partitions # clash on new and already existing partition names CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY HASH(f1) (PARTITION part1, PARTITION part2, PARTITION part3); ALTER TABLE t1 ADD PARTITION (PARTITION part1); ERROR HY000: Duplicate partition name part1 ALTER TABLE t1 ADD PARTITION (PARTITION part2); ERROR HY000: Duplicate partition name part2 ALTER TABLE t1 ADD PARTITION (PARTITION part3); ERROR HY000: Duplicate partition name part3 ALTER TABLE t1 ADD PARTITION (PARTITION part1, PARTITION part2, PARTITION part3); ERROR HY000: Duplicate partition name part1 DROP TABLE t1; # 5.2 alter table add subpartition # 5.2.1 Add one subpartition to a table with subpartitioning rule and # no explicit defined subpartitions CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) (PARTITION part1 VALUES LESS THAN (100)); INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 100 - 1; ALTER TABLE t1 ADD PARTITION (PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21)); DROP TABLE t1; DROP TABLE if exists t0_template;