[MDEV-25619] Bogus ER_TABLE_EXISTS_ERROR upon an attempt to add a foreign key Created: 2021-05-07 Updated: 2023-11-02 Resolved: 2023-11-02 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table, Storage Engine - InnoDB |
| Affects Version/s: | 10.2, 10.3, 10.4, 10.5, 10.6 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Thirunarayanan Balathandayuthapani |
| Resolution: | Duplicate | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
Reproducible on 10.2-10.6. It happens even if we also modify t1.f1 to CHAR(1) NOT NULL after the first ALTER, to restore the consistency between column definitions. It still leaves the foreign key invalid though, because it can't really set NULL to a non-NULL column; so, some error is probably expected, but ER_TABLE_EXISTS_ERROR is clearly a wrong choice. |
| Comments |
| Comment by Marko Mäkelä [ 2021-05-10 ] | ||
|
I think that the correct course of action would be to reject already the statement
because it directly contradicts the previous definition
of the same table. That is, the SET NULL that refers to t2.a clearly implies that t2.a must allow NULL values. The foreign_key_checks=OFF should only relax checks that are related to the referenced tables, i.e., if t1 did not exist, we should allow those statements to get through. But, whether or not t1 exists, I think that we must reject a table definition where SET NULL would be requested on a NOT NULL column. | ||
| Comment by Elena Stepanova [ 2021-05-10 ] | ||
|
While at it, please adjust (or clarify) the description of foreign_key_checks variable to indicate what exactly it is meant to relax.
| ||
| Comment by Thirunarayanan Balathandayuthapani [ 2021-05-18 ] | ||
|
Fails to load the foreign key constraint due to column mismatch. So consecutive alter | ||
| Comment by Thirunarayanan Balathandayuthapani [ 2023-11-02 ] | ||
|
This issue should be fixed by |