1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-24 08:21:29 +03:00

Only open a read-only connection to shared-memory if the "readonly_shm=1" option is specified as part of the database file URI (and if a read-write connection fails).

FossilOrigin-Name: 671ba5fc59f7a958e5a4138d2425b1173a442ad7
This commit is contained in:
dan
2011-05-11 14:57:33 +00:00
parent 4edc6bf3ee
commit b6d2f9c5ef
11 changed files with 61 additions and 33 deletions

View File

@@ -76,6 +76,8 @@ static void attachFunc(
Db *aNew;
char *zErrDyn = 0;
sqlite3_vfs *pVfs;
const char *zVfs = db->pVfs->zName; /* Name of default (main) VFS */
int btflags = 0;
UNUSED_PARAMETER(NotUsed);
@@ -129,7 +131,7 @@ static void attachFunc(
** or may not be initialised.
*/
flags = db->openFlags;
rc = sqlite3ParseUri(db->pVfs->zName, zFile, &flags, &pVfs, &zPath, &zErr);
rc = sqlite3ParseUri(zVfs, zFile, &flags, &btflags, &pVfs, &zPath, &zErr);
if( rc!=SQLITE_OK ){
if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;
sqlite3_result_error(context, zErr, -1);
@@ -138,7 +140,7 @@ static void attachFunc(
}
assert( pVfs );
flags |= SQLITE_OPEN_MAIN_DB;
rc = sqlite3BtreeOpen(pVfs, zPath, db, &aNew->pBt, 0, flags);
rc = sqlite3BtreeOpen(pVfs, zPath, db, &aNew->pBt, btflags, flags);
sqlite3_free( zPath );
db->nDb++;
if( rc==SQLITE_CONSTRAINT ){