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

LP:997397 - TRUNCATE on a partitioned Aria table does not reset AUTO_INCREMENT

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 5.3.9, 10.0.22, 10.1.8
    • 10.1
    • None

    Description

      TRUNCATE TABLE on an Aria table does not reset auto-increment value as it does for other engines, including MyISAM and InnoDB.
      (see http://kb.askmonty.org/en/truncate-table or http://dev.mysql.com/doc/refman/5.5/en/truncate-table.html)

      Reproducible on current MariaDB 5.1 - 5.5.

      Test case:

      CREATE TABLE t ( i INT NOT NULL AUTO_INCREMENT, KEY(i) )
        ENGINE=Aria
        PARTITION BY HASH(i) PARTITIONS 2;
      INSERT INTO t VALUES (NULL),(NULL),(NULL);
       
      SHOW CREATE TABLE t;
      SELECT * FROM t;
      TRUNCATE TABLE t;
      SHOW CREATE TABLE t;
      INSERT INTO t VALUES (NULL),(NULL);
      SELECT * FROM t;
       
      DROP TABLE t;
       

      Expected output (after truncate):

      TRUNCATE TABLE t;
      SHOW CREATE TABLE t;
      Table	Create Table
      t	CREATE TABLE `t` (
        `i` int(11) NOT NULL AUTO_INCREMENT,
        KEY `i` (`i`)
      ) ENGINE=Aria DEFAULT CHARSET=latin1
      /*!50100 PARTITION BY HASH (i)
      PARTITIONS 2 */
      INSERT INTO t VALUES (NULL),(NULL);
      SELECT * FROM t;
      i
      1
      2

      Actual output (after truncate):

      TRUNCATE TABLE t;
      SHOW CREATE TABLE t;
      Table	Create Table
      t	CREATE TABLE `t` (
        `i` int(11) NOT NULL AUTO_INCREMENT,
        KEY `i` (`i`)
      ) ENGINE=Aria AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
      /*!50100 PARTITION BY HASH (i)
      PARTITIONS 2 */
      INSERT INTO t VALUES (NULL),(NULL);
      SELECT * FROM t;
      i
      4
      5

      Attachments

        Activity

          People

            monty Michael Widenius
            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.