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

Simplify the "sqlite3" command in the TCL interface. The filename is now

optional.  There is a new --memdb option with an argument that is the blob
to which the database content should be initialized.

FossilOrigin-Name: 47398ae77236a92f6b9345aa397361b6df127a9a2895c0771d506b0be10822b9
This commit is contained in:
drh
2018-01-03 13:20:02 +00:00
parent 7de2c3e5ee
commit 4dcac40e3d
6 changed files with 94 additions and 49 deletions

View File

@@ -475,13 +475,22 @@ int sqlite3_memdb_config(
unsigned int mFlags
){
MemFile *p = memdbFromDbSchema(db, zSchema);
if( p==0 ) return SQLITE_ERROR;
if( p->eLock!=SQLITE_LOCK_NONE || p->nMmap>0 ) return SQLITE_BUSY;
if( p->mFlags & SQLITE_MEMDB_FREEONCLOSE ) sqlite3_free(p->aData);
p->aData = aData;
p->sz = sz;
p->szMax = szMax;
p->mFlags = mFlags;
int rc;
if( p==0 ){
rc = SQLITE_ERROR;
}else if( p->eLock!=SQLITE_LOCK_NONE || p->nMmap>0 ){
rc = SQLITE_BUSY;
}else{
if( p->mFlags & SQLITE_MEMDB_FREEONCLOSE ) sqlite3_free(p->aData);
p->aData = aData;
p->sz = sz;
p->szMax = szMax;
p->mFlags = mFlags;
rc = SQLITE_OK;
}
if( rc!=SQLITE_OK && (mFlags & SQLITE_MEMDB_FREEONCLOSE)!=0 ){
sqlite3_free(aData);
}
return SQLITE_OK;
}