Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Move the sqlite3_sleep() and sqlite3_clear_bindings() interfaces into the main library and make this official. (CVS 3316) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
eb3442c44ef1dbf8895195bb08fbeeea |
User & Date: | drh 2006-06-27 20:06:45 |
Context
2006-06-27
| ||
20:39 | Better handling of NULL column names. (CVS 3317) check-in: 9f13972b user: drh tags: trunk | |
20:06 | Move the sqlite3_sleep() and sqlite3_clear_bindings() interfaces into the main library and make this official. (CVS 3316) check-in: eb3442c4 user: drh tags: trunk | |
20:05 | Off by 1 error in check-in (3314). Note that this change is a likely fix for ticket #1875. But I have not tested it for that purpose yet. (CVS 3315) check-in: c7477459 user: drh tags: trunk | |
Changes
Changes to src/main.c.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
....
1254
1255
1256
1257
1258
1259
1260
|
** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** ** $Id: main.c,v 1.349 2006/06/26 21:35:45 drh Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* ** The following constant value is used by the SQLITE_BIGENDIAN and ................................................................................ rc = SQLITE_ERROR; } sqlite3Error(db, rc, (zErrMsg?"%s":0), zErrMsg); sqliteFree(zErrMsg); return sqlite3ApiExit(db, rc); } #endif |
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
....
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
|
** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** ** $Id: main.c,v 1.350 2006/06/27 20:06:45 drh Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* ** The following constant value is used by the SQLITE_BIGENDIAN and ................................................................................ rc = SQLITE_ERROR; } sqlite3Error(db, rc, (zErrMsg?"%s":0), zErrMsg); sqliteFree(zErrMsg); return sqlite3ApiExit(db, rc); } #endif /* ** 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; rc==SQLITE_OK && 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); } |
Changes to src/test1.c.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 .... 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 .... 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 .... 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 .... 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 |
** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing all sorts of SQLite interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.215 2006/06/27 15:16:16 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> ................................................................................ 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; ................................................................................ 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 ** ** Return the string representation of the most recent sqlite3_* API ** error code. e.g. "SQLITE_ERROR". */ ................................................................................ #endif { "sqlite_bind", (Tcl_CmdProc*)test_bind }, { "breakpoint", (Tcl_CmdProc*)test_breakpoint }, { "sqlite3_key", (Tcl_CmdProc*)test_key }, { "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 { "sqlite_delete_function", (Tcl_CmdProc*)delete_function }, { "sqlite_delete_collation", (Tcl_CmdProc*)delete_collation }, { "sqlite3_get_autocommit", (Tcl_CmdProc*)get_autocommit }, { "sqlite3_stack_used", (Tcl_CmdProc*)test_stack_used }, }; static struct { char *zName; ................................................................................ { "sqlite3_bind_null", test_bind_null ,0 }, { "sqlite3_bind_text", test_bind_text ,0 }, { "sqlite3_bind_text16", test_bind_text16 ,0 }, { "sqlite3_bind_blob", test_bind_blob ,0 }, { "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 }, { "sqlite3_open", test_open ,0 }, { "sqlite3_open16", test_open16 ,0 }, { "sqlite3_complete16", test_complete16 ,0 }, |
| < < > > > > > > > > > > > > > > > > > > > > > > < < < < < > |
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 .... 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 .... 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 .... 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 .... 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 |
** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing all sorts of SQLite interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.216 2006/06/27 20:06:45 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> ................................................................................ return TCL_OK; } /* ** Usage: sqlite3_clear_bindings STMT ** */ static int test_clear_bindings( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3_stmt *pStmt; ................................................................................ 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; } /* ** Usage: sqlite3_sleep MILLISECONDS */ static int test_sleep( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ int ms; if( objc!=2 ){ Tcl_WrongNumArgs(interp, 1, objv, "MILLISECONDS"); return TCL_ERROR; } if( Tcl_GetIntFromObj(interp, objv[1], &ms) ){ return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_sleep(ms))); return TCL_OK; } /* ** Usage: sqlite3_errcode DB ** ** Return the string representation of the most recent sqlite3_* API ** error code. e.g. "SQLITE_ERROR". */ ................................................................................ #endif { "sqlite_bind", (Tcl_CmdProc*)test_bind }, { "breakpoint", (Tcl_CmdProc*)test_breakpoint }, { "sqlite3_key", (Tcl_CmdProc*)test_key }, { "sqlite3_rekey", (Tcl_CmdProc*)test_rekey }, { "sqlite_set_magic", (Tcl_CmdProc*)sqlite_set_magic }, { "sqlite3_interrupt", (Tcl_CmdProc*)test_interrupt }, { "sqlite_delete_function", (Tcl_CmdProc*)delete_function }, { "sqlite_delete_collation", (Tcl_CmdProc*)delete_collation }, { "sqlite3_get_autocommit", (Tcl_CmdProc*)get_autocommit }, { "sqlite3_stack_used", (Tcl_CmdProc*)test_stack_used }, }; static struct { char *zName; ................................................................................ { "sqlite3_bind_null", test_bind_null ,0 }, { "sqlite3_bind_text", test_bind_text ,0 }, { "sqlite3_bind_text16", test_bind_text16 ,0 }, { "sqlite3_bind_blob", test_bind_blob ,0 }, { "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}, { "sqlite3_clear_bindings", test_clear_bindings, 0}, { "sqlite3_sleep", test_sleep, 0}, { "sqlite3_errcode", test_errcode ,0 }, { "sqlite3_errmsg", test_errmsg ,0 }, { "sqlite3_errmsg16", test_errmsg16 ,0 }, { "sqlite3_open", test_open ,0 }, { "sqlite3_open16", test_open16 ,0 }, { "sqlite3_complete16", test_complete16 ,0 }, |
Changes to test/bind.test.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ... 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 ... 519 520 521 522 523 524 525 526 527 |
# May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script testing the sqlite_bind API. # # $Id: bind.test,v 1.37 2006/01/23 18:42:21 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl proc sqlite_step {stmt N VALS COLS} { upvar VALS vals ................................................................................ do_test bind-11.1 { catchsql {SELECT * FROM sqlite_master WHERE name=$abc(123 and sql NOT NULL;} } {1 {unrecognized token: "$abc(123"}} } if {[execsql {pragma encoding}]=="UTF-8"} { # Test the ability to bind text that contains embedded '\000' characters. # Make sure we can recover the enter input string. # do_test bind-12.1 { execsql { CREATE TABLE t3(x BLOB); } set VM [sqlite3_prepare $DB {INSERT INTO t3 VALUES(?)} -1 TAIL] sqlite_bind $VM 1 not-used blob10 ................................................................................ do_test bind-12.2 { sqlite3_create_function $DB execsql { SELECT quote(cast(x_coalesce(x) AS blob)) FROM t3 } } {X'6162630078797A007071'} } finish_test |
| | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ... 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 ... 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
# May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script testing the sqlite_bind API. # # $Id: bind.test,v 1.38 2006/06/27 20:06:45 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl proc sqlite_step {stmt N VALS COLS} { upvar VALS vals ................................................................................ do_test bind-11.1 { catchsql {SELECT * FROM sqlite_master WHERE name=$abc(123 and sql NOT NULL;} } {1 {unrecognized token: "$abc(123"}} } if {[execsql {pragma encoding}]=="UTF-8"} { # Test the ability to bind text that contains embedded '\000' characters. # Make sure we can recover the entire input string. # do_test bind-12.1 { execsql { CREATE TABLE t3(x BLOB); } set VM [sqlite3_prepare $DB {INSERT INTO t3 VALUES(?)} -1 TAIL] sqlite_bind $VM 1 not-used blob10 ................................................................................ do_test bind-12.2 { sqlite3_create_function $DB execsql { SELECT quote(cast(x_coalesce(x) AS blob)) FROM t3 } } {X'6162630078797A007071'} } # Test the operation of sqlite3_clear_bindings # do_test bind-13.1 { set VM [sqlite3_prepare $DB {SELECT ?,?,?} -1 TAIL] sqlite3_step $VM list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \ [sqlite3_column_type $VM 2] } {NULL NULL NULL} do_test bind-13.2 { sqlite3_reset $VM sqlite3_bind_int $VM 1 1 sqlite3_bind_int $VM 2 2 sqlite3_bind_int $VM 3 3 sqlite3_step $VM list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \ [sqlite3_column_type $VM 2] } {INTEGER INTEGER INTEGER} do_test bind-13.3 { sqlite3_reset $VM sqlite3_step $VM list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \ [sqlite3_column_type $VM 2] } {INTEGER INTEGER INTEGER} do_test bind-13.4 { sqlite3_reset $VM sqlite3_clear_bindings $VM sqlite3_step $VM list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \ [sqlite3_column_type $VM 2] } {NULL NULL NULL} sqlite3_finalize $VM finish_test |
Changes to test/misc1.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
572
573
574
575
576
577
578
579
580
|
# #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # # $Id: misc1.test,v 1.40 2006/01/17 09:35:02 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Mimic the SQLite 2 collation type NUMERIC. db collate numeric numeric_collate proc numeric_collate {lhs rhs} { ................................................................................ INSERT INTO TempTable(TestString) VALUES ('2'); UPDATE TempTable SET TestString = TestString + 1 WHERE TestID=1 OR TestId=2; COMMIT; SELECT TestString FROM RealTable ORDER BY 1; } } {2 3} } finish_test |
|
>
>
>
>
>
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
572
573
574
575
576
577
578
579
580
581
582
583
584
585
|
# #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for miscellanous features that were # left out of other test files. # # $Id: misc1.test,v 1.41 2006/06/27 20:06:45 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Mimic the SQLite 2 collation type NUMERIC. db collate numeric numeric_collate proc numeric_collate {lhs rhs} { ................................................................................ INSERT INTO TempTable(TestString) VALUES ('2'); UPDATE TempTable SET TestString = TestString + 1 WHERE TestID=1 OR TestId=2; COMMIT; SELECT TestString FROM RealTable ORDER BY 1; } } {2 3} } do_test misc1-18.1 { set n [sqlite3_sleep 100] expr {$n>=100} } {1} finish_test |