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

Unified Diff: sql/connection.h

Issue 19281002: [sql] Scoped recovery framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to match Open() retry logic. Created 7 years, 5 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 | « no previous file | sql/connection.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/connection.h
diff --git a/sql/connection.h b/sql/connection.h
index 1c4d72cfffe31dc0c1c60d1f10b90f5492e8bfe0..171cc07c041e9e65f46c25f073aad869e5d3fa22 100644
--- a/sql/connection.h
+++ b/sql/connection.h
@@ -28,6 +28,7 @@ class FilePath;
namespace sql {
+class Recovery;
class Statement;
// Uniquely identifies a statement. There are two modes of operation:
@@ -160,6 +161,12 @@ class SQL_EXPORT Connection {
// empty. You can call this or Open.
bool OpenInMemory() WARN_UNUSED_RESULT;
+ // Create a temporary on-disk database. The database will be
+ // deleted after close. This kind of database is similar to
+ // OpenInMemory() for small databases, but can page to disk if the
+ // database becomes large.
+ bool OpenTemporary() WARN_UNUSED_RESULT;
+
// Returns true if the database has been successfully opened.
bool is_open() const { return !!db_; }
@@ -218,13 +225,17 @@ class SQL_EXPORT Connection {
bool RazeWithTimout(base::TimeDelta timeout);
// Breaks all outstanding transactions (as initiated by
- // BeginTransaction()), calls Raze() to destroy the database, then
- // closes the database. After this is called, any operations
- // against the connections (or statements prepared by the
- // connection) should fail safely.
+ // BeginTransaction()), closes the SQLite database, and poisons the
+ // object so that all future operations against the Connection (or
+ // its Statements) fail safely, without side effects.
//
- // The value from Raze() is returned, with Close() called in all
- // cases.
+ // This is intended as an alternative to Close() in error callbacks.
+ // Close() should still be called at some point.
+ void Poison();
+
+ // Raze() the database and Poison() the handle. Returns the return
+ // value from Raze().
+ // TODO(shess): Rename to RazeAndPoison().
bool RazeAndClose();
// Delete the underlying database files associated with |path|.
@@ -254,10 +265,27 @@ class SQL_EXPORT Connection {
void RollbackTransaction();
bool CommitTransaction();
+ // Rollback all outstanding transactions. Use with care, there may
+ // be scoped transactions on the stack.
+ void RollbackAllTransactions();
+
// Returns the current transaction nesting, which will be 0 if there are
// no open transactions.
int transaction_nesting() const { return transaction_nesting_; }
+ // Attached databases---------------------------------------------------------
+
+ // SQLite supports attaching multiple database files to a single
+ // handle. Attach the database in |other_db_path| to the current
+ // handle under |attachment_point|. |attachment_point| should only
+ // contain characters from [a-zA-Z0-9_].
+ //
+ // Note that calling attach or detach with an open transaction is an
+ // error.
+ bool AttachDatabase(const base::FilePath& other_db_path,
+ const char* attachment_point);
+ bool DetachDatabase(const char* attachment_point);
+
// Statements ----------------------------------------------------------------
// Executes the given SQL string, returning true on success. This is
@@ -350,6 +378,9 @@ class SQL_EXPORT Connection {
const char* GetErrorMessage() const;
private:
+ // For recovery module.
+ friend class Recovery;
+
// Allow test-support code to set/reset error ignorer.
friend class ScopedErrorIgnorer;
« no previous file with comments | « no previous file | sql/connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698