Commit a0905fab authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

sql: Make //sql/vfs_wrapper.cc compatible with SQLITE_OMIT_DEPRECATED.

Our SQLite VFS [1] wrapper implementation unconditionally wraps
xCurrentTime(). However, when SQLite is compiled with the
SQLITE_OMIT_DEPRECATED option [2], xCurrentTime() is null for the VFS
implementations that ship with SQLite, because xCurrentTime() was
deprecated in favor of xCurrentTimeInt64().

This CL replaces the unconditional wrapper with a conditional wrapper.
This ensures that our VFS wrapper exposes an xCurrentTimeInt64()
implementation when used with a modern SQLite library (like the one
bundled with Chromium), and an xCurrentTime() implementation when using
an older SQLite version (which might be the case when using the library
bundled with the operating system).

[1] https://www.sqlite.org/c3ref/vfs.html
[2] https://www.sqlite.org/compile.html#omit_deprecated

Bug: 807093
Change-Id: Id26cc4517a1a23692e7860ed620348c027db990f
Reviewed-on: https://chromium-review.googlesource.com/892484Reviewed-by: default avatarChris Mumford <cmumford@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532969}
parent 39745234
......@@ -498,7 +498,9 @@ sqlite3_vfs* VFSWrapper() {
wrapper_vfs->xDlClose = &DlClose;
wrapper_vfs->xRandomness = &Randomness;
wrapper_vfs->xSleep = &Sleep;
wrapper_vfs->xCurrentTime = &CurrentTime;
// |xCurrentTime| is null when SQLite is built with SQLITE_OMIT_DEPRECATED.
wrapper_vfs->xCurrentTime =
(wrapped_vfs->xCurrentTime ? &CurrentTime : nullptr);
wrapper_vfs->xGetLastError = &GetLastError;
// The methods above are in version 1 of sqlite_vfs.
// There were VFS implementations with nullptr for |xCurrentTimeInt64|.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment