|
If a persistent computed column uses an auto_increment column in its defining expression, upon inserting a new row into the table the value of the auto_increment column is taken to be zero and not the value it gets automatically assigned. The same problem does not happen with a virtual computed column.
Example:
create table test (a int key auto_increment, b int as(a) persistent);
|
insert test set a=null;
|
select * from test;
|
+---+------+
|
| a | b |
|
+---+------+
|
| 1 | 0 |
|
+---+------+
|
One would, however, expect that b is 1, just like a. As it stands, persistent computed columns cannot meaningfully use auto_increment columns.
|