aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2020-05-02 04:08:23 +0000
committerdrh <drh@noemail.net>2020-05-02 04:08:23 +0000
commit278b0517d88d4150830a4ee2c628a55da40d186d (patch)
tree323b5c0a7b6dce1ce7b9ded36f09b5e5fac76712 /src
parent477a357278473b57853b6e5bb7a3184e4e7cd5e9 (diff)
parentfcf31b28ff038dfde90e06814c4a86e1f9aa7499 (diff)
downloadsqlite-278b0517d88d4150830a4ee2c628a55da40d186d.tar.gz
sqlite-278b0517d88d4150830a4ee2c628a55da40d186d.zip
Add the SQLITE_FCNTL_CKPT_START file-control and use it to optimize
the cksumvfs extension. FossilOrigin-Name: efdecb13091316aeac2722f58577cb0314e008e857f2816a2a222bac0a83e9e1
Diffstat (limited to 'src')
-rw-r--r--src/sqlite.h.in6
-rw-r--r--src/wal.c6
2 files changed, 8 insertions, 4 deletions
diff --git a/src/sqlite.h.in b/src/sqlite.h.in
index f65576a15..5c082623c 100644
--- a/src/sqlite.h.in
+++ b/src/sqlite.h.in
@@ -1111,6 +1111,11 @@ struct sqlite3_io_methods {
** happen either internally or externally and that are associated with
** a particular attached database.
**
+** <li>[[SQLITE_FCNTL_CKPT_START]]
+** The [SQLITE_FCNTL_CKPT_START] opcode is invoked from within a checkpoint
+** in wal mode before the client starts to copy pages from the wal
+** file to the database file.
+**
** <li>[[SQLITE_FCNTL_CKPT_DONE]]
** The [SQLITE_FCNTL_CKPT_DONE] opcode is invoked from within a checkpoint
** in wal mode after the client has finished copying pages from the wal
@@ -1155,6 +1160,7 @@ struct sqlite3_io_methods {
#define SQLITE_FCNTL_SIZE_LIMIT 36
#define SQLITE_FCNTL_CKPT_DONE 37
#define SQLITE_FCNTL_RESERVE_BYTES 38
+#define SQLITE_FCNTL_CKPT_START 39
/* deprecated names */
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
diff --git a/src/wal.c b/src/wal.c
index 3e4f4acfd..b23085859 100644
--- a/src/wal.c
+++ b/src/wal.c
@@ -1868,6 +1868,7 @@ static int walCheckpoint(
if( rc==SQLITE_OK ){
i64 nReq = ((i64)mxPage * szPage);
i64 nSize; /* Current size of database file */
+ sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_CKPT_START, 0);
rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
if( rc==SQLITE_OK && nSize<nReq ){
sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
@@ -1895,6 +1896,7 @@ static int walCheckpoint(
rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);
if( rc!=SQLITE_OK ) break;
}
+ sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_CKPT_DONE, 0);
/* If work was actually accomplished... */
if( rc==SQLITE_OK ){
@@ -1907,10 +1909,6 @@ static int walCheckpoint(
}
}
if( rc==SQLITE_OK ){
- rc = sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_CKPT_DONE, 0);
- if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;
- }
- if( rc==SQLITE_OK ){
pInfo->nBackfill = mxSafeFrame;
}
}