Bug #41305 server crashes when inserting duplicate row into a merge table
Submitted: 8 Dec 2008 17:52 Modified: 15 Apr 2009 1:44
Reporter: Balint Toth Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Merge storage engine Severity:S2 (Serious)
Version:5.0/5.1/6.0 OS:Linux (x86_64)
Assigned to: Anurag Shekhar CPU Architecture:Any
Tags: merge unique key, regression

[8 Dec 2008 17:52] Balint Toth
Description:
Server crashes when trying to insert a duplicate row into a merge table. Inserting directly into the merged table works, specifying "IGNORE" keyword also eliminates the crash.

How to repeat:
DROP TABLE IF EXISTS `m`;

DROP TABLE IF EXISTS `m1`;
CREATE TABLE `m1` (
  `dt` datetime NOT NULL default '0000-00-00 00:00:00',
  `i` int(10) unsigned NOT NULL,
  PRIMARY KEY  (`dt`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

DROP TABLE IF EXISTS `m2`;
CREATE TABLE `m2` (
  `dt` datetime NOT NULL default '0000-00-00 00:00:00',
  `i` int(10) unsigned NOT NULL,
  PRIMARY KEY  (`dt`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `m` (
  `dt` datetime NOT NULL,
  `i` int(10) unsigned NOT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`m1`,`m2`);

insert into m (dt,i) values ("2008-12-08 10:00:00",1);
insert into m (dt,i) values ("2008-12-08 10:00:00",1);
[8 Dec 2008 19:51] MySQL Verification Team
Verified on 5.0 bzr tree. I will test 5.1/6.0

081208 17:49:46 [Note] /home/miguel/dbs/5.0/libexec/mysqld: ready for connections.
Version: '5.0.76-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
[New Thread 0x40b8f950 (LWP 28860)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x40b8f950 (LWP 28860)]
0x0000000000599ec3 in Field::val_str (this=0xb318db, str=0x40b8c620) at field.h:117
117       inline String *val_str(String *str) { return val_str(str, str); }
(gdb)
[8 Dec 2008 20:04] MySQL Verification Team
Thank you for the bug report. Verified on 5.1 and 6.0 too. Older release 5.0.22 don't crash.
[15 Dec 2008 22:18] Omer Barnir
setting a PK on the merge table prevents the crash in the above scenario
[24 Feb 2009 12:52] 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/67364

2810 Anurag Shekhar	2009-02-24
      Bug#41305 server crashes when inserting duplicate row into a merge table
      
      This problem comes while inserting a duplicate row in merge table 
      without key but the child table has a primary key. 
      While forming the error message handler tries to locate the key field
      which is creating this problem but as there is no key on the merge 
      table there is a segmentation fault.
      
      An additional check to ensure that the key fields are present 
      fixes this problem.
[26 Feb 2009 10:10] 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/67657

2824 Anurag Shekhar	2009-02-26
      Bug#41305 server crashes when inserting duplicate row into a merge table
      
      This problem comes while inserting a duplicate row in merge table 
      without key but the child table has a primary key. 
      While forming the error message handler tries to locate the key field
      which is creating this problem but as there is no key on the merge 
      table there is a segmentation fault.
[4 Mar 2009 9:18] 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/68182

2832 Anurag Shekhar	2009-03-04
      Bug#41305 server crashes when inserting duplicate row into a merge table
      
      This problem comes while inserting a duplicate row in merge table 
      without key but the child table has a primary key. 
      While forming the error message handler tries to locate the key field
      which is creating this problem but as there is no key on the merge
      table there is a segmentation fault.
[6 Mar 2009 14:18] Ingo Strüwing
Approved. All looks good. No comments.
[9 Mar 2009 8:43] 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/68591

2837 He Zhenxing	2009-03-09 [merge]
      Auto merge
[13 Mar 2009 19:03] Bugs System
Pushed into 5.1.33 (revid:joro@sun.com-20090313111355-7bsi1hgkvrg8pdds) (version source revid:zhou.li@sun.com-20090311061050-ihp0g77znonq1tuq) (merge vers: 5.1.33) (pib:6)
[18 Mar 2009 13:21] Bugs System
Pushed into 6.0.11-alpha (revid:joro@sun.com-20090318122208-1b5kvg6zeb4hxwp9) (version source revid:matthias.leich@sun.com-20090310140952-gwtoq87wykhji3zi) (merge vers: 6.0.11-alpha) (pib:6)
[15 Apr 2009 1:44] Paul DuBois
Noted in 5.1.33, 6.0.11 changelogs.

If the tables underlying a MERGE table had a primary key but the
MERGE table itself did not, inserting a duplicate row into the MERGE
table caused a server crash.
[9 May 2009 16:41] Bugs System
Pushed into 5.1.34-ndb-6.2.18 (revid:jonas@mysql.com-20090508185236-p9b3as7qyauybefl) (version source revid:jonas@mysql.com-20090508100057-30ote4xggi4nq14v) (merge vers: 5.1.33-ndb-6.2.18) (pib:6)
[9 May 2009 17:38] Bugs System
Pushed into 5.1.34-ndb-6.3.25 (revid:jonas@mysql.com-20090509063138-1u3q3v09wnn2txyt) (version source revid:jonas@mysql.com-20090508175813-s6yele2z3oh6o99z) (merge vers: 5.1.33-ndb-6.3.25) (pib:6)
[9 May 2009 18:35] Bugs System
Pushed into 5.1.34-ndb-7.0.6 (revid:jonas@mysql.com-20090509154927-im9a7g846c6u1hzc) (version source revid:jonas@mysql.com-20090509073226-09bljakh9eppogec) (merge vers: 5.1.33-ndb-7.0.6) (pib:6)