Bug #19145 mysqld crashes if you set the default value of an enum field to NULL
Submitted: 17 Apr 2006 18:39 Modified: 2 May 2006 1:50
Reporter: Chris Calender Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:>= 4.1 OS:All OS
Assigned to: Chad MILLER CPU Architecture:Any

[17 Apr 2006 18:39] Chris Calender
Description:
mysqld crashes when trying to set the default value of an enum field to NULL.

I know that one cannot have a NULL in a NOT NULL column, however, it should not cause mysqld to crash.

How to repeat:

DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1`(`c1` ENUM('a','b','c') NOT NULL DEFAULT 'a') ENGINE=MyISAM;
ALTER TABLE t1 ALTER COLUMN c1 SET DEFAULT NULL;
[17 Apr 2006 18:59] MySQL Verification Team
using datatype SET instead of ENUM also crashes
[27 Apr 2006 3:32] 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/5614
[27 Apr 2006 13:29] 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/5641
[28 Apr 2006 13: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/5687
[28 Apr 2006 16:27] Elliot Murphy
Fixed in 4.1.19
[30 Apr 2006 6:58] Nathan Cheng
The already-approved patch may fix this, but I have no way to test.

Here is a simpler test case that crashes 4.1.7:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 ( a enum('a') default NULL ) SELECT NULL AS a;

It crashes for both MyISAM and INNODB.

Please verify that the patch fixeds this also.
[30 Apr 2006 7:15] Nathan Cheng
Actually this may be a different bug, perhaps caused by the same root problem, and perhaps fixed by this patch. Pay special attention to the 5th one because there is no NULL in sight and it still crashes!

Any one of these queries crashes 4.1.7:

CREATE TABLE a ( a enum('a') default NULL ) SELECT NULL AS a;
CREATE TABLE a ( a enum('a') default NULL ) SELECT 'a' AS a;
CREATE TABLE a ( a enum('a') NULL default NULL ) SELECT 'a' AS a;
CREATE TABLE a ( a enum('a') NULL default 'a' ) SELECT 'a' AS a;
CREATE TABLE a ( a enum('a') NOT NULL default 'a' ) SELECT 'a' AS a;
CREATE TABLE a ( a enum('a') NOT NULL ) SELECT 'a' AS a;
CREATE TABLE a ( a enum('a') ) SELECT 'a' AS a;

Note that any one of these queries crashes when creating either INNODB or MyISAM. E.g.:

CREATE TABLE a ( a enum('a') NOT NULL default 'a' ) ENGINE=INNODB SELECT 'a' AS a;

From the committed patch it is apparent that test cases only for MyISAM are included...

I just tried the original test case for INNODB and there is no crash. So this is a different bug...creating new bug...
[1 May 2006 15:43] Chad MILLER
Added in 4.1.19 and 5.0.22, and eventually in 5.1.10.
[2 May 2006 1:50] Paul DuBois
Noted in 4.1.19, 5.0.22, 5.1.10 changelogs.

Attempting to set the default value of an
<literal>ENUM</literal> or <literal>SET</literal> column to
<literal>NULL</literal> caused a server crash. (Bug #19145)