Skip to content

Fix foreign key parsing broken by MariaDB system versioning - #20346

Open
Maria-Berta wants to merge 1 commit into
phpmyadmin:QA_5_2from
Maria-Berta:fix/system-versioning-foreign-keys
Open

Fix foreign key parsing broken by MariaDB system versioning#20346
Maria-Berta wants to merge 1 commit into
phpmyadmin:QA_5_2from
Maria-Berta:fix/system-versioning-foreign-keys

Conversation

@Maria-Berta

Copy link
Copy Markdown

When a MariaDB table has system versioning enabled, SHOW CREATE TABLE
includes constructs the sql-parser library does not handle:

  • GENERATED ALWAYS AS ROW START/END columns
  • PERIOD FOR SYSTEM_TIME clause

These cause getForeignKeysData() to return an empty array, making
the Relation View appear empty for system-versioned tables even though
the foreign keys exist in the database.

Fix: Pre-process the SHOW CREATE TABLE string in getForeignKeysData()
to strip these MariaDB-specific constructs before passing to the parser.

Steps to reproduce:

  1. Create a table with a foreign key and enable system versioning
  2. Navigate to Structure → Relation view in phpMyAdmin
  3. Foreign keys are not shown despite existing in the database

Fixes: #20095

Signed-off-by: Mariamawit Berta mariamawit21geremew@gmail.com

@williamdes

Copy link
Copy Markdown
Member

Thank you for your work
Could you please hard reset your branch to QA_5_2 and cherry pick your fix and force push?
Please do not close this PR or re open a new PR

It would be great if you could add some phpunit tests

When a MariaDB table has system versioning enabled, SHOW CREATE TABLE
includes constructs the sql-parser library does not handle:
- GENERATED ALWAYS AS ROW START/END columns
- PERIOD FOR SYSTEM_TIME clause

These cause getForeigners() to return an empty array, making
the Relation View appear empty for system-versioned tables.

Fix: Pre-process the SHOW CREATE TABLE string to strip these
MariaDB-specific constructs before passing to the parser.
Add PHPUnit tests covering versioned and non-versioned tables.

Fixes: phpmyadmin#20095
Signed-off-by: Mariamawit Berta <mariamawit21geremew@gmail.com>
@Maria-Berta
Maria-Berta force-pushed the fix/system-versioning-foreign-keys branch from 2aac852 to 86bd09b Compare July 7, 2026 18:24
@Maria-Berta
Maria-Berta changed the base branch from master to QA_5_2 July 7, 2026 18:32
@Maria-Berta

Copy link
Copy Markdown
Author

Hi @williamdes , I've completed both requests:

->Hard reset the branch to QA_5_2 and cherry-picked the fix
->Added 4 PHPUnit tests covering:

  1. Foreign key parsing with a fully system-versioned table (PERIOD FOR SYSTEM_TIME + GENERATED ALWAYS AS ROW START/END)
  2. Stripping of PERIOD FOR SYSTEM_TIME clause
  3. Stripping of GENERATED ALWAYS AS ROW START/END columns
  4. Regression test confirming non-versioned tables are unaffected

All 4 tests pass. Please let me know if any further changes are needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Adding system versioning to a table makes foreign keys unusable

2 participants