This commit is contained in:
vladimir%pobox.com 2005-03-24 22:58:30 +00:00
Родитель a64a9d93c1
Коммит 01373a8353
1 изменённых файлов: 34 добавлений и 12 удалений

Просмотреть файл

@ -104,7 +104,9 @@ mozStorageStatement::Initialize(mozIStorageConnection *aDBConnection, const nsAC
while (nRetries < 2) {
srv = sqlite3_prepare (db, nsPromiseFlatCString(aSQLStatement).get(), aSQLStatement.Length(), &mDBStatement, NULL);
if (srv != SQLITE_OK || (srv == SQLITE_SCHEMA && nRetries > 0)) {
if ((srv == SQLITE_SCHEMA && nRetries != 0) ||
(srv != SQLITE_SCHEMA && srv != SQLITE_OK))
{
#ifdef PR_LOGGING
PR_LOG(gStorageLog, PR_LOG_ERROR, ("Sqlite statement prepare error: %d '%s'", srv, sqlite3_errmsg(db)));
PR_LOG(gStorageLog, PR_LOG_ERROR, ("Statement was: '%s'", nsPromiseFlatCString(aSQLStatement).get()));
@ -112,6 +114,9 @@ mozStorageStatement::Initialize(mozIStorageConnection *aDBConnection, const nsAC
return NS_ERROR_FAILURE;
}
if (srv == SQLITE_OK)
break;
nRetries++;
}
@ -374,14 +379,17 @@ mozStorageStatement::Execute()
#endif
mExecuting = PR_FALSE;
return NS_ERROR_FAILURE; // XXX error code
}
if (srv != SQLITE_SCHEMA)
break;
} else if (srv == SQLITE_SCHEMA) {
nRetries++;
sqlite3_reset (mDBStatement);
} else {
break;
}
}
if (nRetries >= 2)
return NS_ERROR_FAILURE;
else
return Reset();
}
@ -406,7 +414,11 @@ mozStorageStatement::ExecuteStep(PRBool *_retval)
int srv = sqlite3_step (mDBStatement);
#ifdef PR_LOGGING
if ((srv != SQLITE_ROW && srv != SQLITE_DONE) || (srv == SQLITE_SCHEMA && nRetries > 0)) {
if ((srv == SQLITE_SCHEMA && nRetries != 0) ||
(srv != SQLITE_SCHEMA &&
srv != SQLITE_ROW &&
srv != SQLITE_DONE))
{
nsCAutoString errStr;
mDBConnection->GetLastErrorString(errStr);
PR_LOG(gStorageLog, PR_LOG_DEBUG, ("mozStorageStatement::ExecuteStep error: %s", errStr.get()));
@ -430,12 +442,22 @@ mozStorageStatement::ExecuteStep(PRBool *_retval)
{
mExecuting = PR_FALSE;
return NS_ERROR_FAILURE;
} else if (srv == SQLITE_SCHEMA) {
// if we're already mid-execute, we can't do much
// to fix SQLITE_SCHEMA errors, so we just pass them
// back.
if (mExecuting == PR_TRUE) {
mExecuting = PR_FALSE;
return NS_ERROR_FAILURE;
}
// otherwise, we reset the statement and try again
sqlite3_reset (mDBStatement);
nRetries++;
} else if (srv != SQLITE_SCHEMA) {
// something that shouldn't happen happened
NS_ERROR ("sqlite3_step returned an error code we don't know about!");
}
nRetries++;
}
// shouldn't get here