[MDEV-32577] Cannot create table with virtual column Created: 2023-10-25 Updated: 2023-10-25 Resolved: 2023-10-25 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Virtual Columns |
| Affects Version/s: | 10.5.22 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Kim Henriksen | Assignee: | Sergei Golubchik |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu 22.04 |
||
| Description |
|
When attempting to import a database dump from a MariaDB 10.5.15 to MariaDB 10.5.22 server, I encounter an error regarding a GENERATED ALWAYS AS / foreign key constraint in a table definition. This is the error: ERROR 1901 (HY000) at line 539: Function or expression 'food_id' cannot be used in the GENERATED ALWAYS AS clause of `open_ended` The error seems to be related to the following change in 10.5.22: Here is the full statement that fails on 10.5.22 but works in previous releases:
|
| Comments |
| Comment by Sergei Golubchik [ 2023-10-25 ] |
|
It is intentional. The way MariaDB works, and always did, foreign key cascading actions are applied to child tables on a very low level where the server cannot update STORED generated column values anymore. In other words, if a STORED generated column depends on a column that can be modified via a cascade action, this STORED column can become out of sync with other columns. Basically, it'll have an incorrect value. That's why such a table structure is no longer allowed. We're planning to lift this restriction. MDEV-31942 (or MDEV-22361) when implemented, will allow us to recalculate STORED generated columns on UPDATE CASCADE and SET NULL actions. Note that ON DELETE CASCADE is fine, it's allowed, because it doesn't modify individual columns, but deletes the complete row. VIRTUAL columns are also fine. |