Subject Re: [firebird-support] Foreign key problem
Author Vlad Horsun
> When one transaction locks (updates) row in Master table,
> then other transactions
> - can Update related rows in Detail table, but

Only if they not changed FK fields, right ?

> - can't Insert new Detail rows (referencing pk of locked row)
> Why ?
>
>
> The error message is also peculiar:
> Statement failed, SQLCODE = -901
> lock conflict on no wait transaction
> -violation of FOREIGN KEY constraint "INTEG_3" on table "DETAIL"
> -Foreign key reference target does not exist
>
> The master row existed(was committed) before these transactions
> started, so the row/pk is normally visible.

Engine can't perform reliable check of old and new values of
PK fields in Master table. Master transaction can change master row
many times in several different savepoints so check for old values in
on-disk backversion is not enough, especially if master and detail
transactions runs in different processes of classic server. So engine
not allow to create new details referenced to active master to preserve
referential integrity

Regards,
Vlad