sql: Introduce Database::ExecuteScript().
Bug: 1230443
Change-Id: I307878c6db31b155a033222e54628e4b8241c18e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3043443
Reviewed-by: Marijn Kruisselbrink <[email protected]>
Commit-Queue: Victor Costan <[email protected]>
Cr-Commit-Position: refs/heads/master@{#904203}
diff --git a/sql/database.h b/sql/database.h
index 92ec6cf..f17a7ba 100644
--- a/sql/database.h
+++ b/sql/database.h
@@ -398,15 +398,23 @@
// Executes a SQL statement. Returns true for success, and false for failure.
//
// `sql` should be a single SQL statement. Production code should not execute
- // multiple SQL statements at once, to facilitate crash debugging.
- //
- // TODO(crbug.com/1230443): Migrate testing code that executes multiple SQL
- // statements to a separate method.
+ // multiple SQL statements at once, to facilitate crash debugging. Test code
+ // should use ExecuteScriptForTesting().
//
// `sql` cannot have parameters. Statements with parameters can be handled by
// sql::Statement. See GetCachedStatement() and GetUniqueStatement().
bool Execute(const char* sql) WARN_UNUSED_RESULT;
+ // Executes a sequence of SQL statements.
+ //
+ // Returns true if all statements execute successfully. If a statement fails,
+ // stops and returns false. Calls should be wrapped in ASSERT_TRUE().
+ //
+ // The database's error handler is not invoked when errors occur. This method
+ // is a convenience for setting up a complex on-disk database state, such as
+ // an old schema version with test contents.
+ bool ExecuteScriptForTesting(const char* sql_script) WARN_UNUSED_RESULT;
+
// Returns a statement for the given SQL using the statement cache. It can
// take a nontrivial amount of work to parse and compile a statement, so
// keeping commonly-used ones around for future use is important for