[MDEV-21051] Store and read foreign key info into/from FRM files Created: 2019-11-14  Updated: 2024-01-31  Resolved: 2020-08-07

Status: Closed
Project: MariaDB Server
Component/s: Server
Fix Version/s: N/A

Type: Task Priority: Critical
Reporter: Aleksey Midenkov Assignee: Aleksey Midenkov
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Blocks
is blocked by MDEV-21311 Converge Foreign_key and supplemental... Closed
Duplicate
duplicates MDEV-20865 Store foreign key info in TABLE_SHARE In Progress
Relates
relates to MDEV-20874 Wrong handling of 'table was dropped'... Stalled
relates to MDEV-21585 Pull off 64k size limit of Extra2 seg... Open

 Description   

1. Introduce Foreign_key_io class which creates/parses binary stream containing foreign key structures. Referenced tables store there only hints about foreign tables (their db and name), they restore full info from the corresponding tables.

Foreign_key_io is stored under new EXTRA2_FOREIGN_KEY_INFO field in extra2 section of FRM file.

2. Modify mysql_prepare_create_table() to generate names for foreign keys. Until InnoDB storage of foreign keys is removed, FK names must be unique across the database: the FK name must be based on table name.

3. Keep stored data in sync on DDL changes. Referenced tables update their foreign hints after following operations on foreign tables:

  • RENAME TABLE
  • DROP TABLE
  • CREATE TABLE
  • ADD FOREIGN KEY
  • DROP FOREIGN KEY

Foreign tables update their foreign info after following operations on referenced tables:

  • RENAME TABLE
  • RENAME COLUMN

4. To achieve 3. there must be ability to rewrite extra2 section of FRM file without full reparse. FRM binary is built from primary structures like HA_CREATE_INFO and cannot be built from TABLE_SHARE.

Use shadow write and rename like fast_alter_partition_table() does.



 Comments   
Comment by Aleksey Midenkov [ 2020-08-07 ]

Merged into MDEV-20865

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