Details
-
New Feature
-
Status: In Review (View Workflow)
-
Critical
-
Resolution: Unresolved
-
None
Description
Implementation of foreign keys in partitioned tables with limitations is relatively simple and is covered by this task. Full support of foreign keys in partitioning is covered by MDEV-12483.
This task is basically divided into 3 parts:
1. Remove prohibiting code, this allows FKs to be created for partitions and DML to work;
2. Allow partitioned FKs at SQL layer for such functions as SHOW CREATE;
3. Implement correct handling of FKs when partitioning configuration changes.
Limitations
1. Foreign keys cannot refer partitioned table
Foreign keys cannot refer to partitioned table even SYSTEM_TIME-partitioned still. create_foreign_keys() at InnoDB layer receives Foreign_key about referenced table T, but no such table exists at InnoDB layer, only partition tables T#P#p0, T#P#p1, ..., T#P#pn. Finding out it is SYSTEM_TIME partitioning and current partition at that point is impossible without modification of SYS_TABLES or opening TABLE object of referenced table. Both should be avoided as this is superseded by MDEV-12483.
2. CASCADE and SET NULL actions cannot work
In partitioned foreign table CASCADE and SET NULL actions cannot work as these actions update row data which is the subject of row placement into another partition and that cannot be done at InnoDB layer. DELETE CASCADE for SYSTEM_TIME partitioning requires the row to be moved from current to history partition. CASCADE and SET NULL actions disabled completely in CREATE TABLE for partitioned foreign tables in this task.
Allow partitioned FKs at SQL layer for such functions as SHOW CREATE
Through standard handler interface get_foreign_key_list() foreign keys are returned to SQL layer. For SYSTEM_TIME partitioning from current partition, for any other partitioning from first read-marked partition.
Implement correct handling of FKs when partitioning configuration changes
ALTER operations such as ADD PARTITION, DROP PARTITION, REMOVE PARTITIONING , etc. must be reflected into correct configuration of foreign keys in InnoDB. Handling of foreign key ID for temporary tables in ALTER may be done similar to MDEV-28933.
Attachments
Issue Links
- is duplicated by
-
MDEV-32493 support foreign keys in tables partitioned by system time
- Closed
- relates to
-
MDEV-12483 Add foreign keys support for partitioned tables
- Stalled
-
MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name
- Stalled