From 9932b116fa2f5159542b4e460f3d5d49c210a62c Mon Sep 17 00:00:00 2001 From: cgp1024 Date: Tue, 29 Jul 2014 11:22:41 -0500 Subject: [PATCH 1/2] Update SQLiteStatementImpl.cpp --- Data/SQLite/src/SQLiteStatementImpl.cpp | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/Data/SQLite/src/SQLiteStatementImpl.cpp b/Data/SQLite/src/SQLiteStatementImpl.cpp index 840471231..e8d1275e2 100644 --- a/Data/SQLite/src/SQLiteStatementImpl.cpp +++ b/Data/SQLite/src/SQLiteStatementImpl.cpp @@ -217,28 +217,19 @@ bool SQLiteStatementImpl::hasNext() for (int i = 0; i <= _maxRetryAttempts; i++) { _nextResponse = sqlite3_step(_pStmt); - switch (_nextResponse) + // Notes: When we get SQLITE_BUSY, we do need to reset the statement + // to try again. + // When we get SQLITE_LOCKED, we must reset the statement before trying + // again. SQLITE_LOCKED is only returned for the first call to sqlite3_step, + // so resetting and retrying is safe. + if ( (_nextResponse & SQLITE_BUSY) || (_nextResponse & SQLITE_LOCKED) ) { - // Notes: When we get SQLITE_BUSY, we do not need to reset the statement - // to try again. - // When we get SQLITE_LOCKED, we must reset the statement before trying - // again. SQLITE_LOCKED is only returned for the first call to sqlite3_step, - // so resetting and retrying is safe. - case SQLITE_LOCKED: - case SQLITE_LOCKED_SHAREDCACHE: - sqlite3_reset(_pStmt); - // fallthrough - case SQLITE_BUSY: if (i < _maxRetryAttempts) { + sqlite3_reset(_pStmt); sleep(); - continue; } - break; - default: - break; } - break; } if (_nextResponse != SQLITE_ROW && _nextResponse != SQLITE_OK && _nextResponse != SQLITE_DONE) From 3c795b8c827e411f6f348055dfa36ab18c4d4b02 Mon Sep 17 00:00:00 2001 From: cgp1024 Date: Thu, 31 Jul 2014 21:21:53 -0500 Subject: [PATCH 2/2] Update SQLiteStatementImpl.cpp --- Data/SQLite/src/SQLiteStatementImpl.cpp | 26 ++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Data/SQLite/src/SQLiteStatementImpl.cpp b/Data/SQLite/src/SQLiteStatementImpl.cpp index e8d1275e2..2c5b8e5d0 100644 --- a/Data/SQLite/src/SQLiteStatementImpl.cpp +++ b/Data/SQLite/src/SQLiteStatementImpl.cpp @@ -217,19 +217,31 @@ bool SQLiteStatementImpl::hasNext() for (int i = 0; i <= _maxRetryAttempts; i++) { _nextResponse = sqlite3_step(_pStmt); - // Notes: When we get SQLITE_BUSY, we do need to reset the statement - // to try again. - // When we get SQLITE_LOCKED, we must reset the statement before trying - // again. SQLITE_LOCKED is only returned for the first call to sqlite3_step, - // so resetting and retrying is safe. - if ( (_nextResponse & SQLITE_BUSY) || (_nextResponse & SQLITE_LOCKED) ) + switch (_nextResponse) { + // When we get SQLITE_BUSY or SQLITE_LOCKED, we must reset the statement before trying + // again. SQLITE_LOCKED is only returned for the first call to sqlite3_step, + // so resetting and retrying is safe. + case SQLITE_LOCKED: + case SQLITE_LOCKED_SHAREDCACHE: + case SQLITE_BUSY: +#ifdef SQLITE_BUSY_RECOVERY + case SQLITE_BUSY_RECOVERY: +#endif +#ifdef SQLITE_BUSY_SNAPSHOT + case SQLITE_BUSY_SNAPSHOT: +#endif + sqlite3_reset(_pStmt); if (i < _maxRetryAttempts) { - sqlite3_reset(_pStmt); sleep(); + continue; } + break; + default: + break; } + } if (_nextResponse != SQLITE_ROW && _nextResponse != SQLITE_OK && _nextResponse != SQLITE_DONE)