问题
This seems like it should be really easy to find out, but I don't see it documented anywhere. If I open a sqlite connection and begin a transaction without specifying a timeout by calling sqlite3_busy_timeout
, what default value is used? Or will this somehow cause undefined behavior? The documentation of this method doesn't say.
My specific use case is the version bundled with iOS, but I'm guessing the answer is pretty much the same across platforms.
回答1:
If neither sqlite3_busy_timeout()
nor sqlite3_busy_handler()
are set and a writer is active then step()
returns SQLITE_BUSY
immediately.
Note: In some cases SQLITE_IOERR_BLOCKED
is returned
See also: Register A Callback To Handle SQLITE_BUSY Errors in the second paragraph where it states
If the busy callback is
NULL
, thenSQLITE_BUSY
orSQLITE_IOERR_BLOCKED
is returned immediately upon encountering the lock. If the busy callback is notNULL
, then the callback might be invoked with two arguments.
来源:https://stackoverflow.com/questions/25319031/what-is-the-default-value-of-sqlite3-busy-timeout