MariaDB [testdb]> CREATE TABLE `cats` (
-> `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
-> `name` varchar(255),
-> `full_nm` varchar(255) AS (TRIM(CONCAT(name, ' - ', id))) PERSISTENT,
-> `display_nm` varchar(255) AS (TRIM(CONCAT(name, ' - ', id))) VIRTUAL,
-> PRIMARY KEY (`id`)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Query OK, 0 rows affected (0.06 sec)
MariaDB [testdb]> insert into cats (`name`) values ('freddy'), ('sammy'), ('spot'), ('boots');
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0
MariaDB [testdb]> select * from cats;
+----+--------+------------+------------+
| id | name | full_nm | display_nm |
+----+--------+------------+------------+
| 1 | freddy | freddy - 0 | freddy - 1 |
| 2 | sammy | sammy - 0 | sammy - 2 |
| 3 | spot | spot - 0 | spot - 3 |
| 4 | boots | boots - 0 | boots - 4 |
+----+--------+------------+------------+
4 rows in set (0.00 sec)
Thanks for the report.
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 cats FORCE or UPDATE cats SET name = name, etc.).
Igor Babaev,
If it's a known limitation, please reassign it back to me or directly to Ian Gilfillan to update the documentation.