summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2015-07-17 00:02:25 +0300
committerMonty <monty@mariadb.org>2015-07-17 00:02:25 +0300
commit44de090a5fdcf799d826226055ee848af653e375 (patch)
tree20d86e536b4ec552d90e17be0763d6996dc803f9
parentbc300464f1674dc774fd166a87d8894cbe498563 (diff)
downloadmariadb-git-44de090a5fdcf799d826226055ee848af653e375.tar.gz
MDEV-8432 Slave cannot replicate signed integer-type values with high bit set to 1
The fix is that if the slave has a different integer size than the master, then they will assume the master has the same signed/unsigned modifier as the slave. This means that one can safely change a coon the slave an int to a bigint or an unsigned int to an unsigned int. Changing an unsigned int to an signed bigint will cause replication failures when the high bit of the unsigned int is set. We can't give an error if the signess is different on the master and slave as the binary log doesn't contain the signess of the column on the master.
-rw-r--r--mysql-test/suite/rpl/r/rpl_alter.result105
-rw-r--r--mysql-test/suite/rpl/t/rpl_alter.test53
2 files changed, 158 insertions, 0 deletions
diff --git a/mysql-test/suite/rpl/r/rpl_alter.result b/mysql-test/suite/rpl/r/rpl_alter.result
index 2cffa70d778..7be3bc576f3 100644
--- a/mysql-test/suite/rpl/r/rpl_alter.result
+++ b/mysql-test/suite/rpl/r/rpl_alter.result
@@ -14,4 +14,109 @@ select * from mysqltest.t3;
n
45
drop database mysqltest;
+use test;
+#
+# Test bug where ALTER TABLE MODIFY didn't replicate properly
+#
+create table t1 (a int unsigned primary key, b int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(10) unsigned NOT NULL,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 (a) values (1),((1<<32)-1);
+select * from t1;
+a b
+1 NULL
+4294967295 NULL
+alter table t1 modify a bigint;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) NOT NULL DEFAULT '0',
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+a b
+1 NULL
+4294967295 NULL
+alter table t1 modify a int unsigned;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(10) unsigned NOT NULL DEFAULT '0',
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+a b
+1 NULL
+4294967295 NULL
+alter table t1 modify a bigint unsigned;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+a b
+1 NULL
+4294967295 NULL
+use test;
+select * from t1;
+a b
+1 NULL
+4294967295 NULL
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+create table t2 (a int unsigned auto_increment primary key, b int);
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+alter table t2 modify a bigint;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` bigint(20) NOT NULL DEFAULT '0',
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+alter table t2 modify a bigint auto_increment;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` bigint(20) NOT NULL AUTO_INCREMENT,
+ `b` int(11) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1,t2;
+#
+# MDEV-8432: Slave cannot replicate signed integer-type values
+# with high bit set to 1
+# Test replication when we have int on master and bigint on slave
+#
+create table t1 (a int unsigned primary key, b int);
+SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_NON_LOSSY';
+alter table t1 modify a bigint unsigned;
+insert into t1 (a) values (1),((1<<32)-1);
+select * from t1;
+a b
+1 NULL
+4294967295 NULL
+SET GLOBAL SLAVE_TYPE_CONVERSIONS='';
+drop table t1;
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_alter.test b/mysql-test/suite/rpl/t/rpl_alter.test
index 630197f8637..8b8bcfb3d26 100644
--- a/mysql-test/suite/rpl/t/rpl_alter.test
+++ b/mysql-test/suite/rpl/t/rpl_alter.test
@@ -15,4 +15,57 @@ drop database mysqltest;
sync_slave_with_master;
# End of 4.1 tests
+
+connection master;
+use test;
+
+--echo #
+--echo # Test bug where ALTER TABLE MODIFY didn't replicate properly
+--echo #
+
+create table t1 (a int unsigned primary key, b int);
+show create table t1;
+insert into t1 (a) values (1),((1<<32)-1);
+select * from t1;
+alter table t1 modify a bigint;
+show create table t1;
+select * from t1;
+alter table t1 modify a int unsigned;
+show create table t1;
+select * from t1;
+alter table t1 modify a bigint unsigned;
+show create table t1;
+select * from t1;
+sync_slave_with_master;
+use test;
+select * from t1;
+show create table t1;
+connection master;
+#
+create table t2 (a int unsigned auto_increment primary key, b int);
+show create table t2;
+alter table t2 modify a bigint;
+show create table t2;
+alter table t2 modify a bigint auto_increment;
+show create table t2;
+drop table t1,t2;
+
+--echo #
+--echo # MDEV-8432: Slave cannot replicate signed integer-type values
+--echo # with high bit set to 1
+--echo # Test replication when we have int on master and bigint on slave
+--echo #
+
+create table t1 (a int unsigned primary key, b int);
+sync_slave_with_master;
+SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_NON_LOSSY';
+alter table t1 modify a bigint unsigned;
+connection master;
+insert into t1 (a) values (1),((1<<32)-1);
+sync_slave_with_master;
+select * from t1;
+SET GLOBAL SLAVE_TYPE_CONVERSIONS='';
+connection master;
+drop table t1;
+
--source include/rpl_end.inc