Hi,
I try to use Sqlite3_progress_handler in my program and everything seems
work fine, except for some unexplained things related to rollback and
Sqlite3_get_autocommit function.

I assume that everything that is related to sqlite3_interrupt can be applied
to interrupting from Sqlite3_progress_handler, right?

First, I saw the behavior that officially explained in the docs. It's about
automatic rollback that occurs when SQLITE_INTERRUPT was returned by the
step function as a result from sqlite3_interrupt or
Sqlite3_progress_handler. The docs says that I either can do rollback with
an error (in my case it was "Sqlite logic or missing database") and it's ok
or rely on the result of sqlite3_get_autocommit function. As long as I
understand If my code invoked 'begin transaction' and this functions returns
non-zero (indicating auto commit is back) then an automatic rollback was
invoked by sqlite itself before and there's no need to do it manually.

The problem is that (tested with 3.6.10 and 3.7.2) if :
- I interrupt a query from Sqlite3_progress_handler
- I didn't invoke this error-processing rollback,

...sqlite after that does the following:
- sqlite3_get_autocommit starts to return 0 (not in auto-commit mode) now
and forever. (But the journal file after interrupted query is not longer
present, so automatic rollback was actually fired by sqlite)
- my 'begin transaction' queries executes successfully, but every following
query that was noticeably fast with normal logic, now slows down like
there's no transaction at all.


So, there are several options:
- it Is a bug somewhere and sqlite just didn't return some variable so after
some fix we still can rely on no-op of rolling back interrupted queries.
- rollback is necessary (even if the query was interrupted). In this case I
see two things: documentation that possible should address this and second
the error that sqlite makes when rollback applied to an interrupted query.
If rollback is necessary, I think there should be no error or maybe some
special error (not so widely spread "Sqlite logic or missing...") in order
to detect this special case in my code

Thanks,

Max Vlasov
maxerist.net
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to