Doug Hanks wrote:
Can someone please explain to me, in laymen's terms, what
sqlite3_busy_timeout() is used for?

 This routine sets a busy handler that sleeps for a while when a
table is locked. The handler will sleep multiple times until at
least "ms" milliseconds of sleeping have been done. After "ms"
milliseconds of sleeping, the handler returns 0 which causes
sqlite3_exec() to return SQLITE_BUSY.

Perhaps an example with an explaination is in order?

Suppose you are trying to perform a select, but there's an update currently in progress. Without sqlite3_busy_timeout or explicit busy handler, your operation will fail immediately with SQLITE_BUSY. But if you set up sqlite3_busy_timeout, SQLite will automatically retry your operation several times before erroring out. Hopefully the writing transaction completes before the timeout has expired, and your select is allowed to proceed.

Igor Tandetnik

Reply via email to