[MDEV-16282] ALTER TABLE t ADD COLUMN c INT, ADD INDEX(c), ALGORITHM=NOCOPY fails Created: 2018-05-24  Updated: 2023-11-28

Status: Stalled
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.3.7
Fix Version/s: 10.6, 10.11, 11.0

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Thirunarayanan Balathandayuthapani
Resolution: Unresolved Votes: 0
Labels: alter, instant

Issue Links:
Relates
relates to MDEV-11369 Instant add column for InnoDB Closed
relates to MDEV-13134 Introduce ALTER TABLE attributes ALGO... Closed
relates to MDEV-15250 UPSERT during ALTER-TABLE results in ... Closed

 Description   

When MDEV-11369 implemented instant ADD COLUMN, it would refuse to do instant ADD together with ADD INDEX.

Adding an index to an instantly added column does not make much sense, because the index would be useless due to every row initially having the same value for the instantly added column.

However, it is meaningful to ADD COLUMN together with ADD INDEX on some old column. This will currently cause the table to be rebuilt:

--source include/have_innodb.inc
create table t1(a int) engine=innodb;
alter table t1 add column b int, add index(a), algorithm=nocopy;
alter table t1 add column c int, add index(c), algorithm=nocopy;
drop table t1;

The first ALTER TABLE should be fixed to allow ALGORITHM=NOCOPY, but the second one can in my opinion continue to rebuild the table with ALGORITHM=INPLACE.



 Comments   
Comment by Marko Mäkelä [ 2022-11-08 ]

Because MDEV-15250 (a significant refactoring of InnoDB online ALTER TABLE) was only implemented starting with 10.6, I do not think that it makes sense to fix this in older versions.

Also, 10.6 is the first release series where InnoDB ALTER TABLE is supposed to be crash-safe. It would be infeasible to test the crash-safety aspects of this fix in older major versions.

Generated at Thu Feb 08 08:27:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.