• Sachin Setiya's avatar
    MDEV-14849 CREATE + ALTER with user-invisible columns produce ... · 16be7469
    Sachin Setiya authored
    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.
    16be7469
sql_table.cc 355 KB