| 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 #ifndef SQL_CONNECTION_H_ | 5 #ifndef SQL_CONNECTION_H_ |
| 6 #define SQL_CONNECTION_H_ | 6 #define SQL_CONNECTION_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // keeping a statement cached). | 241 // keeping a statement cached). |
| 242 // | 242 // |
| 243 // See GetCachedStatement above for examples and error information. | 243 // See GetCachedStatement above for examples and error information. |
| 244 scoped_refptr<StatementRef> GetUniqueStatement(const char* sql); | 244 scoped_refptr<StatementRef> GetUniqueStatement(const char* sql); |
| 245 | 245 |
| 246 // Info querying ------------------------------------------------------------- | 246 // Info querying ------------------------------------------------------------- |
| 247 | 247 |
| 248 // Returns true if the given table exists. | 248 // Returns true if the given table exists. |
| 249 bool DoesTableExist(const char* table_name) const; | 249 bool DoesTableExist(const char* table_name) const; |
| 250 | 250 |
| 251 // Returns true if the given index exists. |
| 252 bool DoesIndexExist(const char* index_name) const; |
| 253 |
| 251 // Returns true if a column with the given name exists in the given table. | 254 // Returns true if a column with the given name exists in the given table. |
| 252 bool DoesColumnExist(const char* table_name, const char* column_name) const; | 255 bool DoesColumnExist(const char* table_name, const char* column_name) const; |
| 253 | 256 |
| 254 // Returns sqlite's internal ID for the last inserted row. Valid only | 257 // Returns sqlite's internal ID for the last inserted row. Valid only |
| 255 // immediately after an insert. | 258 // immediately after an insert. |
| 256 int64 GetLastInsertRowId() const; | 259 int64 GetLastInsertRowId() const; |
| 257 | 260 |
| 258 // Returns sqlite's count of the number of rows modified by the last | 261 // Returns sqlite's count of the number of rows modified by the last |
| 259 // statement executed. Will be 0 if no statement has executed or the database | 262 // statement executed. Will be 0 if no statement has executed or the database |
| 260 // is closed. | 263 // is closed. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 276 private: | 279 private: |
| 277 // Statement access StatementRef which we don't want to expose to erverybody | 280 // Statement access StatementRef which we don't want to expose to erverybody |
| 278 // (they should go through Statement). | 281 // (they should go through Statement). |
| 279 friend class Statement; | 282 friend class Statement; |
| 280 | 283 |
| 281 // Internal initialize function used by both Init and InitInMemory. The file | 284 // Internal initialize function used by both Init and InitInMemory. The file |
| 282 // name is always 8 bits since we want to use the 8-bit version of | 285 // name is always 8 bits since we want to use the 8-bit version of |
| 283 // sqlite3_open. The string can also be sqlite's special ":memory:" string. | 286 // sqlite3_open. The string can also be sqlite's special ":memory:" string. |
| 284 bool OpenInternal(const std::string& file_name); | 287 bool OpenInternal(const std::string& file_name); |
| 285 | 288 |
| 289 // Internal helper for DoesTableExist and DoesIndexExist. |
| 290 bool DoesTableOrIndexExist(const char* name, const char* type) const; |
| 291 |
| 286 // A StatementRef is a refcounted wrapper around a sqlite statement pointer. | 292 // A StatementRef is a refcounted wrapper around a sqlite statement pointer. |
| 287 // Refcounting allows us to give these statements out to sql::Statement | 293 // Refcounting allows us to give these statements out to sql::Statement |
| 288 // objects while also optionally maintaining a cache of compiled statements | 294 // objects while also optionally maintaining a cache of compiled statements |
| 289 // by just keeping a refptr to these objects. | 295 // by just keeping a refptr to these objects. |
| 290 // | 296 // |
| 291 // A statement ref can be valid, in which case it can be used, or invalid to | 297 // A statement ref can be valid, in which case it can be used, or invalid to |
| 292 // indicate that the statement hasn't been created yet, has an error, or has | 298 // indicate that the statement hasn't been created yet, has an error, or has |
| 293 // been destroyed. | 299 // been destroyed. |
| 294 // | 300 // |
| 295 // The Connection may revoke a StatementRef in some error cases, so callers | 301 // The Connection may revoke a StatementRef in some error cases, so callers |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 // This object handles errors resulting from all forms of executing sqlite | 385 // This object handles errors resulting from all forms of executing sqlite |
| 380 // commands or statements. It can be null which means default handling. | 386 // commands or statements. It can be null which means default handling. |
| 381 scoped_refptr<ErrorDelegate> error_delegate_; | 387 scoped_refptr<ErrorDelegate> error_delegate_; |
| 382 | 388 |
| 383 DISALLOW_COPY_AND_ASSIGN(Connection); | 389 DISALLOW_COPY_AND_ASSIGN(Connection); |
| 384 }; | 390 }; |
| 385 | 391 |
| 386 } // namespace sql | 392 } // namespace sql |
| 387 | 393 |
| 388 #endif // SQL_CONNECTION_H_ | 394 #endif // SQL_CONNECTION_H_ |
| OLD | NEW |