| 1 |
# |
| 2 |
# OPTIMIZE TABLE with partitions and OPTIMIZE PARTITIONS |
| 3 |
# |
| 4 |
|
| 5 |
--source include/have_partition.inc |
| 6 |
--source ../have_engine.inc |
| 7 |
|
| 8 |
--disable_warnings |
| 9 |
DROP TABLE IF EXISTS t1,t2; |
| 10 |
--enable_warnings |
| 11 |
|
| 12 |
let $partition_options = PARTITION BY HASH(a) PARTITIONS 2; |
| 13 |
--source ../create_table.inc |
| 14 |
if ($mysql_errname) |
| 15 |
{ |
| 16 |
--let $my_last_stmt = $create_statement |
| 17 |
--let $functionality = Partitions |
| 18 |
--source ../unexpected_result.inc |
| 19 |
} |
| 20 |
if (!$mysql_errname) |
| 21 |
{ |
| 22 |
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(2,'d'),(4,'e'),(100,'f'),(101,'g'); |
| 23 |
|
| 24 |
let $table_name = t2; |
| 25 |
let $partition_options = PARTITION BY RANGE(a) ( |
| 26 |
PARTITION p0 VALUES LESS THAN (100), |
| 27 |
PARTITION p1 VALUES LESS THAN MAXVALUE |
| 28 |
); |
| 29 |
--source ../create_table.inc |
| 30 |
|
| 31 |
INSERT INTO t2 (a,b) SELECT a, b FROM t1; |
| 32 |
|
| 33 |
INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d'); |
| 34 |
|
| 35 |
let $alter_definition = OPTIMIZE PARTITION p1; |
| 36 |
--source ../alter_table.inc |
| 37 |
if ($mysql_errname) |
| 38 |
{ |
| 39 |
--let $my_last_stmt = $alter_statement |
| 40 |
--let $functionality = ALTER TABLE .. OPTIMIZE PARTITION |
| 41 |
--source ../unexpected_result.inc |
| 42 |
} |
| 43 |
|
| 44 |
INSERT INTO t2 (a,b) VALUES (4,'d'); |
| 45 |
|
| 46 |
let $table_name = t2; |
| 47 |
let $alter_definition = OPTIMIZE PARTITION p0 NO_WRITE_TO_BINLOG; |
| 48 |
--source ../alter_table.inc |
| 49 |
|
| 50 |
INSERT INTO t1 (a,b) VALUES (6,'f'); |
| 51 |
|
| 52 |
let $alter_definition = OPTIMIZE PARTITION ALL LOCAL; |
| 53 |
--source ../alter_table.inc |
| 54 |
|
| 55 |
INSERT INTO t2 (a,b) VALUES (5,'e'); |
| 56 |
|
| 57 |
let $table_name = t2; |
| 58 |
let $alter_definition = OPTIMIZE PARTITION p1,p0; |
| 59 |
--source ../alter_table.inc |
| 60 |
|
| 61 |
DROP TABLE t1, t2; |
| 62 |
} |
| 63 |
|
| 64 |
let $extra_tbl_opts = PARTITION BY HASH(a) PARTITIONS 2; |
| 65 |
--source ../optimize_table.inc |
| 66 |
|
| 67 |
|
| 68 |
--source ../cleanup_engine.inc |
| 69 |
|