Backout of Bug 384526 (causes orange)

This commit is contained in:
sdwilsh%shawnwilsher.com 2007-07-10 17:23:36 +00:00
Родитель ac67c4384f
Коммит db42d23135
2 изменённых файлов: 67 добавлений и 37 удалений

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

@ -140,7 +140,7 @@ mozStorageConnection::Initialize(nsIFile *aDatabaseFile)
*/
sqlite3_stmt *stmt = nsnull;
nsCString query("SELECT * FROM sqlite_master");
srv = sqlite3_prepare_v2(mDBConn, query.get(), query.Length(), &stmt, NULL);
srv = sqlite3_prepare (mDBConn, query.get(), query.Length(), &stmt, nsnull);
if (srv == SQLITE_OK) {
srv = sqlite3_step(stmt);
@ -304,8 +304,7 @@ mozStorageConnection::TableExists(const nsACString& aSQLStatement, PRBool *_retv
query.AppendLiteral("'");
sqlite3_stmt *stmt = nsnull;
int srv = sqlite3_prepare_v2(mDBConn, query.get(), query.Length(), &stmt,
NULL);
int srv = sqlite3_prepare (mDBConn, query.get(), query.Length(), &stmt, nsnull);
if (srv != SQLITE_OK) {
HandleSqliteError(query.get());
return ConvertResultCode(srv);
@ -321,9 +320,9 @@ mozStorageConnection::TableExists(const nsACString& aSQLStatement, PRBool *_retv
exists = PR_TRUE;
} else if (srv == SQLITE_DONE) {
exists = PR_FALSE;
} else {
} else if (srv == SQLITE_ERROR) {
HandleSqliteError("TableExists finalize");
return ConvertResultCode(srv);
return NS_ERROR_FAILURE;
}
*_retval = exists;
@ -340,8 +339,7 @@ mozStorageConnection::IndexExists(const nsACString& aIndexName, PRBool* _retval)
query.AppendLiteral("'");
sqlite3_stmt *stmt = nsnull;
int srv = sqlite3_prepare_v2(mDBConn, query.get(), query.Length(), &stmt,
NULL);
int srv = sqlite3_prepare(mDBConn, query.get(), query.Length(), &stmt, nsnull);
if (srv != SQLITE_OK) {
HandleSqliteError(query.get());
return ConvertResultCode(srv);
@ -350,10 +348,14 @@ mozStorageConnection::IndexExists(const nsACString& aIndexName, PRBool* _retval)
*_retval = PR_FALSE;
srv = sqlite3_step(stmt);
(void)sqlite3_finalize(stmt);
// we just care about the return value from step
sqlite3_finalize(stmt);
if (srv == SQLITE_ROW) {
*_retval = PR_TRUE;
} else if (srv == SQLITE_ERROR) {
HandleSqliteError("IndexExists finalize");
return NS_ERROR_FAILURE;
}
return ConvertResultCode(srv);

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

@ -117,8 +117,7 @@ mozStorageStatement::Initialize(mozIStorageConnection *aDBConnection, const nsAC
int nRetries = 0;
while (nRetries < 2) {
srv = sqlite3_prepare_v2(db, nsPromiseFlatCString(aSQLStatement).get(),
aSQLStatement.Length(), &mDBStatement, NULL);
srv = sqlite3_prepare (db, nsPromiseFlatCString(aSQLStatement).get(), aSQLStatement.Length(), &mDBStatement, NULL);
if ((srv == SQLITE_SCHEMA && nRetries != 0) ||
(srv != SQLITE_SCHEMA && srv != SQLITE_OK))
{
@ -413,6 +412,9 @@ mozStorageStatement::ExecuteStep(PRBool *_retval)
}
}
int nRetries = 0;
while (nRetries < 2) {
int srv = sqlite3_step (mDBStatement);
#ifdef PR_LOGGING
@ -435,17 +437,43 @@ mozStorageStatement::ExecuteStep(PRBool *_retval)
mExecuting = PR_FALSE;
*_retval = PR_FALSE;
return NS_OK;
} else if (srv == SQLITE_BUSY || srv == SQLITE_MISUSE) {
} else if (srv == SQLITE_BUSY ||
srv == SQLITE_MISUSE)
{
mExecuting = PR_FALSE;
return NS_ERROR_FAILURE;
} else if (mExecuting == PR_TRUE) {
#ifdef PR_LOGGING
PR_LOG(gStorageLog, PR_LOG_ERROR, ("SQLite error after mExecuting was true!"));
#endif
} else if (srv == SQLITE_SCHEMA) {
// step should never return SQLITE_SCHEMA
NS_NOTREACHED("sqlite3_step returned SQLITE_SCHEMA!");
return NS_ERROR_FAILURE;
} else if (srv == SQLITE_ERROR) {
// so we may end up with a SQLITE_ERROR/SQLITE_SCHEMA only after
// we reset, because SQLite's error reporting story
// sucks.
if (mExecuting == PR_TRUE) {
PR_LOG(gStorageLog, PR_LOG_ERROR, ("SQLITE_ERROR after mExecuting was true!"));
mExecuting = PR_FALSE;
return NS_ERROR_FAILURE;
}
return ConvertResultCode(srv);
srv = sqlite3_reset(mDBStatement);
if (srv == SQLITE_SCHEMA) {
rv = Recreate();
NS_ENSURE_SUCCESS(rv, rv);
nRetries++;
} else {
return NS_ERROR_FAILURE;
}
} else {
// something that shouldn't happen happened
NS_ERROR ("sqlite3_step returned an error code we don't know about!");
}
}
// shouldn't get here
return NS_ERROR_FAILURE;
}
/* [noscript,notxpcom] sqlite3stmtptr getNativeStatementPointer(); */