This is a stupid garden variety bug and I'm not sure why I didn't catch
it previously. The patch included is against fairly current sources, but
it may apply cleanly against 7.0.2 as well.
On Fri, 6 Oct 2000, Vilson farias wrote:
> I found a irregular behavior with constraints.
>
> I can only set a referencial integrity between these tables when there are
> no data, even if there are no change to referential integrity violation.
*** pgsql.old/src/backend/commands/command.c Tue Sep 12 14:06:47 2000
--- pgsql/src/backend/commands/command.c Tue Oct 10 12:15:13 2000
***************
*** 1388,1402 ****
{
Ident *fk_at = lfirst(list);
! trig.tgargs[count++] = fk_at->name;
}
foreach(list, fkconstraint->pk_attrs)
{
Ident *pk_at = lfirst(list);
! trig.tgargs[count++] = pk_at->name;
}
! trig.tgnargs = count;
scan = heap_beginscan(rel, false, SnapshotNow, 0, NULL);
AssertState(scan != NULL);
--- 1388,1405 ----
{
Ident *fk_at = lfirst(list);
! trig.tgargs[count] = fk_at->name;
! count+=2;
}
+ count = 5;
foreach(list, fkconstraint->pk_attrs)
{
Ident *pk_at = lfirst(list);
! trig.tgargs[count] = pk_at->name;
! count+=2;
}
! trig.tgnargs = count-1;
scan = heap_beginscan(rel, false, SnapshotNow, 0, NULL);
AssertState(scan != NULL);