When there is a foreign key with more columns than the underlying table, the code generator fails to allocate enough registers in the virtual machine to handle all the columns in the foreign key. This came about because when we were writing the code for "PRAGMA foreign_key_check", it never occurred to us that anybody would construct a foreign key with more columns than the underlying table. The problem goes back to SQLite 3.8.1, 2013-10-17. Now fixed on trunk.