/*****************************************************************************
** Debugging logic
*/
-#if 1
+#if 0
#define KVVFS_TRACE(X) printf X;
#else
#define KVVFS_TRACE(X)
#endif
+#if 0
+#define KVVFS_LOG(X) printf X;
+#else
+#define KVVFS_LOG(X)
+#endif
/*****************************************************************************
KVVFS_TRACE(("KVVFS-READ %-14s (-1)\n", pStore->zKey));
return -1;
}else{
- fread(zBuf, nBuf-1, 1, fd);
+ sqlite3_int64 n = fread(zBuf, 1, nBuf-1, fd);
fclose(fd);
- KVVFS_TRACE(("KVVFS-READ %-14s (%d) %.30s\n", pStore->zKey,
- nBuf-1, zBuf));
- return nBuf-1;
+ zBuf[n] = 0;
+ KVVFS_TRACE(("KVVFS-READ %-14s (%lld) %.30s\n", pStore->zKey,
+ n, zBuf));
+ return (int)n;
}
}
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 ){
}
}
sqlite3_free(pFile->aJrnl);
- sqlite3_free(pFile);
return SQLITE_OK;
}
** and so forth.
*/
int k;
- for(k=1; a[i+k]==0 && i+k<nData; k++){}
- i += k;
+ for(k=1; i+k<nData && a[i+k]==0; k++){}
+ i += k-1;
while( k>0 ){
aOut[j++] = 'a'+(k%26);
k /= 26;
/* Convert hex to binary */
static char kvvfsHexToBinary(char c){
if( c>='0' && c<='9' ) return c - '0';
- if( c>='a' && c<='f' ) return c - 'a' + 10;
+ if( c>='A' && c<='F' ) return c - 'A' + 10;
return 0;
}
}
}else{
if( j>nOut ) return -1;
- aOut[j] = kvvfsHexToBinary(aIn[i])<<4;
- i++;
- aOut[j] += kvvfsHexToBinary(aIn[i]);
- i++;
+ aOut[j] = kvvfsHexToBinary(aIn[i++])<<4;
+ aOut[j++] += kvvfsHexToBinary(aIn[i++]);
}
}
return j;
sqlite_int64 iOfst
){
assert( pFile->isJournal );
+ KVVFS_LOG(("xRead('journal',%d,%lld)\n", iAmt, iOfst));
if( pFile->aJrnl==0 ){
int szTxt = kvstorageRead(pFile->pVfs->pStore, "journal", 0, 0);
char *aTxt;
char aData[131073];
assert( iOfst>=0 );
assert( iAmt>=0 );
- if( (iOfst % iAmt)!=0 ){
- return SQLITE_IOERR_READ;
- }
- if( iAmt!=100 || iOfst!=0 ){
+ KVVFS_LOG(("xRead('db',%d,%lld)\n", iAmt, iOfst));
+ if( iOfst+iAmt>=512 ){
+ if( (iOfst % iAmt)!=0 ){
+ return SQLITE_IOERR_READ;
+ }
if( (iAmt & (iAmt-1))!=0 || iAmt<512 || iAmt>65536 ){
return SQLITE_IOERR_READ;
}
pFile->szPage = iAmt;
+ pgno = 1 + iOfst/iAmt;
+ }else{
+ pgno = 1;
}
- pgno = 1 + iOfst/iAmt;
sqlite3_snprintf(sizeof(zKey), zKey, "pg-%u", pgno);
got = kvstorageRead(pFile->pVfs->pStore, zKey, aData, sizeof(aData)-1);
if( got<0 ){
n = 0;
}else{
aData[got] = 0;
- n = kvvfsDecode(aData, zBuf, iAmt);
+ if( iOfst+iAmt<512 ){
+ n = kvvfsDecode(aData, &aData[1000], 1000);
+ if( n>=iOfst+iAmt ){
+ memcpy(zBuf, &aData[1000+iOfst], iAmt);
+ n = iAmt;
+ }else{
+ n = 0;
+ }
+ }else{
+ n = kvvfsDecode(aData, zBuf, iAmt);
+ }
}
if( n<iAmt ){
memset(zBuf+n, 0, iAmt-n);
}else{
rc = kvvfsReadFromDb(pFile,zBuf,iAmt,iOfst);
}
+ KVVFS_LOG(("xRead result: 0x%x\n", rc));
return rc;
}
sqlite_int64 iOfst
){
sqlite3_int64 iEnd = iOfst+iAmt;
+ KVVFS_LOG(("xWrite('journal',%d,%lld)\n", iAmt, iOfst));
if( iEnd>=0x10000000 ) return SQLITE_FULL;
if( pFile->aJrnl==0 || pFile->nJrnl<iEnd ){
char *aNew = sqlite3_realloc(pFile->aJrnl, iEnd);
unsigned int pgno;
char zKey[30];
char aData[131073];
+ KVVFS_LOG(("xWrite('db',%d,%lld)\n", iAmt, iOfst));
assert( iAmt>=512 && iAmt<=65536 );
assert( (iAmt & (iAmt-1))==0 );
pgno = 1 + iOfst/iAmt;
}else{
rc = kvvfsWriteToDb(pFile,zBuf,iAmt,iOfst);
}
+ KVVFS_LOG(("xWrite result: 0x%x\n", rc));
return rc;
}
static int kvvfsTruncate(sqlite3_file *pProtoFile, sqlite_int64 size){
KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
if( pFile->isJournal ){
+ KVVFS_LOG(("xTruncate('journal',%lld)\n", size));
assert( size==0 );
kvstorageDelete(pFile->pVfs->pStore, "journal");
sqlite3_free(pFile->aJrnl);
){
char zKey[50];
unsigned int pgno, pgnoMax;
+ KVVFS_LOG(("xTruncate('db',%lld)\n", size));
pgno = 1 + size/pFile->szPage;
pgnoMax = 2 + pFile->szDb/pFile->szPage;
while( pgno<=pgnoMax ){
KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
char *zOut;
if( !pFile->isJournal ){
+ KVVFS_LOG(("xSync('db')\n"));
if( pFile->szDb>0 ){
kvvfsWriteFileSize(pFile, pFile->szDb);
}
return SQLITE_OK;
}
+ KVVFS_LOG(("xSync('journal')\n"));
if( pFile->nJrnl<=0 ){
return kvvfsTruncate(pProtoFile, 0);
}
static int kvvfsFileSize(sqlite3_file *pProtoFile, sqlite_int64 *pSize){
KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
if( pFile->isJournal ){
+ KVVFS_LOG(("xFileSize('journal')\n"));
*pSize = pFile->nJrnl;
}else{
- *pSize = pFile->szDb;
+ KVVFS_LOG(("xFileSize('db')\n"));
+ if( pFile->szDb>=0 ){
+ *pSize = pFile->szDb;
+ }else{
+ *pSize = kvvfsReadFileSize(pFile);
+ }
}
+ KVVFS_LOG(("xFileSize: %lld\n", *pSize));
return SQLITE_OK;
}
static int kvvfsLock(sqlite3_file *pProtoFile, int eLock){
KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
assert( !pFile->isJournal );
+ KVVFS_LOG(("xLock(%d)\n", eLock));
+
if( eLock!=SQLITE_LOCK_NONE ){
pFile->szDb = kvvfsReadFileSize(pFile);
}
static int kvvfsUnlock(sqlite3_file *pProtoFile, int eLock){
KVVfsFile *pFile = (KVVfsFile *)pProtoFile;
assert( !pFile->isJournal );
+ KVVFS_LOG(("xUnlock(%d)\n", eLock));
if( eLock==SQLITE_LOCK_NONE ){
pFile->szDb = -1;
}
** Check if another file-handle holds a RESERVED lock on an kvvfs-file.
*/
static int kvvfsCheckReservedLock(sqlite3_file *pProtoFile, int *pResOut){
+ KVVFS_LOG(("xCheckReservedLock\n"));
*pResOut = 0;
return SQLITE_OK;
}
){
KVVfsFile *pFile = (KVVfsFile*)pProtoFile;
KVVfsVfs *pVfs = (KVVfsVfs*)pProtoVfs;
+ KVVFS_LOG(("xOpen(\"%s\")\n", zName));
pFile->aJrnl = 0;
pFile->nJrnl = 0;
pFile->isJournal = sqlite3_strglob("*-journal", zName)==0;
int *pResOut
){
KVVfsVfs *pVfs = (KVVfsVfs*)pProtoVfs;
+ KVVFS_LOG(("xAccess(\"%s\")\n", zPath));
if( sqlite3_strglob("*-journal", zPath)==0 ){
*pResOut = kvstorageRead(pVfs->pStore, "journal", 0, 0)>0;
+ }else if( sqlite3_strglob("*-wal", zPath)==0 ){
+ *pResOut = 0;
}else{
*pResOut = 1;
}
+ KVVFS_LOG(("xAccess returns %d\n",*pResOut));
return SQLITE_OK;
}
char *zOut
){
size_t nPath = strlen(zPath);
+ KVVFS_LOG(("xFullPathname(\"%s\")\n", zPath));
if( nOut<nPath+1 ) nPath = nOut - 1;
memcpy(zOut, zPath, nPath);
zOut[nPath] = 0;
-C Compiles\sand\sloads\sas\san\sextension.\s\sStarts\sto\srun\sbut\squickly\shits\sissues.
-D 2022-09-08T17:12:12.069
+C Simple\sreading\sand\swriting\snow\sworks.
+D 2022-09-09T11:41:54.677
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F ext/misc/unionvtab.c 36237f0607ca954ac13a4a0e2d2ac40c33bc6e032a5f55f431713061ef1625f9
F ext/misc/urifuncs.c f71360d14fa9e7626b563f1f781c6148109462741c5235ac63ae0f8917b9c751
F ext/misc/uuid.c 5bb2264c1b64d163efa46509544fd7500cb8769cb7c16dd52052da8d961505cf
-F ext/misc/vfskv.c 8664e43778e5d7cda6abd2e57ec374e7e0eb424ff4da093847bac7aa154c7789
+F ext/misc/vfskv.c 8c0d3af0b68fdee50ff46b64bec28d693805bd5fc5e26605e198915e9392d6e3
F ext/misc/vfslog.c 3932ab932eeb2601dbc4447cb14d445aaa9fbe43b863ef5f014401c3420afd20
F ext/misc/vfsstat.c 474d08efc697b8eba300082cb1eb74a5f0f3df31ed257db1cb07e72ab0e53dfb
F ext/misc/vtablog.c 5538acd0c8ddaae372331bee11608d76973436b77d6a91e8635cfc9432fba5ae
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P a329939c32e33d8d00066ba3d4327f07cca1b4e67de0b8d85f1e7f98afe40954
-R 3c0347d709594b19afa07b9bd97b3623
+P 2e38726f46918b28b5c638967f960a20afd3fe84ad245f3bea39a1d64980435b
+R d99171917ec9b13f78c647c76b29147e
U drh
-Z c98d8a23118cf655e6b32d119c295b3c
+Z d5b6013a0fd62dab0ae32db15d37fb8f
# Remove this line to create a well-formed Fossil manifest.