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

virtual columns fail when expression references auto increment column

Details

    Description

      The following create statement fails on 10.2.7:

      CREATE TABLE t1 ( id INT NOT NULL AUTO_INCREMENT, v INT AS (id) VIRTUAL, PRIMARY KEY (id) ) ENGINE=InnoDB;
      

      Giving the error:
      #1901 - Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `id`

      The same create statement works fine on 10.1.22

      Attachments

        Issue Links

          Activity

            honso Taylor Honsowetz created issue -
            honso Taylor Honsowetz made changes -
            Field Original Value New Value
            honso Taylor Honsowetz made changes -
            Description The following create statement fails on 10.2.7:

            {{CREATE TABLE t1 ( i INT NOT NULL AUTO_INCREMENT, v INT AS (i) VIRTUAL, PRIMARY KEY (i) ) ENGINE=InnoDB;}}

            Giving the error:
            {{#1901 - Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `i`}}

            The same create statement works fine on 10.1.22
            The following create statement fails on 10.2.7:

            CREATE TABLE t1 ( i INT NOT NULL AUTO_INCREMENT, v INT AS (i) VIRTUAL, PRIMARY KEY (i) ) ENGINE=InnoDB;

            Giving the error:
            #1901 - Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `i`

            The same create statement works fine on 10.1.22
            honso Taylor Honsowetz made changes -
            Description The following create statement fails on 10.2.7:

            CREATE TABLE t1 ( i INT NOT NULL AUTO_INCREMENT, v INT AS (i) VIRTUAL, PRIMARY KEY (i) ) ENGINE=InnoDB;

            Giving the error:
            #1901 - Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `i`

            The same create statement works fine on 10.1.22
            The following create statement fails on 10.2.7:

            CREATE TABLE t1 ( id INT NOT NULL AUTO_INCREMENT, v INT AS (id) VIRTUAL, PRIMARY KEY (id) ) ENGINE=InnoDB;

            Giving the error:
            #1901 - Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `id`

            The same create statement works fine on 10.1.22
            serg Sergei Golubchik made changes -
            Fix Version/s N/A [ 14700 ]
            Assignee Sergei Golubchik [ serg ]
            Resolution Not a Bug [ 6 ]
            Status Open [ 1 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Description The following create statement fails on 10.2.7:

            CREATE TABLE t1 ( id INT NOT NULL AUTO_INCREMENT, v INT AS (id) VIRTUAL, PRIMARY KEY (id) ) ENGINE=InnoDB;

            Giving the error:
            #1901 - Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `id`

            The same create statement works fine on 10.1.22
            The following create statement fails on 10.2.7:
            {code:sql}
            CREATE TABLE t1 ( id INT NOT NULL AUTO_INCREMENT, v INT AS (id) VIRTUAL, PRIMARY KEY (id) ) ENGINE=InnoDB;
            {code}
            Giving the error:
            #1901 - Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `id`

            The same create statement works fine on 10.1.22
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Ian Gilfillan [ greenman ]
            serg Sergei Golubchik made changes -
            Resolution Not a Bug [ 6 ]
            Status Closed [ 6 ] Stalled [ 10000 ]
            serg Sergei Golubchik made changes -
            Component/s Documentation [ 10903 ]
            greenman Ian Gilfillan made changes -
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            Dean T Dean Trower made changes -
            Comment [ Should also be documented on the *CREATE TABLE* page, under the *DEFAULT Column Option* heading. The text currently says:

            From MariaDB 10.2.1 you can use most functions in DEFAULT. Expressions should have parentheses around them. If you use a non deterministic function in DEFAULT then all inserts to the table will be replicated in row mode. *You can even refer to earlier columns in the DEFAULT expression*:
            ...

            But there's no indication that the "earlier columns" cannot be AUTO_INCREMENT. ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 81665 ] MariaDB v4 [ 152485 ]

            People

              greenman Ian Gilfillan
              honso Taylor Honsowetz
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.