Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-32077

ALTER allows to set default for a virtual column

    XMLWordPrintable

Details

    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
      

      Attachments

        Activity

          People

            nikitamalyavin Nikita Malyavin
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.