MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
check_type.inc
1 # Helper file to perform one insert of a value into a table with
2 # different types on master and slave. The file will insert the
3 # result into the type_conversions table *on the slave* to get a
4 # summary of failing and succeeding tests.
5 
6 # Input:
7 # $source_type Type on the master
8 # $target_type Type on the slave
9 # $source_value Value on the master (inserted into the table)
10 # $target_value Value on the slave (expected value in the table
11 # on the slave)
12 # $can_convert True if conversion shall work, false if it
13 # shall generate an error
14 # $engine_type The storage engine to be used for storing table
15 # on both master and slave
16 
17 if (!$engine_type)
18 {
19  # Use the default storage engine
20  let $engine_type=`SELECT @@storage_engine`;
21 }
22 
23 connection master;
24 disable_warnings;
25 DROP TABLE IF EXISTS t1;
26 enable_warnings;
27 eval CREATE TABLE t1(
28  pk INT NOT NULL PRIMARY KEY,
29  a $source_type
30 ) ENGINE=$engine_type;
31 sync_slave_with_master;
32 eval ALTER TABLE t1 MODIFY a $target_type;
33 
34 connection master;
35 eval INSERT INTO t1 VALUES(1, $source_value);
36 if ($can_convert) {
37  sync_slave_with_master;
38  eval SELECT a = $target_value into @compare FROM t1;
39  eval INSERT INTO type_conversions SET
40  Source = "$source_type",
41  Target = "$target_type",
42  Flags = @@slave_type_conversions,
43  On_Master = $source_value,
44  Expected = $target_value,
45  Compare = @compare;
46  UPDATE type_conversions
47  SET On_Slave = (SELECT a FROM t1)
48  WHERE TestNo = LAST_INSERT_ID();
49 }
50 if (!$can_convert) {
51  connection slave;
52  wait_for_slave_to_stop;
53  let $error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
54  eval INSERT INTO type_conversions SET
55  Source = "$source_type",
56  Target = "$target_type",
57  Flags = @@slave_type_conversions,
58  On_Master = $source_value,
59  Error = "$error";
60  SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
61  START SLAVE;
62 }