Commit d85e052d authored by ramil@ram-book.(none)'s avatar ramil@ram-book.(none)

a fix (bug #6267: ENUM ... NOT NULL w/o default treated differently than other data types).

the behavior of enum changed to be consistent.
parent e7c02801
......@@ -116,7 +116,7 @@ func CREATE TABLE `func` (
`name` char(64) collate utf8_bin NOT NULL default '',
`ret` tinyint(1) NOT NULL default '0',
`dl` char(128) collate utf8_bin NOT NULL default '',
`type` enum('function','aggregate') character set utf8 NOT NULL default 'function',
`type` enum('function','aggregate') character set utf8 NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='User defined functions'
show create table tables_priv;
......@@ -163,7 +163,7 @@ Table Create Table
proc CREATE TABLE `proc` (
`db` char(64) character set latin1 collate latin1_bin NOT NULL default '',
`name` char(64) NOT NULL default '',
`type` enum('FUNCTION','PROCEDURE') NOT NULL default 'FUNCTION',
`type` enum('FUNCTION','PROCEDURE') NOT NULL,
`specific_name` char(64) NOT NULL default '',
`language` enum('SQL') NOT NULL default 'SQL',
`sql_data_access` enum('CONTAINS_SQL','NO_SQL','READS_SQL_DATA','MODIFIES_SQL_DATA') NOT NULL default 'CONTAINS_SQL',
......
......@@ -1626,7 +1626,7 @@ create table t1 (a enum (' ','a','b') not null);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` enum('','a','b') NOT NULL default ''
`a` enum('','a','b') NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a enum (' ','a','b ') not null default 'b ');
......@@ -1670,12 +1670,12 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) default '1',
`b` enum('value','_value','') NOT NULL default 'value'
`b` enum('value','_value','') NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
show columns from t1;
Field Type Null Key Default Extra
a int(11) YES 1
b enum('value','_value','') NO value
b enum('value','_value','') NO
drop table t1;
CREATE TABLE t1 (c enum('a', 'A') BINARY);
INSERT INTO t1 VALUES ('a'),('A');
......
......@@ -62,7 +62,7 @@ blob_col blob NULL YES NULL #
tinyblob_col tinyblob NULL YES NULL #
mediumblob_col mediumblob NULL NO #
longblob_col longblob NULL NO #
options enum('one','two','tree') latin1_swedish_ci NO MUL one #
options enum('one','two','tree') latin1_swedish_ci NO MUL #
flags set('one','two','tree') latin1_swedish_ci NO #
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
......@@ -231,7 +231,7 @@ date_time datetime NULL YES NULL #
new_blob_col varchar(20) latin1_swedish_ci YES NULL #
tinyblob_col tinyblob NULL YES NULL #
mediumblob_col mediumblob NULL NO #
options enum('one','two','tree') latin1_swedish_ci NO MUL one #
options enum('one','two','tree') latin1_swedish_ci NO MUL #
flags set('one','two','tree') latin1_swedish_ci NO #
new_field char(10) latin1_swedish_ci NO new #
show full columns from t2;
......
......@@ -969,7 +969,8 @@ int check_that_all_fields_are_given_values(THD *thd, TABLE *entry)
for (Field **field=entry->field ; *field ; field++)
{
if ((*field)->query_id != thd->query_id &&
((*field)->flags & NO_DEFAULT_VALUE_FLAG))
((*field)->flags & NO_DEFAULT_VALUE_FLAG) &&
((*field)->real_type() != FIELD_TYPE_ENUM))
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_NO_DEFAULT_FOR_FIELD,
......
......@@ -5423,12 +5423,9 @@ new_create_field(THD *thd, char *field_name, enum_field_types type,
new_field->comment=*comment;
/*
Set flag if this field doesn't have a default value
Enum values has always the first value as a default (set in
make_empty_rec().
*/
if (!default_value && !(type_modifier & AUTO_INCREMENT_FLAG) &&
(type_modifier & NOT_NULL_FLAG) && type != FIELD_TYPE_TIMESTAMP &&
type != FIELD_TYPE_ENUM)
(type_modifier & NOT_NULL_FLAG) && type != FIELD_TYPE_TIMESTAMP)
new_field->flags|= NO_DEFAULT_VALUE_FLAG;
if (length && !(new_field->length= (uint) atoi(length)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment