=== collectiondb.cpp ================================================================== --- collectiondb.cpp (revision 464) +++ collectiondb.cpp (local) @@ -5719,13 +5719,15 @@ { QStringList values; - int error; + int error, rc; const char* tail; sqlite3_stmt* stmt; int busyCnt = 0; + int retryCnt = 0; - //compile SQL program to virtual machine, reattempting if busy do { + //compile SQL program to virtual machine, reattempting if busy + do { if ( busyCnt ) { ::usleep( 100000 ); // Sleep 100 msec @@ -5775,16 +5777,31 @@ } } //deallocate vm resources - sqlite3_finalize( stmt ); + rc = sqlite3_finalize( stmt ); - if ( error != SQLITE_DONE ) + if ( error != SQLITE_DONE && rc != SQLITE_SCHEMA ) { Debug::error() << k_funcinfo << "sqlite_step error.\n"; Debug::error() << sqlite3_errmsg( m_db ) << endl; Debug::error() << "on query: " << statement << endl; values = QStringList(); } + if ( rc == SQLITE_SCHEMA ) + { + retryCnt++; + debug() << "SQLITE_SCHEMA error occured on query: " << statement << endl; + if ( retryCnt < 10 ) + debug() << "Retrying now." << endl; + else + { + Debug::error() << "Retry-Count has reached maximum. Aborting this SQL statement!" << endl; + Debug::error() << "SQL statement: " << statement << endl; + values = QStringList(); + } + } } + } + while ( rc == SQLITE_SCHEMA && retryCnt < 10 ); return values; }