On 20 Sep 2015, at 2:55pm, gwenn <gwenn.kahz at gmail.com> wrote: > But if a column is added to one table in your database, your statement > is successfully/transparently recompiled (when calling sqlite3_step) > and the column count may be changed.
Let's assume that you have not used any PRAGMAs to defeat the concurrency and locking operations of SQLite, to share the cache, or anything else which is obviously unsafe in a multi-access scenario. If this is so then you do not have to worry about this problem. Depending on your settings one of two things will happen. A) Use of ALTER TABLE ... ADD COLUMN requires locking the database. This will not be permitted because the database will already be locked, from the first execution of sqlite3_step() until sqlite3_step() returns SQLITE_DONE or an error message. B) The connection executing sqlite3_step() reads from the database. The connection executing ALTER TABLE ... ADD COLUMN creates a modification of the database which the first connection can't see. It won't be able to see that change until it has released its lock on the database. Which of these happens depends at least on the journal mode of the database, and perhaps on other things I can't think of right now. But it will always be one or the other. Simon.