From: danielk1977 Date: Thu, 20 Jan 2005 01:14:23 +0000 (+0000) Subject: Add the experimental sqlite3_sleep() and sqlite3_clear_bindings() APIs. (CVS 2237) X-Git-Tag: version-3.6.10~3915 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=600dd0ba33fdd245a50401575eec3ad4fefa419f;p=thirdparty%2Fsqlite.git Add the experimental sqlite3_sleep() and sqlite3_clear_bindings() APIs. (CVS 2237) FossilOrigin-Name: 9480209e8600bf411975b3950c407d60c800e5c6 --- diff --git a/manifest b/manifest index 803bd995ff..22d7e16f18 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Continued\srefactoring\sof\sthe\sname\sresolution\slogic\sand\squery\soptimizer.\s(CVS\s2236) -D 2005-01-19T23:24:50 +C Add\sthe\sexperimental\ssqlite3_sleep()\sand\ssqlite3_clear_bindings()\sAPIs.\s(CVS\s2237) +D 2005-01-20T01:14:23 F Makefile.in ffd81f5e926d40b457071b4de8d7c1fa18f39b5a F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1 @@ -35,6 +35,7 @@ F src/build.c da5ecd9880f2d19d5e77fe48b722577494dd3290 F src/cursor.c f883813759742068890b1f699335872bfa8fdf41 F src/date.c f3d1f5cd1503dabf426a198f3ebef5afbc122a7f F src/delete.c cbf54c0634c53ef683f7af8ad5c5d5637c9efb90 +F src/experimental.c ddd3efed16f302d460cbddc81336534489c4331d F src/expr.c 7e26c70d6e9d5f6cd65da2d75fd31c87598d9e02 F src/func.c dc188d862d7276ea897655b248e2cb17022686e3 F src/hash.c a97721a55440b7bea31ffe471bb2f6b4123cddd5 @@ -59,11 +60,11 @@ F src/printf.c 3d20b21cfecadacecac3fb7274e746cb81d3d357 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3 F src/select.c e147c81d57f7146d90a4d5a01f523dfec43808f4 F src/shell.c 591364a0e9ca4ce53873e21e0294476c0c2b4770 -F src/sqlite.h.in 0d5e48e506845b74a845c9470e01d3f472b59611 +F src/sqlite.h.in 8249b697d71ef6d7f7f752ba4ca04058e9e8b5ff F src/sqliteInt.h a79a526b2f3c695226add233a41a5c8be3251a09 F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9 F src/tclsqlite.c fd27457b228118be96524dae285146c76efe032b -F src/test1.c b2fd5e50457b82eff4916d1c62bd0caa10f7f4c3 +F src/test1.c 59fc0f0c35cb3bccdf166f36a1a5f9ffb0b951e7 F src/test2.c bbc2ecc58ceeab12d1e40970f831b1017524e40d F src/test3.c a72f20066cccd5a7b9f20b7b78fa9b05b47b3020 F src/test4.c 7c6b9fc33dd1f3f93c7f1ee6e5e6d016afa6c1df @@ -104,7 +105,7 @@ F test/btree5.test 8e5ff32c02e685d36516c6499add9375fe1377f2 F test/btree6.test a5ede6bfbbb2ec8b27e62813612c0f28e8f3e027 F test/btree7.test a6d3b842db22af97dd14b989e90a2fd96066b72f F test/capi2.test 325e8d68fe7b3c518f73a37f039c52278be8f101 -F test/capi3.test 3b33bf7c8836028835354c055989314e9c969c5c +F test/capi3.test ffb8bd785d5fe26e5d63f24c189c45f21297d44f F test/capi3b.test 5b6a66f9f295f79f443b5d3f33187fa5ef6cf336 F test/collate1.test f79736d2ebf5492167ee4d1f4ab4c09dda776b03 F test/collate2.test 12fd658d8f5106a8a5c8a77d66919d8c89394036 @@ -269,7 +270,7 @@ F www/tclsqlite.tcl e73f8f8e5f20e8277619433f7970060ab01088fc F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/whentouse.tcl c3b50d3ac31c54be2a1af9b488a89d22f1e6e746 -P 27cf83224c69e661c19f9a09f39bfdae75e3b0a4 -R 331c9226a76190b62ab0ac4aa62a5446 -U drh -Z 621c5ade2211fc9721f7fb4569d83e10 +P d8b2a7e09187564fe66a2b4bf0992c6a017146cf +R ab09feabec2e6782d25ca35f08bb3c33 +U danielk1977 +Z 4ac0780f5c16aa3ed032021e94f4f097 diff --git a/manifest.uuid b/manifest.uuid index c014e6a810..dcba9ecf83 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d8b2a7e09187564fe66a2b4bf0992c6a017146cf \ No newline at end of file +9480209e8600bf411975b3950c407d60c800e5c6 \ No newline at end of file diff --git a/src/experimental.c b/src/experimental.c new file mode 100644 index 0000000000..6b0689d09b --- /dev/null +++ b/src/experimental.c @@ -0,0 +1,38 @@ + +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains C code routines that are called by the parser +** to handle SELECT statements in SQLite. +** +** $Id: experimental.c,v 1.1 2005/01/20 01:14:23 danielk1977 Exp $ +*/ +#include "sqliteInt.h" + +/* +** Set all the parameters in the compiled SQL statement to NULL. +*/ +int sqlite3_clear_bindings(sqlite3_stmt *pStmt){ + int i; + int rc = SQLITE_OK; + for(i=1; i<=sqlite3_bind_parameter_count(pStmt); i++){ + rc = sqlite3_bind_null(pStmt, i); + } + return rc; +} + +/* +** Sleep for a little while. Return the amount of time slept. +*/ +int sqlite3_sleep(int ms){ + return sqlite3OsSleep(ms); +} + diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 3c5f1f2e5e..7aa05c7862 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -12,7 +12,7 @@ ** This header file defines the interface that the SQLite library ** presents to client programs. ** -** @(#) $Id: sqlite.h.in,v 1.126 2004/12/20 19:01:33 tpoindex Exp $ +** @(#) $Id: sqlite.h.in,v 1.127 2005/01/20 01:14:23 danielk1977 Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ @@ -664,6 +664,13 @@ const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int); */ int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName); +/* +** Set all the parameters in the compiled SQL statement to NULL. +** +******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ****** +*/ +int sqlite3_clear_bindings(sqlite3_stmt*); + /* ** Return the number of columns in the result set returned by the compiled ** SQL statement. This routine returns 0 if pStmt is an SQL statement @@ -1154,6 +1161,19 @@ int sqlite3_rekey( const void *pKey, int nKey /* The new key */ ); +/* +** Sleep for a little while. The second parameter is the number of +** miliseconds to sleep for. +** +** If the operating system does not support sleep requests with +** milisecond time resolution, then the time will be rounded up to +** the nearest second. The number of miliseconds of sleep actually +** requested from the operating system is returned. +** +******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ****** +*/ +int sqlite3_sleep(int); + /* ** If the following global variable is made to point to a ** string which is the name of a directory, then all temporary files diff --git a/src/test1.c b/src/test1.c index 2f9544e30b..4a1318c030 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.123 2005/01/19 23:24:51 drh Exp $ +** $Id: test1.c,v 1.124 2005/01/20 01:14:23 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -1722,6 +1722,29 @@ static int test_bind_parameter_index( return TCL_OK; } +/* +** Usage: sqlite3_clear_bindings STMT +** +*/ +#if 0 +static int test_clear_bindings( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3_stmt *pStmt; + + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "STMT"); + return TCL_ERROR; + } + if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; + Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_clear_bindings(pStmt))); + return TCL_OK; +} +#endif + /* ** Usage: sqlite3_errcode DB ** @@ -2532,6 +2555,28 @@ static int test_interrupt( return TCL_OK; } +/* +** Usage: sqlite3_sleep ms +** +** Sleep for the specified number of ms. +*/ +#if 0 +static int test_sleep( + void * clientData, + Tcl_Interp *interp, + int argc, + char **argv +){ + sqlite3 *db; + if( argc!=2 ){ + Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " ms", 0); + return TCL_ERROR; + } + Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_sleep(atoi(argv[1])))); + return TCL_OK; +} +#endif + /* ** Usage: tcl_variable_type VARIABLENAME ** @@ -2764,6 +2809,9 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_rekey", (Tcl_CmdProc*)test_rekey }, { "sqlite_set_magic", (Tcl_CmdProc*)sqlite_set_magic }, { "sqlite3_interrupt", (Tcl_CmdProc*)test_interrupt }, +#if 0 + { "sqlite3_sleep", (Tcl_CmdProc*)test_sleep }, +#endif }; static struct { char *zName; @@ -2780,6 +2828,9 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_bind_parameter_count", test_bind_parameter_count, 0}, { "sqlite3_bind_parameter_name", test_bind_parameter_name, 0}, { "sqlite3_bind_parameter_index", test_bind_parameter_index, 0}, +#if 0 + { "sqlite3_clear_bindings", test_clear_bindings, 0}, +#endif { "sqlite3_errcode", test_errcode ,0 }, { "sqlite3_errmsg", test_errmsg ,0 }, { "sqlite3_errmsg16", test_errmsg16 ,0 }, diff --git a/test/capi3.test b/test/capi3.test index 9c5921cf6f..81b087f79a 100644 --- a/test/capi3.test +++ b/test/capi3.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script testing the callback-free C/C++ API. # -# $Id: capi3.test,v 1.26 2004/11/22 10:02:22 danielk1977 Exp $ +# $Id: capi3.test,v 1.27 2005/01/20 01:14:23 danielk1977 Exp $ # set testdir [file dirname $argv0] @@ -787,4 +787,41 @@ do_test capi3-12.8 { } } {1 2 3 4} +# Test cases capi3-13.* test the sqlite3_clear_bindings() and +# sqlite3_sleep APIs. +# +if {[llength [info commands sqlite3_clear_bindings]]>0} { + do_test capi3-13.1 { + execsql { + DELETE FROM t1; + } + set STMT [sqlite3_prepare $DB "INSERT INTO t1 VALUES(?, ?)" -1 TAIL] + sqlite3_step $STMT + } {SQLITE_DONE} + do_test capi3-13.2 { + sqlite3_reset $STMT + sqlite3_bind_text $STMT 1 hello 5 + sqlite3_bind_text $STMT 2 world 5 + sqlite3_step $STMT + } {SQLITE_DONE} + do_test capi3-13.3 { + sqlite3_reset $STMT + sqlite3_clear_bindings $STMT + sqlite3_step $STMT + } {SQLITE_DONE} + do_test capi3-13-4 { + sqlite3_finalize $STMT + execsql { + SELECT * FROM t1; + } + } {{} {} hello world {} {}} +} +if {[llength [info commands sqlite3_sleep]]>0} { + do_test capi3-13-5 { + set ms [sqlite3_sleep 80] + expr {$ms==80 || $ms==1000} + } {1} +} + finish_test +