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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } | 105 } |
106 | 106 |
107 bool Statement::BindInt(int col, int val) { | 107 bool Statement::BindInt(int col, int val) { |
108 DCHECK(!stepped_); | 108 DCHECK(!stepped_); |
109 if (!is_valid()) | 109 if (!is_valid()) |
110 return false; | 110 return false; |
111 | 111 |
112 return CheckOk(sqlite3_bind_int(ref_->stmt(), col + 1, val)); | 112 return CheckOk(sqlite3_bind_int(ref_->stmt(), col + 1, val)); |
113 } | 113 } |
114 | 114 |
115 bool Statement::BindInt64(int col, int64 val) { | 115 bool Statement::BindInt64(int col, int64_t val) { |
116 DCHECK(!stepped_); | 116 DCHECK(!stepped_); |
117 if (!is_valid()) | 117 if (!is_valid()) |
118 return false; | 118 return false; |
119 | 119 |
120 return CheckOk(sqlite3_bind_int64(ref_->stmt(), col + 1, val)); | 120 return CheckOk(sqlite3_bind_int64(ref_->stmt(), col + 1, val)); |
121 } | 121 } |
122 | 122 |
123 bool Statement::BindDouble(int col, double val) { | 123 bool Statement::BindDouble(int col, double val) { |
124 DCHECK(!stepped_); | 124 DCHECK(!stepped_); |
125 if (!is_valid()) | 125 if (!is_valid()) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 return !!ColumnInt(col); | 200 return !!ColumnInt(col); |
201 } | 201 } |
202 | 202 |
203 int Statement::ColumnInt(int col) const { | 203 int Statement::ColumnInt(int col) const { |
204 if (!CheckValid()) | 204 if (!CheckValid()) |
205 return 0; | 205 return 0; |
206 | 206 |
207 return sqlite3_column_int(ref_->stmt(), col); | 207 return sqlite3_column_int(ref_->stmt(), col); |
208 } | 208 } |
209 | 209 |
210 int64 Statement::ColumnInt64(int col) const { | 210 int64_t Statement::ColumnInt64(int col) const { |
211 if (!CheckValid()) | 211 if (!CheckValid()) |
212 return 0; | 212 return 0; |
213 | 213 |
214 return sqlite3_column_int64(ref_->stmt(), col); | 214 return sqlite3_column_int64(ref_->stmt(), col); |
215 } | 215 } |
216 | 216 |
217 double Statement::ColumnDouble(int col) const { | 217 double Statement::ColumnDouble(int col) const { |
218 if (!CheckValid()) | 218 if (!CheckValid()) |
219 return 0; | 219 return 0; |
220 | 220 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 320 |
321 int Statement::CheckError(int err) { | 321 int Statement::CheckError(int err) { |
322 // Please don't add DCHECKs here, OnSqliteError() already has them. | 322 // Please don't add DCHECKs here, OnSqliteError() already has them. |
323 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); | 323 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); |
324 if (!succeeded_ && ref_.get() && ref_->connection()) | 324 if (!succeeded_ && ref_.get() && ref_->connection()) |
325 return ref_->connection()->OnSqliteError(err, this, NULL); | 325 return ref_->connection()->OnSqliteError(err, this, NULL); |
326 return err; | 326 return err; |
327 } | 327 } |
328 | 328 |
329 } // namespace sql | 329 } // namespace sql |
OLD | NEW |