[MDEV-9116] Persistent virtual column cannot cope with auto_increment column Created: 2015-11-11  Updated: 2015-11-11  Resolved: 2015-11-11

Status: Closed
Project: MariaDB Server
Component/s: Virtual Columns
Affects Version/s: 10.1.6
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Martin Rieger Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Environment:

Linux OpenSUSE 13.2


Issue Links:
Duplicate
duplicates MDEV-8653 Persistent virtual fields don't inser... Closed

 Description   

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.



 Comments   
Comment by Elena Stepanova [ 2015-11-11 ]

Thanks for the report. We already have it filed, see MDEV-8653.

As a workaround, you can perform an operation on the table (any void operation, just to get virtual column values updated, e.g. ALTER TABLE test FORCE or UPDATE test SET a = a, etc.).

Generated at Thu Feb 08 07:32:15 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.