[MDEV-10568] Implement support for ALTER TABLE ... {DISCARD|IMPORT} PARTITION Created: 2016-08-16  Updated: 2023-11-30

Status: Open
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Partitioning, Storage Engine - InnoDB
Fix Version/s: None

Type: New Feature Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Marko Mäkelä
Resolution: Unresolved Votes: 12
Labels: ddl, innodb, partitioning, upstream-fixed

Issue Links:
Relates
relates to MDEV-13626 Merge InnoDB test cases from MySQL 5.7 Closed
relates to MDEV-17690 Document InnoDB's transportable table... Closed
relates to MDEV-26137 ALTER TABLE IMPORT enhancement Closed
relates to MDEV-17132 Feature request: mariabackup doesn't ... Closed
relates to MDEV-17689 Document how to do partial backups an... Closed

 Description   

MySQL 5.7 supports ALTER TABLE ... {DISCARD|IMPORT} PARTITION. The documentation explains how to use it here:

https://dev.mysql.com/doc/refman/5.7/en/innodb-transportable-tablespace-examples.html
UPDATE: The above page does not exist anymore, page
https://dev.mysql.com/doc/refman/8.0/en/innodb-table-import.html explains it, too

Should MariaDB also support that?



 Comments   
Comment by Manuel Arostegui [ 2016-10-25 ]

What is the alternative to move partitioning if this is not implemented?
Remove partitions in the source and then recreate them once it has been moved over?

Comment by Geoff Montee (Inactive) [ 2016-12-07 ]

marostegui,

You can import/export partitions without this feature using a workaround, but it can be a little tedious. I wrote a blog post about how to do so here:

http://www.geoffmontee.com/importing-innodb-partitions-in-mysql-5-6-and-mariadb-10-010-1/

Comment by Manuel Arostegui [ 2016-12-15 ]

Thanks for the link. I have tried it but I am getting lots of

Column type mismatch

The columns are obviously the same and forcing a rebuild doesn't help anyways.

On varchar columns, and I am importing between exactly the same server versions 10.1.19
So for the moment the only solution I have found is removing the partitions, doing the transfer and creating them again. Not ideal, but...

Comment by Geoff Montee (Inactive) [ 2016-12-15 ]

marostegui,

That's a pretty strange error to see if the columns really are exactly the same. Since these are varchar columns, do you know if the character encoding is the same on both servers?

If you want help tracking down the problem, feel free to post on the maria-discuss mailing list.

https://launchpad.net/~maria-discuss

Comment by Steve Ruby [ 2017-07-04 ]

A slightly different take on this the change in MySQL 5.7 also allows not just ALTER TABLE <table> DISCARD PARTITION <partitions> TABLESPACE for specific partitions. But seems to fix DISCARD TABLESPACE applied to the whole table as well which returns an error in Mariadb (10.2.6). Can we get that fix/improvement as well?

Comment by Hartmut Holzgraefe [ 2021-07-26 ]

Maybe we should split this into two tickets, one for DISCARD/IMPORT support for partitioned tables in general, and one for being able to DISCARD/IMPORT specific partitions only?

Comment by Marko Mäkelä [ 2023-09-26 ]

I see that there is a feature

ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t1p0;

I do not know if it is a viable work-around, but I would think using this syntax, you could export or import partitions as individual tables.

From the InnoDB point of view, each partition or subpartition that stores data is a normal table that uses a funny name.

MDEV-26137 made the step ALTER TABLE…DISCARD TABLESPACE optional.

Comment by Marko Mäkelä [ 2023-11-03 ]

In MDEV-13626, I came across the MySQL 5.7 tests innodb.innodb-import-partition-rpl and innodb.innodb-import-partition. The latter was originally added in the implementation of MySQL WL#6867.

Generated at Thu Feb 08 07:43:13 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.