summaryrefslogtreecommitdiff
path: root/mysql-test/suite/rpl/include/check_type.inc
blob: baba7a21e86a96967f9da9656ff18a4a512c6051 (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
# Helper file to perform one insert of a value into a table with
# different types on master and slave.  The file will insert the
# result into the type_conversions table *on the slave* to get a
# summary of failing and succeeding tests.

# Input:
#    $source_type      Type on the master
#    $target_type      Type on the slave
#    $source_value     Value on the master (inserted into the table)
#    $target_value     Value on the slave (expected value in the table
#                      on the slave)
#    $can_convert      True if conversion shall work, false if it
#                      shall generate an error 
#    $engine_type      The storage engine to be used for storing table
#                      on both master and slave

if (!$engine_type)
{
  # Use the default storage engine
  let $engine_type=`SELECT @@storage_engine`;
}

connection master;
disable_warnings;
DROP TABLE IF EXISTS t1;
enable_warnings;
if ($source_temp_format)
{
  --eval SET @@global.mysql56_temporal_format= $source_temp_format
}
eval CREATE TABLE t1(
  pk INT NOT NULL PRIMARY KEY,
  a $source_type
) ENGINE=$engine_type;
sync_slave_with_master;
if ($target_temp_format)
{
  --eval SET @@global.mysql56_temporal_format= $source_temp_format
}
eval ALTER TABLE t1 MODIFY a $target_type;

connection master;
eval INSERT INTO t1 VALUES(1, $source_value);
if ($can_convert) {
  sync_slave_with_master;
  eval SELECT a = $target_value into @compare FROM t1;
  eval INSERT INTO type_conversions SET
       Source = "$source_type",
       Target = "$target_type",
       Flags = @@slave_type_conversions,
       On_Master = $source_value,
       Expected = $target_value,
       Compare = @compare;
  UPDATE type_conversions
     SET On_Slave = (SELECT a FROM t1)
   WHERE TestNo = LAST_INSERT_ID();
}
if (!$can_convert) {
  connection slave;
  wait_for_slave_to_stop;
  let $error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
  eval INSERT INTO type_conversions SET
       Source = "$source_type",
       Target = "$target_type",
       Flags = @@slave_type_conversions,
       On_Master = $source_value,
       Error = "$error";
  SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
  START SLAVE;
}