summaryrefslogtreecommitdiffstats
path: root/sql/statement.cc
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-07 02:35:38 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-07 02:35:38 +0000
commit41a97c81e1bd78eddc704b00bdad106bf602778c (patch)
tree9fa9ee2eb911762eab05aea401f17e0c87ea6f3a /sql/statement.cc
parentf9036e33644b0fccd9987cb759a17ba7e51b0b2e (diff)
downloadchromium_src-41a97c81e1bd78eddc704b00bdad106bf602778c.zip
chromium_src-41a97c81e1bd78eddc704b00bdad106bf602778c.tar.gz
chromium_src-41a97c81e1bd78eddc704b00bdad106bf602778c.tar.bz2
Implement sql::Connection::RazeAndClose().
Raze() clears out the database, but cannot be called within a transaction. Close() can only be called once all statements have cleared. Error callbacks happen while executing statements (thus often in a transaction, and at least one statement is outstanding). RazeAndClose() forcibly breaks outstanding transactions, calls Raze() to clear the database, then calls Close() to close the handle. All future operations against the database should fail safely (without affecting storage and without crashing). BUG=166419, 136846 Review URL: https://chromiumcodereview.appspot.com/12096073 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181152 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql/statement.cc')
-rw-r--r--sql/statement.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/sql/statement.cc b/sql/statement.cc
index cd55bf7..d92be01 100644
--- a/sql/statement.cc
+++ b/sql/statement.cc
@@ -15,7 +15,7 @@ namespace sql {
// we don't have to NULL-check the ref_ to see if the statement is valid: we
// only have to check the ref's validity bit.
Statement::Statement()
- : ref_(new Connection::StatementRef),
+ : ref_(new Connection::StatementRef(NULL, NULL, false)),
succeeded_(false) {
}
@@ -37,13 +37,15 @@ void Statement::Assign(scoped_refptr<Connection::StatementRef> ref) {
}
void Statement::Clear() {
- Assign(new Connection::StatementRef);
+ Assign(new Connection::StatementRef(NULL, NULL, false));
succeeded_ = false;
}
bool Statement::CheckValid() const {
- if (!is_valid())
- DLOG(FATAL) << "Cannot call mutating statements on an invalid statement.";
+ // Allow operations to fail silently if a statement was invalidated
+ // because the database was closed by an error handler.
+ DLOG_IF(FATAL, !ref_->was_valid())
+ << "Cannot call mutating statements on an invalid statement.";
return is_valid();
}
@@ -306,7 +308,7 @@ bool Statement::CheckOk(int err) const {
int Statement::CheckError(int err) {
// Please don't add DCHECKs here, OnSqliteError() already has them.
succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE);
- if (!succeeded_ && is_valid() && ref_->connection())
+ if (!succeeded_ && ref_ && ref_->connection())
return ref_->connection()->OnSqliteError(err, this);
return err;
}