Ulrich Telle <[EMAIL PROTECTED]> wrote:
Sure, it would be nice if SQLITE_SCHEMA errors could be handled
internally by SQLite, but I think it's a non-trivial task to handle
this kind of error.

For INSERT, UPDATE or DELETE a simple retry might be a good choice.
But how often should the retry take place? The SQLite FAQ code
example contains an endless loop! I didn't want to introduce such
kind of code into wxSQLite3. - Additionally the number of columns in
a table used in these statements might have changed, that is the
statement would probably fail again.

Only if the schema change affects the table you are manipulating. Even if this is the case, the statement might indeed fail again - but with a _different_ error (probably a syntax error), at which point you drop out of the loop and handle this error as you normally would. The only way for you to stay in that "endless" loop for a long time is if some other thread keeps changing the schema on you, in which case your application has worse problems to worry about.

In case of a SELECT statement the situation is still more complex. The
SCHEMA error could happen after reading several result rows.

No it can't. A schema error can only occur between sqlite3_prepare or sqlite3_reset, and the first sqlite3_step.

When retrying a query another problem arises if the SQL statement
contains bind variables. You would have to rebind the variables. To
handle this automatically would induce a lot of extra house keeping,
wouldn't it?

SQLite maintains sufficient information already. See sqlite3_transfer_bindings - it is intended specifically to allow a wrapper to transparently recover from SQLITE_SCHEMA error.

Igor Tandetnik

Reply via email to