From 7cd81af3a99a51348a5bdc9fa41260b2da13415a Mon Sep 17 00:00:00 2001 From: drh <> Date: Thu, 8 Sep 2022 17:12:12 +0000 Subject: [PATCH] Compiles and loads as an extension. Starts to run but quickly hits issues. FossilOrigin-Name: 2e38726f46918b28b5c638967f960a20afd3fe84ad245f3bea39a1d64980435b --- ext/misc/vfskv.c | 23 ++++++++++++----------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/ext/misc/vfskv.c b/ext/misc/vfskv.c index 5d71816a82..bde2f08336 100644 --- a/ext/misc/vfskv.c +++ b/ext/misc/vfskv.c @@ -195,7 +195,7 @@ static int kvstorageWrite( kvstorageMakeKey(pStore, zKey); fd = fopen(pStore->zKey, "wb"); if( fd ){ - KVVFS_TRACE(("KVVFS-WRITE %-12s (%d) %.30s\n", pStore->zKey, + KVVFS_TRACE(("KVVFS-WRITE %-14s (%d) %.30s\n", pStore->zKey, (int)strlen(zData), zData)); fputs(zData, fd); fclose(fd); @@ -210,7 +210,7 @@ static int kvstorageWrite( static int kvstorageDelete(KVStorage *pStore, const char *zKey){ kvstorageMakeKey(pStore, zKey); unlink(pStore->zKey); - KVVFS_TRACE(("KVVFS-DELETE %-12s\n", pStore->zKey)); + KVVFS_TRACE(("KVVFS-DELETE %-14s\n", pStore->zKey)); return 0; } @@ -239,14 +239,14 @@ static int kvstorageRead( || stat(pStore->zKey, &buf)!=0 || !S_ISREG(buf.st_mode) ){ - KVVFS_TRACE(("KVVFS-READ %-12s (-1)\n", pStore->zKey)); + KVVFS_TRACE(("KVVFS-READ %-14s (-1)\n", pStore->zKey)); return -1; } if( nBuf<0 ){ return (int)buf.st_size; }else if( nBuf==1 ){ zBuf[0] = 0; - KVVFS_TRACE(("KVVFS-READ %-12s (%d)\n", pStore->zKey, + KVVFS_TRACE(("KVVFS-READ %-14s (%d)\n", pStore->zKey, (int)buf.st_size)); return (int)buf.st_size; } @@ -255,12 +255,12 @@ static int kvstorageRead( } fd = fopen(pStore->zKey, "rb"); if( fd==0 ){ - KVVFS_TRACE(("KVVFS-READ %-12s (-1)\n", pStore->zKey)); + KVVFS_TRACE(("KVVFS-READ %-14s (-1)\n", pStore->zKey)); return -1; }else{ fread(zBuf, nBuf-1, 1, fd); fclose(fd); - KVVFS_TRACE(("KVVFS-READ %-12s (%d) %.30s\n", pStore->zKey, + KVVFS_TRACE(("KVVFS-READ %-14s (%d) %.30s\n", pStore->zKey, nBuf-1, zBuf)); return nBuf-1; } @@ -456,7 +456,6 @@ static int kvvfsReadFromDb( int got, n; char zKey[30]; char aData[131073]; - assert( pFile->szDb>=0 ); assert( iOfst>=0 ); assert( iAmt>=0 ); if( (iOfst % iAmt)!=0 ){ @@ -472,10 +471,11 @@ static int kvvfsReadFromDb( sqlite3_snprintf(sizeof(zKey), zKey, "pg-%u", pgno); got = kvstorageRead(pFile->pVfs->pStore, zKey, aData, sizeof(aData)-1); if( got<0 ){ - return SQLITE_IOERR_READ; + n = 0; + }else{ + aData[got] = 0; + n = kvvfsDecode(aData, zBuf, iAmt); } - aData[got] = 0; - n = kvvfsDecode(aData, zBuf, iAmt); if( n