0
Commit Graph

3 Commits

Author SHA1 Message Date
Victor Costan
455989b011 sqlite: Rewrite tests for custom recovery code.
Our largest SQLite patch,
0001-Virtual-table-supporting-recovery-of-corrupted-datab.patch,
contains the implementation of a virtual table extension that contains
custom recovery logic. The automated tests for the extension use
SQLite's infrastructure base on Tcl, and don't run on CQ.

This CL rewrites the tests to use C++ and //sql, so they can be run on
CQ. A follow-up CL will replace the recovery code with a rewritten
version that lives in the Chromium tree.

This CL also adds a test covering the edge cases of the recovery code's
SQLite varint decoding logic, which has proven useful for debugging the
rewritten recovery code.

Bug: 945204
Change-Id: I50c6cbf6f94dc698915e6fb4925769051396cb4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1603604
Reviewed-by: Chris Mumford <cmumford@google.com>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659225}
2019-05-13 21:43:15 +00:00
Victor Costan
cfbfa60d86 sql: Rename sql::Connection to sql::Database.
sql::Connection represents an opened SQLite database. Pedantically, the
name is correct. At the same time, it is inconsistent with the naming
convention of similar software -- IndexedDB, LevelDB, and WebSQL all use
a derivative of "Database" (IDBDatabase, DB, WindowDatabase) to name
this concept. Furthermore, most sql::Connection instances have names
like "db" and "database".

This CL renames the class to sql::Database, reducing the cognitive load
caused by dissonances like "sql::Connection db_".

TBR=mpearson

Bug: none
Change-Id: I8abf34016bca236b6e38a772f5848e7ea9bf1c59
Reviewed-on: https://chromium-review.googlesource.com/1157876
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579990}
2018-08-01 23:24:46 +00:00
Victor Costan
7f6abbbec2 sql: Restrict recovery-only API in Connection with passkeys.
This CL uses the passkey idiom recommended in https://abseil.io/tips/134
to restrict APIs in sql::Connection to sql::Recovery. Test APIs are
exposed via a peer class, following recommendations in the same tip.

This CL also exposes sql::Connection::page_size(). Asides from being
used in sql::Recovery, this can be useful in unit tests. It is worth
noting that set_page_size() is a widely-used part of the sql::Connection
API, so page_size() does not introduce a new concept.

Last, in order to make page_size() intuitive, this CL removes the
possibility of having sql::Connection::page_size_ be zero. Instead,
SQLite is configured with an explicit SQLITE_DEFAULT_PAGE_SIZE (matching
the current default), and page_size_ is initialized with
sql::Connection::kDefaultPageSize, which is guaranteed to match the
SQLite configuration.

Bug: none
Change-Id: I555a0bcf02f12ee006bbfc1a91080d7c0b8845d4
Reviewed-on: https://chromium-review.googlesource.com/1146768
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Chris Mumford <cmumford@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578945}
2018-07-29 02:57:27 +00:00