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

Add some very simple test cases (and resulting bug fixes) for release_memory(). (CVS 2826)

FossilOrigin-Name: 154282fca54bf03d310d6931660f99805bb5477f
This commit is contained in:
danielk1977
2005-12-19 14:18:11 +00:00
parent 13f7299bbe
commit 0190d1da46
9 changed files with 234 additions and 57 deletions

View File

@@ -11,7 +11,7 @@
*************************************************************************
** A TCL Interface to SQLite
**
** $Id: tclsqlite.c,v 1.140 2005/12/16 06:54:03 danielk1977 Exp $
** $Id: tclsqlite.c,v 1.141 2005/12/19 14:18:11 danielk1977 Exp $
*/
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
@@ -666,9 +666,9 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
"exists", "function", "last_insert_rowid",
"nullvalue", "onecolumn", "profile",
"progress", "rekey", "rollback_hook",
"soft_heap_limit", "timeout", "total_changes",
"trace", "transaction", "update_hook",
"version", 0
"release_memory", "soft_heap_limit", "timeout",
"total_changes", "trace", "transaction",
"update_hook", "version", 0
};
enum DB_enum {
DB_AUTHORIZER, DB_BUSY, DB_CACHE,
@@ -678,9 +678,9 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
DB_EXISTS, DB_FUNCTION, DB_LAST_INSERT_ROWID,
DB_NULLVALUE, DB_ONECOLUMN, DB_PROFILE,
DB_PROGRESS, DB_REKEY, DB_ROLLBACK_HOOK,
DB_SOFT_HEAP_LIMIT, DB_TIMEOUT, DB_TOTAL_CHANGES,
DB_TRACE, DB_TRANSACTION, DB_UPDATE_HOOK,
DB_VERSION
DB_RELEASE_MEMORY, DB_SOFT_HEAP_LIMIT, DB_TIMEOUT,
DB_TOTAL_CHANGES, DB_TRACE, DB_TRANSACTION,
DB_UPDATE_HOOK, DB_VERSION
};
/* don't leave trailing commas on DB_enum, it confuses the AIX xlc compiler */
@@ -1754,9 +1754,10 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
** $db soft_heap_limit N
**
** Set the soft-heap-limit for this thread. Note that the limit is
** per-thread, not per-database.
** per-thread, not per-database. An empty string is returned.
*/
case DB_SOFT_HEAP_LIMIT: {
#ifndef SQLITE_OMIT_MEMORY_MANAGEMENT
int n;
if( objc!=3 ){
Tcl_WrongNumArgs(interp, 2, objv, "BYTES");
@@ -1767,6 +1768,34 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
}
sqlite3_soft_heap_limit(n);
Tcl_ResetResult(interp);
#endif
break;
}
/*
** $db release_memory ?N?
**
** Try to release memory currently held (but not really required) by
** SQLite database connections opened by the current thread. If an
** integer argument is supplied, then SQLite stops trying to free memory
** after N bytes have been freed.
**
** The value returned is the number of bytes actually freed.
**/
case DB_RELEASE_MEMORY: {
int nRelease = 0;
int N = -1;
if( objc!=2 && objc!=3 ){
Tcl_WrongNumArgs(interp, 2, objv, "?N?");
return TCL_ERROR;
}
#ifndef SQLITE_OMIT_MEMORY_MANAGEMENT
if( objc==3 && TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &N) ){
return TCL_ERROR;
}
nRelease = sqlite3_release_memory(N);
#endif
Tcl_SetObjResult(interp, Tcl_NewIntObj(nRelease));
break;
}