pt-online-schema-change does not support multiple alters in single operation
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Invalid
|
Undecided
|
Unassigned |
Bug Description
pt-online-
Per the documentation:
```
--alter
type: string
The schema modification, without the ALTER TABLE keywords. You can perform multiple modifications to the table by specifying them with commas.
```
However after testing this and looking at the code it doesn't appear that the tool actually parses the alter option into multiple statements. Sample output below. Likely problem line: https:/
```
# pt-online-
No slaves found. See --recursion-method if host uadb1 has slaves.
Not checking slave lag because no slaves were found and --check-slave-lag was not specified.
Operation, tries, wait:
analyze_table, 10, 1
copy_rows, 10, 0.25
create_triggers, 10, 1
drop_triggers, 10, 1
swap_tables, 10, 1
update_
Altering `app_live`
Creating new table...
CREATE TABLE `app_live`
`id` int(11) NOT NULL AUTO_INCREMENT,
`parent_id` int(11) DEFAULT NULL,
`content_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
`filename` varchar(255) DEFAULT NULL,
`thumbnail` varchar(255) DEFAULT NULL,
`size` int(11) DEFAULT NULL,
`width` int(11) DEFAULT NULL,
`height` int(11) DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`profile_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_
KEY `index_
) ENGINE=InnoDB AUTO_INCREMENT=
Created new table app_live.
Altering new table...
ALTER TABLE `app_live`
2016-11-15T20:07:49 Dropping new table...
DROP TABLE IF EXISTS `app_live`
2016-11-15T20:07:49 Dropped new table OK.
`app_live`
Error altering new table `app_live`
```
Not relevant but yes the column has already been converted to varchar(255) and utf-8 by a previous run with multiple executions of pt-online-
First: There is an error on what you are trying to do: Unknown column 'content_type' in '_avatars_new'
Even that, I've tried to reproduce the issue but it works as expected:
mysql> use sakila; ------- +------ ------- ------- --+---- --+---- -+----- ------- ------- +------ ------- ------- ------- --+ ------- +------ ------- ------- --+---- --+---- -+----- ------- ------- +------ ------- ------- ------- --+ ------- +------ ------- ------- --+---- --+---- -+----- ------- ------- +------ ------- ------- ------- --+
Database changed
mysql> describe actor;
+------
| Field | Type | Null | Key | Default | Extra |
+------
| actor_id | smallint(5) unsigned | NO | PRI | NULL | auto_increment |
| first_name | varchar(45) | NO | | NULL | |
| last_name | varchar(45) | NO | MUL | NULL | |
| last_update | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
+------
4 rows in set (0.00 sec)
bin/pt- online- schema- change --host 127.0.0.1 --port 12345 --user msandbox --password=msandbox --alter "ADD COLUMN c1 INT, ADD COLUMN c2 INT" --alter- foreign- keys-method= auto --execute D=sakila,t=actor
mysql> describe actor; ------- +------ ------- ------- --+---- --+---- -+----- ------- ------- +------ ------- ------- ------- --+ ------- +------ ------- ------- --+---- --+---- -+----- ------- ------- +------ ------- ------- ------- --+ ------- +------ ------- ------- --+---- --+---- -+----- ------- ------- +------ ------- ------- ------- --+
+------
| Field | Type | Null | Key | Default | Extra |
+------
| actor_id | smallint(5) unsigned | NO | PRI | NULL | auto_increment |
| first_name | varchar(45) | NO | | NULL | |
| last_name | varchar(45) | NO | MUL | NULL | |
| last_update | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| c1 | int(11) | YES | | NULL | |
| c2 | int(11) | YES | | NULL | |
+------