[MDEV-32078] Information schema does not reflect virtual columns in views Created: 2023-09-03  Updated: 2023-09-03

Status: Open
Project: MariaDB Server
Component/s: Views, Virtual Columns
Affects Version/s: 10.4, 10.5, 10.6, 10.10, 10.11, 11.0, 11.1
Fix Version/s: 11.2

Type: Bug Priority: Trivial
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I'm not really sure how columns for views should look at all in information_schema, but it seems that at least when a column is taken from a table "as is", its attributes such as type, default etc. are generally preserved; virtual columns are an exception, as neither EXTRA nor IS_GENERATED nor GENERATION_EXPRESSION are populated, even though the column is expectedly still treated as virtual upon DML on a view.

create table t (a int, b int as (a));
create view v as select * from t;
select table_name, column_name, column_type, extra, is_generated, generation_expression from information_schema.columns where column_name = 'b';
--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
insert into v (b) values (1);
drop view v;
drop table t;

10.4 900c4d6920

+------------+-------------+-------------+-------------------+--------------+-----------------------+
| table_name | column_name | column_type | extra             | is_generated | generation_expression |
+------------+-------------+-------------+-------------------+--------------+-----------------------+
| v          | b           | int(11)     |                   | NEVER        | NULL                  |
| t          | b           | int(11)     | VIRTUAL GENERATED | ALWAYS       | `a`                   |
+------------+-------------+-------------+-------------------+--------------+-----------------------+
 
MariaDB [test]> insert into v (b) values (1);
ERROR 1906 (HY000): The value specified for generated column 'b' in table 't' has been ignored


Generated at Thu Feb 08 10:28:39 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.