aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/attach.c18
-rw-r--r--src/memdb.c45
2 files changed, 21 insertions, 42 deletions
diff --git a/src/attach.c b/src/attach.c
index 151b52e7a..f177f1a5b 100644
--- a/src/attach.c
+++ b/src/attach.c
@@ -84,7 +84,13 @@ static void attachFunc(
if( zFile==0 ) zFile = "";
if( zName==0 ) zName = "";
- if( db->init.reopenMemdb ){
+#ifdef SQLITE_ENABLE_MEMDB
+# define REOPEN_AS_MEMDB(db) (db->init.reopenMemdb)
+#else
+# define REOPEN_AS_MEMDB(db) (0)
+#endif
+
+ if( REOPEN_AS_MEMDB(db) ){
/* This is not a real ATTACH. Instead, this routine is being called
** from sqlite3_deserialize() to close database db->init.iDb and
** reopen it as a MemDB */
@@ -96,9 +102,9 @@ static void attachFunc(
pNew->pSchema = 0;
rc = sqlite3BtreeOpen(pVfs, "x", db, &pNew->pBt, 0, SQLITE_OPEN_MAIN_DB);
}else{
- /* This is a real ATTACH */
-
- /* Check for the following errors:
+ /* This is a real ATTACH
+ **
+ ** Check for the following errors:
**
** * Too many attached databases,
** * Transaction currently open
@@ -178,7 +184,7 @@ static void attachFunc(
sqlite3BtreeLeave(pNew->pBt);
}
pNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;
- if( !db->init.reopenMemdb ) pNew->zDbSName = sqlite3DbStrDup(db, zName);
+ if( !REOPEN_AS_MEMDB(db) ) pNew->zDbSName = sqlite3DbStrDup(db, zName);
if( rc==SQLITE_OK && pNew->zDbSName==0 ){
rc = SQLITE_NOMEM_BKPT;
}
@@ -235,7 +241,7 @@ static void attachFunc(
}
}
#endif
- if( rc ){
+ if( rc && !REOPEN_AS_MEMDB(db) ){
int iDb = db->nDb - 1;
assert( iDb>=2 );
if( db->aDb[iDb].pBt ){
diff --git a/src/memdb.c b/src/memdb.c
index 5a1f12dcb..5aa66f1fd 100644
--- a/src/memdb.c
+++ b/src/memdb.c
@@ -10,8 +10,11 @@
**
******************************************************************************
**
-** This is an in-memory VFS implementation. The application supplies
-** a chunk of memory to hold the database file.
+** This file implements in-memory VFS. A database is held as a contiguous
+** block of memory.
+**
+** This file also implements interface sqlite3_serialize() and
+** sqlite3_deserialize().
*/
#ifdef SQLITE_ENABLE_MEMDB
#include "sqliteInt.h"
@@ -52,10 +55,6 @@ static int memdbCheckReservedLock(sqlite3_file*, int *pResOut);
static int memdbFileControl(sqlite3_file*, int op, void *pArg);
static int memdbSectorSize(sqlite3_file*);
static int memdbDeviceCharacteristics(sqlite3_file*);
-static int memdbShmMap(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
-static int memdbShmLock(sqlite3_file*, int offset, int n, int flags);
-static void memdbShmBarrier(sqlite3_file*);
-static int memdbShmUnmap(sqlite3_file*, int deleteFlag);
static int memdbFetch(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);
static int memdbUnfetch(sqlite3_file*, sqlite3_int64 iOfst, void *p);
@@ -112,10 +111,10 @@ static const sqlite3_io_methods memdb_io_methods = {
memdbFileControl, /* xFileControl */
memdbSectorSize, /* xSectorSize */
memdbDeviceCharacteristics, /* xDeviceCharacteristics */
- memdbShmMap, /* xShmMap */
- memdbShmLock, /* xShmLock */
- memdbShmBarrier, /* xShmBarrier */
- memdbShmUnmap, /* xShmUnmap */
+ 0, /* xShmMap */
+ 0, /* xShmLock */
+ 0, /* xShmBarrier */
+ 0, /* xShmUnmap */
memdbFetch, /* xFetch */
memdbUnfetch /* xUnfetch */
};
@@ -264,32 +263,6 @@ static int memdbDeviceCharacteristics(sqlite3_file *pFile){
SQLITE_IOCAP_SEQUENTIAL;
}
-/* Create a shared memory file mapping */
-static int memdbShmMap(
- sqlite3_file *pFile,
- int iPg,
- int pgsz,
- int bExtend,
- void volatile **pp
-){
- return SQLITE_IOERR_SHMMAP;
-}
-
-/* Perform locking on a shared-memory segment */
-static int memdbShmLock(sqlite3_file *pFile, int offset, int n, int flags){
- return SQLITE_IOERR_SHMLOCK;
-}
-
-/* Memory barrier operation on shared memory */
-static void memdbShmBarrier(sqlite3_file *pFile){
- return;
-}
-
-/* Unmap a shared memory segment */
-static int memdbShmUnmap(sqlite3_file *pFile, int deleteFlag){
- return SQLITE_OK;
-}
-
/* Fetch a page of a memory-mapped file */
static int memdbFetch(
sqlite3_file *pFile,