From f76ff56512e1e10856816d6e5031f2b44df0990f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Nov 2005 09:34:46 +0300 Subject: [PATCH] BUG#14480: post-fix: use the default field value from CREATE list too. --- mysql-test/r/create.result | 11 +++++++++++ mysql-test/t/create.test | 7 +++++++ sql/sql_table.cc | 1 + 3 files changed, 19 insertions(+) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 0c3b7d5d5e7..a933027cdb1 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -697,4 +697,15 @@ a1 varchar(12) charset utf8 collate utf8_bin not null, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, primary key (a1) ) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ; +drop table t2; +create table t2 ( a int default 3, b int default 3) +select a1,a2 from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) default '3', + `b` int(11) default '3', + `a1` int(11) default NULL, + `a2` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1, t2; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 3bdc970027b..c9d16916f8a 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -594,6 +594,13 @@ create table t2 ( primary key (a1) ) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ; +# Test the default value +drop table t2; + +create table t2 ( a int default 3, b int default 3) + select a1,a2 from t1; +show create table t2; + drop table t1, t2; # End of 4.1 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 40777682251..d6a7d76ac99 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -639,6 +639,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, else { /* Field redefined */ + sql_field->def= dup_field->def; sql_field->sql_type= dup_field->sql_type; sql_field->charset= (dup_field->charset ? dup_field->charset :