Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: sql/connection.cc

Issue 1069313004: [sql] Change DoesStuffExist() to work with ScopedErrorIgnorer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sql/connection.h ('k') | sql/connection_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/connection.cc
diff --git a/sql/connection.cc b/sql/connection.cc
index cc7e69dba741f0fdae3e23713c0a2104a6d6ad21..bfe8bb7447f23bf24d9d4266ee73f3670c0d53db 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -725,7 +725,8 @@ scoped_refptr<Connection::StatementRef> Connection::GetUniqueStatement(
int rc = sqlite3_prepare_v2(db_, sql, -1, &stmt, NULL);
if (rc != SQLITE_OK) {
// This is evidence of a syntax error in the incoming SQL.
maniscalco 2015/04/08 22:40:27 I'm thinking about this comment and the one in Get
Scott Hess - ex-Googler 2015/04/08 22:49:20 Maybe, it depends. Corruption can cause almost an
maniscalco 2015/04/09 15:11:08 That makes sense to me.
- DLOG(FATAL) << "SQL compile error " << GetErrorMessage();
+ DLOG_IF(FATAL, !ShouldIgnoreSqliteError(rc))
maniscalco 2015/04/09 20:40:52 I just realized that ShouldIgnoreSqliteError is no
Scott Hess - ex-Googler 2015/04/09 20:46:30 At this site, OnSqliteError() should call ShouldIg
+ << "SQL compile error " << GetErrorMessage();
// It could also be database corruption.
OnSqliteError(rc, NULL, sql);
@@ -744,7 +745,8 @@ scoped_refptr<Connection::StatementRef> Connection::GetUntrackedStatement(
int rc = sqlite3_prepare_v2(db_, sql, -1, &stmt, NULL);
if (rc != SQLITE_OK) {
// This is evidence of a syntax error in the incoming SQL.
- DLOG(FATAL) << "SQL compile error " << GetErrorMessage();
+ DLOG_IF(FATAL, !ShouldIgnoreSqliteError(rc))
+ << "SQL compile error " << GetErrorMessage();
return new StatementRef(NULL, NULL, false);
}
return new StatementRef(NULL, stmt, true);
@@ -798,8 +800,15 @@ bool Connection::DoesIndexExist(const char* index_name) const {
bool Connection::DoesTableOrIndexExist(
const char* name, const char* type) const {
- const char* kSql = "SELECT name FROM sqlite_master WHERE type=? AND name=?";
+ const char* kSql =
+ "SELECT name FROM sqlite_master WHERE type=? AND name=? COLLATE NOCASE";
Statement statement(GetUntrackedStatement(kSql));
+
+ // This can happen if the database is corrupt and the error is being ignored
+ // for testing purposes.
+ if (!statement.is_valid())
+ return false;
+
statement.BindString(0, type);
statement.BindString(1, name);
@@ -813,8 +822,14 @@ bool Connection::DoesColumnExist(const char* table_name,
sql.append(")");
Statement statement(GetUntrackedStatement(sql.c_str()));
+
+ // This can happen if the database is corrupt and the error is being ignored
+ // for testing purposes.
+ if (!statement.is_valid())
+ return false;
+
while (statement.Step()) {
- if (!statement.ColumnString(1).compare(column_name))
+ if (!base::strcasecmp(statement.ColumnString(1).c_str(), column_name))
return true;
}
return false;
« no previous file with comments | « sql/connection.h ('k') | sql/connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698