Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.3.12
-
None
Description
MariaDB and MySQL create an 'implicit index', for a foreign key whose columns are not part of an index. That implicit index is removed once the client adds an actual index on the columns involved. However, when the reverse is carried out, i.e. the client removes his actual index again, no implicit index is put back and this causes an error message: Cannot drop index: needed in a foreign key constraint. This is inconvenient for scripts that attempt to reverse actions automatically and there does not seem to be a reason that justifies the inconsistency.
Test script:
CREATE TABLE a (id INT NOT NULL PRIMARY KEY); |
CREATE TABLE b (id INT NOT NULL PRIMARY KEY); |
ALTER TABLE b ADD COLUMN a_id INT NOT NULL, ADD CONSTRAINT a_id FOREIGN KEY (a_id) REFERENCES a (id); |
ALTER TABLE b ADD INDEX a_id (a_id); |
Now try to reverse these actions:
ALTER TABLE b DROP INDEX a_id; |
ALTER TABLE b DROP COLUMN a_id, DROP FOREIGN KEY a_id; |
DROP TABLE b; |
DROP TABLE a; |
Attachments
Issue Links
- relates to
-
MDEV-12483 Add foreign keys support for partitioned tables
- Stalled