| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 int col, | 249 int col, |
| 250 std::vector<unsigned char>* val) const { | 250 std::vector<unsigned char>* val) const { |
| 251 return ColumnBlobAsVector(col, reinterpret_cast< std::vector<char>* >(val)); | 251 return ColumnBlobAsVector(col, reinterpret_cast< std::vector<char>* >(val)); |
| 252 } | 252 } |
| 253 | 253 |
| 254 const char* Statement::GetSQLStatement() { | 254 const char* Statement::GetSQLStatement() { |
| 255 return sqlite3_sql(ref_->stmt()); | 255 return sqlite3_sql(ref_->stmt()); |
| 256 } | 256 } |
| 257 | 257 |
| 258 bool Statement::CheckOk(int err) const { | 258 bool Statement::CheckOk(int err) const { |
| 259 // Binding to a non-existent variable is evidence of a serious error. |
| 260 // TODO(gbillock,shess): make this invalidate the statement so it |
| 261 // can't wreak havoc. |
| 262 if (err == SQLITE_RANGE) |
| 263 DLOG(FATAL) << "Bind value out of range"; |
| 259 return err == SQLITE_OK; | 264 return err == SQLITE_OK; |
| 260 } | 265 } |
| 261 | 266 |
| 262 int Statement::CheckError(int err) { | 267 int Statement::CheckError(int err) { |
| 263 // Please don't add DCHECKs here, OnSqliteError() already has them. | 268 // Please don't add DCHECKs here, OnSqliteError() already has them. |
| 264 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); | 269 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); |
| 265 if (!succeeded_ && is_valid()) | 270 if (!succeeded_ && is_valid()) |
| 266 return ref_->connection()->OnSqliteError(err, this); | 271 return ref_->connection()->OnSqliteError(err, this); |
| 267 return err; | 272 return err; |
| 268 } | 273 } |
| 269 | 274 |
| 270 } // namespace sql | 275 } // namespace sql |
| OLD | NEW |