Subject Re: [firebird-support] Re: Possible bug with CHECK constraint
Author Ann W. Harrison
>I wrote:
>
> > Firebird evaluates constraints before the action, not after.

At 01:38 PM 10/3/2004, Roman Rokytskyy wrote:

>Again, please. Do you say that Firebird checks the constraint before
>the INSERT

Yes. Typically, a Firebird constraint checks the new value using
the new context variable against some condition. If the new value
fails the test, then it is not stored. The "Firebird" way to state
your constraint is "new.value < 20".

Check constraints are implemented as special triggers (not necessarily
the best idea, but hey, it's an idea), and executed immediately before
the operation.

>when the table is perfectly consistent, then it allows
>INSERT without checking the values, etc. making the database
>inconsistent (e.g. any update or insert that does not fix the problem
>will fail even when data are perfectly correct)?

Firebird constraints are designed to validate the current update,
not to describe the whole state of the database. That's non-standard
and something we will have to address when we begin supporting
deferred constraints. However, any change will (I suspect) affect
currently working applications, so care is required.

Regards,


Ann