blob: 6fb5e5994eb5f95b77581f28d75ecbee8b18e524 [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
Victor Costancfbfa602018-08-01 23:24:465#ifndef SQL_DATABASE_H_
6#define SQL_DATABASE_H_
[email protected]e5ffd0e42009-09-11 21:30:567
avi0b519202015-12-21 07:25:198#include <stddef.h>
tfarina720d4f32015-05-11 22:31:269#include <stdint.h>
mostynbd82cd9952016-04-11 20:05:3410#include <memory>
[email protected]e5ffd0e42009-09-11 21:30:5611#include <set>
[email protected]7d6aee4e2009-09-12 01:12:3312#include <string>
Victor Costan87cf8c72018-07-19 19:36:0413#include <utility>
[email protected]80abf152013-05-22 12:42:4214#include <vector>
[email protected]e5ffd0e42009-09-11 21:30:5615
[email protected]c3881b372013-05-17 08:39:4616#include "base/callback.h"
[email protected]9fe37552011-12-23 17:07:2017#include "base/compiler_specific.h"
Dmitry Skibaa9ad8fe42017-08-16 21:02:4818#include "base/containers/flat_map.h"
shessc8cd2a162015-10-22 20:30:4619#include "base/gtest_prod_util.h"
tfarina720d4f32015-05-11 22:31:2620#include "base/macros.h"
[email protected]3b63f8f42011-03-28 01:54:1521#include "base/memory/ref_counted.h"
Victor Costan12daa3ac92018-07-19 01:05:5822#include "base/sequence_checker.h"
[email protected]35f7e5392012-07-27 19:54:5023#include "base/threading/thread_restrictions.h"
Victor Costan87cf8c72018-07-19 19:36:0424#include "base/time/tick_clock.h"
Victor Costan7f6abbbe2018-07-29 02:57:2725#include "sql/internal_api_token.h"
[email protected]d4526962011-11-10 21:40:2826#include "sql/sql_export.h"
Victor Costan12daa3ac92018-07-19 01:05:5827#include "sql/statement_id.h"
[email protected]e5ffd0e42009-09-11 21:30:5628
[email protected]e5ffd0e42009-09-11 21:30:5629struct sqlite3;
30struct sqlite3_stmt;
31
[email protected]a3ef4832013-02-02 05:12:3332namespace base {
33class FilePath;
shess58b8df82015-06-03 00:19:3234class HistogramBase;
dskibab4199f82016-11-21 20:16:1335namespace trace_event {
ssid1f4e5362016-12-08 20:41:3836class ProcessMemoryDump;
Victor Costan87cf8c72018-07-19 19:36:0437} // namespace trace_event
38} // namespace base
[email protected]a3ef4832013-02-02 05:12:3339
[email protected]e5ffd0e42009-09-11 21:30:5640namespace sql {
41
Victor Costancfbfa602018-08-01 23:24:4642class DatabaseMemoryDumpProvider;
[email protected]e5ffd0e42009-09-11 21:30:5643class Statement;
44
shess58b8df82015-06-03 00:19:3245// To allow some test classes to be friended.
46namespace test {
47class ScopedCommitHook;
shess976814402016-06-21 06:56:2548class ScopedErrorExpecter;
shess58b8df82015-06-03 00:19:3249class ScopedScalarFunction;
50class ScopedMockTimeSource;
Victor Costan87cf8c72018-07-19 19:36:0451} // namespace test
shess58b8df82015-06-03 00:19:3252
Victor Costancfbfa602018-08-01 23:24:4653// Exposes private Database functionality to unit tests.
Victor Costan7f6abbbe2018-07-29 02:57:2754//
55// This class is only defined in test targets.
Victor Costancfbfa602018-08-01 23:24:4656class DatabaseTestPeer;
[email protected]faa604e2009-09-25 22:38:5957
Victor Costan87cf8c72018-07-19 19:36:0458// Handle to an open SQLite database.
59//
60// Instances of this class are thread-unsafe and DCHECK that they are accessed
61// on the same sequence.
62//
63// TODO(pwnall): This should be renamed to Database. Class instances are
64// typically named "db_" / "db", and the class' equivalents in other systems
65// used by Chrome are named LevelDB::DB and blink::IDBDatabase.
Victor Costancfbfa602018-08-01 23:24:4666class SQL_EXPORT Database {
[email protected]e5ffd0e42009-09-11 21:30:5667 private:
68 class StatementRef; // Forward declaration, see real one below.
69
70 public:
[email protected]765b44502009-10-02 05:01:4271 // The database is opened by calling Open[InMemory](). Any uncommitted
72 // transactions will be rolled back when this object is deleted.
Victor Costancfbfa602018-08-01 23:24:4673 Database();
74 ~Database();
[email protected]e5ffd0e42009-09-11 21:30:5675
76 // Pre-init configuration ----------------------------------------------------
77
[email protected]765b44502009-10-02 05:01:4278 // Sets the page size that will be used when creating a new database. This
[email protected]e5ffd0e42009-09-11 21:30:5679 // must be called before Init(), and will only have an effect on new
80 // databases.
81 //
Victor Costan7f6abbbe2018-07-29 02:57:2782 // The page size must be a power of two between 512 and 65536 inclusive.
Victor Costan87cf8c72018-07-19 19:36:0483 void set_page_size(int page_size) {
Victor Costan7f6abbbe2018-07-29 02:57:2784 DCHECK_GE(page_size, 512);
85 DCHECK_LE(page_size, 65536);
86 DCHECK(!(page_size & (page_size - 1)))
Victor Costan87cf8c72018-07-19 19:36:0487 << "page_size must be a power of two";
88
89 page_size_ = page_size;
90 }
[email protected]e5ffd0e42009-09-11 21:30:5691
Victor Costan7f6abbbe2018-07-29 02:57:2792 // The page size that will be used when creating a new database.
93 int page_size() const { return page_size_; }
94
[email protected]e5ffd0e42009-09-11 21:30:5695 // Sets the number of pages that will be cached in memory by sqlite. The
96 // total cache size in bytes will be page_size * cache_size. This must be
[email protected]765b44502009-10-02 05:01:4297 // called before Open() to have an effect.
Victor Costan87cf8c72018-07-19 19:36:0498 void set_cache_size(int cache_size) {
99 DCHECK_GE(cache_size, 0);
100
101 cache_size_ = cache_size;
102 }
[email protected]e5ffd0e42009-09-11 21:30:56103
104 // Call to put the database in exclusive locking mode. There is no "back to
105 // normal" flag because of some additional requirements sqlite puts on this
[email protected]4ab952f2014-04-01 20:18:16106 // transaction (requires another access to the DB) and because we don't
[email protected]e5ffd0e42009-09-11 21:30:56107 // actually need it.
108 //
109 // Exclusive mode means that the database is not unlocked at the end of each
110 // transaction, which means there may be less time spent initializing the
111 // next transaction because it doesn't have to re-aquire locks.
112 //
[email protected]765b44502009-10-02 05:01:42113 // This must be called before Open() to have an effect.
[email protected]e5ffd0e42009-09-11 21:30:56114 void set_exclusive_locking() { exclusive_locking_ = true; }
115
shessa62504d2016-11-07 19:26:12116 // Call to use alternative status-tracking for mmap. Usually this is tracked
117 // in the meta table, but some databases have no meta table.
118 // TODO(shess): Maybe just have all databases use the alt option?
119 void set_mmap_alt_status() { mmap_alt_status_ = true; }
120
Victor Costan87cf8c72018-07-19 19:36:04121 // Opt out of memory-mapped file I/O.
shess7dbd4dee2015-10-06 17:39:16122 void set_mmap_disabled() { mmap_disabled_ = true; }
123
[email protected]c3881b372013-05-17 08:39:46124 // Set an error-handling callback. On errors, the error number (and
125 // statement, if available) will be passed to the callback.
126 //
127 // If no callback is set, the default action is to crash in debug
128 // mode or return failure in release mode.
Victor Costanc7e7f2e2018-07-18 20:07:55129 using ErrorCallback = base::RepeatingCallback<void(int, Statement*)>;
[email protected]c3881b372013-05-17 08:39:46130 void set_error_callback(const ErrorCallback& callback) {
131 error_callback_ = callback;
132 }
Victor Costan87cf8c72018-07-19 19:36:04133 bool has_error_callback() const { return !error_callback_.is_null(); }
134 void reset_error_callback() { error_callback_.Reset(); }
[email protected]c3881b372013-05-17 08:39:46135
Victor Costancfbfa602018-08-01 23:24:46136 // Set this to enable additional per-database histogramming. Must be called
shess58b8df82015-06-03 00:19:32137 // before Open().
138 void set_histogram_tag(const std::string& tag);
[email protected]c088e3a32013-01-03 23:59:14139
[email protected]210ce0af2013-05-15 09:10:39140 // Record a sparse UMA histogram sample under
141 // |name|+"."+|histogram_tag_|. If |histogram_tag_| is empty, no
142 // histogram is recorded.
143 void AddTaggedHistogram(const std::string& name, size_t sample) const;
144
shess58b8df82015-06-03 00:19:32145 // Track various API calls and results. Values corrospond to UMA
146 // histograms, do not modify, or add or delete other than directly
147 // before EVENT_MAX_VALUE.
148 enum Events {
149 // Number of statements run, either with sql::Statement or Execute*().
150 EVENT_STATEMENT_RUN = 0,
151
152 // Number of rows returned by statements run.
153 EVENT_STATEMENT_ROWS,
154
155 // Number of statements successfully run (all steps returned SQLITE_DONE or
156 // SQLITE_ROW).
157 EVENT_STATEMENT_SUCCESS,
158
159 // Number of statements run by Execute() or ExecuteAndReturnErrorCode().
160 EVENT_EXECUTE,
161
162 // Number of rows changed by autocommit statements.
163 EVENT_CHANGES_AUTOCOMMIT,
164
165 // Number of rows changed by statements in transactions.
166 EVENT_CHANGES,
167
168 // Count actual SQLite transaction statements (not including nesting).
169 EVENT_BEGIN,
170 EVENT_COMMIT,
171 EVENT_ROLLBACK,
172
shessd90aeea82015-11-13 02:24:31173 // Track success and failure in GetAppropriateMmapSize().
174 // GetAppropriateMmapSize() should record at most one of these per run. The
175 // case of mapping everything is not recorded.
176 EVENT_MMAP_META_MISSING, // No meta table present.
177 EVENT_MMAP_META_FAILURE_READ, // Failed reading meta table.
178 EVENT_MMAP_META_FAILURE_UPDATE, // Failed updating meta table.
179 EVENT_MMAP_VFS_FAILURE, // Failed to access VFS.
180 EVENT_MMAP_FAILED, // Failure from past run.
181 EVENT_MMAP_FAILED_NEW, // Read error in this run.
182 EVENT_MMAP_SUCCESS_NEW, // Read to EOF in this run.
183 EVENT_MMAP_SUCCESS_PARTIAL, // Read but did not reach EOF.
184 EVENT_MMAP_SUCCESS_NO_PROGRESS, // Read quota exhausted.
185
Victor Costancfbfa602018-08-01 23:24:46186 EVENT_MMAP_STATUS_FAILURE_READ, // Failure reading MmapStatus view.
187 EVENT_MMAP_STATUS_FAILURE_UPDATE, // Failure updating MmapStatus view.
shessa62504d2016-11-07 19:26:12188
shess58b8df82015-06-03 00:19:32189 // Leave this at the end.
190 // TODO(shess): |EVENT_MAX| causes compile fail on Windows.
191 EVENT_MAX_VALUE
192 };
193 void RecordEvent(Events event, size_t count);
Victor Costan87cf8c72018-07-19 19:36:04194 void RecordOneEvent(Events event) { RecordEvent(event, 1); }
shess58b8df82015-06-03 00:19:32195
[email protected]579446c2013-12-16 18:36:52196 // Run "PRAGMA integrity_check" and post each line of
197 // results into |messages|. Returns the success of running the
198 // statement - per the SQLite documentation, if no errors are found the
199 // call should succeed, and a single value "ok" should be in messages.
200 bool FullIntegrityCheck(std::vector<std::string>* messages);
201
202 // Runs "PRAGMA quick_check" and, unlike the FullIntegrityCheck method,
203 // interprets the results returning true if the the statement executes
204 // without error and results in a single "ok" value.
205 bool QuickIntegrityCheck() WARN_UNUSED_RESULT;
[email protected]80abf152013-05-22 12:42:42206
afakhry7c9abe72016-08-05 17:33:19207 // Meant to be called from a client error callback so that it's able to
208 // get diagnostic information about the database.
209 std::string GetDiagnosticInfo(int extended_error, Statement* statement);
210
ssid1f4e5362016-12-08 20:41:38211 // Reports memory usage into provided memory dump with the given name.
212 bool ReportMemoryUsage(base::trace_event::ProcessMemoryDump* pmd,
213 const std::string& dump_name);
dskibab4199f82016-11-21 20:16:13214
[email protected]e5ffd0e42009-09-11 21:30:56215 // Initialization ------------------------------------------------------------
216
Victor Costancfbfa602018-08-01 23:24:46217 // Initializes the SQL database for the given file, returning true if the
[email protected]35f2094c2009-12-29 22:46:55218 // file could be opened. You can call this or OpenInMemory.
[email protected]a3ef4832013-02-02 05:12:33219 bool Open(const base::FilePath& path) WARN_UNUSED_RESULT;
[email protected]765b44502009-10-02 05:01:42220
Victor Costancfbfa602018-08-01 23:24:46221 // Initializes the SQL database for a temporary in-memory database. There
[email protected]765b44502009-10-02 05:01:42222 // will be no associated file on disk, and the initial database will be
[email protected]35f2094c2009-12-29 22:46:55223 // empty. You can call this or Open.
[email protected]9fe37552011-12-23 17:07:20224 bool OpenInMemory() WARN_UNUSED_RESULT;
[email protected]765b44502009-10-02 05:01:42225
[email protected]8d409412013-07-19 18:25:30226 // Create a temporary on-disk database. The database will be
227 // deleted after close. This kind of database is similar to
228 // OpenInMemory() for small databases, but can page to disk if the
229 // database becomes large.
230 bool OpenTemporary() WARN_UNUSED_RESULT;
231
[email protected]41a97c812013-02-07 02:35:38232 // Returns true if the database has been successfully opened.
Victor Costan87cf8c72018-07-19 19:36:04233 bool is_open() const { return static_cast<bool>(db_); }
[email protected]e5ffd0e42009-09-11 21:30:56234
235 // Closes the database. This is automatically performed on destruction for
236 // you, but this allows you to close the database early. You must not call
237 // any other functions after closing it. It is permissable to call Close on
238 // an uninitialized or already-closed database.
239 void Close();
240
[email protected]8ada10f2013-12-21 00:42:34241 // Reads the first <cache-size>*<page-size> bytes of the file to prime the
242 // filesystem cache. This can be more efficient than faulting pages
243 // individually. Since this involves blocking I/O, it should only be used if
244 // the caller will immediately read a substantial amount of data from the
245 // database.
[email protected]e5ffd0e42009-09-11 21:30:56246 //
[email protected]8ada10f2013-12-21 00:42:34247 // TODO(shess): Design a set of histograms or an experiment to inform this
248 // decision. Preloading should almost always improve later performance
249 // numbers for this database simply because it pulls operations forward, but
250 // if the data isn't actually used soon then preloading just slows down
251 // everything else.
[email protected]e5ffd0e42009-09-11 21:30:56252 void Preload();
253
[email protected]be7995f12013-07-18 18:49:14254 // Try to trim the cache memory used by the database. If |aggressively| is
255 // true, this function will try to free all of the cache memory it can. If
256 // |aggressively| is false, this function will try to cut cache memory
257 // usage by half.
258 void TrimMemory(bool aggressively);
259
[email protected]8e0c01282012-04-06 19:36:49260 // Raze the database to the ground. This approximates creating a
261 // fresh database from scratch, within the constraints of SQLite's
262 // locking protocol (locks and open handles can make doing this with
263 // filesystem operations problematic). Returns true if the database
264 // was razed.
265 //
266 // false is returned if the database is locked by some other
Carlos Knippschild46800c9f2017-09-02 02:21:43267 // process.
[email protected]8e0c01282012-04-06 19:36:49268 //
269 // NOTE(shess): Raze() will DCHECK in the following situations:
270 // - database is not open.
Victor Costancfbfa602018-08-01 23:24:46271 // - the database has a transaction open.
[email protected]8e0c01282012-04-06 19:36:49272 // - a SQLite issue occurs which is structural in nature (like the
273 // statements used are broken).
274 // Since Raze() is expected to be called in unexpected situations,
275 // these all return false, since it is unlikely that the caller
276 // could fix them.
[email protected]6d42f152012-11-10 00:38:24277 //
278 // The database's page size is taken from |page_size_|. The
279 // existing database's |auto_vacuum| setting is lost (the
280 // possibility of corruption makes it unreliable to pull it from the
281 // existing database). To re-enable on the empty database requires
282 // running "PRAGMA auto_vacuum = 1;" then "VACUUM".
283 //
284 // NOTE(shess): For Android, SQLITE_DEFAULT_AUTOVACUUM is set to 1,
285 // so Raze() sets auto_vacuum to 1.
286 //
Victor Costancfbfa602018-08-01 23:24:46287 // TODO(shess): Raze() needs a database so cannot clear SQLITE_NOTADB.
288 // TODO(shess): Bake auto_vacuum into Database's API so it can
[email protected]6d42f152012-11-10 00:38:24289 // just pick up the default.
[email protected]8e0c01282012-04-06 19:36:49290 bool Raze();
[email protected]8e0c01282012-04-06 19:36:49291
[email protected]41a97c812013-02-07 02:35:38292 // Breaks all outstanding transactions (as initiated by
[email protected]8d409412013-07-19 18:25:30293 // BeginTransaction()), closes the SQLite database, and poisons the
Victor Costancfbfa602018-08-01 23:24:46294 // object so that all future operations against the Database (or
[email protected]8d409412013-07-19 18:25:30295 // its Statements) fail safely, without side effects.
[email protected]41a97c812013-02-07 02:35:38296 //
[email protected]8d409412013-07-19 18:25:30297 // This is intended as an alternative to Close() in error callbacks.
298 // Close() should still be called at some point.
299 void Poison();
300
301 // Raze() the database and Poison() the handle. Returns the return
302 // value from Raze().
303 // TODO(shess): Rename to RazeAndPoison().
[email protected]41a97c812013-02-07 02:35:38304 bool RazeAndClose();
305
Victor Costancfbfa602018-08-01 23:24:46306 // Delete the underlying database files associated with |path|. This should be
307 // used on a database which is not opened by any Database instance. Open
308 // Database instances pointing to the database can cause odd results or
309 // corruption (for instance if a hot journal is deleted but the associated
310 // database is not).
[email protected]8d2e39e2013-06-24 05:55:08311 //
312 // Returns true if the database file and associated journals no
313 // longer exist, false otherwise. If the database has never
314 // existed, this will return true.
315 static bool Delete(const base::FilePath& path);
316
[email protected]e5ffd0e42009-09-11 21:30:56317 // Transactions --------------------------------------------------------------
318
319 // Transaction management. We maintain a virtual transaction stack to emulate
320 // nested transactions since sqlite can't do nested transactions. The
321 // limitation is you can't roll back a sub transaction: if any transaction
322 // fails, all transactions open will also be rolled back. Any nested
323 // transactions after one has rolled back will return fail for Begin(). If
324 // Begin() fails, you must not call Commit or Rollback().
325 //
326 // Normally you should use sql::Transaction to manage a transaction, which
327 // will scope it to a C++ context.
328 bool BeginTransaction();
329 void RollbackTransaction();
330 bool CommitTransaction();
331
[email protected]8d409412013-07-19 18:25:30332 // Rollback all outstanding transactions. Use with care, there may
333 // be scoped transactions on the stack.
334 void RollbackAllTransactions();
335
[email protected]e5ffd0e42009-09-11 21:30:56336 // Returns the current transaction nesting, which will be 0 if there are
337 // no open transactions.
338 int transaction_nesting() const { return transaction_nesting_; }
339
[email protected]8d409412013-07-19 18:25:30340 // Attached databases---------------------------------------------------------
341
Victor Costan7f6abbbe2018-07-29 02:57:27342 // SQLite supports attaching multiple database files to a single connection.
[email protected]8d409412013-07-19 18:25:30343 //
Victor Costan7f6abbbe2018-07-29 02:57:27344 // Attach the database in |other_db_path| to the current connection under
345 // |attachment_point|. |attachment_point| must only contain characters from
346 // [a-zA-Z0-9_].
Victor Costan8a87f7e52017-11-10 01:29:30347 //
348 // On the SQLite version shipped with Chrome (3.21+, Oct 2017), databases can
349 // be attached while a transaction is opened. However, these databases cannot
Victor Costan70bedf22018-07-18 21:21:14350 // be detached until the transaction is committed or aborted.
Victor Costan7f6abbbe2018-07-29 02:57:27351 //
352 // These APIs are only exposed for use in recovery. They are extremely subtle
353 // and are not useful for features built on top of //sql.
[email protected]8d409412013-07-19 18:25:30354 bool AttachDatabase(const base::FilePath& other_db_path,
Victor Costan7f6abbbe2018-07-29 02:57:27355 const char* attachment_point,
356 InternalApiToken);
357 bool DetachDatabase(const char* attachment_point, InternalApiToken);
[email protected]8d409412013-07-19 18:25:30358
[email protected]e5ffd0e42009-09-11 21:30:56359 // Statements ----------------------------------------------------------------
360
361 // Executes the given SQL string, returning true on success. This is
362 // normally used for simple, 1-off statements that don't take any bound
363 // parameters and don't return any data (e.g. CREATE TABLE).
[email protected]9fe37552011-12-23 17:07:20364 //
[email protected]eff1fa522011-12-12 23:50:59365 // This will DCHECK if the |sql| contains errors.
[email protected]9fe37552011-12-23 17:07:20366 //
367 // Do not use ignore_result() to ignore all errors. Use
368 // ExecuteAndReturnErrorCode() and ignore only specific errors.
369 bool Execute(const char* sql) WARN_UNUSED_RESULT;
[email protected]e5ffd0e42009-09-11 21:30:56370
[email protected]eff1fa522011-12-12 23:50:59371 // Like Execute(), but returns the error code given by SQLite.
[email protected]9fe37552011-12-23 17:07:20372 int ExecuteAndReturnErrorCode(const char* sql) WARN_UNUSED_RESULT;
[email protected]eff1fa522011-12-12 23:50:59373
[email protected]e5ffd0e42009-09-11 21:30:56374 // Returns a statement for the given SQL using the statement cache. It can
375 // take a nontrivial amount of work to parse and compile a statement, so
376 // keeping commonly-used ones around for future use is important for
377 // performance.
378 //
[email protected]eff1fa522011-12-12 23:50:59379 // If the |sql| has an error, an invalid, inert StatementRef is returned (and
380 // the code will crash in debug). The caller must deal with this eventuality,
381 // either by checking validity of the |sql| before calling, by correctly
382 // handling the return of an inert statement, or both.
[email protected]e5ffd0e42009-09-11 21:30:56383 //
384 // The StatementID and the SQL must always correspond to one-another. The
385 // ID is the lookup into the cache, so crazy things will happen if you use
386 // different SQL with the same ID.
387 //
388 // You will normally use the SQL_FROM_HERE macro to generate a statement
389 // ID associated with the current line of code. This gives uniqueness without
390 // you having to manage unique names. See StatementID above for more.
391 //
392 // Example:
Victor Costancfbfa602018-08-01 23:24:46393 // sql::Statement stmt(database_.GetCachedStatement(
[email protected]3273dce2010-01-27 16:08:08394 // SQL_FROM_HERE, "SELECT * FROM foo"));
[email protected]e5ffd0e42009-09-11 21:30:56395 // if (!stmt)
396 // return false; // Error creating statement.
Victor Costan12daa3ac92018-07-19 01:05:58397 scoped_refptr<StatementRef> GetCachedStatement(StatementID id,
[email protected]e5ffd0e42009-09-11 21:30:56398 const char* sql);
399
[email protected]eff1fa522011-12-12 23:50:59400 // Used to check a |sql| statement for syntactic validity. If the statement is
401 // valid SQL, returns true.
402 bool IsSQLValid(const char* sql);
403
[email protected]e5ffd0e42009-09-11 21:30:56404 // Returns a non-cached statement for the given SQL. Use this for SQL that
405 // is only executed once or only rarely (there is overhead associated with
406 // keeping a statement cached).
407 //
408 // See GetCachedStatement above for examples and error information.
409 scoped_refptr<StatementRef> GetUniqueStatement(const char* sql);
410
411 // Info querying -------------------------------------------------------------
412
shessa62504d2016-11-07 19:26:12413 // Returns true if the given structure exists. Instead of test-then-create,
414 // callers should almost always prefer the "IF NOT EXISTS" version of the
415 // CREATE statement.
[email protected]e2cadec82011-12-13 02:00:53416 bool DoesIndexExist(const char* index_name) const;
shessa62504d2016-11-07 19:26:12417 bool DoesTableExist(const char* table_name) const;
418 bool DoesViewExist(const char* table_name) const;
[email protected]e2cadec82011-12-13 02:00:53419
[email protected]e5ffd0e42009-09-11 21:30:56420 // Returns true if a column with the given name exists in the given table.
[email protected]1ed78a32009-09-15 20:24:17421 bool DoesColumnExist(const char* table_name, const char* column_name) const;
[email protected]e5ffd0e42009-09-11 21:30:56422
423 // Returns sqlite's internal ID for the last inserted row. Valid only
424 // immediately after an insert.
tfarina720d4f32015-05-11 22:31:26425 int64_t GetLastInsertRowId() const;
[email protected]e5ffd0e42009-09-11 21:30:56426
[email protected]1ed78a32009-09-15 20:24:17427 // Returns sqlite's count of the number of rows modified by the last
428 // statement executed. Will be 0 if no statement has executed or the database
429 // is closed.
430 int GetLastChangeCount() const;
431
[email protected]e5ffd0e42009-09-11 21:30:56432 // Errors --------------------------------------------------------------------
433
434 // Returns the error code associated with the last sqlite operation.
435 int GetErrorCode() const;
436
[email protected]767718e52010-09-21 23:18:49437 // Returns the errno associated with GetErrorCode(). See
438 // SQLITE_LAST_ERRNO in SQLite documentation.
439 int GetLastErrno() const;
440
[email protected]e5ffd0e42009-09-11 21:30:56441 // Returns a pointer to a statically allocated string associated with the
442 // last sqlite operation.
443 const char* GetErrorMessage() const;
444
[email protected]92cd00a2013-08-16 11:09:58445 // Return a reproducible representation of the schema equivalent to
446 // running the following statement at a sqlite3 command-line:
447 // SELECT type, name, tbl_name, sql FROM sqlite_master ORDER BY 1, 2, 3, 4;
448 std::string GetSchema() const;
449
shess976814402016-06-21 06:56:25450 // Returns |true| if there is an error expecter (see SetErrorExpecter), and
451 // that expecter returns |true| when passed |error|. Clients which provide an
452 // |error_callback| should use IsExpectedSqliteError() to check for unexpected
Sigurdur Asgeirsson8d82bd02017-09-25 21:05:52453 // errors; if one is detected, DLOG(DCHECK) is generally appropriate (see
shess976814402016-06-21 06:56:25454 // OnSqliteError implementation).
455 static bool IsExpectedSqliteError(int error);
[email protected]74cdede2013-09-25 05:39:57456
shessc8cd2a162015-10-22 20:30:46457 // Collect various diagnostic information and post a crash dump to aid
458 // debugging. Dump rate per database is limited to prevent overwhelming the
459 // crash server.
460 void ReportDiagnosticInfo(int extended_error, Statement* stmt);
461
Victor Costan87cf8c72018-07-19 19:36:04462 // Helper to return the current time from the time source.
463 base::TimeTicks NowTicks() const { return clock_->NowTicks(); }
464
465 // Intended for tests to inject a mock time source.
466 //
467 // Inlined to avoid generating code in the production binary.
468 inline void set_clock_for_testing(std::unique_ptr<base::TickClock> clock) {
469 clock_ = std::move(clock);
470 }
471
Victor Costance678e72018-07-24 10:25:00472 // Computes the path of a database's rollback journal.
473 //
474 // The journal file is created at the beginning of the database's first
475 // transaction. The file may be removed and re-created between transactions,
476 // depending on whether the database is opened in exclusive mode, and on
477 // configuration options. The journal file does not exist when the database
478 // operates in WAL mode.
479 //
480 // This is intended for internal use and tests. To preserve our ability to
481 // iterate on our SQLite configuration, features must avoid relying on
482 // the existence of specific files.
483 static base::FilePath JournalPath(const base::FilePath& db_path);
484
485 // Computes the path of a database's write-ahead log (WAL).
486 //
487 // The WAL file exists while a database is opened in WAL mode.
488 //
489 // This is intended for internal use and tests. To preserve our ability to
490 // iterate on our SQLite configuration, features must avoid relying on
491 // the existence of specific files.
492 static base::FilePath WriteAheadLogPath(const base::FilePath& db_path);
493
494 // Computes the path of a database's shared memory (SHM) file.
495 //
496 // The SHM file is used to coordinate between multiple processes using the
497 // same database in WAL mode. Thus, this file only exists for databases using
498 // WAL and not opened in exclusive mode.
499 //
500 // This is intended for internal use and tests. To preserve our ability to
501 // iterate on our SQLite configuration, features must avoid relying on
502 // the existence of specific files.
503 static base::FilePath SharedMemoryFilePath(const base::FilePath& db_path);
504
Victor Costan7f6abbbe2018-07-29 02:57:27505 // Default page size for newly created databases.
506 //
507 // Guaranteed to match SQLITE_DEFAULT_PAGE_SIZE.
508 static constexpr int kDefaultPageSize = 4096;
[email protected]8d409412013-07-19 18:25:30509
Victor Costan7f6abbbe2018-07-29 02:57:27510 // Internal state accessed by other classes in //sql.
511 sqlite3* db(InternalApiToken) const { return db_; }
512 bool poisoned(InternalApiToken) const { return poisoned_; }
513
514 private:
shess976814402016-06-21 06:56:25515 // Allow test-support code to set/reset error expecter.
516 friend class test::ScopedErrorExpecter;
[email protected]4350e322013-06-18 22:18:10517
[email protected]eff1fa522011-12-12 23:50:59518 // Statement accesses StatementRef which we don't want to expose to everybody
[email protected]e5ffd0e42009-09-11 21:30:56519 // (they should go through Statement).
520 friend class Statement;
521
Victor Costancfbfa602018-08-01 23:24:46522 friend class DatabaseTestPeer;
Victor Costan7f6abbbe2018-07-29 02:57:27523
shess58b8df82015-06-03 00:19:32524 friend class test::ScopedCommitHook;
525 friend class test::ScopedScalarFunction;
526 friend class test::ScopedMockTimeSource;
527
Victor Costancfbfa602018-08-01 23:24:46528 FRIEND_TEST_ALL_PREFIXES(SQLDatabaseTest, CachedStatement);
529 FRIEND_TEST_ALL_PREFIXES(SQLDatabaseTest, CollectDiagnosticInfo);
530 FRIEND_TEST_ALL_PREFIXES(SQLDatabaseTest, GetAppropriateMmapSize);
531 FRIEND_TEST_ALL_PREFIXES(SQLDatabaseTest, GetAppropriateMmapSizeAltStatus);
532 FRIEND_TEST_ALL_PREFIXES(SQLDatabaseTest, OnMemoryDump);
533 FRIEND_TEST_ALL_PREFIXES(SQLDatabaseTest, RegisterIntentToUpload);
shessf7fcc452017-04-19 22:10:41534 FRIEND_TEST_ALL_PREFIXES(SQLiteFeaturesTest, WALNoClose);
shessc8cd2a162015-10-22 20:30:46535
[email protected]765b44502009-10-02 05:01:42536 // Internal initialize function used by both Init and InitInMemory. The file
537 // name is always 8 bits since we want to use the 8-bit version of
538 // sqlite3_open. The string can also be sqlite's special ":memory:" string.
[email protected]fed734a2013-07-17 04:45:13539 //
540 // |retry_flag| controls retrying the open if the error callback
541 // addressed errors using RazeAndClose().
Victor Costancfbfa602018-08-01 23:24:46542 enum Retry { NO_RETRY = 0, RETRY_ON_POISON };
[email protected]fed734a2013-07-17 04:45:13543 bool OpenInternal(const std::string& file_name, Retry retry_flag);
[email protected]765b44502009-10-02 05:01:42544
[email protected]41a97c812013-02-07 02:35:38545 // Internal close function used by Close() and RazeAndClose().
546 // |forced| indicates that orderly-shutdown checks should not apply.
547 void CloseInternal(bool forced);
548
[email protected]35f7e5392012-07-27 19:54:50549 // Check whether the current thread is allowed to make IO calls, but only
550 // if database wasn't open in memory. Function is inlined to be a no-op in
551 // official build.
shessc8cd2a162015-10-22 20:30:46552 void AssertIOAllowed() const {
[email protected]35f7e5392012-07-27 19:54:50553 if (!in_memory_)
Francois Doray66bdfd82017-10-20 13:50:37554 base::AssertBlockingAllowed();
[email protected]35f7e5392012-07-27 19:54:50555 }
556
shessa62504d2016-11-07 19:26:12557 // Internal helper for Does*Exist() functions.
558 bool DoesSchemaItemExist(const char* name, const char* type) const;
[email protected]e2cadec82011-12-13 02:00:53559
shess976814402016-06-21 06:56:25560 // Accessors for global error-expecter, for injecting behavior during tests.
561 // See test/scoped_error_expecter.h.
Victor Costanc7e7f2e2018-07-18 20:07:55562 using ErrorExpecterCallback = base::RepeatingCallback<bool(int)>;
shess976814402016-06-21 06:56:25563 static ErrorExpecterCallback* current_expecter_cb_;
564 static void SetErrorExpecter(ErrorExpecterCallback* expecter);
565 static void ResetErrorExpecter();
[email protected]4350e322013-06-18 22:18:10566
[email protected]e5ffd0e42009-09-11 21:30:56567 // A StatementRef is a refcounted wrapper around a sqlite statement pointer.
568 // Refcounting allows us to give these statements out to sql::Statement
569 // objects while also optionally maintaining a cache of compiled statements
570 // by just keeping a refptr to these objects.
571 //
572 // A statement ref can be valid, in which case it can be used, or invalid to
573 // indicate that the statement hasn't been created yet, has an error, or has
574 // been destroyed.
575 //
Victor Costancfbfa602018-08-01 23:24:46576 // The Database may revoke a StatementRef in some error cases, so callers
[email protected]e5ffd0e42009-09-11 21:30:56577 // should always check validity before using.
[email protected]601dc6a2011-11-12 01:14:23578 class SQL_EXPORT StatementRef : public base::RefCounted<StatementRef> {
[email protected]e5ffd0e42009-09-11 21:30:56579 public:
Victor Costan3b02cdf2018-07-18 00:39:56580 REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE();
581
Victor Costancfbfa602018-08-01 23:24:46582 // |database| is the sql::Database instance associated with
[email protected]41a97c812013-02-07 02:35:38583 // the statement, and is used for tracking outstanding statements
Victor Costanbd623112018-07-18 04:17:27584 // and for error handling. Set to nullptr for invalid or untracked
585 // refs. |stmt| is the actual statement, and should only be null
[email protected]41a97c812013-02-07 02:35:38586 // to create an invalid ref. |was_valid| indicates whether the
587 // statement should be considered valid for diagnistic purposes.
Victor Costancfbfa602018-08-01 23:24:46588 // |was_valid| can be true for a null |stmt| if the Database has
[email protected]41a97c812013-02-07 02:35:38589 // been forcibly closed by an error handler.
Victor Costancfbfa602018-08-01 23:24:46590 StatementRef(Database* database, sqlite3_stmt* stmt, bool was_valid);
[email protected]e5ffd0e42009-09-11 21:30:56591
592 // When true, the statement can be used.
593 bool is_valid() const { return !!stmt_; }
594
[email protected]41a97c812013-02-07 02:35:38595 // When true, the statement is either currently valid, or was
Victor Costancfbfa602018-08-01 23:24:46596 // previously valid but the database was forcibly closed. Used
[email protected]41a97c812013-02-07 02:35:38597 // for diagnostic checks.
598 bool was_valid() const { return was_valid_; }
599
Victor Costancfbfa602018-08-01 23:24:46600 // If we've not been linked to a database, this will be null.
Victor Costanbd623112018-07-18 04:17:27601 //
Victor Costancfbfa602018-08-01 23:24:46602 // TODO(shess): database_ can be nullptr in case of
Victor Costanbd623112018-07-18 04:17:27603 // GetUntrackedStatement(), which prevents Statement::OnError() from
604 // forwarding errors.
Victor Costancfbfa602018-08-01 23:24:46605 Database* database() const { return database_; }
[email protected]e5ffd0e42009-09-11 21:30:56606
607 // Returns the sqlite statement if any. If the statement is not active,
Victor Costanbd623112018-07-18 04:17:27608 // this will return nullptr.
[email protected]e5ffd0e42009-09-11 21:30:56609 sqlite3_stmt* stmt() const { return stmt_; }
610
Victor Costanbd623112018-07-18 04:17:27611 // Destroys the compiled statement and sets it to nullptr. The statement
612 // will no longer be active. |forced| is used to indicate if
Victor Costancfbfa602018-08-01 23:24:46613 // orderly-shutdown checks should apply (see Database::RazeAndClose()).
[email protected]41a97c812013-02-07 02:35:38614 void Close(bool forced);
[email protected]e5ffd0e42009-09-11 21:30:56615
[email protected]35f7e5392012-07-27 19:54:50616 // Check whether the current thread is allowed to make IO calls, but only
617 // if database wasn't open in memory.
Victor Costanc7e7f2e2018-07-18 20:07:55618 void AssertIOAllowed() const {
Victor Costancfbfa602018-08-01 23:24:46619 if (database_)
620 database_->AssertIOAllowed();
Victor Costanc7e7f2e2018-07-18 20:07:55621 }
[email protected]35f7e5392012-07-27 19:54:50622
[email protected]e5ffd0e42009-09-11 21:30:56623 private:
[email protected]877d55d2009-11-05 21:53:08624 friend class base::RefCounted<StatementRef>;
625
626 ~StatementRef();
627
Victor Costancfbfa602018-08-01 23:24:46628 Database* database_;
[email protected]e5ffd0e42009-09-11 21:30:56629 sqlite3_stmt* stmt_;
[email protected]41a97c812013-02-07 02:35:38630 bool was_valid_;
[email protected]e5ffd0e42009-09-11 21:30:56631
632 DISALLOW_COPY_AND_ASSIGN(StatementRef);
633 };
634 friend class StatementRef;
635
636 // Executes a rollback statement, ignoring all transaction state. Used
637 // internally in the transaction management code.
638 void DoRollback();
639
640 // Called by a StatementRef when it's being created or destroyed. See
641 // open_statements_ below.
642 void StatementRefCreated(StatementRef* ref);
643 void StatementRefDeleted(StatementRef* ref);
644
[email protected]2f496b42013-09-26 18:36:58645 // Called when a sqlite function returns an error, which is passed
646 // as |err|. The return value is the error code to be reflected
Victor Costanbd623112018-07-18 04:17:27647 // back to client code. |stmt| is non-null if the error relates to
648 // an sql::Statement instance. |sql| is non-nullptr if the error
[email protected]2f496b42013-09-26 18:36:58649 // relates to non-statement sql code (Execute, for instance). Both
Victor Costanbd623112018-07-18 04:17:27650 // can be null, but both should never be set.
[email protected]2f496b42013-09-26 18:36:58651 // NOTE(shess): Originally, the return value was intended to allow
652 // error handlers to transparently convert errors into success.
653 // Unfortunately, transactions are not generally restartable, so
654 // this did not work out.
shess9e77283d2016-06-13 23:53:20655 int OnSqliteError(int err, Statement* stmt, const char* sql) const;
[email protected]faa604e2009-09-25 22:38:59656
[email protected]5b96f3772010-09-28 16:30:57657 // Like |Execute()|, but retries if the database is locked.
Victor Costancfbfa602018-08-01 23:24:46658 bool ExecuteWithTimeout(const char* sql,
659 base::TimeDelta ms_timeout) WARN_UNUSED_RESULT;
[email protected]5b96f3772010-09-28 16:30:57660
shess9e77283d2016-06-13 23:53:20661 // Implementation helper for GetUniqueStatement() and GetUntrackedStatement().
662 // |tracking_db| is the db the resulting ref should register with for
Victor Costanbd623112018-07-18 04:17:27663 // outstanding statement tracking, which should be |this| to track or null to
shess9e77283d2016-06-13 23:53:20664 // not track.
Victor Costancfbfa602018-08-01 23:24:46665 scoped_refptr<StatementRef> GetStatementImpl(sql::Database* tracking_db,
666 const char* sql) const;
shess9e77283d2016-06-13 23:53:20667
668 // Helper for implementing const member functions. Like GetUniqueStatement(),
669 // except the StatementRef is not entered into |open_statements_|, so an
670 // outstanding StatementRef from this function can block closing the database.
671 // The StatementRef will not call OnSqliteError(), because that can call
672 // |error_callback_| which can close the database.
[email protected]2eec0a22012-07-24 01:59:58673 scoped_refptr<StatementRef> GetUntrackedStatement(const char* sql) const;
674
Victor Costancfbfa602018-08-01 23:24:46675 bool IntegrityCheckHelper(const char* pragma_sql,
676 std::vector<std::string>* messages)
677 WARN_UNUSED_RESULT;
[email protected]579446c2013-12-16 18:36:52678
shess58b8df82015-06-03 00:19:32679 // Record time spent executing explicit COMMIT statements.
680 void RecordCommitTime(const base::TimeDelta& delta);
681
682 // Record time in DML (Data Manipulation Language) statements such as INSERT
683 // or UPDATE outside of an explicit transaction. Due to implementation
684 // limitations time spent on DDL (Data Definition Language) statements such as
685 // ALTER and CREATE is not included.
686 void RecordAutoCommitTime(const base::TimeDelta& delta);
687
688 // Record all time spent on updating the database. This includes CommitTime()
689 // and AutoCommitTime(), plus any time spent spilling to the journal if
690 // transactions do not fit in cache.
691 void RecordUpdateTime(const base::TimeDelta& delta);
692
693 // Record all time spent running statements, including time spent doing
694 // updates and time spent on read-only queries.
695 void RecordQueryTime(const base::TimeDelta& delta);
696
697 // Record |delta| as query time if |read_only| (from sqlite3_stmt_readonly) is
698 // true, autocommit time if the database is not in a transaction, or update
699 // time if the database is in a transaction. Also records change count to
700 // EVENT_CHANGES_AUTOCOMMIT or EVENT_CHANGES_COMMIT.
701 void RecordTimeAndChanges(const base::TimeDelta& delta, bool read_only);
702
shess7dbd4dee2015-10-06 17:39:16703 // Release page-cache memory if memory-mapped I/O is enabled and the database
704 // was changed. Passing true for |implicit_change_performed| allows
705 // overriding the change detection for cases like DDL (CREATE, DROP, etc),
706 // which do not participate in the total-rows-changed tracking.
707 void ReleaseCacheMemoryIfNeeded(bool implicit_change_performed);
708
shessc8cd2a162015-10-22 20:30:46709 // Returns the results of sqlite3_db_filename(), which should match the path
710 // passed to Open().
711 base::FilePath DbPath() const;
712
713 // Helper to prevent uploading too many diagnostic dumps for a given database,
714 // since every dump will likely show the same problem. Returns |true| if this
715 // function was not previously called for this database, and the persistent
716 // storage which tracks state was updated.
717 //
718 // |false| is returned if the function was previously called for this
719 // database, even across restarts. |false| is also returned if the persistent
720 // storage cannot be updated, possibly indicating problems requiring user or
721 // admin intervention, such as filesystem corruption or disk full. |false| is
722 // also returned if the persistent storage contains invalid data or is not
723 // readable.
724 //
725 // TODO(shess): It would make sense to reset the persistent state if the
726 // database is razed or recovered, or if the diagnostic code adds new
727 // capabilities.
728 bool RegisterIntentToUpload() const;
729
730 // Helper to collect diagnostic info for a corrupt database.
731 std::string CollectCorruptionInfo();
732
733 // Helper to collect diagnostic info for errors.
734 std::string CollectErrorInfo(int error, Statement* stmt) const;
735
shessd90aeea82015-11-13 02:24:31736 // Calculates a value appropriate to pass to "PRAGMA mmap_size = ". So errors
737 // can make it unsafe to map a file, so the file is read using regular I/O,
738 // with any errors causing 0 (don't map anything) to be returned. If the
739 // entire file is read without error, a large value is returned which will
740 // allow the entire file to be mapped in most cases.
741 //
742 // Results are recorded in the database's meta table for future reference, so
743 // the file should only be read through once.
744 size_t GetAppropriateMmapSize();
745
shessa62504d2016-11-07 19:26:12746 // Helpers for GetAppropriateMmapSize().
747 bool GetMmapAltStatus(int64_t* status);
748 bool SetMmapAltStatus(int64_t status);
749
Victor Costanbd623112018-07-18 04:17:27750 // The actual sqlite database. Will be null before Init has been called or if
[email protected]e5ffd0e42009-09-11 21:30:56751 // Init resulted in an error.
752 sqlite3* db_;
753
754 // Parameters we'll configure in sqlite before doing anything else. Zero means
755 // use the default value.
756 int page_size_;
757 int cache_size_;
758 bool exclusive_locking_;
759
Victor Costanc7e7f2e2018-07-18 20:07:55760 // Holds references to all cached statements so they remain active.
761 //
762 // flat_map is appropriate here because the codebase has ~400 cached
763 // statements, and each statement is at most one insertion in the map
764 // throughout a process' lifetime.
765 base::flat_map<StatementID, scoped_refptr<StatementRef>> statement_cache_;
[email protected]e5ffd0e42009-09-11 21:30:56766
767 // A list of all StatementRefs we've given out. Each ref must register with
768 // us when it's created or destroyed. This allows us to potentially close
769 // any open statements when we encounter an error.
Victor Costanc7e7f2e2018-07-18 20:07:55770 std::set<StatementRef*> open_statements_;
[email protected]e5ffd0e42009-09-11 21:30:56771
772 // Number of currently-nested transactions.
773 int transaction_nesting_;
774
775 // True if any of the currently nested transactions have been rolled back.
776 // When we get to the outermost transaction, this will determine if we do
777 // a rollback instead of a commit.
778 bool needs_rollback_;
779
[email protected]35f7e5392012-07-27 19:54:50780 // True if database is open with OpenInMemory(), False if database is open
781 // with Open().
782 bool in_memory_;
783
Victor Costancfbfa602018-08-01 23:24:46784 // |true| if the Database was closed using RazeAndClose(). Used
[email protected]41a97c812013-02-07 02:35:38785 // to enable diagnostics to distinguish calls to never-opened
786 // databases (incorrect use of the API) from calls to once-valid
787 // databases.
788 bool poisoned_;
789
shessa62504d2016-11-07 19:26:12790 // |true| to use alternate storage for tracking mmap status.
791 bool mmap_alt_status_;
792
Victor Costancfbfa602018-08-01 23:24:46793 // |true| if SQLite memory-mapped I/O is not desired for this database.
shess7dbd4dee2015-10-06 17:39:16794 bool mmap_disabled_;
795
Victor Costancfbfa602018-08-01 23:24:46796 // |true| if SQLite memory-mapped I/O was enabled for this database.
shess7dbd4dee2015-10-06 17:39:16797 // Used by ReleaseCacheMemoryIfNeeded().
798 bool mmap_enabled_;
799
800 // Used by ReleaseCacheMemoryIfNeeded() to track if new changes have happened
801 // since memory was last released.
802 int total_changes_at_last_release_;
803
[email protected]c3881b372013-05-17 08:39:46804 ErrorCallback error_callback_;
805
[email protected]210ce0af2013-05-15 09:10:39806 // Tag for auxiliary histograms.
807 std::string histogram_tag_;
[email protected]c088e3a32013-01-03 23:59:14808
shess58b8df82015-06-03 00:19:32809 // Linear histogram for RecordEvent().
810 base::HistogramBase* stats_histogram_;
811
812 // Histogram for tracking time taken in commit.
813 base::HistogramBase* commit_time_histogram_;
814
815 // Histogram for tracking time taken in autocommit updates.
816 base::HistogramBase* autocommit_time_histogram_;
817
818 // Histogram for tracking time taken in updates (including commit and
819 // autocommit).
820 base::HistogramBase* update_time_histogram_;
821
822 // Histogram for tracking time taken in all queries.
823 base::HistogramBase* query_time_histogram_;
824
825 // Source for timing information, provided to allow tests to inject time
826 // changes.
Victor Costan87cf8c72018-07-19 19:36:04827 std::unique_ptr<base::TickClock> clock_;
shess58b8df82015-06-03 00:19:32828
ssid3be5b1ec2016-01-13 14:21:57829 // Stores the dump provider object when db is open.
Victor Costancfbfa602018-08-01 23:24:46830 std::unique_ptr<DatabaseMemoryDumpProvider> memory_dump_provider_;
ssid3be5b1ec2016-01-13 14:21:57831
Victor Costancfbfa602018-08-01 23:24:46832 DISALLOW_COPY_AND_ASSIGN(Database);
[email protected]e5ffd0e42009-09-11 21:30:56833};
834
835} // namespace sql
836
Victor Costancfbfa602018-08-01 23:24:46837#endif // SQL_DATABASE_H_