diff options
-rw-r--r-- | mysql-test/r/default.result | 18 | ||||
-rw-r--r-- | mysql-test/t/default.test | 10 | ||||
-rw-r--r-- | sql/field.cc | 4 |
3 files changed, 30 insertions, 2 deletions
diff --git a/mysql-test/r/default.result b/mysql-test/r/default.result index 62dee045604..81568d6c654 100644 --- a/mysql-test/r/default.result +++ b/mysql-test/r/default.result @@ -3063,3 +3063,21 @@ t1 CREATE TABLE `t1` ( `c` int(11) DEFAULT (-a) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +create table t1 (a int default 5 check (a>10), b int default (5+5), c int as (a+b)); +create table t2 as select a, b, c from t1; +create table t3 as select max(a), max(b), max(c) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT 5 CHECK (a>10), + `b` int(11) DEFAULT (5+5), + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `max(a)` int(11) DEFAULT NULL, + `max(b)` int(11) DEFAULT NULL, + `max(c)` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2, t3; diff --git a/mysql-test/t/default.test b/mysql-test/t/default.test index 14eb16bacd4..47de4a00a50 100644 --- a/mysql-test/t/default.test +++ b/mysql-test/t/default.test @@ -1827,3 +1827,13 @@ alter table t1 alter a set default (2+3), alter b set default 4, alter table t1 alter a set default 1+2; show create table t1; drop table t1; + +# +# CREATE ... SELECT +# +create table t1 (a int default 5 check (a>10), b int default (5+5), c int as (a+b)); +create table t2 as select a, b, c from t1; +create table t3 as select max(a), max(b), max(c) from t1; +show create table t2; +show create table t3; +drop table t1, t2, t3; diff --git a/sql/field.cc b/sql/field.cc index 73e6b4edc3c..b5d971d4ce2 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -10482,8 +10482,8 @@ Column_definition::Column_definition(THD *thd, Field *old_field, comment= old_field->comment; decimals= old_field->decimals(); vcol_info= old_field->vcol_info; - default_value= old_field->default_value; - check_constraint= old_field->check_constraint; + default_value= orig_field ? orig_field->default_value : 0; + check_constraint= orig_field ? orig_field->check_constraint : 0; option_list= old_field->option_list; switch (sql_type) { |