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

            This is intentional. Generated columns do not work with auto-incremented columns, they won't see the value. We've introduced the limitation in MDEV-11117. It's the same in MySQL 5.7.

            In 10.1 (and earlier version) this was allowed, but it did not work correctly.

            To let generated columns work with auto-increment would need a rather big internal refactoring. We want to do that, but it's not a change for 10.2.

            serg Sergei Golubchik added a comment - This is intentional. Generated columns do not work with auto-incremented columns, they won't see the value. We've introduced the limitation in MDEV-11117 . It's the same in MySQL 5.7. In 10.1 (and earlier version) this was allowed, but it did not work correctly. To let generated columns work with auto-increment would need a rather big internal refactoring. We want to do that, but it's not a change for 10.2.

            If this is intentional, it should be included within the documentation for AUTO_INCREMENT.

            Currently this is an undocumented incompatible change between 10.1 and 10.2.

            honso Taylor Honsowetz added a comment - If this is intentional, it should be included within the documentation for AUTO_INCREMENT. Currently this is an undocumented incompatible change between 10.1 and 10.2.
            greenman Ian Gilfillan added a comment - Documented in: https://mariadb.com/kb/en/mariadb/upgrading-from-mariadb-101-to-mariadb-102/ https://mariadb.com/kb/en/mariadb/what-is-mariadb-102/ https://mariadb.com/kb/en/mariadb/mariadb-1026-release-notes/ https://mariadb.com/kb/en/mariadb/auto_increment https://mariadb.com/kb/en/mariadb/virtual-computed-columns/ https://mariadb.com/kb/en/mariadb/constraint/

            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.