Details
Description
Creating a view with some extra virtual/computed fields are not insertable
The intention should be that 'extra computed fields' in a view should work identical
to how virtual fields works for a table.
- If one inserts into the table without specifying the virtual fields, it should work without any
warnings. - If one tries to insert into a virtual field, one should get an error/warning that the field is ignored.
CREATE TABLE table1 (x INT);
CREATE VIEW view1 AS SELECT x, x as x1 FROM table1;
INSERT INTO view1(x) VALUES (1);
ERROR 1471 (HY000): The target table view1 of the INSERT is not insertable-into
Â
An example with virtual columns
MariaDB [test]> create table t1 (a int, b int generated always as (a+1));
MariaDB [test]> insert into t1 (a) values(1);
MariaDB [test]> insert into t1 values(1,2);
ERROR 1906 (HY000): The value specified for generated column 'b' in table 't1' has been ignored
MariaDB [test]> insert ignore into t1 values(1,2);
Query OK, 1 row affected, 1 warning (0.018 sec)