Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 10.1, 10.0
-
Labels:
-
Environment:Linux
-
Sprint:10.1.6-2
Description
Reproduction:
1) Create table
CREATE TABLE `table2` ( `i1` INT(10) UNSIGNED NOT NULL, `d1` TIMESTAMP NULL DEFAULT NULL ) ENGINE=INNODB;
2) Fill table
INSERT INTO table2 (i1) VALUES (1), (2), (3), (4), (5);
3) Try Alter table with making field `d1` not nullable with default value CURRENT_TIMESTAMP
ALTER TABLE `table2` CHANGE `d1` `d1` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
Error happens here:
Error Code: 1138 Invalid use of NULL value
Expected that column `d1` will be filled with NOW() value
SELECT @@sql_mode
@@sql_mode --------------------------------------------------------------------------------------------------------------------------- NO_BACKSLASH_ESCAPES,STRICT_ALL_TABLES,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
In continue bug https://mariadb.atlassian.net/browse/MDEV-6880 but also needed with already created fields.
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
Thanks for the report.
Same happens on MySQL 5.6/5.7; only with InnoDB.
CURRENT_TIMESTAMP is not important, there could be a constant instead, the result is the same.
Apparently, it's caused by online alter table. If I force ALGORITHM=COPY in the alter, it works all right.
Jan Lindström,
Do you think it's supposed to be like that? I doubt that, but I would like to get the 2nd opinion. If it's a bug, we should probably re-report it at bugs.mysql.com.