Bug #41687 Foreign keys: crash if varbinary or varchar or datetime or decimal
Submitted: 23 Dec 2008 0:09 Modified: 23 Jan 2009 18:41
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:6.1.0-alpha-debug OS:Linux (SUSE 10.0 / 32-bit)
Assigned to: Dmitry Lenev CPU Architecture:Any

[23 Dec 2008 0:09] Peter Gulutzan
Description:
I'm using mysql-6.1-fk.
I start the server with mysqld --foreign-key-all-engines=1.

I create a primary-key table and a foreign-key table.
The tables contain VARCHAR, VARBINARY, or DATETIME columns.
I insert into the primary-key table.
I insert into the foreign-key table.
Crash.

How to repeat:
create table t1 (s1 varchar(5) not null unique) engine=falcon;
create table t2 (s1 varchar(5) references t1(s1)) engine=falcon;
insert into t1 values ('a');
insert into t2 values ('a');
/* Crash */

OR

create table t1 (s1 varbinary(5) not null unique) engine=falcon;
create table t2 (s1 varbinary(5) references t1(s1)) engine=falcon;
insert into t1 values (0x00);
insert into t2 values (0x00);
/* Crash */

OR

create table t1 (s1 decimal(5) not null unique) engine=falcon;
create table t2 (s1 decimal(5) references t1(s1)) engine=falcon;
insert into t1 values (5);
insert into t2 values (5);
/* Crash */

OR

create table t1 (s1 datetime not null unique) engine=falcon;
create table t2 (s1 datetime references t1(s1)) engine=falcon;
insert into t1 values ('2008-10-14 01:02:03');
insert into t2 values ('2008-10-14 01:02:03');
/* Crash */
[23 Dec 2008 15:03] MySQL Verification Team
Thank you for the bug report. Verified as described:

mysql> use db5
Database changed
mysql> create table t1 (s1 varchar(5) not null unique) engine=falcon;
Query OK, 0 rows affected (0.01 sec)

mysql> create table t2 (s1 varchar(5) references t1(s1)) engine=falcon;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1 values ('a');
Query OK, 1 row affected (0.01 sec)

mysql> insert into t2 values ('a');
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> /* Crash */
[31 Dec 2008 12:12] 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/commits/62461

2694 Dmitry Lenev	2008-12-31
      Tentative fix for bug #41687 "Foreign keys: crash if varbinary
      or varchar or datetime or decimal".
      
      In --foreign-key-all-engines mode attempts to insert values into
      table with foreign keys using these datatypes triggered assert
      about using values of fields which were not retrieved from
      storage engine.
      
      Since INSERT provides values for all fields for record this fix
      satisfies this assertion by simply marking all fields in child
      table as read when creating foreign key value for lookup in
      parent table (i.e. in the case when assertion was triggered).
      
      Question for reviewer is marked by QQ.
[23 Jan 2009 18:36] 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/commits/63925

2696 Dmitry Lenev	2009-01-23
      Fix for bug #41687 "Foreign keys: crash if varbinary or varchar
      or datetime or decimal".
      
      In --foreign-key-all-engines mode attempts to insert values into
      table with foreign keys using these datatypes triggered assert
      about using values of fields which were not retrieved from
      storage engine.
      
      Since INSERT provides values for all fields for record this fix
      satisfies this assertion by simply marking all fields in child
      table as read when creating foreign key value for lookup in
      parent table (i.e. in the case when assertion was triggered).
[23 Jan 2009 18:41] Dmitry Lenev
Patch fixing this problem was pushed into mysql-6.1-fk tree. Since the problem was reported against tree which is not publicly available yet I am simply closing this bug report.