1
by brian
clean slate |
1 |
--source include/have_innodb.inc
|
2 |
--source include/have_partition.inc
|
|
3 |
--source include/have_binlog_format_mixed_or_row.inc
|
|
4 |
--source include/master-slave.inc
|
|
5 |
||
6 |
# Set the default connection to 'master' |
|
7 |
||
8 |
--vertical_results
|
|
9 |
||
10 |
let $engine_type= 'innodb'; |
|
11 |
||
12 |
######## Creat Table Section ######### |
|
13 |
use test; |
|
14 |
||
15 |
eval CREATE TABLE test.regular_tbl(id MEDIUMINT NOT NULL AUTO_INCREMENT, |
|
16 |
dt TIMESTAMP, user CHAR(255), uuidf LONGBLOB, |
|
17 |
fkid MEDIUMINT, filler VARCHAR(255), |
|
18 |
PRIMARY KEY(id)) ENGINE=$engine_type; |
|
19 |
||
20 |
eval CREATE TABLE test.bykey_tbl(id MEDIUMINT NOT NULL AUTO_INCREMENT, |
|
21 |
dt TIMESTAMP, user CHAR(255), uuidf LONGBLOB, |
|
22 |
fkid MEDIUMINT, filler VARCHAR(255), |
|
23 |
PRIMARY KEY(id)) ENGINE=$engine_type |
|
24 |
PARTITION BY KEY(id) partitions 5; |
|
25 |
||
26 |
eval CREATE TABLE test.byrange_tbl(id MEDIUMINT NOT NULL AUTO_INCREMENT, |
|
27 |
dt TIMESTAMP, user CHAR(255), uuidf LONGBLOB, |
|
28 |
fkid MEDIUMINT, filler VARCHAR(255), |
|
29 |
PRIMARY KEY(id)) ENGINE=$engine_type |
|
30 |
PARTITION BY RANGE(id) |
|
31 |
SUBPARTITION BY hash(id) subpartitions 2 |
|
32 |
(PARTITION pa1 values less than (10), |
|
33 |
PARTITION pa2 values less than (20), |
|
34 |
PARTITION pa3 values less than (30), |
|
35 |
PARTITION pa4 values less than (40), |
|
36 |
PARTITION pa5 values less than (50), |
|
37 |
PARTITION pa6 values less than (60), |
|
38 |
PARTITION pa7 values less than (70), |
|
39 |
PARTITION pa8 values less than (80), |
|
40 |
PARTITION pa9 values less than (90), |
|
41 |
PARTITION pa10 values less than (100), |
|
42 |
PARTITION pa11 values less than MAXVALUE); |
|
43 |
||
44 |
######## Create SPs, Functions, Views and Triggers Section ############## |
|
45 |
||
46 |
delimiter |; |
|
47 |
CREATE PROCEDURE test.proc_norm() |
|
48 |
BEGIN
|
|
49 |
DECLARE ins_count INT DEFAULT 1000; |
|
50 |
DECLARE del_count INT; |
|
51 |
DECLARE cur_user VARCHAR(255); |
|
52 |
DECLARE local_uuid VARCHAR(255); |
|
53 |
DECLARE local_time TIMESTAMP; |
|
54 |
||
55 |
SET local_time= NOW(); |
|
56 |
SET cur_user= CURRENT_USER(); |
|
57 |
SET local_uuid= UUID(); |
|
58 |
||
59 |
WHILE ins_count > 0 DO |
|
60 |
INSERT INTO test.regular_tbl VALUES (NULL, NOW(), USER() , UUID(), |
|
61 |
ins_count,'Going to test MBR for MySQL'); |
|
62 |
SET ins_count = ins_count - 1; |
|
63 |
END WHILE; |
|
64 |
||
65 |
SELECT MAX(id) FROM test.regular_tbl INTO del_count; |
|
66 |
WHILE del_count > 0 DO |
|
67 |
DELETE FROM test.regular_tbl WHERE id = del_count; |
|
68 |
SET del_count = del_count - 2; |
|
69 |
END WHILE; |
|
70 |
END| |
|
71 |
||
72 |
CREATE PROCEDURE test.proc_bykey() |
|
73 |
BEGIN
|
|
74 |
DECLARE ins_count INT DEFAULT 1000; |
|
75 |
DECLARE del_count INT; |
|
76 |
DECLARE cur_user VARCHAR(255); |
|
77 |
DECLARE local_uuid VARCHAR(255); |
|
78 |
DECLARE local_time TIMESTAMP; |
|
79 |
||
80 |
SET local_time= NOW(); |
|
81 |
SET cur_user= CURRENT_USER(); |
|
82 |
SET local_uuid= UUID(); |
|
83 |
||
84 |
WHILE ins_count > 0 DO |
|
85 |
INSERT INTO test.bykey_tbl VALUES (NULL, NOW(), USER() , UUID(), |
|
86 |
ins_count,'Going to test MBR for MySQL'); |
|
87 |
SET ins_count = ins_count - 1; |
|
88 |
END WHILE; |
|
89 |
||
90 |
SELECT MAX(id) FROM test.bykey_tbl INTO del_count; |
|
91 |
WHILE del_count > 0 DO |
|
92 |
DELETE FROM test.bykey_tbl WHERE id = del_count; |
|
93 |
SET del_count = del_count - 2; |
|
94 |
END WHILE; |
|
95 |
END| |
|
96 |
||
97 |
CREATE PROCEDURE test.proc_byrange() |
|
98 |
BEGIN
|
|
99 |
DECLARE ins_count INT DEFAULT 1000; |
|
100 |
DECLARE del_count INT; |
|
101 |
DECLARE cur_user VARCHAR(255); |
|
102 |
DECLARE local_uuid VARCHAR(255); |
|
103 |
DECLARE local_time TIMESTAMP; |
|
104 |
||
105 |
SET local_time= NOW(); |
|
106 |
SET cur_user = CURRENT_USER(); |
|
107 |
SET local_uuid=UUID(); |
|
108 |
||
109 |
WHILE ins_count > 0 DO |
|
110 |
INSERT INTO test.byrange_tbl VALUES (NULL, NOW(), USER(), UUID(), |
|
111 |
ins_count,'Going to test MBR for MySQL'); |
|
112 |
SET ins_count = ins_count - 1; |
|
113 |
END WHILE; |
|
114 |
||
115 |
SELECT MAX(id) FROM test.byrange_tbl INTO del_count; |
|
116 |
WHILE del_count > 0 DO |
|
117 |
DELETE FROM test.byrange_tbl WHERE id = del_count; |
|
118 |
SET del_count = del_count - 2; |
|
119 |
END WHILE; |
|
120 |
END| |
|
121 |
||
122 |
delimiter ;| |
|
123 |
||
124 |
############ Finish Setup Section ################### |
|
125 |
||
126 |
||
127 |
############ Test Section ################### |
|
128 |
||
129 |
CALL test.proc_norm(); |
|
130 |
SELECT count(*) as "Master regular" FROM test.regular_tbl; |
|
131 |
CALL test.proc_bykey(); |
|
132 |
SELECT count(*) as "Master bykey" FROM test.bykey_tbl; |
|
133 |
CALL test.proc_byrange(); |
|
134 |
SELECT count(*) as "Master byrange" FROM test.byrange_tbl; |
|
135 |
||
136 |
--sync_slave_with_master
|
|
137 |
connection slave; |
|
138 |
show create table test.byrange_tbl; |
|
139 |
source include/show_slave_status.inc; |
|
140 |
SELECT count(*) "Slave norm" FROM test.regular_tbl; |
|
141 |
SELECT count(*) "Slave bykey" FROM test.bykey_tbl; |
|
142 |
SELECT count(*) "Slave byrange" FROM test.byrange_tbl; |
|
143 |
||
144 |
###### CLEAN UP SECTION ############## |
|
145 |
||
146 |
connection master; |
|
147 |
DROP PROCEDURE test.proc_norm; |
|
148 |
DROP PROCEDURE test.proc_bykey; |
|
149 |
DROP PROCEDURE test.proc_byrange; |
|
150 |
DROP TABLE test.regular_tbl; |
|
151 |
DROP TABLE test.bykey_tbl; |
|
152 |
DROP TABLE test.byrange_tbl; |
|
153 |
||
154 |
--source include/master-slave-end.inc
|