aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/global.c12
-rw-r--r--src/main.c7
-rw-r--r--src/memdb.c11
-rw-r--r--src/sqlite.h.in12
-rw-r--r--src/sqliteInt.h3
5 files changed, 36 insertions, 9 deletions
diff --git a/src/global.c b/src/global.c
index f1a391248..a78ea65a7 100644
--- a/src/global.c
+++ b/src/global.c
@@ -189,6 +189,13 @@ const unsigned char sqlite3CtypeMap[256] = {
#endif
+/* The default maximum size of an in-memory database created using
+** sqlite3_deserialize()
+*/
+#ifndef SQLITE_MEMDB_DEFAULT_MAXSIZE
+# define SQLITE_MEMDB_DEFAULT_MAXSIZE 1073741824
+#endif
+
/*
** The following singleton contains the global configuration for
** the SQLite library.
@@ -236,13 +243,16 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = {
0, /* xVdbeBranch */
0, /* pVbeBranchArg */
#endif
+#ifdef SQLITE_ENABLE_DESERIALIZE
+ SQLITE_MEMDB_DEFAULT_MAXSIZE, /* mxMemdbSize */
+#endif
#ifndef SQLITE_UNTESTABLE
0, /* xTestCallback */
#endif
0, /* bLocaltimeFault */
0, /* bInternalFunctions */
0x7ffffffe, /* iOnceResetThreshold */
- SQLITE_DEFAULT_SORTERREF_SIZE /* szSorterRef */
+ SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */
};
/*
diff --git a/src/main.c b/src/main.c
index efffc2b63..c40e6e877 100644
--- a/src/main.c
+++ b/src/main.c
@@ -653,6 +653,13 @@ int sqlite3_config(int op, ...){
}
#endif /* SQLITE_ENABLE_SORTER_REFERENCES */
+#ifdef SQLITE_ENABLE_DESERIALIZE
+ case SQLITE_CONFIG_MEMDB_MAXSIZE: {
+ sqlite3GlobalConfig.mxMemdbSize = va_arg(ap, sqlite3_int64);
+ break;
+ }
+#endif /* SQLITE_ENABLE_DESERIALIZE */
+
default: {
rc = SQLITE_ERROR;
break;
diff --git a/src/memdb.c b/src/memdb.c
index 75e83a95d..9252164a6 100644
--- a/src/memdb.c
+++ b/src/memdb.c
@@ -42,11 +42,6 @@ struct MemFile {
int eLock; /* Most recent lock against this file */
};
-/* The default maximum size of an in-memory database */
-#ifndef SQLITE_MEMDB_DEFAULT_MAXSIZE
-# define SQLITE_MEMDB_DEFAULT_MAXSIZE 1073741824
-#endif
-
/*
** Methods for MemFile
*/
@@ -346,7 +341,7 @@ static int memdbOpen(
assert( pOutFlags!=0 ); /* True because flags==SQLITE_OPEN_MAIN_DB */
*pOutFlags = flags | SQLITE_OPEN_MEMORY;
p->base.pMethods = &memdb_io_methods;
- p->szMax = SQLITE_MEMDB_DEFAULT_MAXSIZE;
+ p->szMax = sqlite3GlobalConfig.mxMemdbSize;
return SQLITE_OK;
}
@@ -598,8 +593,8 @@ int sqlite3_deserialize(
p->sz = szDb;
p->szAlloc = szBuf;
p->szMax = szBuf;
- if( p->szMax<SQLITE_MEMDB_DEFAULT_MAXSIZE ){
- p->szMax = SQLITE_MEMDB_DEFAULT_MAXSIZE;
+ if( p->szMax<sqlite3GlobalConfig.mxMemdbSize ){
+ p->szMax = sqlite3GlobalConfig.mxMemdbSize;
}
p->mFlags = mFlags;
rc = SQLITE_OK;
diff --git a/src/sqlite.h.in b/src/sqlite.h.in
index eb7895364..bbc1d13b3 100644
--- a/src/sqlite.h.in
+++ b/src/sqlite.h.in
@@ -1982,6 +1982,17 @@ struct sqlite3_mem_methods {
** negative value for this option restores the default behaviour.
** This option is only available if SQLite is compiled with the
** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.
+**
+** [[SQLITE_CONFIG_MEMDB_MAXSIZE]]
+** <dt>SQLITE_CONFIG_MEMDB_MAXSIZE
+** <dd>The SQLITE_CONFIG_MEMDB_MAXSIZE option accepts a single parameter
+** [sqlite3_int64] parameter which is the default maximum size for an in-memory
+** database created using [sqlite3_deserialize()]. This default maximum
+** size can be adjusted up or down for individual databases using the
+** [SQLITE_FCNTL_SIZE_LIMIT] [sqlite3_file_control|file-control]. If this
+** configuration setting is never used, then the default maximum is determined
+** by the [SQLITE_MEMDB_DEFAULT_MAXSIZE] compile-time option. If that
+** compile-time option is not set, then the default maximum is 1073741824.
** </dl>
*/
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
@@ -2012,6 +2023,7 @@ struct sqlite3_mem_methods {
#define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */
#define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */
#define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */
+#define SQLITE_CONFIG_MEMDB_MAXSIZE 29 /* sqlite3_int64 */
/*
** CAPI3REF: Database Connection Configuration Options
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index b67b3ed76..e8211a142 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -3428,6 +3428,9 @@ struct Sqlite3Config {
void (*xVdbeBranch)(void*,unsigned iSrcLine,u8 eThis,u8 eMx); /* Callback */
void *pVdbeBranchArg; /* 1st argument */
#endif
+#ifdef SQLITE_ENABLE_DESERIALIZE
+ sqlite3_int64 mxMemdbSize; /* Default max memdb size */
+#endif
#ifndef SQLITE_UNTESTABLE
int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */
#endif