Commit 7a525e7e authored by Aleksey Midenkov's avatar Aleksey Midenkov

Parser: no implicit NOT NULL for system fields [fixes #163]

parent 14f007f9
......@@ -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;
......
......@@ -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
......
......@@ -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:
......
......@@ -3871,6 +3871,7 @@ class Column_definition: public Sql_alloc
*check_constraint; // Check constraint
enum_column_versioning versioning;
bool implicit_not_null;
Column_definition():
comment(null_lex_str),
......@@ -3880,7 +3881,8 @@ class Column_definition: public Sql_alloc
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();
}
......
......@@ -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;
......
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