Bug #84055 inconsistent behavior for inserting default value to a column of enum type
Submitted: 5 Dec 2016 9:25 Modified: 5 Dec 2016 14:16
Reporter: 帅 Bang Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.6/5.7/8.0 OS:Linux
Assigned to: CPU Architecture:Any

[5 Dec 2016 9:25] 帅 Bang
Description:
mysql> create table def_enum(c1 enum('a','b','c') NOT NULL, c2 int default 99);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into def_enum(c2)values(1);
Query OK, 1 row affected (0.00 sec)

mysql> insert into def_enum(c1, c2) values(default, 1);
Query OK, 1 row affected (0.00 sec)

OK, OK, it is quite ok right now.

mysql> insert into def_enum(c1, c2) values(default(c1), 1);
ERROR 1364 (HY000): Field 'c1' doesn't have a default value

After consulting with doc of mysql5.7(http://dev.mysql.com/doc/refman/5.7/en/enum.html), we can find that, 

"If an ENUM column is declared NOT NULL, its default value is the first element of the list of permitted values."

So, IHMO, insert into def_enum(c1, c2) values(default(c1), 1); should not have been failed.

How to repeat:
create table def_enum(c1 enum('a','b','c') NOT NULL, c2 int default 99);
insert into def_enum(c1, c2) values(default(c1), 1);

Suggested fix:
insert into def_enum(c1, c2) values(default(c1), 1);  succeed and row('a', 1) is inserted.
[5 Dec 2016 14:16] MySQL Verification Team
Thank you for the bug report. Verified as described.