List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:February 21 2003 10:31pm
Subject:Re: create fails with on delete set null
View as plain text  
At 22:07 +0000 2/21/03, Ross Davis wrote:
>Simply said this works:
>drop table if exists detail;
>create table detail
>(
>detail_id int not null auto_increment
>,  master_id int not null
>,  name varchar(50) not null
>,  primary key (detail_id)
>,  index master_idx(master_id)
>,  foreign key (master_id) references master (master_id) on delete 
>cascade on update cascade
>)
>type=InnoDB;
>This doesn't:
>drop table if exists detail;
>create table detail
>(
>detail_id int not null auto_increment
>,  master_id int not null
>,  name varchar(50) not null
>,  primary key (detail_id)
>,  index master_idx(master_id)
>,  foreign key (master_id) references master (master_id) on delete 
>set null on update cascade
>)
>type=InnoDB;
>mysql 4.0.10 on Windows XP Pro
>Anyone else have this problem?  Is it a bug?

It's a bug on your part. :-)

You've defined master_id as NOT NULL.  How to you expect it to be
set to NULL when you delete a parent table record?

>Ross

Thread
create fails with on delete set nullRoss Davis21 Feb
  • Re: create fails with on delete set nullPaul DuBois21 Feb
Re: create fails with on delete set nullHeikki Tuuri21 Feb