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

Unified Diff: sql/statement.cc

Issue 40733003: [sql] Complain about statement mutations after stepping has started. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment tweak Created 7 years, 2 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 | « sql/statement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/statement.cc
diff --git a/sql/statement.cc b/sql/statement.cc
index 67b7334c05709ea8ab51eb48429171910a9b9523..4f5e17f1684bdf221616e3db272f73a05096bef3 100644
--- a/sql/statement.cc
+++ b/sql/statement.cc
@@ -16,11 +16,13 @@ namespace sql {
// only have to check the ref's validity bit.
Statement::Statement()
: ref_(new Connection::StatementRef(NULL, NULL, false)),
+ stepped_(false),
succeeded_(false) {
}
Statement::Statement(scoped_refptr<Connection::StatementRef> ref)
: ref_(ref),
+ stepped_(false),
succeeded_(false) {
}
@@ -50,10 +52,12 @@ bool Statement::CheckValid() const {
}
bool Statement::Run() {
+ DCHECK(!stepped_);
ref_->AssertIOAllowed();
if (!CheckValid())
return false;
+ stepped_ = true;
return CheckError(sqlite3_step(ref_->stmt())) == SQLITE_DONE;
}
@@ -62,6 +66,7 @@ bool Statement::Step() {
if (!CheckValid())
return false;
+ stepped_ = true;
return CheckError(sqlite3_step(ref_->stmt())) == SQLITE_ROW;
}
@@ -77,6 +82,7 @@ void Statement::Reset(bool clear_bound_vars) {
}
succeeded_ = false;
+ stepped_ = false;
}
bool Statement::Succeeded() const {
@@ -87,6 +93,7 @@ bool Statement::Succeeded() const {
}
bool Statement::BindNull(int col) {
+ DCHECK(!stepped_);
if (!is_valid())
return false;
@@ -98,6 +105,7 @@ bool Statement::BindBool(int col, bool val) {
}
bool Statement::BindInt(int col, int val) {
+ DCHECK(!stepped_);
if (!is_valid())
return false;
@@ -105,6 +113,7 @@ bool Statement::BindInt(int col, int val) {
}
bool Statement::BindInt64(int col, int64 val) {
+ DCHECK(!stepped_);
if (!is_valid())
return false;
@@ -112,6 +121,7 @@ bool Statement::BindInt64(int col, int64 val) {
}
bool Statement::BindDouble(int col, double val) {
+ DCHECK(!stepped_);
if (!is_valid())
return false;
@@ -119,6 +129,7 @@ bool Statement::BindDouble(int col, double val) {
}
bool Statement::BindCString(int col, const char* val) {
+ DCHECK(!stepped_);
if (!is_valid())
return false;
@@ -127,6 +138,7 @@ bool Statement::BindCString(int col, const char* val) {
}
bool Statement::BindString(int col, const std::string& val) {
+ DCHECK(!stepped_);
if (!is_valid())
return false;
@@ -142,6 +154,7 @@ bool Statement::BindString16(int col, const string16& value) {
}
bool Statement::BindBlob(int col, const void* val, int val_len) {
+ DCHECK(!stepped_);
if (!is_valid())
return false;
« no previous file with comments | « sql/statement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698