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

Unified Diff: sql/recovery.cc

Issue 1665913003: [sql] Use IGNORE conflict resolution in recovery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@zzsql_recover_autorecover_review
Patch Set: Created 4 years, 11 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
Index: sql/recovery.cc
diff --git a/sql/recovery.cc b/sql/recovery.cc
index 5c4223c024cb650957dc1674762db7494ecb0f68..09e0c37b8fb643c379d46b670e5277bfeef1c8e7 100644
--- a/sql/recovery.cc
+++ b/sql/recovery.cc
@@ -375,7 +375,6 @@ bool Recovery::AutoRecoverTable(const char* table_name,
while (s.Step()) {
const std::string column_name(s.ColumnString(1));
const std::string column_type(s.ColumnString(2));
- const bool not_null = s.ColumnBool(3);
const int default_type = s.ColumnType(4);
const bool default_is_null = (default_type == COLUMN_TYPE_NULL);
const int pk_column = s.ColumnInt(5);
@@ -422,16 +421,6 @@ bool Recovery::AutoRecoverTable(const char* table_name,
return false;
}
- // If column has constraint "NOT NULL", then inserting NULL into
- // that column will fail. If the column has a non-NULL DEFAULT
- // specified, the INSERT will handle it (see below). If the
- // DEFAULT is also NULL, the row must be filtered out.
- // TODO(shess): The above scenario applies to INSERT OR REPLACE,
- // whereas INSERT OR IGNORE drops such rows.
- // http://www.sqlite.org/lang_conflict.html
Ryan Hamilton 2016/02/04 01:38:17 Looks like you planned ahead! Nice comment.
- if (not_null && default_is_null)
- column_decl += " NOT NULL";
-
create_column_decls.push_back(column_decl);
// Per the NOTE in the header file, convert NULL values to the
@@ -464,8 +453,10 @@ bool Recovery::AutoRecoverTable(const char* table_name,
table_name,
base::JoinString(create_column_decls, ",").c_str()));
+ // INSERT OR IGNORE means that it will drop rows resulting from constraint
+ // violations. INSERT OR REPLACE only handles UNIQUE constraint violations.
std::string recover_insert(base::StringPrintf(
- "INSERT OR REPLACE INTO main.%s SELECT %s FROM temp.recover_%s",
+ "INSERT OR IGNORE INTO main.%s SELECT %s FROM temp.recover_%s",
table_name,
base::JoinString(insert_columns, ",").c_str(),
table_name));
« no previous file with comments | « sql/recovery.h ('k') | sql/recovery_unittest.cc » ('j') | sql/recovery_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698