Bug #25899 Foreign key settings does not work properly
Submitted: 28 Jan 2007 15:03 Modified: 29 Jan 2007 13:34
Reporter: Yasin Hinislioglu Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S1 (Critical)
Version:5.1.14-beta OS:Windows (Windows XP SP2, Linux)
Assigned to: Assigned Account CPU Architecture:Any
Tags: ON DELETE ON UPDATE SET NULL FOREIGN KEY

[28 Jan 2007 15:03] Yasin Hinislioglu
Description:
I have created a foreign key. Setted ON DELETE and ON UPDATE settings to SET NULL. Everything works fine. I can insert and delete foreign key nicely. It is automatically sets the key null on child table. 

When I restarted the mysql server, I have observed that the settings of the foreign key is automatically setted to RESTRICT.

How to repeat:
Use following dump. Monitor foreign key settings on table named a. Restart the mysql server. Monitor foreign key on table a.

-- MySQL Administrator dump 1.4
--
-- ------------------------------------------------------
-- Server version	5.1.14-beta-community-nt

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;

--
-- Create schema deneme
--

CREATE DATABASE IF NOT EXISTS deneme;
USE deneme;

--
-- Definition of table `a`
--

DROP TABLE IF EXISTS `a`;
CREATE TABLE `a` (
  `ida` bigint(20) NOT NULL AUTO_INCREMENT,
  `idb` bigint(20) DEFAULT '0',
  PRIMARY KEY (`ida`),
  KEY `FK_ALIM_ISLEMID` (`idb`) USING BTREE,
  CONSTRAINT `FK_a_1` FOREIGN KEY (`idb`) REFERENCES `b` (`idb`) ON DELETE SET NULL ON UPDATE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='InnoDB free: 22528 kB; (`KullaniciID`) REFER `yhticari/kulla';

--
-- Dumping data for table `a`
--

/*!40000 ALTER TABLE `a` DISABLE KEYS */;
/*!40000 ALTER TABLE `a` ENABLE KEYS */;

--
-- Definition of table `b`
--

DROP TABLE IF EXISTS `b`;
CREATE TABLE `b` (
  `idb` bigint(20) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`idb`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;

--
-- Dumping data for table `b`
--

/*!40000 ALTER TABLE `b` DISABLE KEYS */;
/*!40000 ALTER TABLE `b` ENABLE KEYS */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
[28 Jan 2007 15:04] Yasin Hinislioglu
no comment
[29 Jan 2007 9:52] Sveta Smirnova
Thank you for the report.

Verified as described on Linux using last BK sources.

may be related to Bug #24741
[29 Jan 2007 12:44] Marko Mäkelä
Yes, this is most likely a duplicate of Bug #24741.
[29 Jan 2007 13:34] Heikki Tuuri
Thank you, this is a duplicate of:

http://bugs.mysql.com/bug.php?id=24741

Marko sent the fixed InnoDB version to MySQL AB about 2 - 3 weeks ago.