| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# The purpose of this test script is to test the behavior of |
| 4 |
# CREATE..SELECT with a partition table |
| 5 |
# |
| 6 |
# ==== Implementation === |
| 7 |
# Create a table using CREATE..SELECT clause based on a partition table |
| 8 |
# and test for INSERT in the new table |
| 9 |
# |
| 10 |
# ==== References ==== |
| 11 |
# |
| 12 |
# WL#12168:Add Partition Information into the Binary Log |
| 13 |
# |
| 14 |
|
| 15 |
--source include/have_binlog_format_row.inc |
| 16 |
--source include/master-slave.inc |
| 17 |
--echo #### Create a table using CREATE..SELECT clause ##### |
| 18 |
|
| 19 |
CREATE TABLE store (store_id INT) PARTITION BY RANGE (store_id) ( PARTITION p0 VALUES LESS THAN (10), PARTITION p1 VALUES LESS THAN (20)); |
| 20 |
|
| 21 |
--source include/save_binlog_position.inc |
| 22 |
INSERT INTO store VALUES (5); |
| 23 |
INSERT INTO store VALUES (12); |
| 24 |
|
| 25 |
# Check if the partition_id is correctly logged for this event. |
| 26 |
--let $expected_partition_id = 0;1 |
| 27 |
--source suite/rpl/include/rpl_partition_info.inc |
| 28 |
|
| 29 |
# Create the table using CREATE..SELECT based on a partitioned table |
| 30 |
--source include/save_binlog_position.inc |
| 31 |
CREATE TABLE emp (m INT) PARTITION BY RANGE (store_id) ( PARTITION p0 VALUES LESS THAN (10), PARTITION p1 VALUES LESS THAN (20)) |
| 32 |
SELECT store_id FROM store; |
| 33 |
|
| 34 |
#Check if the rows inserted in table emp from table store has the correct partition_id info |
| 35 |
--let $expected_partition_id = 0;1 |
| 36 |
--source suite/rpl/include/rpl_partition_info.inc |
| 37 |
|
| 38 |
--let $store_table_count = `SELECT COUNT(PARTITION_ORDINAL_POSITION) FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 'store'` |
| 39 |
--let $emp_table_count = `SELECT COUNT(PARTITION_ORDINAL_POSITION) FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 'emp'` |
| 40 |
|
| 41 |
# Check if the number of partition is same in both tables |
| 42 |
--let $assert_text= Check that the partition count is same in both tables |
| 43 |
--let $assert_cond= $store_table_count = $emp_table_count |
| 44 |
--source include/assert.inc |
| 45 |
|
| 46 |
let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = "emp" AND PARTITION_NAME ="p0"; |
| 47 |
--source include/wait_condition_or_abort.inc |
| 48 |
let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = "emp" AND PARTITION_NAME ="p1"; |
| 49 |
--source include/wait_condition_or_abort.inc |
| 50 |
|
| 51 |
# Check if the partition_id is correctly logged for this event. |
| 52 |
--source include/save_binlog_position.inc |
| 53 |
INSERT INTO emp values (3, 12); |
| 54 |
|
| 55 |
--let $expected_partition_id = 1 |
| 56 |
--source suite/rpl/include/rpl_partition_info.inc |
| 57 |
|
| 58 |
--source include/save_binlog_position.inc |
| 59 |
INSERT INTO emp values (4, 6), (5, 13) ; |
| 60 |
|
| 61 |
# Check if the partition_id is correctly logged for this event. |
| 62 |
--let $expected_partition_id = 0;1 |
| 63 |
--source suite/rpl/include/rpl_partition_info.inc |
| 64 |
|
| 65 |
DROP TABLE store; |
| 66 |
DROP TABLE emp; |
| 67 |
RESET MASTER; |
| 68 |
--source include/rpl_end.inc |