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

Unified Diff: sql/connection.cc

Issue 8396013: AppCache INTERCEPT namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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
Index: sql/connection.cc
===================================================================
--- sql/connection.cc (revision 113546)
+++ sql/connection.cc (working copy)
@@ -268,14 +268,24 @@
}
bool Connection::DoesTableExist(const char* table_name) const {
+ return DoesTableOrIndexExist(table_name, "table");
+}
+
+bool Connection::DoesIndexExist(const char* index_name) const {
+ return DoesTableOrIndexExist(index_name, "index");
+}
+
+bool Connection::DoesTableOrIndexExist(
+ const char* name, const char* type) const {
// GetUniqueStatement can't be const since statements may modify the
// database, but we know ours doesn't modify it, so the cast is safe.
Statement statement(const_cast<Connection*>(this)->GetUniqueStatement(
"SELECT name FROM sqlite_master "
- "WHERE type='table' AND name=?"));
+ "WHERE type=? AND name=?"));
if (!statement)
return false;
- statement.BindString(0, table_name);
+ statement.BindString(0, type);
+ statement.BindString(1, name);
return statement.Step(); // Table exists if any row was returned.
}

Powered by Google App Engine
This is Rietveld 408576698