aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2006-01-05 15:50:06 +0000
committerdrh <drh@noemail.net>2006-01-05 15:50:06 +0000
commit6aafc29b5fd184fe77ce507252fb377c9c8dd152 (patch)
treefa338e8f6e6d43c843d0e881425ec590daddb03e /src
parentad68cb6b6943f288d5f6221dc482a12e8ee8b4cb (diff)
downloadsqlite-6aafc29b5fd184fe77ce507252fb377c9c8dd152.tar.gz
sqlite-6aafc29b5fd184fe77ce507252fb377c9c8dd152.zip
Move TCL interface for sqlite3_release_memory() and sqlite3_soft_heap_limit()
out of tclsqlite.c and into test1.c. Update the TCL interface documention to describe the "exists" method. (CVS 2862) FossilOrigin-Name: 98194a45cc60cb9942847f773bc797fb5463bd10
Diffstat (limited to 'src')
-rw-r--r--src/tclsqlite.c64
-rw-r--r--src/test1.c72
2 files changed, 77 insertions, 59 deletions
diff --git a/src/tclsqlite.c b/src/tclsqlite.c
index 610e9063e..c469f75eb 100644
--- a/src/tclsqlite.c
+++ b/src/tclsqlite.c
@@ -11,7 +11,7 @@
*************************************************************************
** A TCL Interface to SQLite
**
-** $Id: tclsqlite.c,v 1.144 2006/01/04 18:13:26 drh Exp $
+** $Id: tclsqlite.c,v 1.145 2006/01/05 15:50:07 drh 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",
- "release_memory", "soft_heap_limit", "timeout",
- "total_changes", "trace", "transaction",
- "update_hook", "version", 0
+ "timeout", "total_changes", "trace",
+ "transaction", "update_hook", "version",
+ 0
};
enum DB_enum {
DB_AUTHORIZER, DB_BUSY, DB_CACHE,
@@ -678,9 +678,8 @@ 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_RELEASE_MEMORY, DB_SOFT_HEAP_LIMIT, DB_TIMEOUT,
- DB_TOTAL_CHANGES, DB_TRACE, DB_TRANSACTION,
- DB_UPDATE_HOOK, DB_VERSION
+ 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 */
@@ -1752,57 +1751,6 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
sqlite3_busy_timeout(pDb->db, ms);
break;
}
-
- /*
- ** $db soft_heap_limit N
- **
- ** Set the soft-heap-limit for this thread. Note that the limit is
- ** per-thread, not per-database. The previous limit is returned.
- */
- case DB_SOFT_HEAP_LIMIT: {
-#ifndef SQLITE_OMIT_MEMORY_MANAGEMENT
- int n;
- int ret;
- if( objc!=3 ){
- Tcl_WrongNumArgs(interp, 2, objv, "BYTES");
- return TCL_ERROR;
- }
- if( Tcl_GetIntFromObj(interp, objv[2], &n) ){
- return TCL_ERROR;
- }
- ret = sqlite3Tsd()->nSoftHeapLimit;
- sqlite3_soft_heap_limit(n);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(ret));
-#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;
- }
/*
** $db total_changes
diff --git a/src/test1.c b/src/test1.c
index 263666ca9..f960ef746 100644
--- a/src/test1.c
+++ b/src/test1.c
@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
-** $Id: test1.c,v 1.179 2006/01/03 00:33:50 drh Exp $
+** $Id: test1.c,v 1.180 2006/01/05 15:50:07 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -2939,6 +2939,67 @@ static int tcl_variable_type(
}
/*
+** Usage: sqlite3_release_memory ?N?
+**
+** Attempt to release memory currently held but not actually required.
+** The integer N is the number of bytes we are trying to release. The
+** return value is the amount of memory actually released.
+*/
+static int test_release_memory(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+#ifndef SQLITE_OMIT_MEMORY_MANAGEMENT
+ int N;
+ int amt;
+ if( objc!=1 && objc!=2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "?N?");
+ return TCL_ERROR;
+ }
+ if( objc==2 ){
+ if( Tcl_GetIntFromObj(interp, objv[1], &N) ) return TCL_ERROR;
+ }else{
+ N = -1;
+ }
+ amt = sqlite3_release_memory(N);
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(amt));
+#endif
+ return TCL_OK;
+}
+
+/*
+** Usage: sqlite3_soft_heap_limit ?N?
+**
+** Query or set the soft heap limit for the current thread. The
+** limit is only changed if the N is present. The previous limit
+** is returned.
+*/
+static int test_soft_heap_limit(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+#ifndef SQLITE_OMIT_MEMORY_MANAGEMENT
+ int amt;
+ if( objc!=1 && objc!=2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "?N?");
+ return TCL_ERROR;
+ }
+ amt = sqlite3Tsd()->nSoftHeapLimit;
+ if( objc==2 ){
+ int N;
+ if( Tcl_GetIntFromObj(interp, objv[1], &N) ) return TCL_ERROR;
+ sqlite3_soft_heap_limit(N);
+ }
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(amt));
+#endif
+ return TCL_OK;
+}
+
+/*
** This routine sets entries in the global ::sqlite_options() array variable
** according to the compile-time configuration of the database. Test
** procedures use this to determine when tests should be omitted.
@@ -3099,6 +3160,12 @@ static void set_options(Tcl_Interp *interp){
Tcl_SetVar2(interp, "sqlite_options", "memorydb", "1", TCL_GLOBAL_ONLY);
#endif
+#ifdef SQLITE_OMIT_MEMORY_MANAGEMENT
+ Tcl_SetVar2(interp, "sqlite_options", "memorymanage", "0", TCL_GLOBAL_ONLY);
+#else
+ Tcl_SetVar2(interp, "sqlite_options", "memorymanage", "1", TCL_GLOBAL_ONLY);
+#endif
+
#ifdef SQLITE_OMIT_OR_OPTIMIZATION
Tcl_SetVar2(interp, "sqlite_options", "or_opt", "0", TCL_GLOBAL_ONLY);
#else
@@ -3291,6 +3358,9 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "sqlite3_changes", test_changes ,0 },
{ "sqlite3_step", test_step ,0 },
+ { "sqlite3_release_memory", test_release_memory, 0},
+ { "sqlite3_soft_heap_limit", test_soft_heap_limit, 0},
+
/* sqlite3_column_*() API */
{ "sqlite3_column_count", test_column_count ,0 },
{ "sqlite3_data_count", test_data_count ,0 },