[MDEV-6420] REFERENCES syntax in CREATE TABLE Created: 2014-07-05 Updated: 2021-06-02 Resolved: 2014-07-21 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Fix Version/s: | N/A |
| Type: | Task | Priority: | Minor |
| Reporter: | Federico Razzoli | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | foreign-keys | ||
| Issue Links: |
|
||||||||
| Description |
|
After all these years, sometimes I still see people who use the REFERENCES syntax to create foreign keys:
The problem is that they may think that a foreign key is created, until they realize that data is inconsistent. Please, consider producing a warning when this syntax is used. Or maybe support the syntax. |
| Comments |
| Comment by Sergei Golubchik [ 2014-07-21 ] |
|
There is no good way to do it. MariaDB does not support foreign keys yet. InnoDB works around it by parsing the CREATE TABLE statement with the internal parser and extracting foreign key definitions from there. To support REFERENCES one needs to extend InnoDB to parse that syntax too. To issue a warning MariaDB needs to become aware that some engines parse CREATE TABLE and implement foreign keys internally. It needs to know what engines can do it, when an engine does it, and what exactly syntax is supports. There is no API for that, we never wanted to require the engine to implement an SQL parser internally. |
| Comment by Federico Razzoli [ 2019-04-12 ] |
|
But probably it will be possible after MDEV-16417 is implemented? |
| Comment by Matthias Dieter Wallnöfer [ 2021-05-26 ] |
|
Just as a follow-up: I have noticed that the bug has been filed against MySQL 8.0 too: https://bugs.mysql.com/bug.php?id=102904. |