SQLite Forum

It doesn't call xCommit if xBegin is not defined
Login

It doesn't call xCommit if xBegin is not defined

(1) By anonymous on 2020-09-22 02:20:58 [link] [source]

It doesn't call the xCommit method of a virtual table if the xBegin method has not been specified. This should probably be either documented or corrected.

(2) By Gunter Hick (gunter_hick) on 2020-09-22 05:45:28 in reply to 1 [link] [source]

Why would you expect a transaction to be closed if there is no way to open one?

See https://sqlite.org/vtab.html#the_xbegin_method and the immediately following descriptions of xSync, xCommit and xRollback. They all state that they are only called after a call to xBegin, which is impossible if your virtual table implementation does not provide one.

(3) By anonymous on 2020-09-22 19:32:55 in reply to 2 [source]

It isn't very clear, though. (Anyways, xSync is not required, even though for xCommit it says "A call to this method always follows a prior call to xBegin and xSync.")

There are reasons why you might not care about the beginning of a transaction but you do care once it is completed. I suppose it is OK to require xBegin too even if it doesn't do anything, although it should be made more clearly in the documentation that it is the case, I think.