OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "third_party/sqlite/sqlite3.h" | 9 #include "third_party/sqlite/sqlite3.h" |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 // one statement active for a given sqlite3_stmt at any time, so this won't | 28 // one statement active for a given sqlite3_stmt at any time, so this won't |
29 // mess with anything. | 29 // mess with anything. |
30 Reset(); | 30 Reset(); |
31 } | 31 } |
32 | 32 |
33 void Statement::Assign(scoped_refptr<Connection::StatementRef> ref) { | 33 void Statement::Assign(scoped_refptr<Connection::StatementRef> ref) { |
34 Reset(); | 34 Reset(); |
35 ref_ = ref; | 35 ref_ = ref; |
36 } | 36 } |
37 | 37 |
| 38 void Statement::Clear() { |
| 39 Assign(new Connection::StatementRef); |
| 40 succeeded_ = false; |
| 41 } |
| 42 |
38 bool Statement::CheckValid() const { | 43 bool Statement::CheckValid() const { |
39 if (!is_valid()) | 44 if (!is_valid()) |
40 DLOG(FATAL) << "Cannot call mutating statements on an invalid statement."; | 45 DLOG(FATAL) << "Cannot call mutating statements on an invalid statement."; |
41 return is_valid(); | 46 return is_valid(); |
42 } | 47 } |
43 | 48 |
44 bool Statement::Run() { | 49 bool Statement::Run() { |
45 if (!CheckValid()) | 50 if (!CheckValid()) |
46 return false; | 51 return false; |
47 | 52 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 271 |
267 int Statement::CheckError(int err) { | 272 int Statement::CheckError(int err) { |
268 // Please don't add DCHECKs here, OnSqliteError() already has them. | 273 // Please don't add DCHECKs here, OnSqliteError() already has them. |
269 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); | 274 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); |
270 if (!succeeded_ && is_valid()) | 275 if (!succeeded_ && is_valid()) |
271 return ref_->connection()->OnSqliteError(err, this); | 276 return ref_->connection()->OnSqliteError(err, this); |
272 return err; | 277 return err; |
273 } | 278 } |
274 | 279 |
275 } // namespace sql | 280 } // namespace sql |
OLD | NEW |