aboutsummaryrefslogtreecommitdiff
path: root/src/tclsqlite.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tclsqlite.c')
-rw-r--r--src/tclsqlite.c45
1 files changed, 37 insertions, 8 deletions
diff --git a/src/tclsqlite.c b/src/tclsqlite.c
index 337cdefb4..7d1dc0348 100644
--- a/src/tclsqlite.c
+++ b/src/tclsqlite.c
@@ -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;
}