mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
1a8cf15d63
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.
27 lines
648 B
Text
27 lines
648 B
Text
--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 = '';
|
|
|
|
|
|
|
|
|