Skip to content

Commit

Permalink
MDEV-11527 Virtual columns do not get along well with NO_ZERO_DATE
Browse files Browse the repository at this point in the history
don't check defaults for vcols
  • Loading branch information
vuvova committed Jan 12, 2017
1 parent 0d1d0d7 commit 20ca1bc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions mysql-test/suite/vcol/r/vcol_misc.result
Expand Up @@ -330,3 +330,10 @@ t1 CREATE TABLE `t1` (
`c1` varchar(50) COLLATE latin1_general_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
drop table t1;
set sql_mode='no_zero_date';
create table t1 (
ts timestamp not null default current_timestamp,
tsv timestamp as (adddate(ts, interval 1 day)) virtual
);
drop table t1;
set sql_mode=default;
11 changes: 11 additions & 0 deletions mysql-test/suite/vcol/t/vcol_misc.test
Expand Up @@ -290,3 +290,14 @@ create table t1 (a int, b int as (b is null) virtual);
create table t1 (v1 varchar(255) as (c1) persistent, c1 varchar(50)) collate=latin1_general_ci;
show create table t1;
drop table t1;

#
# MDEV-11527 Virtual columns do not get along well with NO_ZERO_DATE
#
set sql_mode='no_zero_date';
create table t1 (
ts timestamp not null default current_timestamp,
tsv timestamp as (adddate(ts, interval 1 day)) virtual
);
drop table t1;
set sql_mode=default;
2 changes: 1 addition & 1 deletion sql/sql_table.cc
Expand Up @@ -3826,7 +3826,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
Field::utype type= (Field::utype) MTYP_TYPENR(sql_field->unireg_check);

if (thd->variables.sql_mode & MODE_NO_ZERO_DATE &&
!sql_field->def &&
!sql_field->def && !sql_field->vcol_info &&
sql_field->sql_type == MYSQL_TYPE_TIMESTAMP &&
(sql_field->flags & NOT_NULL_FLAG) &&
(type == Field::NONE || type == Field::TIMESTAMP_UN_FIELD))
Expand Down

0 comments on commit 20ca1bc

Please sign in to comment.