On 12 September 2015 at 20:59, David Kazlauskas <david at templatious.org> wrote:
> Hi, I see something in the second backup example ( > http://www.sqlite.org/backup.html ) that seems like logical error to me. > > if( rc==SQLITE_OK || rc==SQLITE_BUSY || rc==SQLITE_LOCKED ){ > sqlite3_sleep <http://www.sqlite.org/c3ref/sleep.html>(250); > } > > > Why should we sleep 250 milliseconds if sqlite result is OK? Shouldn't we > wait only if database is busy or locked? > That's intentional - the point of the second example is to demonstrate how to backup a database without starving starving other processes that might want to update it. Without the sleep the backup process would re-enter sqlite3_backup_step and re-obtain a lock on the DB almost immediately. -Rowan