create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innodb;
create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42);
insert into t2 values(0x42);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
insert into t2 values(0x41);
select hex(s1) from t2;
hex(s1)
4100
update t1 set s1=0x123456 where a=2;
select hex(s1) from t2;
hex(s1)
4100
update t1 set s1=0x12 where a=1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
update t1 set s1=0x12345678 where a=1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
update t1 set s1=0x123457 where a=1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
update t1 set s1=0x1220 where a=1;
select hex(s1) from t2;
hex(s1)
1220
update t1 set s1=0x1200 where a=1;
select hex(s1) from t2;
hex(s1)
1200
update t1 set s1=0x4200 where a=1;
select hex(s1) from t2;
hex(s1)
4200
delete from t1 where a=1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
delete from t1 where a=2;
update t2 set s1=0x4120;
delete from t1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
delete from t1 where a!=3;
select a,hex(s1) from t1;
a hex(s1)
3 4120
select hex(s1) from t2;
hex(s1)
4120
drop table t2,t1;
create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb;
create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
insert into t1 values(1,0x4100),(2,0x41);
insert into t2 values(0x41);
select hex(s1) from t2;
hex(s1)
41
update t1 set s1=0x1234 where a=1;
select hex(s1) from t2;
hex(s1)
41
update t1 set s1=0x12 where a=2;
select hex(s1) from t2;
hex(s1)
12
delete from t1 where a=1;
delete from t1 where a=2;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
select a,hex(s1) from t1;
a hex(s1)
2 12
select hex(s1) from t2;
hex(s1)
12
drop table t2,t1;
CREATE TABLE t1 (
ind enum('0','1','2') NOT NULL default '0',
string1 varchar(250) NOT NULL,
PRIMARY KEY (ind)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE t2 (
ind enum('0','1','2') NOT NULL default '0',
string1 varchar(250) NOT NULL,
PRIMARY KEY (ind)
) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
INSERT INTO t1 VALUES ('1', ''),('2', '');
INSERT INTO t2 VALUES ('1', ''),('2', '');
SELECT hex(ind),hex(string1) FROM t1 ORDER BY string1;
hex(ind) hex(string1)
31
32
SELECT hex(ind),hex(string1) FROM t2 ORDER BY string1;
hex(ind) hex(string1)
0031
0032
drop table t1,t2;
CREATE TABLE t1 (
ind set('0','1','2') NOT NULL default '0',
string1 varchar(250) NOT NULL,
PRIMARY KEY (ind)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE t2 (
ind set('0','1','2') NOT NULL default '0',
string1 varchar(250) NOT NULL,
PRIMARY KEY (ind)
) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
INSERT INTO t1 VALUES ('1', ''),('2', '');
INSERT INTO t2 VALUES ('1', ''),('2', '');
SELECT hex(ind),hex(string1) FROM t1 ORDER BY string1;
hex(ind) hex(string1)
31
32
SELECT hex(ind),hex(string1) FROM t2 ORDER BY string1;
hex(ind) hex(string1)
0031
0032
drop table t1,t2;
CREATE TABLE t1 (
ind bit not null,
string1 varchar(250) NOT NULL,
PRIMARY KEY (ind)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE t2 (
ind bit not null,
string1 varchar(250) NOT NULL,
PRIMARY KEY (ind)
) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
insert into t1 values(0,''),(1,'');
insert into t2 values(0,''),(1,'');
select hex(ind),hex(string1) from t1 order by string1;
hex(ind) hex(string1)
0
1
select hex(ind),hex(string1) from t2 order by string1;
hex(ind) hex(string1)
0
1
drop table t1,t2;
create table t2 (
a int, b char(10), filler char(10), primary key(a, b(2))
) character set utf8 engine = innodb;
insert into t2 values (1,'abcdefg','one');
insert into t2 values (2,'ijkilmn','two');
insert into t2 values (3, 'qrstuvw','three');
update t2 set a=5, filler='booo' where a=1;
drop table t2;
create table t2 (
a int, b char(10), filler char(10), primary key(a, b(2))
) character set ucs2 engine = innodb;
insert into t2 values (1,'abcdefg','one');
insert into t2 values (2,'ijkilmn','two');
insert into t2 values (3, 'qrstuvw','three');
update t2 set a=5, filler='booo' where a=1;
drop table t2;
create table t1(a int not null, b char(110),primary key(a,b(100))) engine=innodb default charset=utf8;
insert into t1 values(1,'abcdefg'),(2,'defghijk');
insert into t1 values(6,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1);
insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2);
create table t1(a int not null, b text(110),primary key(a,b(100))) engine=innodb default charset=utf8;
insert into t1 values(1,'abcdefg'),(2,'defghijk');
insert into t1 values(6,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1);
insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2);