[MDEV-32077] ALTER allows to set default for a virtual column Created: 2023-09-03  Updated: 2023-09-04

Status: Open
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Virtual Columns
Affects Version/s: 10.4, 10.5, 10.6, 10.10, 10.11, 11.0, 11.1, 11.2
Fix Version/s: 11.2

Type: Bug Priority: Trivial
Reporter: Elena Stepanova Assignee: Nikita Malyavin
Resolution: Unresolved Votes: 0
Labels: None


 Description   

ALTER TABLE .. ALTER .. SET DEFAULT allows to set a default value for a virtual column, which doesn't make sense. It is not further reflected in SHOW CREATE TABLE because there is no such syntax, but it is shown in INFORMATION_SCHEMA, which can be misleading (and is inconsistent).

create table t (a int, b int as (a));
alter table t alter b set default 1;
show create table t;
select column_name, column_default from information_schema.columns where table_name = 't';
drop table t;

11.2 9ad7c899

alter table t alter b set default 1;
show create table t;
Table	Create Table
t	CREATE TABLE `t` (
  `a` int(11) DEFAULT NULL,
  `b` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
select column_name, column_default from information_schema.columns where table_name = 't';
column_name	column_default
a	NULL
b	1


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