1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Enable the use of shared cache for an in-memory database, so that separate

database connections can share the same in-memory database.

FossilOrigin-Name: 4590e433f2a595bb80fb061024b0a3d2ca25b7b2
This commit is contained in:
drh
2012-05-26 18:06:38 +00:00
parent 3773b29167
commit afc8b7f0c1
6 changed files with 52 additions and 22 deletions

View File

@@ -1757,7 +1757,7 @@ int sqlite3BtreeOpen(
** If this Btree is a candidate for shared cache, try to find an
** existing BtShared object that we can share with
*/
if( isMemdb==0 && isTempDb==0 ){
if( isTempDb==0 ){
if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){
int nFullPathname = pVfs->mxPathname+1;
char *zFullPathname = sqlite3Malloc(nFullPathname);
@@ -1767,11 +1767,16 @@ int sqlite3BtreeOpen(
sqlite3_free(p);
return SQLITE_NOMEM;
}
rc = sqlite3OsFullPathname(pVfs, zFilename, nFullPathname, zFullPathname);
if( rc ){
sqlite3_free(zFullPathname);
sqlite3_free(p);
return rc;
if( isMemdb ){
memcpy(zFullPathname, zFilename, sqlite3Strlen30(zFilename)+1);
}else{
rc = sqlite3OsFullPathname(pVfs, zFilename,
nFullPathname, zFullPathname);
if( rc ){
sqlite3_free(zFullPathname);
sqlite3_free(p);
return rc;
}
}
#if SQLITE_THREADSAFE
mutexOpen = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_OPEN);