Skip to content

Mysql: Incorrect / missing foreign key for innodb tables #1028

Description

@als2002

Steps to reproduce this issue

Create table:

CREATE TABLE contract_info_lv_tmp111 (
ID int(11) unsigned NOT NULL auto_increment,
Agent_id int(11) unsigned default NULL,
PRIMARY KEY (ID),
CONSTRAINT FK_contract_info_lv_agent_info_lv_zz
FOREIGN KEY (Agent_id) REFERENCES agent_info (ID) ON UPDATE CASCADE

) ENGINE=InnoDB AUTO_INCREMENT=25447 DEFAULT CHARSET=latin1

Current behavior

Foreign key tab is empty. There is 'FK_contract_info_lv_agent_info_lv_zz' KEY/BTREE index in 'Indexes' tab.

Tab 'Create code' shows:

CREATE TABLE contract_info_lv_tmp111 (
ID INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
Agent_id INT(11) UNSIGNED NULL DEFAULT NULL,
PRIMARY KEY (ID) USING BTREE,
INDEX FK_contract_info_lv_agent_info_lv_zz (Agent_id) USING BTREE
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
AUTO_INCREMENT=25447;

Executing SHOW CREATE TABLE contract_info_lv_tmp111; returns:

CREATE TABLE contract_info_lv_tmp111 (
ID int(11) unsigned NOT NULL auto_increment,
Agent_id int(11) unsigned default NULL,
PRIMARY KEY (ID),
KEY FK_contract_info_lv_agent_info_lv_zz (Agent_id),
CONSTRAINT FK_contract_info_lv_agent_info_lv_zz FOREIGN KEY (Agent_id) REFERENCES agent_info (ID) ON UPDATE CASCADE

) ENGINE=InnoDB AUTO_INCREMENT=25447 DEFAULT CHARSET=latin1

Expected behavior

Foreign keys should remain in 'foreign keys' tab...

Environment

  • HeidiSQL version:
    Revision 5978 (yours: 5978)
    Compiled: 2020-05-10 (yours: 2020-05-11)
  • Database system and version:
    mysql
    5.6.30-1 (debian) -- not affected.
    5.7.12-5 Percona server -- affected
    5.0.67 - redhat -- affected
  • Operating system:
    Win 10 pro 64 bit.

image
image
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixNothing planned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions