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

Improve error messaging when there is duplicate key or foreign key names

    Details

    • Sprint:
      5.5.45

      Description

      CREATE TABLE t111 (
        id int(11) NOT NULL PRIMARY KEY,
        a int(11) NOT NULL,
        b int(11) NOT NULL,
        c int not null,
        CONSTRAINT test FOREIGN KEY (b) REFERENCES t111 (id)
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
       
      CREATE TABLE t112 (
        id int(11) NOT NULL PRIMARY KEY,
        a int(11) NOT NULL,
        b int(11) NOT NULL,
        c int not null,
        CONSTRAINT test FOREIGN KEY (b) REFERENCES t61 (id)
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
      ERROR 1005 (HY000): Can't create table `test`.`t112` (errno: 121 "Duplicate key on write or update")
      MariaDB [test]> show warnings;
      +---------+------+----------------------------------------------------------------------------------+
      | Level   | Code | Message                                                                          |
      +---------+------+----------------------------------------------------------------------------------+
      | Error   | 1005 | Can't create table `test`.`t112` (errno: 121 "Duplicate key on write or update") |
      | Warning | 1022 | Can't write; duplicate key in table 't112'                                       |
      +---------+------+----------------------------------------------------------------------------------+
      2 rows in set (0.00 sec)

      This error message is not very helpful, it should contain what is the duplicate key name and why.

        Attachments

          Activity

            People

            • Assignee:
              jplindst Jan Lindström
              Reporter:
              jplindst Jan Lindström
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: