Bug #10511 Wrong padding of UCS2 CHAR columns in ON UPDATE CASCADE
Submitted: 10 May 2005 14:17 Modified: 30 Nov 2005 17:52
Reporter: Marko Mäkelä Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:4.1.15 OS:Any (all)
Assigned to: Alexander Ivanov CPU Architecture:Any

[10 May 2005 14:17] Marko Mäkelä
Description:
When a UCS2 CHAR column references a UCS2 VARCHAR column, it will be padded with 0x2020 instead of 0x0020 during ON UPDATE CASCADE.

How to repeat:
create table parent(a varchar(5) primary key) engine=innodb charset=ucs2;
create table child(a char(4) primary key,constraint c foreign key(a)references parent(a) on update cascade) engine=innodb charset=ucs2;

insert into parent values ('abc'),('def'),('gh');
insert into child values ('abc'),('def');
update parent set a='d' where a='def';
select * from child natural join parent;
-- huh? referential integrity for 'def' will be broken

Suggested fix:
Check mbminlen in row_ins_cascade_calc_update_vec() and pad UCS2 columns with 0x0020 instead of 0x2020.
[13 May 2005 10:48] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/24850
[4 Jul 2005 13:03] Marko Mäkelä
Fixed in MySQL 5.0.8
[30 Sep 2005 11:26] Marko Mäkelä
This bug is still present in MySQL 4.1.
[24 Oct 2005 21:20] Heikki Tuuri
Marko now has a patch.
[27 Oct 2005 11:25] Marko Mäkelä
The patch has been submitted to Elliot Murphy.
The bug was already fixed in MySQL 5.0 in a different way.
[28 Oct 2005 13:06] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/31620
[30 Nov 2005 17:52] Paul DuBois
Noted in 4.1.16 changelog.