Jay Sprenkle <[EMAIL PROTECTED]> wrote:
It was prepared after the schema was changed and written to disk.
That seems pretty unintuitive to me. When you prepare the statement
it evidently doesn't use the current schema, though it knows the
schema has changed...

When a new connection is opened, SQLite reads and caches the schema. Prepare operation uses this cached schema, without reading from disk. This is why prepare doesn't know that schema has changed.

It would be pretty pointless to have prepare check for schema changes. This would incur a disk read, and the schema can very well change again between prepare and step so this read won't achieve anything. Now, the first step operation has to perform a disk I/O anyway, in order to acquire a lock. This is when the schema is checked and, if a change is detected, the current schema is retrieved and cached for the connection.

Igor Tandetnik

Reply via email to