sql - H2 Referential integrity constraint violation on update -
i use h2 integration tests , have strange behavior can't explain. here steps recreate :
drop table if exists a; drop table if exists b; create table a(id int primary key, column1 varchar(255)); create table b(id int primary key, a_id int, column1 varchar(255)); alter table b add foreign key (a_id) references a(id); insert values(1,'foo'); insert b values(1,1,'foo'); create index idx1 on a(id,column1); alter table add column column2 varchar(255); update set column1='bar';
this last update generates following error : referential integrity constraint violation: "constraint_42_1: public.b foreign key(a_id) references public.a(id) (1)"; i've tried sames steps hsqldb success (no referential integrity constraint violation). workaround found make work h2 drop index before adding column , recreate same index again.
is there reason why h2 complain violation, don't see, i'm not updating id column ?
this bug in database engine. problem is, wrong index used (idx1 in case), , database thinks row removed when in fact updated.
this fixed in trunk, in revision 5462. fixed in next version of h2.
Comments
Post a Comment