mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-poco.git
synced 2025-11-01 19:17:59 +00:00
Merge pull request #509 from cgp1024/poco-1.4.6
Fix for sqlite dropping data intermittantly, and add handling for SQLITE_BUSY errors introduced in later sqlite revisions.
This commit is contained in:
@@ -217,18 +217,21 @@ bool SQLiteStatementImpl::hasNext()
|
||||
for (int i = 0; i <= _maxRetryAttempts; i++)
|
||||
{
|
||||
_nextResponse = sqlite3_step(_pStmt);
|
||||
switch (_nextResponse)
|
||||
switch (_nextResponse)
|
||||
{
|
||||
// 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
|
||||
// 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:
|
||||
sqlite3_reset(_pStmt);
|
||||
// fallthrough
|
||||
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)
|
||||
{
|
||||
sleep();
|
||||
@@ -238,7 +241,7 @@ bool SQLiteStatementImpl::hasNext()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (_nextResponse != SQLITE_ROW && _nextResponse != SQLITE_OK && _nextResponse != SQLITE_DONE)
|
||||
|
||||
Reference in New Issue
Block a user