]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Initial restructuring of kvvfs working towards generic support of JS's Strorage inter...
authorstephan <stephan@noemail.net>
Fri, 21 Nov 2025 15:23:52 +0000 (15:23 +0000)
committerstephan <stephan@noemail.net>
Fri, 21 Nov 2025 15:23:52 +0000 (15:23 +0000)
FossilOrigin-Name: 190ef4a94005b0feebe865a960d846a1b60ec1b267b15d5a24749f174a6169bc

ext/wasm/api/sqlite3-vfs-kvvfs.c-pp.js
ext/wasm/api/sqlite3-wasm.c
manifest
manifest.tags
manifest.uuid
src/os_kv.c

index c4f9109cb132325e39c1540c885db1d38c566ff6..3cb98d299a6cc623ebdf8a2f2600155dbd040017 100644 (file)
@@ -134,7 +134,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
          kvstorageDelete().
       */
       for(const e of Object.entries({
-        xRead: (zClass, zKey, zBuf, nBuf)=>{
+        xStorageRead: (zClass, zKey, zBuf, nBuf)=>{
           const stack = pstack.pointer,
                 astack = wasm.scopedAllocPush();
           try {
@@ -166,7 +166,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
             wasm.scopedAllocPop(astack);
           }
         },
-        xWrite: (zClass, zKey, zData)=>{
+        xStorageWrite: (zClass, zKey, zData)=>{
           const stack = pstack.pointer;
           try {
             const zXKey = kvvfsMakeKey(zClass,zKey);
@@ -181,7 +181,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
             pstack.restore(stack);
           }
         },
-        xDelete: (zClass, zKey)=>{
+        xStorageDelete: (zClass, zKey)=>{
           const stack = pstack.pointer;
           try {
             const zXKey = kvvfsMakeKey(zClass,zKey);
@@ -213,10 +213,11 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
      We can call back into the native impls when needed, but we need
      to override certain operations here to bypass its strict
      db-naming rules (which, funnily enough, are in place because
-     they're relevant (only) for this browser-side
-     implementation). Apropos: the port to generic objects would also
-     make non-persistent kvvfs available in Worker threads and
-     non-browser builds.
+     they're relevant (only) for what should soon be the previous
+     version of this browser-side implementation). Apropos: the port
+     to generic objects would also make non-persistent kvvfs available
+     in Worker threads and non-browser builds. They could optionally
+     be exported to/from JSON.
   */
   const eventualTodo = 1 || {
     vfsMethods:{
index 316ee8277e80d94f7013386832670459dd063842..98a9c2bff4e0f6cca67b3ed37ef44b687e021cb7 100644 (file)
@@ -1089,10 +1089,13 @@ const char * sqlite3__wasm_enum_json(void){
 
 #define CurrentStruct sqlite3_kvvfs_methods
     StructBinder {
-      M(xRead,    "i(sspi)");
-      M(xWrite,   "i(sss)");
-      M(xDelete,  "i(ss)");
-      M(nKeySize, "i");
+      M(xRcrdRead,           "i(sspi)");
+      M(xRcrdWrite,          "i(sss)");
+      M(xRcrdDelete,         "i(s)");
+      M(nKeySize,               "i");
+      M(pVfs,                   "p");
+      M(pIoDb,                  "p");
+      M(pIoJrnl,                "p");
     } _StructBinder;
 #undef CurrentStruct
 
index eaff89674fb38ee3438540492b4a38a336f4f329..29895a8d4467a08e252346ac3024f5a7523a4dc0 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\snew\sfile\smissing\sfrom\s[3c4061428544].
-D 2025-11-21T15:03:38.538
+C Initial\srestructuring\sof\skvvfs\sworking\stowards\sgeneric\ssupport\sof\sJS's\sStrorage\sinterface\sas\sstorage\srather\sthan\shard-coding\sit\sto\sjust\swindow.localStorage\sand\swindow.sessionStorage.\sThe\seventual\sgoal\sof\sthat\sis\sto\shave\sa\sstorage\ssolution\swhich\sworks\swithout\sthe\sPOSIX\sI/O\sAPIs,\sgetting\sus\sone\sstep\scloser\sto\sa\swasi-sdk\sbuild.\sIt\swould\sbe\stransient,\slike\sEmscripten's\svirtual\sfilesystem,\sand\scould\shypothetically\sreplace\sour\sdependency\son\sthat\sparticular\sfeature.
+D 2025-11-21T15:23:52.218
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -600,11 +600,11 @@ F ext/wasm/api/sqlite3-api-worker1.c-pp.js 1041dd645e8e821c082b628cd8d9acf70c667
 F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89
 F ext/wasm/api/sqlite3-opfs-async-proxy.js 9654b565b346dc609b75d15337f20acfa7af7d9d558da1afeb9b6d8eaa404966
 F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d
-F ext/wasm/api/sqlite3-vfs-kvvfs.c-pp.js f44a4396b2305b27dc81c00a1629fe4f615520f7fb11ed4e606255e365956ba2
+F ext/wasm/api/sqlite3-vfs-kvvfs.c-pp.js c4e6009351a2841ade6ecab247c9883974eccd8d5e2d8c00d4bcc9999023b0ad
 F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 26cb41d5a62f46a106b6371eb00fef02de3cdbfaa51338ba087a45f53028e0d0
 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js aa330fa0e8ef35cbd92eb0d52e05fbaa07e61540c5cb164e693c82428ce1d763
 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js 9097074724172e31e56ce20ccd7482259cf72a76124213cbc9469d757676da86
-F ext/wasm/api/sqlite3-wasm.c 7778527bdbb241b8e742a5fc50e470e8b8d0529c41fab9ac127c2c63f3c90d47
+F ext/wasm/api/sqlite3-wasm.c 2179f102b6c851070f4e780d71f8294e2aa53ba010f1e7cfd8fc101b81df8b0e
 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bda1c75bd674a92a0e27cc2f3d46dbbf21e422413f8046814515a0bd7409328a
 F ext/wasm/api/sqlite3-worker1.c-pp.js 802d69ead8c38dc1be52c83afbfc77e757da8a91a2e159e7ed3ecda8b8dba2e7
 F ext/wasm/c-pp-lite.c 943be1a36774d58385dca32de36fc18d4f432fe79f7aa35e6c85dd6a6b825bd0
@@ -717,7 +717,7 @@ F src/notify.c 57c2d1a2805d6dee32acd5d250d928ab94e02d76369ae057dee7d445fd64e878
 F src/os.c 509452169d5ea739723e213b8e2481cf0e587f0e88579a912d200db5269f5f6d
 F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63
 F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06
-F src/os_kv.c fb7ba8d6204197357f1eb7e1c7450d09c10043bf7e99aba602f4aa46b8fb11a3
+F src/os_kv.c 2963455c752a20eb60d6d497a9bace5a6cc83af4ecd40ed0e33fdfb370864fce
 F src/os_setup.h 8efc64eda6a6c2f221387eefc2e7e45fd5a3d5c8337a7a83519ba4fbd2957ae2
 F src/os_unix.c 7945ede1e85b2d1b910e1b4af9ba342e964b1e30e79f4176480a60736445cb36
 F src/os_win.c a89b501fc195085c7d6c9eec7f5bd782625e94bb2a96b000f4d009703df1083f
@@ -2178,8 +2178,11 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd
 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
 F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 895498e4431e02cff65a5d96db22f0b0cb9c96aedf1e3cdcdeb3c34c6fec432b
-R ce0350baf4d1de88228e71ca89be9093
+P 41f94eca01d8317364aa60ddd8e5fe3cd21a215040ef271a157d450a914139d0
+R c24190ae7a0835568d82af728a2e7bdd
+T *branch * kvvfs-v2
+T *sym-kvvfs-v2 *
+T -sym-trunk * Cancelled\sby\sbranch.
 U stephan
-Z 923ff40315e60b496c7ed96ee0be8e80
+Z 9210a0cee9d8767f1b346041ef3e7366
 # Remove this line to create a well-formed Fossil manifest.
index bec971799ff1b8ee641c166c7aeb22d12c785393..4a6dd7dc3c21adf01e3cc69089783d3eabffa9f9 100644 (file)
@@ -1,2 +1,2 @@
-branch trunk
-tag trunk
+branch kvvfs-v2
+tag kvvfs-v2
index 675d8849ad4b499e08f77bdffbd49a77ebda571c..89eab4b71b158d834127050c3ee01355dc3a1f66 100644 (file)
@@ -1 +1 @@
-41f94eca01d8317364aa60ddd8e5fe3cd21a215040ef271a157d450a914139d0
+190ef4a94005b0feebe865a960d846a1b60ec1b267b15d5a24749f174a6169bc
index c2d1f9b7addc56f1dca4f41db0fb2ce2e41a156f..4f282d6a986fb5b5b6b500529a459b6edda4f779 100644 (file)
@@ -35,7 +35,6 @@
 #define SQLITE_KV_LOG(X)
 #endif
 
-
 /*
 ** Forward declaration of objects used by this VFS implementation
 */
@@ -91,7 +90,11 @@ static int kvvfsSleep(sqlite3_vfs*, int microseconds);
 static int kvvfsCurrentTime(sqlite3_vfs*, double*);
 static int kvvfsCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*);
 
-static sqlite3_vfs sqlite3OsKvvfsObject = {
+static
+#ifndef SQLITE_WASM
+const
+#endif
+sqlite3_vfs sqlite3OsKvvfsObject = {
   1,                              /* iVersion */
   sizeof(KVVfsFile),              /* szOsFile */
   1024,                           /* mxPathname */
@@ -115,7 +118,11 @@ static sqlite3_vfs sqlite3OsKvvfsObject = {
 
 /* Methods for sqlite3_file objects referencing a database file
 */
-static sqlite3_io_methods kvvfs_db_io_methods = {
+static
+#ifndef SQLITE_WASM
+const
+#endif
+sqlite3_io_methods kvvfs_db_io_methods = {
   1,                              /* iVersion */
   kvvfsClose,                     /* xClose */
   kvvfsReadDb,                    /* xRead */
@@ -139,7 +146,11 @@ static sqlite3_io_methods kvvfs_db_io_methods = {
 
 /* Methods for sqlite3_file objects referencing a rollback journal
 */
-static sqlite3_io_methods kvvfs_jrnl_io_methods = {
+static
+#ifndef SQLITE_WASM
+const
+#endif
+sqlite3_io_methods kvvfs_jrnl_io_methods = {
   1,                              /* iVersion */
   kvvfsClose,                     /* xClose */
   kvvfsReadJrnl,                  /* xRead */
@@ -168,21 +179,21 @@ static sqlite3_io_methods kvvfs_jrnl_io_methods = {
 
 /* Forward declarations for the low-level storage engine
 */
-static int kvstorageWrite(const char*, const char *zKey, const char *zData);
-static int kvstorageDelete(const char*, const char *zKey);
-static int kvstorageRead(const char*, const char *zKey, char *zBuf, int nBuf);
-#define KVSTORAGE_KEY_SZ  32
+static int kvrecordWrite(const char*, const char *zKey, const char *zData);
+static int kvrecordDelete(const char*, const char *zKey);
+static int kvrecordRead(const char*, const char *zKey, char *zBuf, int nBuf);
+#define KVRECORD_KEY_SZ  32
 
 /* Expand the key name with an appropriate prefix and put the result
 ** in zKeyOut[].  The zKeyOut[] buffer is assumed to hold at least
-** KVSTORAGE_KEY_SZ bytes.
+** KVRECORD_KEY_SZ bytes.
 */
-static void kvstorageMakeKey(
+static void kvrecordMakeKey(
   const char *zClass,
   const char *zKeyIn,
   char *zKeyOut
 ){
-  sqlite3_snprintf(KVSTORAGE_KEY_SZ, zKeyOut, "kvvfs-%s-%s", zClass, zKeyIn);
+  sqlite3_snprintf(KVRECORD_KEY_SZ, zKeyOut, "kvvfs-%s-%s", zClass, zKeyIn);
 }
 
 /* Write content into a key.  zClass is the particular namespace of the
@@ -192,14 +203,14 @@ static void kvstorageMakeKey(
 **
 ** Return the number of errors.
 */
-static int kvstorageWrite(
+static int kvrecordWrite(
   const char *zClass,
   const char *zKey,
   const char *zData
 ){
   FILE *fd;
-  char zXKey[KVSTORAGE_KEY_SZ];
-  kvstorageMakeKey(zClass, zKey, zXKey);
+  char zXKey[KVRECORD_KEY_SZ];
+  kvrecordMakeKey(zClass, zKey, zXKey);
   fd = fopen(zXKey, "wb");
   if( fd ){
     SQLITE_KV_TRACE(("KVVFS-WRITE  %-15s (%d) %.50s%s\n", zXKey,
@@ -217,9 +228,9 @@ static int kvstorageWrite(
 ** namespace given by zClass.  If the key does not previously exist,
 ** this routine is a no-op.
 */
-static int kvstorageDelete(const char *zClass, const char *zKey){
-  char zXKey[KVSTORAGE_KEY_SZ];
-  kvstorageMakeKey(zClass, zKey, zXKey);
+static int kvrecordDelete(const char *zClass, const char *zKey){
+  char zXKey[KVRECORD_KEY_SZ];
+  kvrecordMakeKey(zClass, zKey, zXKey);
   unlink(zXKey);
   SQLITE_KV_TRACE(("KVVFS-DELETE %-15s\n", zXKey));
   return 0;
@@ -240,7 +251,7 @@ static int kvstorageDelete(const char *zClass, const char *zKey){
 ** zero-terminates zBuf at zBuf[0] and returns the size of the data
 ** without reading it.
 */
-static int kvstorageRead(
+static int kvrecordRead(
   const char *zClass,
   const char *zKey,
   char *zBuf,
@@ -248,8 +259,8 @@ static int kvstorageRead(
 ){
   FILE *fd;
   struct stat buf;
-  char zXKey[KVSTORAGE_KEY_SZ];
-  kvstorageMakeKey(zClass, zKey, zXKey);
+  char zXKey[KVRECORD_KEY_SZ];
+  kvrecordMakeKey(zClass, zKey, zXKey);
   if( access(zXKey, R_OK)!=0
    || stat(zXKey, &buf)!=0
    || !S_ISREG(buf.st_mode)
@@ -293,12 +304,22 @@ static int kvstorageRead(
 */
 typedef struct sqlite3_kvvfs_methods sqlite3_kvvfs_methods;
 struct sqlite3_kvvfs_methods {
-  int (*xRead)(const char *zClass, const char *zKey, char *zBuf, int nBuf);
-  int (*xWrite)(const char *zClass, const char *zKey, const char *zData);
-  int (*xDelete)(const char *zClass, const char *zKey);
+  int (*xRcrdWrite)(const char*, const char *zKey, const char *zData);
+  int (*xRcrdDelete)(const char*, const char *zKey);
+  int (*xRcrdRead)(const char*, const char *zKey, char *zBuf, int nBuf);
   const int nKeySize;
+#ifndef SQLITE_WASM
+#  define MAYBE_CONST const
+#else
+#  define MAYBE_CONST
+#endif
+  MAYBE_CONST sqlite3_vfs * pVfs;
+  MAYBE_CONST sqlite3_io_methods *pIoDb;
+  MAYBE_CONST sqlite3_io_methods *pIoJrnl;
+#undef MAYBE_CONST
 };
 
+
 /*
 ** This object holds the kvvfs I/O methods which may be swapped out
 ** for JavaScript-side implementations in WASM builds. In such builds
@@ -313,10 +334,13 @@ struct sqlite3_kvvfs_methods {
 const
 #endif
 sqlite3_kvvfs_methods sqlite3KvvfsMethods = {
-kvstorageRead,
-kvstorageWrite,
-kvstorageDelete,
-KVSTORAGE_KEY_SZ
+  .xRcrdRead    = kvrecordRead,
+  .xRcrdWrite   = kvrecordWrite,
+  .xRcrdDelete  = kvrecordDelete,
+  .nKeySize        = KVRECORD_KEY_SZ,
+  .pVfs            = &sqlite3OsKvvfsObject,
+  .pIoDb           = &kvvfs_db_io_methods,
+  .pIoJrnl         = &kvvfs_jrnl_io_methods
 };
 
 /****** Utility subroutines ************************************************/
@@ -474,13 +498,14 @@ static void kvvfsDecodeJournal(
 static sqlite3_int64 kvvfsReadFileSize(KVVfsFile *pFile){
   char zData[50];
   zData[0] = 0;
-  sqlite3KvvfsMethods.xRead(pFile->zClass, "sz", zData, sizeof(zData)-1);
+  sqlite3KvvfsMethods.xRcrdRead(pFile->zClass, "sz", zData,
+                                   sizeof(zData)-1);
   return strtoll(zData, 0, 0);
 }
 static int kvvfsWriteFileSize(KVVfsFile *pFile, sqlite3_int64 sz){
   char zData[50];
   sqlite3_snprintf(sizeof(zData), zData, "%lld", sz);
-  return sqlite3KvvfsMethods.xWrite(pFile->zClass, "sz", zData);
+  return sqlite3KvvfsMethods.xRcrdWrite(pFile->zClass, "sz", zData);
 }
 
 /****** sqlite3_io_methods methods ******************************************/
@@ -491,7 +516,7 @@ static int kvvfsWriteFileSize(KVVfsFile *pFile, sqlite3_int64 sz){
 static int kvvfsClose(sqlite3_file *pProtoFile){
   KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
 
-  SQLITE_KV_LOG(("xClose %s %s\n", pFile->zClass, 
+  SQLITE_KV_LOG(("xClose %s %s\n", pFile->zClass,
              pFile->isJournal ? "journal" : "db"));
   sqlite3_free(pFile->aJrnl);
   sqlite3_free(pFile->aData);
@@ -503,22 +528,22 @@ static int kvvfsClose(sqlite3_file *pProtoFile){
 */
 static int kvvfsReadJrnl(
   sqlite3_file *pProtoFile,
-  void *zBuf, 
-  int iAmt, 
+  void *zBuf,
+  int iAmt,
   sqlite_int64 iOfst
 ){
   KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
   assert( pFile->isJournal );
   SQLITE_KV_LOG(("xRead('%s-journal',%d,%lld)\n", pFile->zClass, iAmt, iOfst));
   if( pFile->aJrnl==0 ){
-    int szTxt = kvstorageRead(pFile->zClass, "jrnl", 0, 0);
+    int szTxt = kvrecordRead(pFile->zClass, "jrnl", 0, 0);
     char *aTxt;
     if( szTxt<=4 ){
       return SQLITE_IOERR;
     }
     aTxt = sqlite3_malloc64( szTxt+1 );
     if( aTxt==0 ) return SQLITE_NOMEM;
-    kvstorageRead(pFile->zClass, "jrnl", aTxt, szTxt+1);
+    kvrecordRead(pFile->zClass, "jrnl", aTxt, szTxt+1);
     kvvfsDecodeJournal(pFile, aTxt, szTxt);
     sqlite3_free(aTxt);
     if( pFile->aJrnl==0 ) return SQLITE_IOERR;
@@ -535,8 +560,8 @@ static int kvvfsReadJrnl(
 */
 static int kvvfsReadDb(
   sqlite3_file *pProtoFile,
-  void *zBuf, 
-  int iAmt, 
+  void *zBuf,
+  int iAmt,
   sqlite_int64 iOfst
 ){
   KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
@@ -560,8 +585,8 @@ static int kvvfsReadDb(
     pgno = 1;
   }
   sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno);
-  got = sqlite3KvvfsMethods.xRead(pFile->zClass, zKey,
-                                  aData, SQLITE_KVOS_SZ-1);
+  got = sqlite3KvvfsMethods.xRcrdRead(pFile->zClass, zKey,
+                                         aData, SQLITE_KVOS_SZ-1);
   if( got<0 ){
     n = 0;
   }else{
@@ -593,8 +618,8 @@ static int kvvfsReadDb(
 */
 static int kvvfsWriteJrnl(
   sqlite3_file *pProtoFile,
-  const void *zBuf, 
-  int iAmt, 
+  const void *zBuf,
+  int iAmt,
   sqlite_int64 iOfst
 ){
   KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
@@ -621,14 +646,15 @@ static int kvvfsWriteJrnl(
 */
 static int kvvfsWriteDb(
   sqlite3_file *pProtoFile,
-  const void *zBuf, 
-  int iAmt, 
+  const void *zBuf,
+  int iAmt,
   sqlite_int64 iOfst
 ){
   KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
   unsigned int pgno;
   char zKey[30];
   char *aData = pFile->aData;
+  int rc;
   SQLITE_KV_LOG(("xWrite('%s-db',%d,%lld)\n", pFile->zClass, iAmt, iOfst));
   assert( iAmt>=512 && iAmt<=65536 );
   assert( (iAmt & (iAmt-1))==0 );
@@ -637,13 +663,13 @@ static int kvvfsWriteDb(
   pgno = 1 + iOfst/iAmt;
   sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno);
   kvvfsEncode(zBuf, iAmt, aData);
-  if( sqlite3KvvfsMethods.xWrite(pFile->zClass, zKey, aData) ){
-    return SQLITE_IOERR;
-  }
-  if( iOfst+iAmt > pFile->szDb ){
-    pFile->szDb = iOfst + iAmt;
+  rc = sqlite3KvvfsMethods.xRcrdWrite(pFile->zClass, zKey, aData);
+  if( 0==rc ){
+    if( iOfst+iAmt > pFile->szDb ){
+      pFile->szDb = iOfst + iAmt;
+    }
   }
-  return SQLITE_OK;
+  return rc;
 }
 
 /*
@@ -653,7 +679,7 @@ static int kvvfsTruncateJrnl(sqlite3_file *pProtoFile, sqlite_int64 size){
   KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
   SQLITE_KV_LOG(("xTruncate('%s-journal',%lld)\n", pFile->zClass, size));
   assert( size==0 );
-  sqlite3KvvfsMethods.xDelete(pFile->zClass, "jrnl");
+  sqlite3KvvfsMethods.xRcrdDelete(pFile->zClass, "jrnl");
   sqlite3_free(pFile->aJrnl);
   pFile->aJrnl = 0;
   pFile->nJrnl = 0;
@@ -662,7 +688,7 @@ static int kvvfsTruncateJrnl(sqlite3_file *pProtoFile, sqlite_int64 size){
 static int kvvfsTruncateDb(sqlite3_file *pProtoFile, sqlite_int64 size){
   KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
   if( pFile->szDb>size
-   && pFile->szPage>0 
+   && pFile->szPage>0
    && (size % pFile->szPage)==0
   ){
     char zKey[50];
@@ -672,7 +698,7 @@ static int kvvfsTruncateDb(sqlite3_file *pProtoFile, sqlite_int64 size){
     pgnoMax = 2 + pFile->szDb/pFile->szPage;
     while( pgno<=pgnoMax ){
       sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno);
-      sqlite3KvvfsMethods.xDelete(pFile->zClass, zKey);
+      sqlite3KvvfsMethods.xRcrdDelete(pFile->zClass, zKey);
       pgno++;
     }
     pFile->szDb = size;
@@ -704,7 +730,7 @@ static int kvvfsSyncJrnl(sqlite3_file *pProtoFile, int flags){
   }while( n>0 );
   zOut[i++] = ' ';
   kvvfsEncode(pFile->aJrnl, pFile->nJrnl, &zOut[i]);
-  i = sqlite3KvvfsMethods.xWrite(pFile->zClass, "jrnl", zOut);
+  i = sqlite3KvvfsMethods.xRcrdWrite(pFile->zClass, "jrnl", zOut);
   sqlite3_free(zOut);
   return i ? SQLITE_IOERR : SQLITE_OK;
 }
@@ -855,10 +881,10 @@ static int kvvfsOpen(
 */
 static int kvvfsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
   if( strcmp(zPath, "local-journal")==0 ){
-    sqlite3KvvfsMethods.xDelete("local", "jrnl");
+    sqlite3KvvfsMethods.xRcrdDelete("local", "jrnl");
   }else
   if( strcmp(zPath, "session-journal")==0 ){
-    sqlite3KvvfsMethods.xDelete("session", "jrnl");
+    sqlite3KvvfsMethods.xRcrdDelete("session", "jrnl");
   }
   return SQLITE_OK;
 }
@@ -868,23 +894,27 @@ static int kvvfsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
 ** is available, or false otherwise.
 */
 static int kvvfsAccess(
-  sqlite3_vfs *pProtoVfs, 
-  const char *zPath, 
-  int flags, 
+  sqlite3_vfs *pProtoVfs,
+  const char *zPath,
+  int flags,
   int *pResOut
 ){
   SQLITE_KV_LOG(("xAccess(\"%s\")\n", zPath));
   if( strcmp(zPath, "local-journal")==0 ){
-    *pResOut = sqlite3KvvfsMethods.xRead("local", "jrnl", 0, 0)>0;
+    *pResOut =
+      sqlite3KvvfsMethods.xRcrdRead("local", "jrnl", 0, 0)>0;
   }else
   if( strcmp(zPath, "session-journal")==0 ){
-    *pResOut = sqlite3KvvfsMethods.xRead("session", "jrnl", 0, 0)>0;
+    *pResOut =
+      sqlite3KvvfsMethods.xRcrdRead("session", "jrnl", 0, 0)>0;
   }else
   if( strcmp(zPath, "local")==0 ){
-    *pResOut = sqlite3KvvfsMethods.xRead("local", "sz", 0, 0)>0;
+    *pResOut =
+      sqlite3KvvfsMethods.xRcrdRead("local", "sz", 0, 0)>0;
   }else
   if( strcmp(zPath, "session")==0 ){
-    *pResOut = sqlite3KvvfsMethods.xRead("session", "sz", 0, 0)>0;
+    *pResOut =
+      sqlite3KvvfsMethods.xRcrdRead("session", "sz", 0, 0)>0;
   }else
   {
     *pResOut = 0;
@@ -899,9 +929,9 @@ static int kvvfsAccess(
 ** of at least (INST_MAX_PATHNAME+1) bytes.
 */
 static int kvvfsFullPathname(
-  sqlite3_vfs *pVfs, 
-  const char *zPath, 
-  int nOut, 
+  sqlite3_vfs *pVfs,
+  const char *zPath,
+  int nOut,
   char *zOut
 ){
   size_t nPath;
@@ -924,7 +954,7 @@ static void *kvvfsDlOpen(sqlite3_vfs *pVfs, const char *zPath){
 }
 
 /*
-** Populate the buffer pointed to by zBufOut with nByte bytes of 
+** Populate the buffer pointed to by zBufOut with nByte bytes of
 ** random data.
 */
 static int kvvfsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
@@ -933,7 +963,7 @@ static int kvvfsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
 }
 
 /*
-** Sleep for nMicro microseconds. Return the number of microseconds 
+** Sleep for nMicro microseconds. Return the number of microseconds
 ** actually slept.
 */
 static int kvvfsSleep(sqlite3_vfs *pVfs, int nMicro){
@@ -961,7 +991,7 @@ static int kvvfsCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *pTimeOut){
 #endif /* SQLITE_OS_KV || SQLITE_OS_UNIX */
 
 #if SQLITE_OS_KV
-/* 
+/*
 ** This routine is called initialize the KV-vfs as the default VFS.
 */
 int sqlite3_os_init(void){