| 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 @@default_storage_engine`; |
| 21 |
} |
| 22 |
|
| 23 |
connection master; |
| 24 |
disable_warnings; |
| 25 |
DROP TABLE IF EXISTS t1; |
| 26 |
enable_warnings; |
| 27 |
if ($source_temp_format) |
| 28 |
{ |
| 29 |
--eval SET @@global.mysql56_temporal_format= $source_temp_format |
| 30 |
} |
| 31 |
eval CREATE TABLE t1( |
| 32 |
pk INT NOT NULL PRIMARY KEY, |
| 33 |
a $source_type |
| 34 |
) ENGINE=$engine_type; |
| 35 |
sync_slave_with_master; |
| 36 |
if ($target_temp_format) |
| 37 |
{ |
| 38 |
--eval SET @@global.mysql56_temporal_format= $target_temp_format |
| 39 |
} |
| 40 |
eval ALTER TABLE t1 MODIFY a $target_type; |
| 41 |
|
| 42 |
connection master; |
| 43 |
eval INSERT INTO t1 VALUES(1, $source_value); |
| 44 |
if ($can_convert) { |
| 45 |
sync_slave_with_master; |
| 46 |
--disable_cursor_protocol |
| 47 |
eval SELECT a = $target_value into @compare FROM t1; |
| 48 |
--enable_cursor_protocol |
| 49 |
eval INSERT INTO type_conversions SET |
| 50 |
Source = "$source_type", |
| 51 |
Target = "$target_type", |
| 52 |
Flags = @@slave_type_conversions, |
| 53 |
On_Master = $source_value, |
| 54 |
Expected = $target_value, |
| 55 |
Compare = @compare; |
| 56 |
UPDATE type_conversions |
| 57 |
SET On_Slave = (SELECT a FROM t1) |
| 58 |
WHERE TestNo = LAST_INSERT_ID(); |
| 59 |
} |
| 60 |
if (!$can_convert) { |
| 61 |
connection slave; |
| 62 |
wait_for_slave_to_stop; |
| 63 |
let $error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1); |
| 64 |
eval INSERT INTO type_conversions SET |
| 65 |
Source = "$source_type", |
| 66 |
Target = "$target_type", |
| 67 |
Flags = @@slave_type_conversions, |
| 68 |
On_Master = $source_value, |
| 69 |
Error = $error; |
| 70 |
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; |
| 71 |
START SLAVE; |
| 72 |
} |