]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Database must be named either "local" or "session". Each has a distinct
authordrh <>
Fri, 9 Sep 2022 16:16:33 +0000 (16:16 +0000)
committerdrh <>
Fri, 9 Sep 2022 16:16:33 +0000 (16:16 +0000)
namespace.

FossilOrigin-Name: c8e41279294ea7c2f041c7d4cbbd85fce47d55f2f56180ca837316f7dfd75237

ext/misc/vfskv.c
manifest
manifest.uuid

index 05259eaa43aec766563cf805e0f6647085f4adf4..fee190f256b1c58f9d9c7cd88d42c943ce461e19 100644 (file)
@@ -47,40 +47,23 @@ SQLITE_EXTENSION_INIT1
 /*****************************************************************************
 ** The low-level storage engine
 */
-typedef struct KVStorage KVStorage;
-struct KVStorage {
-  char *zDir;
-  char zKey[50];
-};
-
-static KVStorage *kvstorageOpen(void);
-static void kvstorageClose(KVStorage*);
-static int kvstorageWrite(KVStorage*, const char *zKey, const char *zData);
-static int kvstorageDelete(KVStorage*, const char *zKey);
-static int kvstorageRead(KVStorage*, const char *zKey, char *zBuf, int nBuf);
+#define KVSTORAGE_KEY_SZ  24
+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);
 
 
 /*
-** Forward declaration of objects used by this utility
+** Forward declaration of objects used by this VFS implementation
 */
-typedef struct KVVfsVfs KVVfsVfs;
 typedef struct KVVfsFile KVVfsFile;
 
-
-/* All information about the database */
-struct KVVfsVfs {
-  sqlite3_vfs base;               /* VFS methods */
-  KVStorage *pStore;              /* Single command KV storage object */
-  KVVfsFile *pFiles;              /* List of open KVVfsFile objects */
-};
-
 /* A single open file.  There are only two files represented by this
 ** VFS - the database and the rollback journal.
 */
 struct KVVfsFile {
   sqlite3_file base;              /* IO methods */
-  KVVfsVfs *pVfs;                 /* The VFS to which this file belongs */
-  KVVfsFile *pNext;               /* Next in list of all files */
+  const char *zClass;             /* Storage class */
   int isJournal;                  /* True if this is a journal file */
   unsigned int nJrnl;             /* Space allocated for aJrnl[] */
   char *aJrnl;                    /* Journal content */
@@ -110,7 +93,7 @@ static int kvvfsSectorSize(sqlite3_file*);
 static int kvvfsDeviceCharacteristics(sqlite3_file*);
 
 /*
-** Methods for KVVfsVfs
+** Methods for sqlite3_vfs
 */
 static int kvvfsOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);
 static int kvvfsDelete(sqlite3_vfs*, const char *zName, int syncDir);
@@ -122,30 +105,26 @@ static int kvvfsSleep(sqlite3_vfs*, int microseconds);
 static int kvvfsCurrentTime(sqlite3_vfs*, double*);
 static int kvvfsCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*);
 
-static KVVfsVfs kvvfs_vfs = {
-  {
-    1,                            /* iVersion */
-    sizeof(KVVfsFile),            /* szOsFile */
-    1024,                         /* mxPathname */
-    0,                            /* pNext */
-    "kvvfs",                      /* zName */
-    0,                            /* pAppData */
-    kvvfsOpen,                    /* xOpen */
-    kvvfsDelete,                  /* xDelete */
-    kvvfsAccess,                  /* xAccess */
-    kvvfsFullPathname,            /* xFullPathname */
-    kvvfsDlOpen,                  /* xDlOpen */
-    0,                            /* xDlError */
-    0,                            /* xDlSym */
-    0,                            /* xDlClose */
-    kvvfsRandomness,              /* xRandomness */
-    kvvfsSleep,                   /* xSleep */
-    kvvfsCurrentTime,             /* xCurrentTime */
-    0,                            /* xGetLastError */
-    kvvfsCurrentTimeInt64         /* xCurrentTimeInt64 */
-  },
-  0,
-  0
+static sqlite3_vfs kvvfs_vfs = {
+  1,                              /* iVersion */
+  sizeof(KVVfsFile),              /* szOsFile */
+  1024,                           /* mxPathname */
+  0,                              /* pNext */
+  "kvvfs",                        /* zName */
+  0,                              /* pAppData */
+  kvvfsOpen,                      /* xOpen */
+  kvvfsDelete,                    /* xDelete */
+  kvvfsAccess,                    /* xAccess */
+  kvvfsFullPathname,              /* xFullPathname */
+  kvvfsDlOpen,                    /* xDlOpen */
+  0,                              /* xDlError */
+  0,                              /* xDlSym */
+  0,                              /* xDlClose */
+  kvvfsRandomness,                /* xRandomness */
+  kvvfsSleep,                     /* xSleep */
+  kvvfsCurrentTime,               /* xCurrentTime */
+  0,                              /* xGetLastError */
+  kvvfsCurrentTimeInt64           /* xCurrentTimeInt64 */
 };
 
 /* Methods for sqlite3_file objects referencing a database file
@@ -198,27 +177,16 @@ static sqlite3_io_methods kvvfs_jrnl_io_methods = {
 
 /****** Storage subsystem **************************************************/
 
-/* Allocate a new storage subsystem.
-** Return NULL if OOM
-*/
-static KVStorage *kvstorageOpen(void){
-  KVStorage *pStore;
-  pStore = sqlite3_malloc64( sizeof(*pStore) );
-  if( pStore==0 ) return 0;
-  memset(pStore, 0, sizeof(*pStore));
-  return pStore;
-}
-
-/* Free all resources associated with the storage subsystem */
-static void kvstorageClose(KVStorage *pStore){
-  sqlite3_free(pStore);
-}
 
 /* Expand the key name with an appropriate prefix and put the result
 ** in pStore->zKey[]
 */
-static void kvstorageMakeKey(KVStorage *pStore, const char *zKey){
-  sqlite3_snprintf(sizeof(pStore->zKey), pStore->zKey, "kvvfs-%s", zKey);
+static void kvstorageMakeKey(
+  const char *zClass,
+  const char *zKeyIn,
+  char *zKeyOut
+){
+  sqlite3_snprintf(KVSTORAGE_KEY_SZ, zKeyOut, "%s-%s", zClass, zKeyIn);
 }
 
 /* Write content into a key.  zKey is of limited size.  zData should be
@@ -227,15 +195,16 @@ static void kvstorageMakeKey(KVStorage *pStore, const char *zKey){
 ** Return the number of errors.
 */
 static int kvstorageWrite(
-  KVStorage *pStore,
+  const char *zClass,
   const char *zKey,
   const char *zData
 ){
   FILE *fd;
-  kvstorageMakeKey(pStore, zKey);
-  fd = fopen(pStore->zKey, "wb");
+  char zXKey[KVSTORAGE_KEY_SZ];
+  kvstorageMakeKey(zClass, zKey, zXKey);
+  fd = fopen(zXKey, "wb");
   if( fd ){
-    KVVFS_TRACE(("KVVFS-WRITE  %-10s (%d) %.50s%s\n", pStore->zKey,
+    KVVFS_TRACE(("KVVFS-WRITE  %-15s (%d) %.50s%s\n", zXKey,
                  (int)strlen(zData), zData,
                  strlen(zData)>50 ? "..." : ""));
     fputs(zData, fd);
@@ -248,10 +217,11 @@ static int kvstorageWrite(
 
 /* Delete a key
 */
-static int kvstorageDelete(KVStorage *pStore, const char *zKey){
-  kvstorageMakeKey(pStore, zKey);
-  unlink(pStore->zKey);
-  KVVFS_TRACE(("KVVFS-DELETE %-10s\n", pStore->zKey));
+static int kvstorageDelete(const char *zClass, const char *zKey){
+  char zXKey[KVSTORAGE_KEY_SZ];
+  kvstorageMakeKey(zClass, zKey, zXKey);
+  unlink(zXKey);
+  KVVFS_TRACE(("KVVFS-DELETE %-15s\n", zXKey));
   return 0;
 }
 
@@ -268,41 +238,42 @@ static int kvstorageDelete(KVStorage *pStore, const char *zKey){
 ** actually reading it.
 */
 static int kvstorageRead(
-  KVStorage *pStore,
+  const char *zClass,
   const char *zKey,
   char *zBuf,
   int nBuf
 ){
   FILE *fd;
   struct stat buf;
-  kvstorageMakeKey(pStore, zKey);
-  if( access(pStore->zKey, R_OK)!=0
-   || stat(pStore->zKey, &buf)!=0
+  char zXKey[KVSTORAGE_KEY_SZ];
+  kvstorageMakeKey(zClass, zKey, zXKey);
+  if( access(zXKey, R_OK)!=0
+   || stat(zXKey, &buf)!=0
    || !S_ISREG(buf.st_mode)
   ){
-    KVVFS_TRACE(("KVVFS-READ   %-10s (-1)\n", pStore->zKey));
+    KVVFS_TRACE(("KVVFS-READ   %-15s (-1)\n", zXKey));
     return -1;
   }
   if( nBuf<0 ){
     return (int)buf.st_size;
   }else if( nBuf==1 ){
     zBuf[0] = 0;
-    KVVFS_TRACE(("KVVFS-READ   %-10s (%d)\n", pStore->zKey,
+    KVVFS_TRACE(("KVVFS-READ   %-15s (%d)\n", zXKey,
                  (int)buf.st_size));
     return (int)buf.st_size;
   }
-  if( nBuf-1 > buf.st_size ){
+  if( nBuf > buf.st_size + 1 ){
     nBuf = buf.st_size + 1;
   }
-  fd = fopen(pStore->zKey, "rb");
+  fd = fopen(zXKey, "rb");
   if( fd==0 ){
-    KVVFS_TRACE(("KVVFS-READ   %-10s (-1)\n", pStore->zKey));
+    KVVFS_TRACE(("KVVFS-READ   %-15s (-1)\n", zXKey));
     return -1;
   }else{
     sqlite3_int64 n = fread(zBuf, 1, nBuf-1, fd);
     fclose(fd);
     zBuf[n] = 0;
-    KVVFS_TRACE(("KVVFS-READ   %-10s (%lld) %.50s%s\n", pStore->zKey,
+    KVVFS_TRACE(("KVVFS-READ   %-15s (%lld) %.50s%s\n", zXKey,
                  n, zBuf, n>50 ? "..." : ""));
     return (int)n;
   }
@@ -445,42 +416,25 @@ static void kvvfsDecodeJournal(
 static sqlite3_int64 kvvfsReadFileSize(KVVfsFile *pFile){
   char zData[50];
   zData[0] = 0;
-  kvstorageRead(pFile->pVfs->pStore, "sz", zData, sizeof(zData)-1);
+  kvstorageRead(pFile->zClass, "sz", zData, sizeof(zData)-1);
   return strtoll(zData, 0, 0);
 }
 static void kvvfsWriteFileSize(KVVfsFile *pFile, sqlite3_int64 sz){
   char zData[50];
   sqlite3_snprintf(sizeof(zData), zData, "%lld", sz);
-  kvstorageWrite(pFile->pVfs->pStore, "sz", zData);
+  kvstorageWrite(pFile->zClass, "sz", zData);
 }
 
-/****** VFS methods ********************************************************/
+/****** sqlite3_io_methods methods ******************************************/
 
 /*
 ** Close an kvvfs-file.
 */
 static int kvvfsClose(sqlite3_file *pProtoFile){
   KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
-  KVVfsVfs *pVfs = pFile->pVfs;
-
-  KVVFS_LOG(("xClose %s\n", pFile->isJournal ? "journal" : "db"));
-  if( pVfs->pFiles==pFile ){
-    pVfs->pFiles = pFile->pNext;
-    if( pVfs->pFiles==0 ){
-      kvstorageClose(pVfs->pStore);
-      pVfs->pStore = 0;
-    }
-  }else{
-    KVVfsFile *pX = pVfs->pFiles;
-    while( 1 ){
-      assert( pX );
-      if( pX->pNext==pFile ){
-        pX->pNext = pFile->pNext;
-        break;
-      }
-      pX = pX->pNext; 
-    }
-  }
+
+  KVVFS_LOG(("xClose %s %s\n", pFile->zClass, 
+             pFile->isJournal ? "journal" : "db"));
   sqlite3_free(pFile->aJrnl);
   return SQLITE_OK;
 }
@@ -496,16 +450,16 @@ static int kvvfsReadJrnl(
 ){
   KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
   assert( pFile->isJournal );
-  KVVFS_LOG(("xRead('journal',%d,%lld)\n", iAmt, iOfst));
+  KVVFS_LOG(("xRead('%s-journal',%d,%lld)\n", pFile->zClass, iAmt, iOfst));
   if( pFile->aJrnl==0 ){
-    int szTxt = kvstorageRead(pFile->pVfs->pStore, "jrnl", 0, 0);
+    int szTxt = kvstorageRead(pFile->zClass, "jrnl", 0, -1);
     char *aTxt;
     if( szTxt<=4 ){
       return SQLITE_IOERR;
     }
     aTxt = sqlite3_malloc64( szTxt+1 );
     if( aTxt==0 ) return SQLITE_NOMEM;
-    kvstorageRead(pFile->pVfs->pStore, "jrnl", aTxt, szTxt+1);
+    kvstorageRead(pFile->zClass, "jrnl", aTxt, szTxt+1);
     kvvfsDecodeJournal(pFile, aTxt, szTxt);
     sqlite3_free(aTxt);
     if( pFile->aJrnl==0 ) return SQLITE_IOERR;
@@ -533,7 +487,7 @@ static int kvvfsReadDb(
   char aData[131073];
   assert( iOfst>=0 );
   assert( iAmt>=0 );
-  KVVFS_LOG(("xRead('db',%d,%lld)\n", iAmt, iOfst));
+  KVVFS_LOG(("xRead('%s-db',%d,%lld)\n", pFile->zClass, iAmt, iOfst));
   if( iOfst+iAmt>=512 ){
     if( (iOfst % iAmt)!=0 ){
       return SQLITE_IOERR_READ;
@@ -547,7 +501,7 @@ static int kvvfsReadDb(
     pgno = 1;
   }
   sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno);
-  got = kvstorageRead(pFile->pVfs->pStore, zKey, aData, sizeof(aData)-1);
+  got = kvstorageRead(pFile->zClass, zKey, aData, sizeof(aData)-1);
   if( got<0 ){
     n = 0;
   }else{
@@ -583,7 +537,7 @@ static int kvvfsWriteJrnl(
 ){
   KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
   sqlite3_int64 iEnd = iOfst+iAmt;
-  KVVFS_LOG(("xWrite('journal',%d,%lld)\n", iAmt, iOfst));
+  KVVFS_LOG(("xWrite('%s-journal',%d,%lld)\n", pFile->zClass, iAmt, iOfst));
   if( iEnd>=0x10000000 ) return SQLITE_FULL;
   if( pFile->aJrnl==0 || pFile->nJrnl<iEnd ){
     char *aNew = sqlite3_realloc(pFile->aJrnl, iEnd);
@@ -613,13 +567,13 @@ static int kvvfsWriteDb(
   unsigned int pgno;
   char zKey[30];
   char aData[131073];
-  KVVFS_LOG(("xWrite('db',%d,%lld)\n", iAmt, iOfst));
+  KVVFS_LOG(("xWrite('%s-db',%d,%lld)\n", pFile->zClass, iAmt, iOfst));
   assert( iAmt>=512 && iAmt<=65536 );
   assert( (iAmt & (iAmt-1))==0 );
   pgno = 1 + iOfst/iAmt;
   sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno);
   kvvfsEncode(zBuf, iAmt, aData);
-  kvstorageWrite(pFile->pVfs->pStore, zKey, aData);
+  kvstorageWrite(pFile->zClass, zKey, aData);
   if( iOfst+iAmt > pFile->szDb ){
     pFile->szDb = iOfst + iAmt;
   }
@@ -631,9 +585,9 @@ static int kvvfsWriteDb(
 */
 static int kvvfsTruncateJrnl(sqlite3_file *pProtoFile, sqlite_int64 size){
   KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
-  KVVFS_LOG(("xTruncate('journal',%lld)\n", size));
+  KVVFS_LOG(("xTruncate('%s-journal',%lld)\n", pFile->zClass, size));
   assert( size==0 );
-  kvstorageDelete(pFile->pVfs->pStore, "jrnl");
+  kvstorageDelete(pFile->zClass, "jrnl");
   sqlite3_free(pFile->aJrnl);
   pFile->aJrnl = 0;
   pFile->nJrnl = 0;
@@ -647,12 +601,12 @@ static int kvvfsTruncateDb(sqlite3_file *pProtoFile, sqlite_int64 size){
   ){
     char zKey[50];
     unsigned int pgno, pgnoMax;
-    KVVFS_LOG(("xTruncate('db',%lld)\n", size));
+    KVVFS_LOG(("xTruncate('%s-db',%lld)\n", pFile->zClass, size));
     pgno = 1 + size/pFile->szPage;
     pgnoMax = 2 + pFile->szDb/pFile->szPage;
     while( pgno<=pgnoMax ){
       sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno);
-      kvstorageDelete(pFile->pVfs->pStore, zKey);
+      kvstorageDelete(pFile->zClass, zKey);
       pgno++;
     }
     pFile->szDb = size;
@@ -669,7 +623,7 @@ static int kvvfsSyncJrnl(sqlite3_file *pProtoFile, int flags){
   int i, n;
   KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
   char *zOut;
-  KVVFS_LOG(("xSync('journal')\n"));
+  KVVFS_LOG(("xSync('%s-journal')\n", pFile->zClass));
   if( pFile->nJrnl<=0 ){
     return kvvfsTruncateJrnl(pProtoFile, 0);
   }
@@ -685,13 +639,13 @@ static int kvvfsSyncJrnl(sqlite3_file *pProtoFile, int flags){
   }while( n>0 );
   zOut[i++] = ' ';
   kvvfsEncode(pFile->aJrnl, pFile->nJrnl, &zOut[i]);
-  kvstorageWrite(pFile->pVfs->pStore, "jrnl", zOut);
+  kvstorageWrite(pFile->zClass, "jrnl", zOut);
   sqlite3_free(zOut);
   return SQLITE_OK;
 }
 static int kvvfsSyncDb(sqlite3_file *pProtoFile, int flags){
   KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
-  KVVFS_LOG(("xSync('db')\n"));
+  KVVFS_LOG(("xSync('%s-db')\n", pFile->zClass));
   if( pFile->szDb>0 ){
     kvvfsWriteFileSize(pFile, pFile->szDb);
   }
@@ -703,13 +657,13 @@ static int kvvfsSyncDb(sqlite3_file *pProtoFile, int flags){
 */
 static int kvvfsFileSizeJrnl(sqlite3_file *pProtoFile, sqlite_int64 *pSize){
   KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
-  KVVFS_LOG(("xFileSize('journal')\n"));
+  KVVFS_LOG(("xFileSize('%s-journal')\n", pFile->zClass));
   *pSize = pFile->nJrnl;
   return SQLITE_OK;
 }
 static int kvvfsFileSizeDb(sqlite3_file *pProtoFile, sqlite_int64 *pSize){
   KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
-  KVVFS_LOG(("xFileSize('db')\n"));
+  KVVFS_LOG(("xFileSize('%s-db')\n", pFile->zClass));
   if( pFile->szDb>=0 ){
     *pSize = pFile->szDb;
   }else{
@@ -724,7 +678,7 @@ static int kvvfsFileSizeDb(sqlite3_file *pProtoFile, sqlite_int64 *pSize){
 static int kvvfsLock(sqlite3_file *pProtoFile, int eLock){
   KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
   assert( !pFile->isJournal );
-  KVVFS_LOG(("xLock(%d)\n", eLock));
+  KVVFS_LOG(("xLock(%s,%d)\n", pFile->zClass, eLock));
 
   if( eLock!=SQLITE_LOCK_NONE ){
     pFile->szDb = kvvfsReadFileSize(pFile);
@@ -738,7 +692,7 @@ static int kvvfsLock(sqlite3_file *pProtoFile, int eLock){
 static int kvvfsUnlock(sqlite3_file *pProtoFile, int eLock){
   KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
   assert( !pFile->isJournal );
-  KVVFS_LOG(("xUnlock(%d)\n", eLock));
+  KVVFS_LOG(("xUnlock(%s,%d)\n", pFile->zClass, eLock));
   if( eLock==SQLITE_LOCK_NONE ){
     pFile->szDb = -1;
   }
@@ -775,6 +729,7 @@ static int kvvfsDeviceCharacteristics(sqlite3_file *pProtoFile){
   return 0;
 }
 
+/****** sqlite3_vfs methods *************************************************/
 
 /*
 ** Open an kvvfs file handle.
@@ -787,25 +742,26 @@ static int kvvfsOpen(
   int *pOutFlags
 ){
   KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
-  KVVfsVfs *pVfs = (KVVfsVfs*)pProtoVfs;
   KVVFS_LOG(("xOpen(\"%s\")\n", zName));
-  pFile->aJrnl = 0;
-  pFile->nJrnl = 0;
-  if( sqlite3_strglob("*-journal", zName)==0 ){
+  if( strcmp(zName, "local")==0
+   || strcmp(zName, "session")==0
+  ){
+    pFile->isJournal = 0;
+    pFile->base.pMethods = &kvvfs_db_io_methods;
+  }else
+  if( strcmp(zName, "local-journal")==0 
+   || strcmp(zName, "session-journal")==0
+  ){
     pFile->isJournal = 1;
     pFile->base.pMethods = &kvvfs_jrnl_io_methods;
   }else{
-    pFile->isJournal = 0;
-    pFile->base.pMethods = &kvvfs_db_io_methods;
+    return SQLITE_CANTOPEN;
   }
+  pFile->zClass = zName[0]=='s' ? "kvvfs-ses" : "kvvfs-loc";
+  pFile->aJrnl = 0;
+  pFile->nJrnl = 0;
   pFile->szPage = -1;
   pFile->szDb = -1;
-  pFile->pVfs = pVfs;
-  if( pVfs->pFiles==0 ){
-    pVfs->pStore = kvstorageOpen();
-  }
-  pFile->pNext = pVfs->pFiles;
-  pVfs->pFiles = pFile;
   return SQLITE_OK;
 }
 
@@ -815,9 +771,11 @@ static int kvvfsOpen(
 ** returning.
 */
 static int kvvfsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
-  KVVfsVfs *p = (KVVfsVfs*)pVfs;
-  if( sqlite3_strglob("*-journal",zPath)==0 ){
-    kvstorageDelete(p->pStore, "jrnl");
+  if( strcmp(zPath, "local-journal")==0 ){
+    kvstorageDelete("kvvfs-loc", "jrnl");
+  }else
+  if( strcmp(zPath, "session-journal")==0 ){
+    kvstorageDelete("kvvfs-ses", "jrnl");
   }
   return SQLITE_OK;
 }
@@ -832,14 +790,21 @@ static int kvvfsAccess(
   int flags, 
   int *pResOut
 ){
-  KVVfsVfs *pVfs = (KVVfsVfs*)pProtoVfs;
   KVVFS_LOG(("xAccess(\"%s\")\n", zPath));
-  if( sqlite3_strglob("*-journal", zPath)==0 ){
-    *pResOut = kvstorageRead(pVfs->pStore, "jrnl", 0, 0)>0;
-  }else if( sqlite3_strglob("*-wal", zPath)==0 ){
+  if( strcmp(zPath, "local-journal")==0 ){
+    *pResOut = kvstorageRead("kvvfs-loc", "jrnl", 0, -1)>0;
+  }else
+  if( strcmp(zPath, "session-journal")==0 ){
+    *pResOut = kvstorageRead("kvvfs-ses", "jrnl", 0, -1)>0;
+  }else
+  if( strcmp(zPath, "local")==0 ){
+    *pResOut = kvstorageRead("kvvfs-loc", "sz", 0, -1)>0;
+  }else
+  if( strcmp(zPath, "session")==0 ){
+    *pResOut = kvstorageRead("kvvfs-ses", "sz", 0, -1)>0;
+  }else
+  {
     *pResOut = 0;
-  }else{
-    *pResOut = 1;
   }
   KVVFS_LOG(("xAccess returns %d\n",*pResOut));
   return SQLITE_OK;
@@ -915,6 +880,6 @@ int sqlite3_vfskv_init(
   const sqlite3_api_routines *pApi
 ){
   SQLITE_EXTENSION_INIT2(pApi);
-  sqlite3_vfs_register(&kvvfs_vfs.base, 1);
+  sqlite3_vfs_register(&kvvfs_vfs, 1);
   return SQLITE_OK_LOAD_PERMANENTLY;
 }
index 0a3a99233832ef7269aacafa1cfc5825027d1ef6..fb9682d0f2714bc6425239b0cfc11e48f2a71aed 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Separate\ssqlite3_io_methods\sobjects\sfor\sdatabase\sfiles\sand\sjournals.
-D 2022-09-09T14:22:41.989
+C Database\smust\sbe\snamed\seither\s"local"\sor\s"session".\s\sEach\shas\sa\sdistinct\nnamespace.
+D 2022-09-09T16:16:33.749
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -335,7 +335,7 @@ F ext/misc/uint.c 053fed3bce2e89583afcd4bf804d75d659879bbcedac74d0fa9ed548839a03
 F ext/misc/unionvtab.c 36237f0607ca954ac13a4a0e2d2ac40c33bc6e032a5f55f431713061ef1625f9
 F ext/misc/urifuncs.c f71360d14fa9e7626b563f1f781c6148109462741c5235ac63ae0f8917b9c751
 F ext/misc/uuid.c 5bb2264c1b64d163efa46509544fd7500cb8769cb7c16dd52052da8d961505cf
-F ext/misc/vfskv.c 7b2fa888cd33f41a7a3821eec10ed258fe029af41ad788a43856958c4d216432
+F ext/misc/vfskv.c f154254c7585a0434d50d1b0fa0bb27b03ae4231a9045961e58a046dc5ea40ab
 F ext/misc/vfslog.c 3932ab932eeb2601dbc4447cb14d445aaa9fbe43b863ef5f014401c3420afd20
 F ext/misc/vfsstat.c 474d08efc697b8eba300082cb1eb74a5f0f3df31ed257db1cb07e72ab0e53dfb
 F ext/misc/vtablog.c 5538acd0c8ddaae372331bee11608d76973436b77d6a91e8635cfc9432fba5ae
@@ -2001,8 +2001,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 00845ac9ef2616e90f5f6a20da3dd040fa8bdcfe73f72fe9c06039561150a82d
-R 460848ff6f3cd63ef5eccab59824c77b
+P 74fbf6c2a97729e481d5562344e960d0c237aeb1f07240262d32a24fb1f4b5a3
+R ef722c3c17f5bd16a7c59b26dec45e05
 U drh
-Z 26961af5f4b759d7a43ac0a5cf8d117b
+Z c4e335313d89d964aa7abb0331378ddc
 # Remove this line to create a well-formed Fossil manifest.
index 581c44b25010fea18b6b668939ca4d83bc2c39d5..8a58829e44be647f4738f857e8cf0b69cd658f0e 100644 (file)
@@ -1 +1 @@
-74fbf6c2a97729e481d5562344e960d0c237aeb1f07240262d32a24fb1f4b5a3
\ No newline at end of file
+c8e41279294ea7c2f041c7d4cbbd85fce47d55f2f56180ca837316f7dfd75237
\ No newline at end of file