Thread: deferred constraints don't work correctly

deferred constraints don't work correctly

From
pgsql-bugs@postgresql.org
Date:
Robert Bihlmeyer (robbe@orcus.priv.at) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
deferred constraints don't work correctly

Long Description
Using the example code, I get "ERROR:  <unnamed> referential integrity violation - key in foo still referenced from
bar".It should be ok to delete and reinsert referenced keys with deferred contraints -- that's one of their points,
ain'tit? 

Sample Code
create table foo(
  key int primary key,
  val varchar
);

create table bar(
  foo int references foo(key) deferrable initially deferred,
  attr varchar
);

insert into foo(key, val)  values (1, 'one');
insert into foo(key, val)  values (2, 'two');
insert into bar(foo, attr) values (1, 'low');
insert into bar(foo, attr) values (1, 'small');
insert into bar(foo, attr) values (2, 'higher');
insert into bar(foo, attr) values (2, 'bigger');

begin work;
  delete from foo where key = 1;
  insert into foo(key, val) values (1, 'uno');
commit;


No file was uploaded with this report