Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Cannot Reproduce
-
None
Description
MariaDB 10.8.7
I'm trying to add a new foreign key without any FK checks or tables locked.
I tried this (with and without "GLOBAL"):
SET GLOBAL FOREIGN_KEY_CHECKS=OFF;
|
ALTER ONLINE TABLE `table` ADD FOREIGN KEY (`initiator`) REFERENCES `main_table`(`uid`) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
SET GLOBAL FOREIGN_KEY_CHECKS=ON;
|
However, I get this error:
#1846 - LOCK=NONE is not supported. Reason: Adding foreign keys needs foreign_key_checks=OFF. Try LOCK=SHARED
—
Then I tried without "ONLINE":
SET GLOBAL FOREIGN_KEY_CHECKS=OFF;
|
ALTER TABLE `table` ADD FOREIGN KEY (`initiator`) REFERENCES `main_table`(`uid`) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
SET GLOBAL FOREIGN_KEY_CHECKS=ON;
|
However, the "main_table" gets immediately locked for many queries, with "Waiting for table metadata lock".
—
If I'm disabling FOREIGN_KEY_CHECKS, isn't the ALTER TABLE supposed to be performed ONLINE, without locking any tables and without checking for integrity?
Attachments
Issue Links
- relates to
-
MDEV-16356 Allow ALGORITHM=NOCOPY for ADD CONSTRAINT
- Open