| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sql/statement.h" | 5 #include "sql/statement.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "third_party/sqlite/sqlite3.h" | 10 #include "third_party/sqlite/sqlite3.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 // StepInternal() cannot track success because statements may be reset | 104 // StepInternal() cannot track success because statements may be reset |
| 105 // before reaching SQLITE_DONE. Don't call CheckError() because | 105 // before reaching SQLITE_DONE. Don't call CheckError() because |
| 106 // sqlite3_reset() returns the last step error, which StepInternal() already | 106 // sqlite3_reset() returns the last step error, which StepInternal() already |
| 107 // checked. | 107 // checked. |
| 108 const int rc =sqlite3_reset(ref_->stmt()); | 108 const int rc =sqlite3_reset(ref_->stmt()); |
| 109 if (rc == SQLITE_OK && ref_->connection()) | 109 if (rc == SQLITE_OK && ref_->connection()) |
| 110 ref_->connection()->RecordOneEvent(Connection::EVENT_STATEMENT_SUCCESS); | 110 ref_->connection()->RecordOneEvent(Connection::EVENT_STATEMENT_SUCCESS); |
| 111 } | 111 } |
| 112 | 112 |
| 113 // Potentially release dirty cache pages if an autocommit statement made | |
| 114 // changes. | |
| 115 if (ref_->connection()) | |
| 116 ref_->connection()->ReleaseCacheMemoryIfNeeded(false); | |
| 117 | |
| 118 succeeded_ = false; | 113 succeeded_ = false; |
| 119 stepped_ = false; | 114 stepped_ = false; |
| 120 } | 115 } |
| 121 | 116 |
| 122 bool Statement::Succeeded() const { | 117 bool Statement::Succeeded() const { |
| 123 if (!is_valid()) | 118 if (!is_valid()) |
| 124 return false; | 119 return false; |
| 125 | 120 |
| 126 return succeeded_; | 121 return succeeded_; |
| 127 } | 122 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 | 349 |
| 355 int Statement::CheckError(int err) { | 350 int Statement::CheckError(int err) { |
| 356 // Please don't add DCHECKs here, OnSqliteError() already has them. | 351 // Please don't add DCHECKs here, OnSqliteError() already has them. |
| 357 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); | 352 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); |
| 358 if (!succeeded_ && ref_.get() && ref_->connection()) | 353 if (!succeeded_ && ref_.get() && ref_->connection()) |
| 359 return ref_->connection()->OnSqliteError(err, this, NULL); | 354 return ref_->connection()->OnSqliteError(err, this, NULL); |
| 360 return err; | 355 return err; |
| 361 } | 356 } |
| 362 | 357 |
| 363 } // namespace sql | 358 } // namespace sql |
| OLD | NEW |