File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,4 +98,20 @@ SELECT * FROM ttb1;
9898id name age
99991 AAA
1001002 BBB
101+ create table stu(id int primary key, name char(20))engine=tianmu;
102+ insert into stu(id, name) values(1, 'zhang fei');
103+ insert into stu(id, name) values(2, 'zhao yun');
104+ insert into stu(id, name) values(3, 'zhen ji');
105+ insert into stu(id, name) values(4, 'zhou yu');
106+ insert into stu(id, name) values(5, 'zhu ge liang');
107+ insert into stu(id, name) values(6, 'ma chao');
108+ alter table stu add column ctm2 timestamp default current_timestamp();
109+ select id,name,length(ctm2) from stu;
110+ id name length(ctm2)
111+ 1 zhang fei 19
112+ 2 zhao yun 19
113+ 3 zhen ji 19
114+ 4 zhou yu 19
115+ 5 zhu ge liang 19
116+ 6 ma chao 19
101117DROP DATABASE alter_colunm;
Original file line number Diff line number Diff line change @@ -111,6 +111,22 @@ SHOW CREATE TABLE ttb1;
111111
112112SELECT * FROM ttb1;
113113
114+ #################
115+ # ADD timestamp COLUMN with default current_timestam
116+ #################
117+ create table stu(id int primary key, name char(20))engine=tianmu;
118+
119+ insert into stu(id, name) values(1, 'zhang fei');
120+ insert into stu(id, name) values(2, 'zhao yun');
121+ insert into stu(id, name) values(3, 'zhen ji');
122+ insert into stu(id, name) values(4, 'zhou yu');
123+ insert into stu(id, name) values(5, 'zhu ge liang');
124+ insert into stu(id, name) values(6, 'ma chao');
125+
126+ alter table stu add column ctm2 timestamp default current_timestamp();
127+ select id,name,length(ctm2) from stu;
128+
129+
114130#################
115131# CLEAR UP
116132#################
Original file line number Diff line number Diff line change @@ -1628,7 +1628,7 @@ bool ha_tianmu::check_if_notnull_of_added_column(TABLE *altered_table) {
16281628 if (j < old_cols.size ()) // column exists
16291629 continue ;
16301630
1631- if ((*new_cols[i]).null_bit == 0 )
1631+ if ((*new_cols[i]).null_bit == 0 || (*new_cols[i]). has_insert_default_function () )
16321632 return true ;
16331633 }
16341634
You can’t perform that action at this time.
0 commit comments