diff --git a/mysql-test/suite/versioning/r/alter.result b/mysql-test/suite/versioning/r/alter.result index 598aa6b98a8..13932ea1805 100644 --- a/mysql-test/suite/versioning/r/alter.result +++ b/mysql-test/suite/versioning/r/alter.result @@ -53,8 +53,8 @@ show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL, - `trx_start` timestamp(6) NOT NULL GENERATED ALWAYS AS ROW START, - `trx_end` timestamp(6) NOT NULL GENERATED ALWAYS AS ROW END, + `trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (`trx_start`, `trx_end`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING alter table t without system versioning; diff --git a/mysql-test/suite/versioning/r/create.result b/mysql-test/suite/versioning/r/create.result index ad27bc065c3..81c240297e3 100644 --- a/mysql-test/suite/versioning/r/create.result +++ b/mysql-test/suite/versioning/r/create.result @@ -9,8 +9,8 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `XNo` int(10) unsigned DEFAULT NULL, - `Sys_start` timestamp(6) NOT NULL GENERATED ALWAYS AS ROW START, - `Sys_end` timestamp(6) NOT NULL GENERATED ALWAYS AS ROW END, + `Sys_start` timestamp(6) GENERATED ALWAYS AS ROW START, + `Sys_end` timestamp(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (`Sys_start`, `Sys_end`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING # Implicit fields test diff --git a/sql/field.cc b/sql/field.cc index 3c34d973bf5..3a1fee59937 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -10630,6 +10630,8 @@ Column_definition::Column_definition(THD *thd, Field *old_field, check_constraint= orig_field ? orig_field->check_constraint : 0; option_list= old_field->option_list; pack_flag= 0; + versioning= VERSIONING_NOT_SET; + implicit_not_null= false; switch (sql_type) { case MYSQL_TYPE_BLOB: diff --git a/sql/field.h b/sql/field.h index e955323b917..317ae018066 100644 --- a/sql/field.h +++ b/sql/field.h @@ -3871,6 +3871,7 @@ public: *check_constraint; // Check constraint enum_column_versioning versioning; + bool implicit_not_null; Column_definition(): comment(null_lex_str), @@ -3880,7 +3881,8 @@ public: srid(0), geom_type(Field::GEOM_GEOMETRY), option_list(NULL), pack_flag(0), vcol_info(0), default_value(0), check_constraint(0), - versioning(VERSIONING_NOT_SET) + versioning(VERSIONING_NOT_SET), + implicit_not_null(false) { interval_list.empty(); } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 7a17b90a191..5eab752df3f 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -6305,6 +6305,11 @@ field_def: my_yyabort_error((ER_VERS_WRONG_PARAMS, MYF(0), table_name, err)); } *p= field_name; + if (lex->last_field->implicit_not_null) + { + lex->last_field->flags&= ~NOT_NULL_FLAG; + lex->last_field->implicit_not_null= false; + } } ; @@ -6517,7 +6522,10 @@ field_type: Unless --explicit-defaults-for-timestamp is given. */ if (!opt_explicit_defaults_for_timestamp) + { Lex->last_field->flags|= NOT_NULL_FLAG; + Lex->last_field->implicit_not_null= true; + } $$.set(opt_mysql56_temporal_format ? MYSQL_TYPE_TIMESTAMP2 : MYSQL_TYPE_TIMESTAMP, $2); } @@ -6704,7 +6712,11 @@ opt_attribute_list: ; attribute: - NULL_SYM { Lex->last_field->flags&= ~ NOT_NULL_FLAG; } + NULL_SYM + { + Lex->last_field->flags&= ~ NOT_NULL_FLAG; + Lex->last_field->implicit_not_null= false; + } | DEFAULT column_default_expr { Lex->last_field->default_value= $2; } | ON UPDATE_SYM NOW_SYM opt_default_time_precision { @@ -6731,7 +6743,11 @@ attribute: ; serial_attribute: - not NULL_SYM { Lex->last_field->flags|= NOT_NULL_FLAG; } + not NULL_SYM + { + Lex->last_field->flags|= NOT_NULL_FLAG; + Lex->last_field->implicit_not_null= false; + } | opt_primary KEY_SYM { LEX *lex=Lex;