summaryrefslogtreecommitdiff
path: root/mysql-test/suite/rpl/t/rpl_row_type_conv_err_msg.test
blob: 2442f869abc62c85003c3e25406981c609432deb (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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# ==== Purpose ====
#
# Test verifies that when slave side type conversion fails in row based
# replication, more informative error message is displayed. It also verifies
# that in the case of blob fields appropriate type name is displayed in error
# message.
#
# ==== Implementation ====
#
# Steps:
# Test case1:
#          1. Create a table on master with VARCHAR filed and charset
#             'utf8mb3'.
#          2. Create a table on slave with VARCHAR field and charset
#             'utf8mb4'.
#          3. Insert a tuple on master.
#          4. Verify that slave provides more informative error message with
#             respect to difference in charsets.
# Test case2: Repeat same steps as above for CHAR field
# Test case3:
#          1. Create a table on master with LONGBLOB field.
#          2. Create a table on slave with TINYBLOB field.
#          3. Insert a tuple on master.
#          4. Verify that error message displayed on slave clearly states type
#             conversion failure from 'longblob' to 'tinyblob'.
#          5. Also verify that error message doesn't show additional details
#             of charset when not required.
# Test Case4: Verifies varbinary to binary type conversion failure specific
#             error message.
# Test Case5: Verifies binary to varbinary type conversion failure specific
#             error message.
# Test Case6: Verifies binary to binary type conversion failure specific
#             error message.
# Test Case7: Verifies char to blob type conversion failure specific
#             error message.
# Test Case8: Verifies char to text type conversion failure specific
#             error message.
# ==== References ====
#
# MDEV-19925: Column ... cannot be converted from type 'varchar(20)' to type
#             'varchar(20)'
#

--source include/have_binlog_format_row.inc
# Inorder to grep a specific error pattern in error log a fresh error log
# needs to be generated.
--source include/force_restart.inc
--source include/master-slave.inc

--echo ####################################################################
--echo # Test Case1: Improved error message with charset information
--echo ####################################################################
--connection master
SET SQL_LOG_BIN=0;
CREATE TABLE t1 (c1 VARCHAR(1) CHARACTER SET 'utf8mb3');
SET SQL_LOG_BIN=1;

--connection slave
CREATE TABLE t1 (c1 VARCHAR(1) CHARACTER SET 'utf8mb4');

--connection master
INSERT INTO t1 VALUES ('a');

--connection slave
--let $slave_sql_errno= 1677
--source include/wait_for_slave_sql_error.inc

# Check error log for correct messages.
let $log_error_= `SELECT @@GLOBAL.log_error`;
if(!$log_error_)
{
    # MySQL Server on windows is started with --console and thus
    # does not know the location of its .err log, use default location
    let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.2.err;
}

# Error msg before: Column 0 of table 'test.t1' cannot be converted from type 'varchar(3)' to type 'varchar(1)'
# Error msg after : Column 0 of table 'test.t1' cannot be converted from type 'varchar(3 octets)' to type 'varchar(4 octets) character set utf8mb4'
--let SEARCH_FILE=$log_error_
--let SEARCH_PATTERN=\'varchar\(3 octets\)\' to type \'varchar\(4 octets\) character set utf8mb4\'
--source include/search_pattern_in_file.inc

--connection master
DROP TABLE t1;
--connection slave
DROP TABLE t1;
--let $rpl_only_running_threads= 1
--source include/rpl_reset.inc

--echo ####################################################################
--echo # Test Case2: Improved error message with charset information for CHAR
--echo # type
--echo ####################################################################
--connection master
SET SQL_LOG_BIN=0;
CREATE TABLE t1 (c1 CHAR(1) CHARACTER SET 'utf8mb3');
SET SQL_LOG_BIN=1;

--connection slave
CREATE TABLE t1 (c1 CHAR(1) CHARACTER SET 'utf8mb4');

--connection master
INSERT INTO t1 VALUES ('a');

--connection slave
--let $slave_sql_errno= 1677
--source include/wait_for_slave_sql_error.inc

# Error msg before: Column 0 of table 'test.t1' cannot be converted from type 'char(0)' to type 'char(1)'
# Error msg after : Column 0 of table 'test.t1' cannot be converted from type 'char(3 octets)' to type 'char(4 octets) character set utf8mb4)'
--let SEARCH_FILE=$log_error_
--let SEARCH_PATTERN=\'char\(3 octets\)\' to type \'char\(4 octets\) character set utf8mb4\'
--source include/search_pattern_in_file.inc

--connection master
DROP TABLE t1;
--connection slave
DROP TABLE t1;
--let $rpl_only_running_threads= 1
--source include/rpl_reset.inc

--echo ####################################################################
--echo # Test Case3: For BLOB type fileds, when type conversion failed on
--echo # slave, the errormessage had incorrect type names.
--echo ####################################################################
--connection master
SET SQL_LOG_BIN=0;
CREATE TABLE t1 (c1 LONGBLOB);
SET SQL_LOG_BIN=1;

--connection slave
CREATE TABLE t1 (c1 TINYBLOB);

--connection master
INSERT INTO t1 VALUES ('a');

--connection slave
--let $slave_sql_errno= 1677
--source include/wait_for_slave_sql_error.inc

# Error msg before: Column 0 of table 'test.t1' cannot be converted from type 'tinyblob' to type 'tinyblob'
# Error msg after : Column 0 of table 'test.t1' cannot be converted from type 'longblob' to type 'tinyblob'
--let SEARCH_FILE=$log_error_
--let SEARCH_PATTERN=\'longblob\' to type \'tinyblob\'
--source include/search_pattern_in_file.inc

--connection master
DROP TABLE t1;
--connection slave
DROP TABLE t1;
--let $rpl_only_running_threads= 1
--source include/rpl_reset.inc

--echo ####################################################################
--echo # Test Case4: Verifies varbinary to binary type conversion failure
--echo #             specific error message.
--echo ####################################################################
--connection master
SET SQL_LOG_BIN=0;
CREATE TABLE t1 (c1 VARBINARY(10));
SET SQL_LOG_BIN=1;

--connection slave
CREATE TABLE t1 (c1 BINARY(10));

--connection master
INSERT INTO t1 VALUES ('a');

--connection slave
--let $slave_sql_errno= 1677
--source include/wait_for_slave_sql_error.inc

# Check error log for correct messages.
let $log_error_= `SELECT @@GLOBAL.log_error`;
if(!$log_error_)
{
    # MySQL Server on windows is started with --console and thus
    # does not know the location of its .err log, use default location
    let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.2.err;
}

# Expected Error : Column 0 of table 'test.t1' cannot be converted from type 'varbinary(10)' to type 'binary(10)'
--let SEARCH_FILE=$log_error_
--let SEARCH_PATTERN=\'varbinary\(10\)\' to type \'binary\(10\)\'
--source include/search_pattern_in_file.inc

--connection master
DROP TABLE t1;
--connection slave
DROP TABLE t1;
--let $rpl_only_running_threads= 1
--source include/rpl_reset.inc

--echo ####################################################################
--echo # Test Case5: Verifies binary to varbinary type conversion failure
--echo #             specific error message.
--echo ####################################################################
--connection master
SET SQL_LOG_BIN=0;
CREATE TABLE t1 (c1 BINARY(10));
SET SQL_LOG_BIN=1;

--connection slave
CREATE TABLE t1 (c1 VARBINARY(10));

--connection master
INSERT INTO t1 VALUES ('a');

--connection slave
--let $slave_sql_errno= 1677
--source include/wait_for_slave_sql_error.inc

# Check error log for correct messages.
let $log_error_= `SELECT @@GLOBAL.log_error`;
if(!$log_error_)
{
    # MySQL Server on windows is started with --console and thus
    # does not know the location of its .err log, use default location
    let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.2.err;
}

# Expected Error : Column 0 of table 'test.t1' cannot be converted from type 'binary(10)' to type 'varbinary(10)'
--let SEARCH_FILE=$log_error_
--let SEARCH_PATTERN=\'binary\(10\)\' to type \'varbinary\(10\)\'
--source include/search_pattern_in_file.inc

--connection master
DROP TABLE t1;
--connection slave
DROP TABLE t1;
--let $rpl_only_running_threads= 1
--source include/rpl_reset.inc

--echo ####################################################################
--echo # Test Case6: Verifies binary to binary type conversion failure
--echo #             specific error message.
--echo ####################################################################
--connection master
SET SQL_LOG_BIN=0;
CREATE TABLE t1 (c1 BINARY(1));
SET SQL_LOG_BIN=1;

--connection slave
CREATE TABLE t1 (c1 BINARY(10));

--connection master
INSERT INTO t1 VALUES ('a');

--connection slave
--let $slave_sql_errno= 1677
--source include/wait_for_slave_sql_error.inc

# Check error log for correct messages.
let $log_error_= `SELECT @@GLOBAL.log_error`;
if(!$log_error_)
{
    # MySQL Server on windows is started with --console and thus
    # does not know the location of its .err log, use default location
    let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.2.err;
}

# Expected Error : Column 0 of table 'test.t1' cannot be converted from type 'binary(1)' to type 'binary(10)'
--let SEARCH_FILE=$log_error_
--let SEARCH_PATTERN=\'binary\(1\)\' to type \'binary\(10\)\'
--source include/search_pattern_in_file.inc

--connection master
DROP TABLE t1;
--connection slave
DROP TABLE t1;
--let $rpl_only_running_threads= 1
--source include/rpl_reset.inc

--echo ####################################################################
--echo # Test Case7: Verifies char to blob type conversion failure
--echo #             specific error message. BLOB field on slave has no
--echo #             associated character set hence the master side field
--echo #             is also considered as binary.
--echo ####################################################################
--connection master
SET SQL_LOG_BIN=0;
CREATE TABLE t1 (c1 CHAR(1));
SET SQL_LOG_BIN=1;

--connection slave
CREATE TABLE t1 (c1 BLOB);

--connection master
INSERT INTO t1 VALUES ('a');

--connection slave
--let $slave_sql_errno= 1677
--source include/wait_for_slave_sql_error.inc

# Check error log for correct messages.
let $log_error_= `SELECT @@GLOBAL.log_error`;
if(!$log_error_)
{
    # MySQL Server on windows is started with --console and thus
    # does not know the location of its .err log, use default location
    let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.2.err;
}

# Expected Error : Column 0 of table 'test.t1' cannot be converted from type 'binary(1)' to type 'binary(10)'
--let SEARCH_FILE=$log_error_
--let SEARCH_PATTERN=\'binary\(1\)\' to type \'blob\'
--source include/search_pattern_in_file.inc

--connection master
DROP TABLE t1;
--connection slave
DROP TABLE t1;
--let $rpl_only_running_threads= 1
--source include/rpl_reset.inc

--echo ####################################################################
--echo # Test Case8: Verifies char to text type conversion failure
--echo #             specific error message.
--echo ####################################################################
--connection master
SET SQL_LOG_BIN=0;
CREATE TABLE t1 (c1 CHAR(1));
SET SQL_LOG_BIN=1;

--connection slave
CREATE TABLE t1 (c1 TEXT);

--connection master
INSERT INTO t1 VALUES ('a');

--connection slave
--let $slave_sql_errno= 1677
--source include/wait_for_slave_sql_error.inc

# Check error log for correct messages.
let $log_error_= `SELECT @@GLOBAL.log_error`;
if(!$log_error_)
{
    # MySQL Server on windows is started with --console and thus
    # does not know the location of its .err log, use default location
    let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.2.err;
}

# Expected Error : Column 0 of table 'test.t1' cannot be converted from type 'binary(1)' to type 'binary(10)'
--let SEARCH_FILE=$log_error_
--let SEARCH_PATTERN=\'char\(1 octets\)\' to type \'text\'
--source include/search_pattern_in_file.inc

--connection master
DROP TABLE t1;
--connection slave
DROP TABLE t1;
--let $rpl_only_running_threads= 1
--source include/rpl_reset.inc

--source include/rpl_end.inc