sqlite: Add fix for ticket #2922
sqlite: Add fix for ticket #2922

- sqlite3_step() automatically re-prepares an expired statement before
running it, returning SQLITE_SCHEMA if the original SQL is no longer valid
due to a schema change.  Through at least 3.5.5, it also returns
SQLITE_SCHEMA if any other error occurs during repreparation, including
a failure to acquire a lock to read database schema.  As a result, PK
would occasionally fail in hoard_sync_refs() with:

hoard_sync_refs(): Couldn't generate tag list (17, database is locked)

sqlite3_step() should be returning SQLITE_BUSY instead of SQLITE_SCHEMA in
this case.  The problem is not necessarily limited to hoard_sync_refs(): any
statement which needed repreparation for any reason could fail if the hoard
cache was EXCLUSIVE-locked at the time.  (Actions such as the creation of a
temp table expire all prepared statements.)

If necessary we could work around this problem in PK by checking
sqlite3_errcode() instead of the sqlite3_step() return code, since the
sqlite3_errcode() return is correct, but for now we'll fix it in SQLite
instead.

cmusatyalab/openisr,cmusatyalab/openisr,cmusatyalab/openisr,cmusatyalab/openisr,cmusatyalab/openisr