-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDEV-8392: Couldn't alter field with default value for make it not nu…
…llable. Analysis; Problem is that InnoDB does not have support for generating CURRENT_TIMESTAMP or constant default. Fix: Add additional check if column has changed from NULL -> NOT NULL and column default has changed. If this is is first column definition whose SQL type is TIMESTAMP and it is defined as NOT NULL and it has either constant default or function default we must use "Copy" method for alter table.
- Loading branch information
Jan Lindström
committed
Jun 30, 2015
1 parent
8af5ab4
commit 1a8cf15
Showing
4 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
CREATE TABLE t1 ( | ||
`i1` INT(10) UNSIGNED NOT NULL, | ||
`d1` TIMESTAMP NULL DEFAULT NULL | ||
) ENGINE=innodb; | ||
show create table t1; | ||
Table Create Table | ||
t1 CREATE TABLE `t1` ( | ||
`i1` int(10) unsigned NOT NULL, | ||
`d1` timestamp NULL DEFAULT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 | ||
INSERT INTO t1 (i1) VALUES (1), (2), (3), (4), (5); | ||
select * from t1; | ||
i1 d1 | ||
1 NULL | ||
2 NULL | ||
3 NULL | ||
4 NULL | ||
5 NULL | ||
set sql_mode = 'STRICT_ALL_TABLES,NO_ZERO_DATE'; | ||
ALTER TABLE t1 CHANGE `d1` `d1` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL; | ||
drop table t1; | ||
CREATE TABLE t1 ( | ||
`i1` INT(10) UNSIGNED NOT NULL, | ||
`d1` TIMESTAMP NULL DEFAULT NULL | ||
) ENGINE=innodb; | ||
INSERT INTO t1 (i1) VALUES (1), (2), (3), (4), (5); | ||
ALTER TABLE t1 CHANGE `d1` `d1` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP; | ||
drop table t1; | ||
set sql_mode = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--source include/have_innodb.inc | ||
|
||
CREATE TABLE t1 ( | ||
`i1` INT(10) UNSIGNED NOT NULL, | ||
`d1` TIMESTAMP NULL DEFAULT NULL | ||
) ENGINE=innodb; | ||
|
||
show create table t1; | ||
|
||
INSERT INTO t1 (i1) VALUES (1), (2), (3), (4), (5); | ||
select * from t1; | ||
set sql_mode = 'STRICT_ALL_TABLES,NO_ZERO_DATE'; | ||
ALTER TABLE t1 CHANGE `d1` `d1` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL; | ||
drop table t1; | ||
|
||
CREATE TABLE t1 ( | ||
`i1` INT(10) UNSIGNED NOT NULL, | ||
`d1` TIMESTAMP NULL DEFAULT NULL | ||
) ENGINE=innodb; | ||
INSERT INTO t1 (i1) VALUES (1), (2), (3), (4), (5); | ||
ALTER TABLE t1 CHANGE `d1` `d1` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP; | ||
drop table t1; | ||
set sql_mode = ''; | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters