On Fri, Jan 21, 2011 at 1:38 PM, Steve Campbell <scampb...@rim.com> wrote:
> > To summarize, we can prevent foreign keys from being properly enforced if > we declare the constraints to be deferred and we leave lingering statement > handles open. > > Is this a bug? > > We cannot check FK constraints until all statement handles that might potentially change those constraints have finished running. Otherwise, the FK checks might get the wrong answer because they are not taking into account changes that haven't yet been made. I think you are surprised here because of confusion about when a statement "has finished running". Sometimes a statement "finishes running" (for the purpose of FK constraint enforcement) on the final sqlite3_step() call that returns SQLITE_DONE. Other times, it finishes when sqlite3_finalize() or sqlite3_reset() is called. SQLite makes no guarantees about when the statement will finish other than that it will be finished by the time sqlite3_finalize() or sqlite3_reset() returns. It might finish before then, or it might not. Perhaps it would be less surprising to developers if a statement always finished on the sqlite3_step() call that returned SQLITE_DONE. That is a reasonable request and we will look into enhancing SQLite to do that. For version 3.7.6. The thing is, changing this involves making subtle changes to the core that carry a high risk of breaking other things. So we are not willing to undertake such a change so late in the release cycle. If you are diligent to always finalize or reset your statements when you finish with them, you should not have any trouble. Meanwhile, we will work to make SQLite robust and consistent in the face of less pedantic programs in the future. I consider this an enhancement request, not a bug. -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users