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

MyISAM allows AUTO_INCREMENT columns with no index

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL)
    • N/A
    • None

    Description

      This script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a CHAR(20) NOT NULL, b INT NOT NULL AUTO_INCREMENT, INDEX(a,b)) ENGINE=InnoDB;
      

      correctly return an error:

      ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key
      

      If I now change ENGINE to MyISAM, it creates the table with no errors:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a CHAR(20) NOT NULL, b INT NOT NULL AUTO_INCREMENT, INDEX(a,b)) ENGINE=MyISAM;
      INSERT INTO t1 (a) VALUES ('a'),('b'),('c');
      SELECT * FROM t1;
      

      but AUTO_INCREMENT does not actually work:

      +---+---+
      | a | b |
      +---+---+
      | a | 1 |
      | b | 1 |
      | c | 1 |
      +---+---+
      

      The problem seems to be introduced by:

      Author: unknown <monty@mashka.mysql.fi>  2003-03-07 14:36:52
      Committer: unknown <monty@mashka.mysql.fi>  2003-03-07 14:36:52
       
          Fixed AUTO_INCREMENT handling in MyISAM (last auto_increment patch broke things)
          Some after merge fixes
      

      Attachments

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            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.