pt-online-schema-change should clear sql_mode before CREATE and ALTER TABLE
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
In environments where sql_mode was changed after database schema was deployed, some tables may no longer compatible with the current sql_mode settings. In such case any CREATE TABLE or ALTER TABLE statements fail for reasons that are beyond pt-online-
pt-online-
Here's an example:
mysql> select @@global.sql_mode;
+------
| @@global.sql_mode |
+------
| STRICT_
+------
Error creating new table: DBD::mysql::db do failed: Invalid default value for 'updated_at' [for Statement "CREATE TABLE `test`.`_test_new` (
`id` int(11) NOT NULL AUTO_INCREMENT,
...
`updated_at` timestamp NOT NULL ON UPDATE CURRENT_TIMESTAMP,
`created_at` timestamp NOT NULL,
...
) ENGINE=InnoDB AUTO_INCREMENT=
A quick patch to fix the problem. The diff comes from a modified 2.2.14, but it should apply on a vanilla 2.2.14 too.