summaryrefslogtreecommitdiffstats
path: root/mysql-test/include/column_compression_rpl.inc
blob: f9986f69cc78bb71675f68f1f4dd8ee77582d71e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
--disable_ps2_protocol

--connection slave

SET @saved_slave_type_conversions = @@slave_type_conversions;
SET GLOBAL SLAVE_TYPE_CONVERSIONS = 'ALL_NON_LOSSY';

--connection master
if (!$engine_type)  {let $engine_type=`SELECT @@default_storage_engine`; let $engine_type2=`SELECT @@default_storage_engine`;}

--disable_warnings
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
--enable_warnings

echo --------------------------------------------------------------------------------------------------------------;
echo --------------------------------------------COMPRESSED TO COMPRESSED------------------------------------------;
echo --------------------------------------------------------------------------------------------------------------;

--sync_slave_with_master
eval CREATE TABLE  t1  (a BLOB COMPRESSED default "1111111111") ENGINE=$engine_type2;
eval CREATE TABLE  t2  (a TINYBLOB COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE  t3  (a MEDIUMBLOB COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE  t4  (a LONGBLOB COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE  t5  (a TEXT COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE  t6  (a TINYTEXT COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE  t7  (a MEDIUMTEXT COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE  t8  (a LONGTEXT COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE  t9  (a VARCHAR(10000) COMPRESSED default "0") ENGINE=$engine_type2;
eval CREATE TABLE  t10 (a VARBINARY(10000) COMPRESSED) ENGINE=$engine_type2;

--connection master
eval CREATE TABLE  t1  (a BLOB COMPRESSED default "1111111111") ENGINE=$engine_type;
eval CREATE TABLE  t2  (a TINYBLOB COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE  t3  (a MEDIUMBLOB COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE  t4  (a LONGBLOB COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE  t5  (a TEXT COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE  t6  (a TINYTEXT COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE  t7  (a MEDIUMTEXT COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE  t8  (a LONGTEXT COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE  t9  (a VARCHAR(10000) COMPRESSED default "0") ENGINE=$engine_type;
eval CREATE TABLE  t10 (a VARBINARY(10000) COMPRESSED) ENGINE=$engine_type;

INSERT INTO t1(a)  VALUES(REPEAT('a',1000)),(REPEAT('v',200)),(REPEAT('r',300)),(NULL),(default);
INSERT INTO t2(a)  VALUES(REPEAT('a',100)),(REPEAT('v',200)),(REPEAT('r',254)),(NULL); 
INSERT INTO t3(a)  VALUES(REPEAT('a',100)),(REPEAT('v',2000)),("April"),(NULL);
INSERT INTO t4(a)  VALUES(REPEAT('a',10000)),(REPEAT('v',200)),(REPEAT('r',300)),(NULL),("00-00-00");
INSERT INTO t5(a)  VALUES(REPEAT('a',1000)),(REPEAT('v',200)),(REPEAT('r',300)),(NULL);
INSERT INTO t6(a)  VALUES(REPEAT('a',100)),(REPEAT('v',200)),(REPEAT('r',254)),(NULL); 
INSERT INTO t7(a)  VALUES(REPEAT('a',100)),(REPEAT('v',200)),(REPEAT('r',3000)),(NULL);
INSERT INTO t8(a)  VALUES(REPEAT('a',10000)),(REPEAT('v',200)),(REPEAT('r',300)),(NULL),("qwerty");
INSERT INTO t9(a)  VALUES(REPEAT('a',1000)),(REPEAT('v',200)),(REPEAT('r',300)),(NULL),("12-12-2009"),(default);
INSERT INTO t10(a) VALUES(REPEAT('a',1000)),(REPEAT('v',2000)),(REPEAT('r',300)),(NULL), ("");

echo --------------------------------------------------data on master------------------------------------------------;

let $a= 10;
while ($a)
{
	--sorted_result
 	eval SELECT LENGTH(a), SUBSTRING(a,1,10), "M,compressed" from t$a;
 	--sorted_result
 	eval SELECT DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t$a';
 	dec $a;
}
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN('Column_compressions', 'Column_decompressions');

echo --------------------------------------------------data on slave-------------------------------------------------;

--sync_slave_with_master
let $a= 10;
while ($a)
{
	--sorted_result
	eval SELECT LENGTH(a), SUBSTRING(a,1,10), "S,compressed" from t$a;
	--sorted_result
	eval SELECT DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t$a';
	dec $a;
}

SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN('Column_compressions', 'Column_decompressions');

--connection master
DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
FLUSH STATUS;

echo -----------------------------------------------------------------------------------------------------------------;
echo ---------------------------------------COMPRESSED TO NOT COMPRESSED----------------------------------------------;
echo -----------------------------------------------------------------------------------------------------------------;

--sync_slave_with_master
FLUSH STATUS;
eval CREATE TABLE t1  (a BLOB) ENGINE=$engine_type2;
eval CREATE TABLE t2  (a TINYBLOB) ENGINE=$engine_type2;
eval CREATE TABLE t3  (a MEDIUMBLOB) ENGINE=$engine_type2;
eval CREATE TABLE t4  (a LONGBLOB) ENGINE=$engine_type2;
eval CREATE TABLE t5  (a TEXT) ENGINE=$engine_type2;
eval CREATE TABLE t6  (a TINYTEXT) ENGINE=$engine_type2;
eval CREATE TABLE t7  (a MEDIUMTEXT) ENGINE=$engine_type2;
eval CREATE TABLE t8  (a LONGTEXT) ENGINE=$engine_type2;
eval CREATE TABLE t9  (a VARCHAR(10000)) ENGINE=$engine_type2;
eval CREATE TABLE t10 (a VARBINARY(10000)) ENGINE=$engine_type2;

--connection master
eval CREATE TABLE IF NOT EXISTS t1  (a BLOB COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t2  (a TINYBLOB COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t3  (a MEDIUMBLOB COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t4  (a LONGBLOB COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t5  (a TEXT COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t6  (a TINYTEXT COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t7  (a MEDIUMTEXT COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t8  (a LONGTEXT COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t9  (a VARCHAR(10000) COMPRESSED) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t10 (a VARBINARY(10000) COMPRESSED) ENGINE=$engine_type;

INSERT INTO t1(a)  VALUES(REPEAT('a',1000)),(REPEAT('v',200)),(REPEAT('r',300)),(NULL);
INSERT INTO t2(a)  VALUES(REPEAT('a',100)),(REPEAT('v',200)),(REPEAT('r',254)),(NULL); 
INSERT INTO t3(a)  VALUES(REPEAT('a',100)),(REPEAT('v',2000)),("April"),(NULL);
INSERT INTO t4(a)  VALUES(REPEAT('a',10000)),(REPEAT('v',200)),(REPEAT('r',300)),(NULL),("00-00-00");
INSERT INTO t5(a)  VALUES(REPEAT('a',1000)),(REPEAT('v',200)),(REPEAT('r',300)),(NULL);
INSERT INTO t6(a)  VALUES(REPEAT('a',100)),(REPEAT('v',200)),(REPEAT('r',254)),(NULL); 
INSERT INTO t7(a)  VALUES(REPEAT('a',100)),(REPEAT('v',200)),(REPEAT('r',3000)),(NULL);
INSERT INTO t8(a)  VALUES(REPEAT('a',10000)),(REPEAT('v',200)),(REPEAT('r',300)),(NULL),("qwerty");
INSERT INTO t9(a)  VALUES(REPEAT('a',1000)),(REPEAT('v',200)),(REPEAT('r',300)),(NULL),("12-12-2009");
INSERT INTO t10(a) VALUES(REPEAT('a',1000)),(REPEAT('v',2000)),(REPEAT('r',300)),(NULL), ("");

echo ---------------------------------------data on master-----------------------------------------------------------;

let $a= 10;
while ($a)
{
	--sorted_result
	eval SELECT LENGTH(a),SUBSTRING(a,1,10), "M,compressed"  from t$a;
	--sorted_result
 	eval SELECT DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t$a';
	dec $a;
}
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN('Column_compressions', 'Column_decompressions');

echo ---------------------------------------data on slave-------------------------------------------------------------;

--sync_slave_with_master
let $a= 10;
while ($a)
{
	--sorted_result
 	eval SELECT LENGTH(a), SUBSTRING(a,1,10), "S,not compressed" from t$a;
	--sorted_result
	eval SELECT DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t$a';
	dec $a;
}

SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN('Column_compressions', 'Column_decompressions');
--connection master
DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
FLUSH STATUS;

echo -----------------------------------------------------------------------------------------------------------------;
echo -----------------------------------NOT COMPRESSED to COMPRESSED--------------------------------------------------;
echo -----------------------------------------------------------------------------------------------------------------;

--sync_slave_with_master
FLUSH STATUS;
eval CREATE TABLE t1  (a BLOB COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE t2  (a TINYBLOB COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE t3  (a MEDIUMBLOB COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE t4  (a LONGBLOB COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE t5  (a TEXT COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE t6  (a TINYTEXT COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE t7  (a MEDIUMTEXT COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE t8  (a LONGTEXT COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE t9  (a VARCHAR(10000) COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE t10 (a VARBINARY(10000) COMPRESSED) ENGINE=$engine_type2;

--connection master
eval CREATE TABLE IF NOT EXISTS t1  (a BLOB) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t2  (a TINYBLOB) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t3  (a MEDIUMBLOB) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t4  (a LONGBLOB) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t5  (a TEXT) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t6  (a TINYTEXT) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t7  (a MEDIUMTEXT) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t8  (a LONGTEXT) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t9  (a VARCHAR(10000)) ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t10 (a VARBINARY(10000)) ENGINE=$engine_type;

INSERT INTO t1(a)  VALUES(REPEAT('a',1000)),(REPEAT('v',200)),(REPEAT('r',300)),(NULL);
INSERT INTO t2(a)  VALUES(REPEAT('a',100)),(REPEAT('v',200)),(REPEAT('r',254)),(NULL); 
INSERT INTO t3(a)  VALUES(REPEAT('a',100)),(REPEAT('v',2000)),("April"),(NULL);
INSERT INTO t4(a)  VALUES(REPEAT('a',10000)),(REPEAT('v',200)),(REPEAT('r',300)),(NULL),("00-00-00");
INSERT INTO t5(a)  VALUES(REPEAT('a',1000)),(REPEAT('v',200)),(REPEAT('r',300)),(NULL);
INSERT INTO t6(a)  VALUES(REPEAT('a',100)),(REPEAT('v',200)),(REPEAT('r',254)),(NULL); 
INSERT INTO t7(a)  VALUES(REPEAT('a',100)),(REPEAT('v',200)),(REPEAT('r',3000)),(NULL);
INSERT INTO t8(a)  VALUES(REPEAT('a',10000)),(REPEAT('v',200)),(REPEAT('r',300)),(NULL),("qwerty");
INSERT INTO t9(a)  VALUES(REPEAT('a',1000)),(REPEAT('v',200)),(REPEAT('r',300)),(NULL),("12-12-2009");
INSERT INTO t10(a) VALUES(REPEAT('a',1000)),(REPEAT('v',2000)),(REPEAT('r',300)),(NULL), ("");

echo -----------------------------------data on master---------------------------------------------------------------;

let $a= 10;
while ($a)
{
	--sorted_result
	eval SELECT LENGTH(a),SUBSTRING(a,1,10), "M,not compressed" from t$a;
	--sorted_result
 	eval SELECT DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t$a';
	dec $a;
}
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN('Column_compressions', 'Column_decompressions');

echo -----------------------------------data on slave-----------------------------------------------------------------;

--sync_slave_with_master
let $a= 10;
while ($a)
{
	--sorted_result
	eval SELECT LENGTH(a), SUBSTRING(a,1,10), "S,compressed" from t$a;
	--sorted_result
	eval SELECT DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t$a';
	dec $a;
}
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN('Column_compressions', 'Column_decompressions');

--connection master
DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;

echo -----------------------------------------------------------------------------------------------------------------;
echo ------varchar(1000)->varchar(999) compressed, varchar(1000) compressed->varchar(999) ----------------------------;
echo -----------------------------------------------------------------------------------------------------------------;

--sync_slave_with_master
eval CREATE TABLE t1  (a VARCHAR(999) COMPRESSED) ENGINE=$engine_type2;
eval CREATE TABLE t2  (a VARCHAR(999)) ENGINE=$engine_type2;
show warnings;
call mtr.add_suppression("Slave: Data too long for column 'a' at row 1 Error_code: 1406");
call mtr.add_suppression("Slave: Table 't2' already exists Error_code: 1050");

--connection master
eval CREATE TABLE IF NOT EXISTS t1 (a VARCHAR(1000))ENGINE=$engine_type;
eval CREATE TABLE IF NOT EXISTS t2 (a VARCHAR(1000) COMPRESSED)ENGINE=$engine_type;

INSERT INTO t1(a) VALUES(REPEAT('a',1000)); 
--connection slave
--let $slave_sql_errno= 1406,1677
--source include/wait_for_slave_sql_error_and_skip.inc
show warnings;

--connection master
 INSERT INTO t2(a) VALUES(REPEAT('a',1000)); 
--connection slave
--let $slave_sql_errno= 1406,1677
--source include/wait_for_slave_sql_error_and_skip.inc
show warnings;

SET GLOBAL SLAVE_TYPE_CONVERSIONS = @saved_slave_type_conversions;

--connection master
DROP TABLE t1,t2;
--sync_slave_with_master

--enable_ps2_protocol