1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-7318 RENAME INDEX

This patch adds support of RENAME INDEX operation to the ALTER TABLE
statement. Code which determines if ALTER TABLE can be done in-place
for "simple" storage engines like MyISAM, Heap and etc. was updated to
handle ALTER TABLE ... RENAME INDEX as an in-place operation. Support
for in-place ALTER TABLE ... RENAME INDEX for InnoDB was covered by
MDEV-13301.

Syntax changes
==============

A new type of <alter_specification> is added:

<rename index clause> ::= RENAME ( INDEX | KEY ) <oldname> TO <newname>

Where <oldname> and <newname> are identifiers for old name and new
name of the index.

Semantic changes
================

The result of "ALTER TABLE t1 RENAME INDEX a TO b" is a table which
contents and structure are identical to the old version of 't1' with
the only exception index 'a' being called 'b'.

Neither <oldname> nor <newname> can be "primary". The index being
renamed should exist and its new name should not be occupied
by another index on the same table.

Related to: WL#6555, MDEV-13301
This commit is contained in:
Aleksey Midenkov
2020-03-03 13:50:33 +03:00
parent fa8ad75439
commit 193725b81e
13 changed files with 2204 additions and 2 deletions

View File

@ -132,3 +132,15 @@ DROP TABLE t1;
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
--echo #
--echo # MDEV-7318 RENAME INDEX
--echo #
CREATE TABLE t (c1 INT, c2 INT, KEY i2 (c2)) ENGINE=INNODB;
SET DEBUG_DBUG= '+d,ib_rename_index_fail1';
-- error ER_LOCK_DEADLOCK
ALTER TABLE t RENAME INDEX i2 to x, ALGORITHM=INPLACE;
SET DEBUG_DBUG= '-d,ib_rename_index_fail1';
DROP TABLE t;