mirror of
https://github.com/MariaDB/server.git
synced 2025-07-16 00:42:55 +03:00
MDEV-14849 CREATE + ALTER with user-invisible columns produce ...
Problem:- create or replace table t1 (pk int auto_increment primary key invisible, i int); alter table t1 modify pk int invisible; This last alter makes a invisible column which is not null and does not have default value. Analysis:- This is caused because our error check for NOT_NULL_FLAG and NO_DEFAULT_VALUE_FLAG flag misses this sql_field , but this is not the fault of error check :).Actually this field come via mysql_prepare_alter_table and it does not have NO_DEFAULT_VALUE_FLAG flag turned on. (If it was create table NO_DEFAULT_VALUE_FLAG would have turned on Column_definition::check) and this would have generated error. Solution:- I have moved the error check to kind last of mysql_prepare_create_table because upto this point we have applied NO_DEFAULT_VALUE_FLAG to required column.
This commit is contained in:
committed by
Sachin Setiya
parent
2d73b58101
commit
16be7469ac
@ -3593,14 +3593,6 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
record_offset+= sql_field->pack_length;
|
||||
if (sql_field->flags & VERS_SYSTEM_FIELD)
|
||||
continue;
|
||||
if (sql_field->invisible == INVISIBLE_USER &&
|
||||
sql_field->flags & NOT_NULL_FLAG &&
|
||||
sql_field->flags & NO_DEFAULT_VALUE_FLAG)
|
||||
{
|
||||
my_error(ER_INVISIBLE_NOT_NULL_WITHOUT_DEFAULT, MYF(0),
|
||||
sql_field->field_name.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
/* Update virtual fields' offset and give error if
|
||||
All fields are invisible */
|
||||
@ -4244,6 +4236,14 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (sql_field->invisible == INVISIBLE_USER &&
|
||||
sql_field->flags & NOT_NULL_FLAG &&
|
||||
sql_field->flags & NO_DEFAULT_VALUE_FLAG)
|
||||
{
|
||||
my_error(ER_INVISIBLE_NOT_NULL_WITHOUT_DEFAULT, MYF(0),
|
||||
sql_field->field_name.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check table level constraints */
|
||||
|
Reference in New Issue
Block a user