FoundationDB/sql-layer — pull request #1225 by MMcM (2014-03-11 00:50:32+00:00)
Title: Deferrable foreign key support

* New fields in the AIS object and associated plumbing.
* SET CONTRAINTS command maintains a set of overrides through the transaction service.
* Associated errors for that command.
* Persistit implementation maintains a queue of failures to recheck on statement end (in the case of non-deferred NO ACTION) or commit (in actual DEFERRED cases).
* Re-enables self-reference tests, which now work due to statement-time recheck, even without the FK being deferrable.

Note that this statement deferral happens most of the time, even though the situations where it it possible are rare. I was not able to convince myself that there was a simple check to determine whether a given operation + FK is vulnerable. Self-referencing tables are, but I think longer combinations of ON DELETE CASCADE and multiple FKs are, too. I would be happy to be convinced otherwise.