blob: 91139cedc638ee9eb5e31db38dffe08392100f13 [file] [log] [blame]
[email protected]2eec0a22012-07-24 01:59:581// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]e5ffd0e42009-09-11 21:30:562// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]f0a54b22011-07-19 18:40:215#ifndef SQL_CONNECTION_H_
6#define SQL_CONNECTION_H_
[email protected]e5ffd0e42009-09-11 21:30:567
8#include <map>
9#include <set>
[email protected]7d6aee4e2009-09-12 01:12:3310#include <string>
[email protected]80abf152013-05-22 12:42:4211#include <vector>
[email protected]e5ffd0e42009-09-11 21:30:5612
13#include "base/basictypes.h"
[email protected]c3881b372013-05-17 08:39:4614#include "base/callback.h"
[email protected]9fe37552011-12-23 17:07:2015#include "base/compiler_specific.h"
[email protected]3b63f8f42011-03-28 01:54:1516#include "base/memory/ref_counted.h"
[email protected]49dc4f22012-10-17 17:41:1617#include "base/memory/scoped_ptr.h"
[email protected]35f7e5392012-07-27 19:54:5018#include "base/threading/thread_restrictions.h"
[email protected]5b96f3772010-09-28 16:30:5719#include "base/time.h"
[email protected]d4526962011-11-10 21:40:2820#include "sql/sql_export.h"
[email protected]e5ffd0e42009-09-11 21:30:5621
[email protected]e5ffd0e42009-09-11 21:30:5622struct sqlite3;
23struct sqlite3_stmt;
24
[email protected]a3ef4832013-02-02 05:12:3325namespace base {
26class FilePath;
27}
28
[email protected]e5ffd0e42009-09-11 21:30:5629namespace sql {
30
31class Statement;
32
33// Uniquely identifies a statement. There are two modes of operation:
34//
35// - In the most common mode, you will use the source file and line number to
36// identify your statement. This is a convienient way to get uniqueness for
37// a statement that is only used in one place. Use the SQL_FROM_HERE macro
38// to generate a StatementID.
39//
40// - In the "custom" mode you may use the statement from different places or
41// need to manage it yourself for whatever reason. In this case, you should
42// make up your own unique name and pass it to the StatementID. This name
43// must be a static string, since this object only deals with pointers and
44// assumes the underlying string doesn't change or get deleted.
45//
46// This object is copyable and assignable using the compiler-generated
47// operator= and copy constructor.
48class StatementID {
49 public:
50 // Creates a uniquely named statement with the given file ane line number.
51 // Normally you will use SQL_FROM_HERE instead of calling yourself.
52 StatementID(const char* file, int line)
53 : number_(line),
54 str_(file) {
55 }
56
57 // Creates a uniquely named statement with the given user-defined name.
58 explicit StatementID(const char* unique_name)
59 : number_(-1),
60 str_(unique_name) {
61 }
62
63 // This constructor is unimplemented and will generate a linker error if
64 // called. It is intended to try to catch people dynamically generating
65 // a statement name that will be deallocated and will cause a crash later.
66 // All strings must be static and unchanging!
67 explicit StatementID(const std::string& dont_ever_do_this);
68
69 // We need this to insert into our map.
70 bool operator<(const StatementID& other) const;
71
72 private:
73 int number_;
74 const char* str_;
75};
76
77#define SQL_FROM_HERE sql::StatementID(__FILE__, __LINE__)
78
[email protected]faa604e2009-09-25 22:38:5979class Connection;
80
[email protected]d4526962011-11-10 21:40:2881class SQL_EXPORT Connection {
[email protected]e5ffd0e42009-09-11 21:30:5682 private:
83 class StatementRef; // Forward declaration, see real one below.
84
85 public:
[email protected]765b44502009-10-02 05:01:4286 // The database is opened by calling Open[InMemory](). Any uncommitted
87 // transactions will be rolled back when this object is deleted.
[email protected]e5ffd0e42009-09-11 21:30:5688 Connection();
89 ~Connection();
90
91 // Pre-init configuration ----------------------------------------------------
92
[email protected]765b44502009-10-02 05:01:4293 // Sets the page size that will be used when creating a new database. This
[email protected]e5ffd0e42009-09-11 21:30:5694 // must be called before Init(), and will only have an effect on new
95 // databases.
96 //
97 // From sqlite.org: "The page size must be a power of two greater than or
98 // equal to 512 and less than or equal to SQLITE_MAX_PAGE_SIZE. The maximum
99 // value for SQLITE_MAX_PAGE_SIZE is 32768."
100 void set_page_size(int page_size) { page_size_ = page_size; }
101
102 // Sets the number of pages that will be cached in memory by sqlite. The
103 // total cache size in bytes will be page_size * cache_size. This must be
[email protected]765b44502009-10-02 05:01:42104 // called before Open() to have an effect.
[email protected]e5ffd0e42009-09-11 21:30:56105 void set_cache_size(int cache_size) { cache_size_ = cache_size; }
106
107 // Call to put the database in exclusive locking mode. There is no "back to
108 // normal" flag because of some additional requirements sqlite puts on this
109 // transaition (requires another access to the DB) and because we don't
110 // actually need it.
111 //
112 // Exclusive mode means that the database is not unlocked at the end of each
113 // transaction, which means there may be less time spent initializing the
114 // next transaction because it doesn't have to re-aquire locks.
115 //
[email protected]765b44502009-10-02 05:01:42116 // This must be called before Open() to have an effect.
[email protected]e5ffd0e42009-09-11 21:30:56117 void set_exclusive_locking() { exclusive_locking_ = true; }
118
[email protected]c3881b372013-05-17 08:39:46119 // Set an error-handling callback. On errors, the error number (and
120 // statement, if available) will be passed to the callback.
121 //
122 // If no callback is set, the default action is to crash in debug
123 // mode or return failure in release mode.
[email protected]c3881b372013-05-17 08:39:46124 typedef base::Callback<void(int, Statement*)> ErrorCallback;
125 void set_error_callback(const ErrorCallback& callback) {
126 error_callback_ = callback;
127 }
128 void reset_error_callback() {
129 error_callback_.Reset();
130 }
131
[email protected]210ce0af2013-05-15 09:10:39132 // Set this tag to enable additional connection-type histogramming
133 // for SQLite error codes and database version numbers.
134 void set_histogram_tag(const std::string& tag) {
135 histogram_tag_ = tag;
[email protected]c088e3a32013-01-03 23:59:14136 }
137
[email protected]210ce0af2013-05-15 09:10:39138 // Record a sparse UMA histogram sample under
139 // |name|+"."+|histogram_tag_|. If |histogram_tag_| is empty, no
140 // histogram is recorded.
141 void AddTaggedHistogram(const std::string& name, size_t sample) const;
142
[email protected]80abf152013-05-22 12:42:42143 // Run "PRAGMA integrity_check" and post each line of results into
144 // |messages|. Returns the success of running the statement - per
145 // the SQLite documentation, if no errors are found the call should
146 // succeed, and a single value "ok" should be in messages.
147 bool IntegrityCheck(std::vector<std::string>* messages);
148
[email protected]e5ffd0e42009-09-11 21:30:56149 // Initialization ------------------------------------------------------------
150
151 // Initializes the SQL connection for the given file, returning true if the
[email protected]35f2094c2009-12-29 22:46:55152 // file could be opened. You can call this or OpenInMemory.
[email protected]a3ef4832013-02-02 05:12:33153 bool Open(const base::FilePath& path) WARN_UNUSED_RESULT;
[email protected]765b44502009-10-02 05:01:42154
155 // Initializes the SQL connection for a temporary in-memory database. There
156 // will be no associated file on disk, and the initial database will be
[email protected]35f2094c2009-12-29 22:46:55157 // empty. You can call this or Open.
[email protected]9fe37552011-12-23 17:07:20158 bool OpenInMemory() WARN_UNUSED_RESULT;
[email protected]765b44502009-10-02 05:01:42159
[email protected]41a97c812013-02-07 02:35:38160 // Returns true if the database has been successfully opened.
[email protected]765b44502009-10-02 05:01:42161 bool is_open() const { return !!db_; }
[email protected]e5ffd0e42009-09-11 21:30:56162
163 // Closes the database. This is automatically performed on destruction for
164 // you, but this allows you to close the database early. You must not call
165 // any other functions after closing it. It is permissable to call Close on
166 // an uninitialized or already-closed database.
167 void Close();
168
169 // Pre-loads the first <cache-size> pages into the cache from the file.
170 // If you expect to soon use a substantial portion of the database, this
171 // is much more efficient than allowing the pages to be populated organically
172 // since there is no per-page hard drive seeking. If the file is larger than
173 // the cache, the last part that doesn't fit in the cache will be brought in
174 // organically.
175 //
176 // This function assumes your class is using a meta table on the current
177 // database, as it openes a transaction on the meta table to force the
178 // database to be initialized. You should feel free to initialize the meta
179 // table after calling preload since the meta table will already be in the
180 // database if it exists, and if it doesn't exist, the database won't
181 // generally exist either.
182 void Preload();
183
[email protected]8e0c01282012-04-06 19:36:49184 // Raze the database to the ground. This approximates creating a
185 // fresh database from scratch, within the constraints of SQLite's
186 // locking protocol (locks and open handles can make doing this with
187 // filesystem operations problematic). Returns true if the database
188 // was razed.
189 //
190 // false is returned if the database is locked by some other
191 // process. RazeWithTimeout() may be used if appropriate.
192 //
193 // NOTE(shess): Raze() will DCHECK in the following situations:
194 // - database is not open.
195 // - the connection has a transaction open.
196 // - a SQLite issue occurs which is structural in nature (like the
197 // statements used are broken).
198 // Since Raze() is expected to be called in unexpected situations,
199 // these all return false, since it is unlikely that the caller
200 // could fix them.
[email protected]6d42f152012-11-10 00:38:24201 //
202 // The database's page size is taken from |page_size_|. The
203 // existing database's |auto_vacuum| setting is lost (the
204 // possibility of corruption makes it unreliable to pull it from the
205 // existing database). To re-enable on the empty database requires
206 // running "PRAGMA auto_vacuum = 1;" then "VACUUM".
207 //
208 // NOTE(shess): For Android, SQLITE_DEFAULT_AUTOVACUUM is set to 1,
209 // so Raze() sets auto_vacuum to 1.
210 //
211 // TODO(shess): Raze() needs a connection so cannot clear SQLITE_NOTADB.
212 // TODO(shess): Bake auto_vacuum into Connection's API so it can
213 // just pick up the default.
[email protected]8e0c01282012-04-06 19:36:49214 bool Raze();
215 bool RazeWithTimout(base::TimeDelta timeout);
216
[email protected]41a97c812013-02-07 02:35:38217 // Breaks all outstanding transactions (as initiated by
218 // BeginTransaction()), calls Raze() to destroy the database, then
219 // closes the database. After this is called, any operations
220 // against the connections (or statements prepared by the
221 // connection) should fail safely.
222 //
223 // The value from Raze() is returned, with Close() called in all
224 // cases.
225 bool RazeAndClose();
226
[email protected]e5ffd0e42009-09-11 21:30:56227 // Transactions --------------------------------------------------------------
228
229 // Transaction management. We maintain a virtual transaction stack to emulate
230 // nested transactions since sqlite can't do nested transactions. The
231 // limitation is you can't roll back a sub transaction: if any transaction
232 // fails, all transactions open will also be rolled back. Any nested
233 // transactions after one has rolled back will return fail for Begin(). If
234 // Begin() fails, you must not call Commit or Rollback().
235 //
236 // Normally you should use sql::Transaction to manage a transaction, which
237 // will scope it to a C++ context.
238 bool BeginTransaction();
239 void RollbackTransaction();
240 bool CommitTransaction();
241
242 // Returns the current transaction nesting, which will be 0 if there are
243 // no open transactions.
244 int transaction_nesting() const { return transaction_nesting_; }
245
246 // Statements ----------------------------------------------------------------
247
248 // Executes the given SQL string, returning true on success. This is
249 // normally used for simple, 1-off statements that don't take any bound
250 // parameters and don't return any data (e.g. CREATE TABLE).
[email protected]9fe37552011-12-23 17:07:20251 //
[email protected]eff1fa522011-12-12 23:50:59252 // This will DCHECK if the |sql| contains errors.
[email protected]9fe37552011-12-23 17:07:20253 //
254 // Do not use ignore_result() to ignore all errors. Use
255 // ExecuteAndReturnErrorCode() and ignore only specific errors.
256 bool Execute(const char* sql) WARN_UNUSED_RESULT;
[email protected]e5ffd0e42009-09-11 21:30:56257
[email protected]eff1fa522011-12-12 23:50:59258 // Like Execute(), but returns the error code given by SQLite.
[email protected]9fe37552011-12-23 17:07:20259 int ExecuteAndReturnErrorCode(const char* sql) WARN_UNUSED_RESULT;
[email protected]eff1fa522011-12-12 23:50:59260
[email protected]e5ffd0e42009-09-11 21:30:56261 // Returns true if we have a statement with the given identifier already
262 // cached. This is normally not necessary to call, but can be useful if the
263 // caller has to dynamically build up SQL to avoid doing so if it's already
264 // cached.
265 bool HasCachedStatement(const StatementID& id) const;
266
267 // Returns a statement for the given SQL using the statement cache. It can
268 // take a nontrivial amount of work to parse and compile a statement, so
269 // keeping commonly-used ones around for future use is important for
270 // performance.
271 //
[email protected]eff1fa522011-12-12 23:50:59272 // If the |sql| has an error, an invalid, inert StatementRef is returned (and
273 // the code will crash in debug). The caller must deal with this eventuality,
274 // either by checking validity of the |sql| before calling, by correctly
275 // handling the return of an inert statement, or both.
[email protected]e5ffd0e42009-09-11 21:30:56276 //
277 // The StatementID and the SQL must always correspond to one-another. The
278 // ID is the lookup into the cache, so crazy things will happen if you use
279 // different SQL with the same ID.
280 //
281 // You will normally use the SQL_FROM_HERE macro to generate a statement
282 // ID associated with the current line of code. This gives uniqueness without
283 // you having to manage unique names. See StatementID above for more.
284 //
285 // Example:
[email protected]3273dce2010-01-27 16:08:08286 // sql::Statement stmt(connection_.GetCachedStatement(
287 // SQL_FROM_HERE, "SELECT * FROM foo"));
[email protected]e5ffd0e42009-09-11 21:30:56288 // if (!stmt)
289 // return false; // Error creating statement.
290 scoped_refptr<StatementRef> GetCachedStatement(const StatementID& id,
291 const char* sql);
292
[email protected]eff1fa522011-12-12 23:50:59293 // Used to check a |sql| statement for syntactic validity. If the statement is
294 // valid SQL, returns true.
295 bool IsSQLValid(const char* sql);
296
[email protected]e5ffd0e42009-09-11 21:30:56297 // Returns a non-cached statement for the given SQL. Use this for SQL that
298 // is only executed once or only rarely (there is overhead associated with
299 // keeping a statement cached).
300 //
301 // See GetCachedStatement above for examples and error information.
302 scoped_refptr<StatementRef> GetUniqueStatement(const char* sql);
303
304 // Info querying -------------------------------------------------------------
305
306 // Returns true if the given table exists.
[email protected]765b44502009-10-02 05:01:42307 bool DoesTableExist(const char* table_name) const;
[email protected]e5ffd0e42009-09-11 21:30:56308
[email protected]e2cadec82011-12-13 02:00:53309 // Returns true if the given index exists.
310 bool DoesIndexExist(const char* index_name) const;
311
[email protected]e5ffd0e42009-09-11 21:30:56312 // Returns true if a column with the given name exists in the given table.
[email protected]1ed78a32009-09-15 20:24:17313 bool DoesColumnExist(const char* table_name, const char* column_name) const;
[email protected]e5ffd0e42009-09-11 21:30:56314
315 // Returns sqlite's internal ID for the last inserted row. Valid only
316 // immediately after an insert.
317 int64 GetLastInsertRowId() const;
318
[email protected]1ed78a32009-09-15 20:24:17319 // Returns sqlite's count of the number of rows modified by the last
320 // statement executed. Will be 0 if no statement has executed or the database
321 // is closed.
322 int GetLastChangeCount() const;
323
[email protected]e5ffd0e42009-09-11 21:30:56324 // Errors --------------------------------------------------------------------
325
326 // Returns the error code associated with the last sqlite operation.
327 int GetErrorCode() const;
328
[email protected]767718e52010-09-21 23:18:49329 // Returns the errno associated with GetErrorCode(). See
330 // SQLITE_LAST_ERRNO in SQLite documentation.
331 int GetLastErrno() const;
332
[email protected]e5ffd0e42009-09-11 21:30:56333 // Returns a pointer to a statically allocated string associated with the
334 // last sqlite operation.
335 const char* GetErrorMessage() const;
336
337 private:
[email protected]4350e322013-06-18 22:18:10338 // Allow test-support code to set/reset error ignorer.
339 friend class ScopedErrorIgnorer;
340
[email protected]eff1fa522011-12-12 23:50:59341 // Statement accesses StatementRef which we don't want to expose to everybody
[email protected]e5ffd0e42009-09-11 21:30:56342 // (they should go through Statement).
343 friend class Statement;
344
[email protected]765b44502009-10-02 05:01:42345 // Internal initialize function used by both Init and InitInMemory. The file
346 // name is always 8 bits since we want to use the 8-bit version of
347 // sqlite3_open. The string can also be sqlite's special ":memory:" string.
348 bool OpenInternal(const std::string& file_name);
349
[email protected]41a97c812013-02-07 02:35:38350 // Internal close function used by Close() and RazeAndClose().
351 // |forced| indicates that orderly-shutdown checks should not apply.
352 void CloseInternal(bool forced);
353
[email protected]35f7e5392012-07-27 19:54:50354 // Check whether the current thread is allowed to make IO calls, but only
355 // if database wasn't open in memory. Function is inlined to be a no-op in
356 // official build.
357 void AssertIOAllowed() {
358 if (!in_memory_)
359 base::ThreadRestrictions::AssertIOAllowed();
360 }
361
[email protected]e2cadec82011-12-13 02:00:53362 // Internal helper for DoesTableExist and DoesIndexExist.
363 bool DoesTableOrIndexExist(const char* name, const char* type) const;
364
[email protected]4350e322013-06-18 22:18:10365 // Accessors for global error-ignorer, for injecting behavior during tests.
366 // See test/scoped_error_ignorer.h.
367 typedef base::Callback<bool(int)> ErrorIgnorerCallback;
368 static ErrorIgnorerCallback* current_ignorer_cb_;
369 static bool ShouldIgnore(int error);
370 static void SetErrorIgnorer(ErrorIgnorerCallback* ignorer);
371 static void ResetErrorIgnorer();
372
[email protected]e5ffd0e42009-09-11 21:30:56373 // A StatementRef is a refcounted wrapper around a sqlite statement pointer.
374 // Refcounting allows us to give these statements out to sql::Statement
375 // objects while also optionally maintaining a cache of compiled statements
376 // by just keeping a refptr to these objects.
377 //
378 // A statement ref can be valid, in which case it can be used, or invalid to
379 // indicate that the statement hasn't been created yet, has an error, or has
380 // been destroyed.
381 //
382 // The Connection may revoke a StatementRef in some error cases, so callers
383 // should always check validity before using.
[email protected]601dc6a2011-11-12 01:14:23384 class SQL_EXPORT StatementRef : public base::RefCounted<StatementRef> {
[email protected]e5ffd0e42009-09-11 21:30:56385 public:
[email protected]41a97c812013-02-07 02:35:38386 // |connection| is the sql::Connection instance associated with
387 // the statement, and is used for tracking outstanding statements
388 // and for error handling. Set to NULL for invalid or untracked
389 // refs. |stmt| is the actual statement, and should only be NULL
390 // to create an invalid ref. |was_valid| indicates whether the
391 // statement should be considered valid for diagnistic purposes.
392 // |was_valid| can be true for NULL |stmt| if the connection has
393 // been forcibly closed by an error handler.
394 StatementRef(Connection* connection, sqlite3_stmt* stmt, bool was_valid);
[email protected]e5ffd0e42009-09-11 21:30:56395
396 // When true, the statement can be used.
397 bool is_valid() const { return !!stmt_; }
398
[email protected]41a97c812013-02-07 02:35:38399 // When true, the statement is either currently valid, or was
400 // previously valid but the connection was forcibly closed. Used
401 // for diagnostic checks.
402 bool was_valid() const { return was_valid_; }
403
[email protected]b4c363b2013-01-17 13:11:17404 // If we've not been linked to a connection, this will be NULL.
405 // TODO(shess): connection_ can be NULL in case of GetUntrackedStatement(),
406 // which prevents Statement::OnError() from forwarding errors.
[email protected]e5ffd0e42009-09-11 21:30:56407 Connection* connection() const { return connection_; }
408
409 // Returns the sqlite statement if any. If the statement is not active,
410 // this will return NULL.
411 sqlite3_stmt* stmt() const { return stmt_; }
412
413 // Destroys the compiled statement and marks it NULL. The statement will
[email protected]41a97c812013-02-07 02:35:38414 // no longer be active. |forced| is used to indicate if orderly-shutdown
415 // checks should apply (see Connection::RazeAndClose()).
416 void Close(bool forced);
[email protected]e5ffd0e42009-09-11 21:30:56417
[email protected]35f7e5392012-07-27 19:54:50418 // Check whether the current thread is allowed to make IO calls, but only
419 // if database wasn't open in memory.
420 void AssertIOAllowed() { if (connection_) connection_->AssertIOAllowed(); }
421
[email protected]e5ffd0e42009-09-11 21:30:56422 private:
[email protected]877d55d2009-11-05 21:53:08423 friend class base::RefCounted<StatementRef>;
424
425 ~StatementRef();
426
[email protected]e5ffd0e42009-09-11 21:30:56427 Connection* connection_;
428 sqlite3_stmt* stmt_;
[email protected]41a97c812013-02-07 02:35:38429 bool was_valid_;
[email protected]e5ffd0e42009-09-11 21:30:56430
431 DISALLOW_COPY_AND_ASSIGN(StatementRef);
432 };
433 friend class StatementRef;
434
435 // Executes a rollback statement, ignoring all transaction state. Used
436 // internally in the transaction management code.
437 void DoRollback();
438
439 // Called by a StatementRef when it's being created or destroyed. See
440 // open_statements_ below.
441 void StatementRefCreated(StatementRef* ref);
442 void StatementRefDeleted(StatementRef* ref);
443
[email protected]faa604e2009-09-25 22:38:59444 // Called by Statement objects when an sqlite function returns an error.
445 // The return value is the error code reflected back to client code.
446 int OnSqliteError(int err, Statement* stmt);
447
[email protected]5b96f3772010-09-28 16:30:57448 // Like |Execute()|, but retries if the database is locked.
[email protected]9fe37552011-12-23 17:07:20449 bool ExecuteWithTimeout(const char* sql, base::TimeDelta ms_timeout)
450 WARN_UNUSED_RESULT;
[email protected]5b96f3772010-09-28 16:30:57451
[email protected]2eec0a22012-07-24 01:59:58452 // Internal helper for const functions. Like GetUniqueStatement(),
453 // except the statement is not entered into open_statements_,
454 // allowing this function to be const. Open statements can block
455 // closing the database, so only use in cases where the last ref is
456 // released before close could be called (which should always be the
457 // case for const functions).
458 scoped_refptr<StatementRef> GetUntrackedStatement(const char* sql) const;
459
[email protected]e5ffd0e42009-09-11 21:30:56460 // The actual sqlite database. Will be NULL before Init has been called or if
461 // Init resulted in an error.
462 sqlite3* db_;
463
464 // Parameters we'll configure in sqlite before doing anything else. Zero means
465 // use the default value.
466 int page_size_;
467 int cache_size_;
468 bool exclusive_locking_;
469
470 // All cached statements. Keeping a reference to these statements means that
471 // they'll remain active.
472 typedef std::map<StatementID, scoped_refptr<StatementRef> >
473 CachedStatementMap;
474 CachedStatementMap statement_cache_;
475
476 // A list of all StatementRefs we've given out. Each ref must register with
477 // us when it's created or destroyed. This allows us to potentially close
478 // any open statements when we encounter an error.
479 typedef std::set<StatementRef*> StatementRefSet;
480 StatementRefSet open_statements_;
481
482 // Number of currently-nested transactions.
483 int transaction_nesting_;
484
485 // True if any of the currently nested transactions have been rolled back.
486 // When we get to the outermost transaction, this will determine if we do
487 // a rollback instead of a commit.
488 bool needs_rollback_;
489
[email protected]35f7e5392012-07-27 19:54:50490 // True if database is open with OpenInMemory(), False if database is open
491 // with Open().
492 bool in_memory_;
493
[email protected]41a97c812013-02-07 02:35:38494 // |true| if the connection was closed using RazeAndClose(). Used
495 // to enable diagnostics to distinguish calls to never-opened
496 // databases (incorrect use of the API) from calls to once-valid
497 // databases.
498 bool poisoned_;
499
[email protected]c3881b372013-05-17 08:39:46500 ErrorCallback error_callback_;
501
[email protected]210ce0af2013-05-15 09:10:39502 // Tag for auxiliary histograms.
503 std::string histogram_tag_;
[email protected]c088e3a32013-01-03 23:59:14504
[email protected]e5ffd0e42009-09-11 21:30:56505 DISALLOW_COPY_AND_ASSIGN(Connection);
506};
507
508} // namespace sql
509
[email protected]f0a54b22011-07-19 18:40:21510#endif // SQL_CONNECTION_H_