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

[HY000][1553] Changing name of primary key column with foreign key constraint fails.

    XMLWordPrintable

    Details

      Description

      Changing the name of a primary key column with a foreign key constraint fails with the following error since 10.4.13:

      [HY000][1553] (conn=17) Cannot drop index 'PRIMARY': needed in a foreign key constraint

      create schema test collate utf8_unicode_ci;
      create table test.input_type
      (
          input_type_id int(11) unsigned auto_increment
              primary key
      );
       
      create table test.input
      (
          input_id int unsigned auto_increment
              primary key,
          input_type_id int unsigned not null,
          constraint ibfk
              foreign key (input_type_id) references test.input_type (input_type_id)
      );
       
      create index type_id
          on test.input (input_type_id);
       
      alter table test.input_type change input_type_id id int(11) unsigned auto_increment;
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bar Alexander Barkov
              Reporter:
              mac89 Maarten Manders
              Votes:
              6 Vote for this issue
              Watchers:
              13 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: