diff options
author | stephan <stephan@noemail.net> | 2022-09-16 01:08:06 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-09-16 01:08:06 +0000 |
commit | d22cfa8c80e9d95ed4068083f7dd5ffbb8f29dda (patch) | |
tree | 271c9e736ecfff32190c503b0bd4ee2d107263a3 /src | |
parent | 5fd8f27bfb5abf924ca26d239b3352d7b6d82264 (diff) | |
download | sqlite-d22cfa8c80e9d95ed4068083f7dd5ffbb8f29dda.tar.gz sqlite-d22cfa8c80e9d95ed4068083f7dd5ffbb8f29dda.zip |
Pull the src/os_kv.c part of [13839759f8f4] into the kv-vfs branch.
FossilOrigin-Name: e334449912d5176e355d02024a07ed867741f71c9d10ce6744ca800414bf3eeb
Diffstat (limited to 'src')
-rw-r--r-- | src/os_kv.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/os_kv.c b/src/os_kv.c index 62214a13a..17d4c254e 100644 --- a/src/os_kv.c +++ b/src/os_kv.c @@ -351,7 +351,7 @@ int sqlite3__wasm_emjs_kvvfs(int whichOp){ switch( whichOp ){ case 0: break; case 1: - kvstorageWrite(zClass, zKey, "world"); + rc = kvstorageWrite(zClass, zKey, "world"); break; case 2: { char buffer[128] = {0}; @@ -602,7 +602,7 @@ static void kvvfsDecodeJournal( const char *zTxt, /* Text encoding. Zero-terminated */ int nTxt /* Bytes in zTxt, excluding zero terminator */ ){ - unsigned int n = 0; + unsigned int n; int c, i, mult; i = 0; mult = 1; @@ -634,10 +634,10 @@ static sqlite3_int64 kvvfsReadFileSize(KVVfsFile *pFile){ kvstorageRead(pFile->zClass, "sz", zData, sizeof(zData)-1); return strtoll(zData, 0, 0); } -static void kvvfsWriteFileSize(KVVfsFile *pFile, sqlite3_int64 sz){ +static int kvvfsWriteFileSize(KVVfsFile *pFile, sqlite3_int64 sz){ char zData[50]; sqlite3_snprintf(sizeof(zData), zData, "%lld", sz); - kvstorageWrite(pFile->zClass, "sz", zData); + return kvstorageWrite(pFile->zClass, "sz", zData); } /****** sqlite3_io_methods methods ******************************************/ @@ -788,7 +788,9 @@ static int kvvfsWriteDb( pgno = 1 + iOfst/iAmt; sqlite3_snprintf(sizeof(zKey), zKey, "%u", pgno); kvvfsEncode(zBuf, iAmt, aData); - kvstorageWrite(pFile->zClass, zKey, aData); + if( kvstorageWrite(pFile->zClass, zKey, aData) ){ + return SQLITE_IOERR; + } if( iOfst+iAmt > pFile->szDb ){ pFile->szDb = iOfst + iAmt; } @@ -825,8 +827,7 @@ static int kvvfsTruncateDb(sqlite3_file *pProtoFile, sqlite_int64 size){ pgno++; } pFile->szDb = size; - kvvfsWriteFileSize(pFile, size); - return SQLITE_OK; + return kvvfsWriteFileSize(pFile, size) ? SQLITE_IOERR : SQLITE_OK; } return SQLITE_IOERR; } @@ -854,17 +855,18 @@ static int kvvfsSyncJrnl(sqlite3_file *pProtoFile, int flags){ }while( n>0 ); zOut[i++] = ' '; kvvfsEncode(pFile->aJrnl, pFile->nJrnl, &zOut[i]); - kvstorageWrite(pFile->zClass, "jrnl", zOut); + i = kvstorageWrite(pFile->zClass, "jrnl", zOut); sqlite3_free(zOut); - return SQLITE_OK; + return i ? SQLITE_IOERR : SQLITE_OK; } static int kvvfsSyncDb(sqlite3_file *pProtoFile, int flags){ KVVfsFile *pFile = (KVVfsFile *)pProtoFile; + int rc = SQLITE_OK; SQLITE_KV_LOG(("xSync('%s-db')\n", pFile->zClass)); - if( pFile->szDb>0 ){ - kvvfsWriteFileSize(pFile, pFile->szDb); + if( pFile->szDb>0 && 0!=kvvfsWriteFileSize(pFile, pFile->szDb) ){ + rc = SQLITE_IOERR; } - return SQLITE_OK; + return rc; } /* |