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

ALTER TABLE ... ENGINE=InnoDB on a DuckDB table with duplicate PRIMARY KEY values reports the wrong duplicate value in ER_DUP_ENTRY

    XMLWordPrintable

Details

    • Can result in unexpected behaviour

    Description

      ALTER TABLE ... ENGINE=InnoDB on a DuckDB table with duplicate PRIMARY KEY values reports the wrong duplicate value in ER_DUP_ENTRY. This is misleading for users trying to identify and fix the actual duplicate before converting the table. Similar issue was already fixed for MyISAM in MDEV-23507

      Test case

      INSTALL SONAME 'ha_duckdb';
      CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=DuckDB;
      INSERT INTO t1 VALUES (1),(1),(2),(3);
      ALTER TABLE t1 ENGINE=InnoDB;
      

      CLI Output

      13.1.0-opt>INSTALL SONAME 'ha_duckdb';
      Query OK, 0 rows affected (0.000 sec)
       
      13.1.0-opt>CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=DuckDB;
      Query OK, 0 rows affected (0.014 sec)
       
      13.1.0-opt>INSERT INTO t1 VALUES (1),(1),(2),(3);
      Query OK, 4 rows affected (0.004 sec)
      Records: 4  Duplicates: 0  Warnings: 0
       
      13.1.0-opt>ALTER TABLE t1 ENGINE=InnoDB;
      ERROR 1062 (23000): Duplicate entry '3' for key 'PRIMARY'
      13.1.0-opt>
      

      Expected error

       

      Expected: `ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'`.
      {noformat]

      Attachments

        Issue Links

          Activity

            People

              drrtuy Roman
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 0.5h
                  0.5h

                  Git Integration

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