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

CREATE + ALTER with user-invisible columns produce invalid table definition

Details

    • 10.1.31

    Description

      Even though user invisible columns are supposed to have default values, this works:

      MariaDB [test]> create or replace table t1 (pk int auto_increment primary key invisible, i int);
      # Query OK, 0 rows affected (0.16 sec)
       
      MariaDB [test]> alter table t1 modify pk int invisible;
      # Query OK, 0 rows affected (0.80 sec)
      # Records: 0  Duplicates: 0  Warnings: 0
      

      The resulting table structure is this:

      MariaDB [test]> show create table t1;
      +-------+------------------------------------------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                                                   |
      +-------+------------------------------------------------------------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `pk` int(11) NOT NULL INVISIBLE,
        `i` int(11) DEFAULT NULL,
        PRIMARY KEY (`pk`)
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+------------------------------------------------------------------------------------------------------------------------------------------------+
      1 row in set (0.01 sec)
      

      If you try to execute it, it produces an error:

      MariaDB [test]> drop table t1;
      Query OK, 0 rows affected (0.07 sec)
       
      MariaDB [test]> CREATE TABLE `t1` (
          ->   `pk` int(11) NOT NULL INVISIBLE,
          ->   `i` int(11) DEFAULT NULL,
          ->   PRIMARY KEY (`pk`)
          -> ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
      ERROR 4106 (HY000): Invisible column `pk` must have a default value
      

      My guess is that ALTER in the initial pair of commands should be rejected.

      Attachments

        Activity

          There are no comments yet on this issue.

          People

            sachin.setiya.007 Sachin Setiya (Inactive)
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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