From: drh Date: Tue, 6 Mar 2018 19:14:32 +0000 (+0000) Subject: Simplifications to the memdb VFS. X-Git-Tag: version-3.23.0~85^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=14714167f700c005ad08007677d6ef40adfd54ea;p=thirdparty%2Fsqlite.git Simplifications to the memdb VFS. FossilOrigin-Name: 6c3f723a6856fa38ea3f11a36b56f46c5c1fcf17f4daf712e5e0b42562d5f4c6 --- diff --git a/manifest b/manifest index 3dabf8b492..f599a85e45 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\smemdb\sVFS. -D 2018-03-06T04:01:08.317 +C Simplifications\sto\sthe\smemdb\sVFS. +D 2018-03-06T19:14:32.801 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 1d5a68043cc4d8a6e45b37e2639b148cdd7973aa75e90ec71e12d55cd95e32c0 @@ -460,7 +460,7 @@ F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944 -F src/memdb.c a559d61e55a715ec48b48685d20431fde1e114fb4df689df89334cedf4c0101c +F src/memdb.c ffdca40946f9cff49c6d0f452648233d1a5234bb1dfa456787ee82333164d126 F src/memjournal.c 6f3d36a0a8f72f48f6c3c722f04301ac64f2515435fa42924293e46fc7994661 F src/msvc.h 4942752b6a253116baaa8de75256c51a459a5e81 F src/mutex.c b021263554c8a3995e9d53193b8194b96d1ed28e06c3b532dd7f7d29cf0c7d53 @@ -1710,7 +1710,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6399e101d5f6b8582640e0d90783e56042eaa1600db3bd02f8df5e7b01ac1cab -R 308fbe14b615cda601b7af6fc89baf23 +P a14fed69d0d4932fc6c71cf8acc5199cca4efbd10bca563a8e86038d6afd5c64 +R b9fff9a384a4ae44f14923e3716823bc U drh -Z b79ee0d17ceeeb3759cd662f53a7e6c2 +Z ed8ab2a467fe746aa3cc4991867879e0 diff --git a/manifest.uuid b/manifest.uuid index bbe7322aa5..77b67bccf4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a14fed69d0d4932fc6c71cf8acc5199cca4efbd10bca563a8e86038d6afd5c64 \ No newline at end of file +6c3f723a6856fa38ea3f11a36b56f46c5c1fcf17f4daf712e5e0b42562d5f4c6 \ No newline at end of file diff --git a/src/memdb.c b/src/memdb.c index ec917e776b..b2eefde955 100644 --- a/src/memdb.c +++ b/src/memdb.c @@ -51,7 +51,7 @@ static int memdbTruncate(sqlite3_file*, sqlite3_int64 size); static int memdbSync(sqlite3_file*, int flags); static int memdbFileSize(sqlite3_file*, sqlite3_int64 *pSize); static int memdbLock(sqlite3_file*, int); -static int memdbCheckReservedLock(sqlite3_file*, int *pResOut); +/* static int memdbCheckReservedLock(sqlite3_file*, int *pResOut);// not used */ static int memdbFileControl(sqlite3_file*, int op, void *pArg); /* static int memdbSectorSize(sqlite3_file*); // not used */ static int memdbDeviceCharacteristics(sqlite3_file*); @@ -62,7 +62,7 @@ static int memdbUnfetch(sqlite3_file*, sqlite3_int64 iOfst, void *p); ** Methods for MemVfs */ static int memdbOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *); -static int memdbDelete(sqlite3_vfs*, const char *zName, int syncDir); +/* static int memdbDelete(sqlite3_vfs*, const char *zName, int syncDir); */ static int memdbAccess(sqlite3_vfs*, const char *zName, int flags, int *); static int memdbFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut); static void *memdbDlOpen(sqlite3_vfs*, const char *zFilename); @@ -71,7 +71,7 @@ static void (*memdbDlSym(sqlite3_vfs *pVfs, void *p, const char*zSym))(void); static void memdbDlClose(sqlite3_vfs*, void*); static int memdbRandomness(sqlite3_vfs*, int nByte, char *zOut); static int memdbSleep(sqlite3_vfs*, int microseconds); -static int memdbCurrentTime(sqlite3_vfs*, double*); +/* static int memdbCurrentTime(sqlite3_vfs*, double*); */ static int memdbGetLastError(sqlite3_vfs*, int, char *); static int memdbCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*); @@ -83,7 +83,7 @@ static sqlite3_vfs memdb_vfs = { "memdb", /* zName */ 0, /* pAppData (set when registered) */ memdbOpen, /* xOpen */ - memdbDelete, /* xDelete */ + 0, /* memdbDelete, */ /* xDelete */ memdbAccess, /* xAccess */ memdbFullPathname, /* xFullPathname */ memdbDlOpen, /* xDlOpen */ @@ -92,7 +92,7 @@ static sqlite3_vfs memdb_vfs = { memdbDlClose, /* xDlClose */ memdbRandomness, /* xRandomness */ memdbSleep, /* xSleep */ - memdbCurrentTime, /* xCurrentTime */ + 0, /* memdbCurrentTime, */ /* xCurrentTime */ memdbGetLastError, /* xGetLastError */ memdbCurrentTimeInt64 /* xCurrentTimeInt64 */ }; @@ -107,7 +107,7 @@ static const sqlite3_io_methods memdb_io_methods = { memdbFileSize, /* xFileSize */ memdbLock, /* xLock */ memdbLock, /* xUnlock - same as xLock in this case */ - memdbCheckReservedLock, /* xCheckReservedLock */ + 0, /* memdbCheckReservedLock, */ /* xCheckReservedLock */ memdbFileControl, /* xFileControl */ 0, /* memdbSectorSize,*/ /* xSectorSize */ memdbDeviceCharacteristics, /* xDeviceCharacteristics */ @@ -193,16 +193,14 @@ static int memdbWrite( /* ** Truncate an memdb-file. +** +** In rollback mode (which is always the case for memdb, as it does not +** support WAL mode) the truncate() method is only used to reduce +** the size of a file, never to increase the size. */ static int memdbTruncate(sqlite3_file *pFile, sqlite_int64 size){ MemFile *p = (MemFile *)pFile; - if( size>p->sz ){ - int rc; - if( size>p->szMax && (rc = memdbEnlarge(p, size))!=SQLITE_OK ){ - return rc; - } - memset(p->aData+p->sz, 0, size-p->sz); - } + if( NEVER(size>p->sz) ) return SQLITE_FULL; p->sz = size; return SQLITE_OK; } @@ -232,6 +230,7 @@ static int memdbLock(sqlite3_file *pFile, int eLock){ return SQLITE_OK; } +#if 0 /* Never used because memdbAccess() always returns false */ /* ** Check if another file-handle holds a RESERVED lock on an memdb-file. */ @@ -239,6 +238,7 @@ static int memdbCheckReservedLock(sqlite3_file *pFile, int *pResOut){ *pResOut = 0; return SQLITE_OK; } +#endif /* ** File control method. For custom operations on an memdb-file. @@ -308,11 +308,14 @@ static int memdbOpen( } memset(p, 0, sizeof(*p)); p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE | SQLITE_DESERIALIZE_FREEONCLOSE; - if( pOutFlags ) *pOutFlags = flags | SQLITE_OPEN_MEMORY; + assert( pOutFlags!=0 ); /* True because flags==SQLITE_OPEN_MAIN_DB */ + *pOutFlags = flags | SQLITE_OPEN_MEMORY; p->base.pMethods = &memdb_io_methods; return SQLITE_OK; } +#if 0 /* Only used to delete rollback journals, master journals, and WAL + ** files, none of which exist in memdb. So this routine is never used */ /* ** Delete the file located at zPath. If the dirSync argument is true, ** ensure the file-system modifications are synced to disk before @@ -321,10 +324,13 @@ static int memdbOpen( static int memdbDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ return SQLITE_IOERR_DELETE; } +#endif /* ** Test for access permissions. Return true if the requested permission ** is available, or false otherwise. +** +** With memdb, no files ever exist on disk. So always return false. */ static int memdbAccess( sqlite3_vfs *pVfs, @@ -397,12 +403,14 @@ static int memdbSleep(sqlite3_vfs *pVfs, int nMicro){ return ORIGVFS(pVfs)->xSleep(ORIGVFS(pVfs), nMicro); } +#if 0 /* Never used. Modern cores only call xCurrentTimeInt64() */ /* ** Return the current time as a Julian Day number in *pTimeOut. */ static int memdbCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){ return ORIGVFS(pVfs)->xCurrentTime(ORIGVFS(pVfs), pTimeOut); } +#endif static int memdbGetLastError(sqlite3_vfs *pVfs, int a, char *b){ return ORIGVFS(pVfs)->xGetLastError(ORIGVFS(pVfs), a, b); @@ -528,15 +536,15 @@ int sqlite3_deserialize( goto end_deserialize; } p = memdbFromDbSchema(db, zSchema); - if( p==0 ){ - rc = SQLITE_ERROR; - }else{ - p->aData = pData; - p->sz = szDb; - p->szMax = szBuf; - p->mFlags = mFlags; - rc = SQLITE_OK; - } + /* The memdbFromDbSchema() call can only fail if zSchema is not + ** a valid schema name or if the schema is not a memdb schema. But + ** neither of those things can be true here, so failure is not possible */ + assert( p!=0 ); + p->aData = pData; + p->sz = szDb; + p->szMax = szBuf; + p->mFlags = mFlags; + rc = SQLITE_OK; end_deserialize: sqlite3_finalize(pStmt); sqlite3_mutex_leave(db->mutex);