Re: SQL deferred constraints (a bit O/T, I know)
Date: Sat, 2 Apr 2011 08:21:18 -0700 (PDT)
Message-ID: <e42fc278-14ac-4b7b-a67f-24d92c62e51c_at_q36g2000yqn.googlegroups.com>
Constraint : "Table1 UNION Table2 have at most one row"
Table1 is empty and Table2 is empty.
Trans1 starts (meaning all its reads from both Table1/2 will return
zero rows) .
Trans2 starts (meaning all its reads from both Table1/2 will return
zero rows).
Trans1 inserts a row into Table1.
Trans2 inserts a row into Table2.
Trans1 commits, checking that no rows exist in both of Table1 and
Table2, which is "true" because the check is run under MVCC, with
Trans1 as a 'mere reader' on Table2.
Trans2 commits, checking that no rows exist in both of Table1 and
Table2, which is "true" because the check is run under MVCC, with
Trans2 as a 'mere reader' on Table1.
Both transactions succeed, leaving the database inconsistent.
This has been documented before. MVCC and database constraint checking do not fit together.
D&D have stated several times before that "Serializable" really is the only option if you want data(base) integrity to be _guaranteed_.
I suppose they might even be delighted to see this positions of theirs being confirmed by the SQL standard admitting as much !!!
I suppose you already know that MVCC does not guarantee the isolation level "Serializable" in all and every circumstance. Received on Sat Apr 02 2011 - 17:21:18 CEST