Commit 262232bc authored by Sergey Vojtovich's avatar Sergey Vojtovich Committed by Sergei Golubchik

ALTER TABLE fixes for high-level indexes

quick_rm_table() expects .frm to exist when it removes high-level indexes.
For cases like ALTER TABLE t1 RENAME TO t2, ENGINE=other_engine .frm was
removed earlier.

Another option would be removing high-level indexes explicitly before the
first quick_rm_table() and skipping high-level indexes for subsequent
quick_rm_table(NO_FRM_RENAME).

But this suggested order may also help with ddl log recovery. That is
if we crash before high-level indexes are removed, .frm is going to
exist.
parent 9ace07b3
......@@ -393,7 +393,7 @@
create vector index if not exists v on t1(v);
# CHANGE/MODIFY/DROP COLUMN (vector)
alter table t1 modify column v int;
@@ -666,34 +666,6 @@
@@ -666,62 +666,6 @@
alter table t1 alter key if exists v ignored;
alter table t1 alter key if exists v not ignored;
# ENGINE
......@@ -424,6 +424,34 @@
- `v` blob NOT NULL,
- PRIMARY KEY (`id`),
- VECTOR KEY `v` (`v`)
-) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
-alter table t1 rename to t2, engine=myisam;
-db.opt
-t2#i#01.MYD
-t2#i#01.MYI
-t2.MYD
-t2.MYI
-t2.frm
-show create table t2;
-Table Create Table
-t2 CREATE TABLE `t2` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `v` blob NOT NULL,
- PRIMARY KEY (`id`),
- VECTOR KEY `v` (`v`)
-) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
-alter table t2 rename to t1, engine=innodb;
-db.opt
-t1#i#01.ibd
-t1.frm
-t1.ibd
-show create table t1;
-Table Create Table
-t1 CREATE TABLE `t1` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `v` blob NOT NULL,
- PRIMARY KEY (`id`),
- VECTOR KEY `v` (`v`)
-) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
# CHANGE/MODIFY/DROP COLUMN (vector)
alter table t1 modify column v int;
......
......@@ -767,6 +767,34 @@ t1 CREATE TABLE `t1` (
PRIMARY KEY (`id`),
VECTOR KEY `v` (`v`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
alter table t1 rename to t2, engine=myisam;
db.opt
t2#i#01.MYD
t2#i#01.MYI
t2.MYD
t2.MYI
t2.frm
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`v` blob NOT NULL,
PRIMARY KEY (`id`),
VECTOR KEY `v` (`v`)
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
alter table t2 rename to t1, engine=innodb;
db.opt
t1#i#01.ibd
t1.frm
t1.ibd
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`v` blob NOT NULL,
PRIMARY KEY (`id`),
VECTOR KEY `v` (`v`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
# CHANGE/MODIFY/DROP COLUMN (vector)
alter table t1 modify column v int;
ERROR HY000: Incorrect arguments to VECTOR INDEX
......
......@@ -341,6 +341,12 @@ show create table t1;
alter table t1 engine=innodb;
list_files $datadir/test;
show create table t1;
alter table t1 rename to t2, engine=myisam;
list_files $datadir/test;
show create table t2;
alter table t2 rename to t1, engine=innodb;
list_files $datadir/test;
show create table t1;
}
--echo # CHANGE/MODIFY/DROP COLUMN (vector)
......
......@@ -11844,10 +11844,6 @@ do_continue:;
thd->push_internal_handler(&errors_to_warnings);
error_handler_pushed=1;
quick_rm_table(thd, old_db_type, &alter_ctx.db, &backup_name,
FN_IS_TMP | (engine_changed ? NO_HA_TABLE | NO_PAR_TABLE: 0));
debug_crash_here("ddl_log_alter_after_delete_backup");
if (engine_changed)
{
/* the .frm file was removed but not the original table */
......@@ -11855,6 +11851,11 @@ do_continue:;
NO_FRM_RENAME | (engine_changed ? 0 : FN_IS_TMP));
}
debug_crash_here("ddl_log_alter_after_delete_backup");
quick_rm_table(thd, old_db_type, &alter_ctx.db, &backup_name,
FN_IS_TMP | (engine_changed ? NO_HA_TABLE | NO_PAR_TABLE: 0));
debug_crash_here("ddl_log_alter_after_drop_original_table");
if (binlog_as_create_select)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment