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

LOAD DATA with a PARTITION clause gives 'Out of range value' for a generated AUTO_INCREMENT value

    XMLWordPrintable

Details

    Description

      --source include/have_partition.inc
       
      CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY) PARTITION BY HASH(pk) PARTITIONS 2;
      INSERT INTO t1 VALUES (2),(4);
      FLUSH TABLES;
      --write_file $MYSQLTEST_VARDIR/tmp/t1.txt
      \N
      EOF
      --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
      --eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/t1.txt' INTO TABLE t1 PARTITION (p1)
      let $ok= `SELECT GROUP_CONCAT(pk ORDER BY pk)='2,4,5' FROM t1`;
      if (!$ok)
      {
        --die The loaded row did not get AUTO_INCREMENT value 5, the next value over all partitions
      }
      DROP TABLE t1;
      --remove_file $MYSQLTEST_VARDIR/tmp/t1.txt

      Leads to:

      CS 10.11.19 ece09631eaf7a66e4e832f5e17059e73a9f24851 (Debug, Clang 22.1.8-20260622) Build 05/10/2026

      mysqltest: At line 10: query 'LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/t1.txt' INTO TABLE t1 PARTITION (p1)' failed: HA_ERR_AUTOINC_ERANGE (167): Out of range value for column 'pk' at row 1

      Without the PARTITION clause, or with PARTITION (p0,p1), the row gets the value 5. A file with an explicit value loads fine. Optimized builds give the same error.

      From the code it seems that check_insert_or_replace_autoincrement() in sql/ha_partition.h does not list SQLCOM_LOAD, so only the named partition is opened before the next AUTO_INCREMENT value is read.

      Attachments

        Issue Links

          Activity

            People

              ycp Yuchen Pei
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 1h 20m
                  1h 20m

                  Git Integration

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