| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2001 September 15 | 2 ** 2001 September 15 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| 11 ************************************************************************* | 11 ************************************************************************* |
| 12 ** Code for testing all sorts of SQLite interfaces. This code | 12 ** Code for testing all sorts of SQLite interfaces. This code |
| 13 ** is not included in the SQLite library. It is used for automated | 13 ** is not included in the SQLite library. It is used for automated |
| 14 ** testing of the SQLite library. | 14 ** testing of the SQLite library. |
| 15 */ | 15 */ |
| 16 #include "sqliteInt.h" | 16 #include "sqliteInt.h" |
| 17 #if SQLITE_OS_WIN | 17 #if SQLITE_OS_WIN |
| 18 # include "os_win.h" | 18 # include "os_win.h" |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 #include "vdbeInt.h" | 21 #include "vdbeInt.h" |
| 22 #include "tcl.h" | 22 #if defined(INCLUDE_SQLITE_TCL_H) |
| 23 # include "sqlite_tcl.h" |
| 24 #else |
| 25 # include "tcl.h" |
| 26 #endif |
| 23 #include <stdlib.h> | 27 #include <stdlib.h> |
| 24 #include <string.h> | 28 #include <string.h> |
| 25 | 29 |
| 26 /* | 30 /* |
| 27 ** This is a copy of the first part of the SqliteDb structure in | 31 ** This is a copy of the first part of the SqliteDb structure in |
| 28 ** tclsqlite.c. We need it here so that the get_sqlite_pointer routine | 32 ** tclsqlite.c. We need it here so that the get_sqlite_pointer routine |
| 29 ** can extract the sqlite3* pointer from an existing Tcl SQLite | 33 ** can extract the sqlite3* pointer from an existing Tcl SQLite |
| 30 ** connection. | 34 ** connection. |
| 31 */ | 35 */ |
| 32 struct SqliteDb { | 36 struct SqliteDb { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 } | 72 } |
| 69 return p; | 73 return p; |
| 70 } | 74 } |
| 71 | 75 |
| 72 | 76 |
| 73 /* | 77 /* |
| 74 ** A TCL command that returns the address of the sqlite* pointer | 78 ** A TCL command that returns the address of the sqlite* pointer |
| 75 ** for an sqlite connection instance. Bad things happen if the | 79 ** for an sqlite connection instance. Bad things happen if the |
| 76 ** input is not an sqlite connection. | 80 ** input is not an sqlite connection. |
| 77 */ | 81 */ |
| 78 static int get_sqlite_pointer( | 82 static int SQLITE_TCLAPI get_sqlite_pointer( |
| 79 void * clientData, | 83 void * clientData, |
| 80 Tcl_Interp *interp, | 84 Tcl_Interp *interp, |
| 81 int objc, | 85 int objc, |
| 82 Tcl_Obj *CONST objv[] | 86 Tcl_Obj *CONST objv[] |
| 83 ){ | 87 ){ |
| 84 struct SqliteDb *p; | 88 struct SqliteDb *p; |
| 85 Tcl_CmdInfo cmdInfo; | 89 Tcl_CmdInfo cmdInfo; |
| 86 char zBuf[100]; | 90 char zBuf[100]; |
| 87 if( objc!=2 ){ | 91 if( objc!=2 ){ |
| 88 Tcl_WrongNumArgs(interp, 1, objv, "SQLITE-CONNECTION"); | 92 Tcl_WrongNumArgs(interp, 1, objv, "SQLITE-CONNECTION"); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 } | 218 } |
| 215 #endif | 219 #endif |
| 216 | 220 |
| 217 /* | 221 /* |
| 218 ** Usage: io_trace FILENAME | 222 ** Usage: io_trace FILENAME |
| 219 ** | 223 ** |
| 220 ** Turn I/O tracing on or off. If FILENAME is not an empty string, | 224 ** Turn I/O tracing on or off. If FILENAME is not an empty string, |
| 221 ** I/O tracing begins going into FILENAME. If FILENAME is an empty | 225 ** I/O tracing begins going into FILENAME. If FILENAME is an empty |
| 222 ** string, I/O tracing is turned off. | 226 ** string, I/O tracing is turned off. |
| 223 */ | 227 */ |
| 224 static int test_io_trace( | 228 static int SQLITE_TCLAPI test_io_trace( |
| 225 void *NotUsed, | 229 void *NotUsed, |
| 226 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 230 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 227 int argc, /* Number of arguments */ | 231 int argc, /* Number of arguments */ |
| 228 char **argv /* Text of each argument */ | 232 char **argv /* Text of each argument */ |
| 229 ){ | 233 ){ |
| 230 #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE) | 234 #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE) |
| 231 if( argc!=2 ){ | 235 if( argc!=2 ){ |
| 232 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 236 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 233 " FILENAME\"", 0); | 237 " FILENAME\"", 0); |
| 234 return TCL_ERROR; | 238 return TCL_ERROR; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 255 } | 259 } |
| 256 | 260 |
| 257 /* | 261 /* |
| 258 ** Usage: clang_sanitize_address | 262 ** Usage: clang_sanitize_address |
| 259 ** | 263 ** |
| 260 ** Returns true if the program was compiled using clang with the | 264 ** Returns true if the program was compiled using clang with the |
| 261 ** -fsanitize=address switch on the command line. False otherwise. | 265 ** -fsanitize=address switch on the command line. False otherwise. |
| 262 ** | 266 ** |
| 263 ** Also return true if the OMIT_MISUSE environment variable exists. | 267 ** Also return true if the OMIT_MISUSE environment variable exists. |
| 264 */ | 268 */ |
| 265 static int clang_sanitize_address( | 269 static int SQLITE_TCLAPI clang_sanitize_address( |
| 266 void *NotUsed, | 270 void *NotUsed, |
| 267 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 271 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 268 int argc, /* Number of arguments */ | 272 int argc, /* Number of arguments */ |
| 269 char **argv /* Text of each argument */ | 273 char **argv /* Text of each argument */ |
| 270 ){ | 274 ){ |
| 271 int res = 0; | 275 int res = 0; |
| 272 #if defined(__has_feature) | 276 #if defined(__has_feature) |
| 273 # if __has_feature(address_sanitizer) | 277 # if __has_feature(address_sanitizer) |
| 274 res = 1; | 278 res = 1; |
| 275 # endif | 279 # endif |
| 276 #endif | 280 #endif |
| 277 #ifdef __SANITIZE_ADDRESS__ | 281 #ifdef __SANITIZE_ADDRESS__ |
| 278 res = 1; | 282 res = 1; |
| 279 #endif | 283 #endif |
| 280 if( res==0 && getenv("OMIT_MISUSE")!=0 ) res = 1; | 284 if( res==0 && getenv("OMIT_MISUSE")!=0 ) res = 1; |
| 281 Tcl_SetObjResult(interp, Tcl_NewIntObj(res)); | 285 Tcl_SetObjResult(interp, Tcl_NewIntObj(res)); |
| 282 return TCL_OK; | 286 return TCL_OK; |
| 283 } | 287 } |
| 284 | 288 |
| 285 /* | 289 /* |
| 286 ** Usage: sqlite3_exec_printf DB FORMAT STRING | 290 ** Usage: sqlite3_exec_printf DB FORMAT STRING |
| 287 ** | 291 ** |
| 288 ** Invoke the sqlite3_exec_printf() interface using the open database | 292 ** Invoke the sqlite3_exec_printf() interface using the open database |
| 289 ** DB. The SQL is the string FORMAT. The format string should contain | 293 ** DB. The SQL is the string FORMAT. The format string should contain |
| 290 ** one %s or %q. STRING is the value inserted into %s or %q. | 294 ** one %s or %q. STRING is the value inserted into %s or %q. |
| 291 */ | 295 */ |
| 292 static int test_exec_printf( | 296 static int SQLITE_TCLAPI test_exec_printf( |
| 293 void *NotUsed, | 297 void *NotUsed, |
| 294 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 298 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 295 int argc, /* Number of arguments */ | 299 int argc, /* Number of arguments */ |
| 296 char **argv /* Text of each argument */ | 300 char **argv /* Text of each argument */ |
| 297 ){ | 301 ){ |
| 298 sqlite3 *db; | 302 sqlite3 *db; |
| 299 Tcl_DString str; | 303 Tcl_DString str; |
| 300 int rc; | 304 int rc; |
| 301 char *zErr = 0; | 305 char *zErr = 0; |
| 302 char *zSql; | 306 char *zSql; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 320 return TCL_OK; | 324 return TCL_OK; |
| 321 } | 325 } |
| 322 | 326 |
| 323 /* | 327 /* |
| 324 ** Usage: sqlite3_exec_hex DB HEX | 328 ** Usage: sqlite3_exec_hex DB HEX |
| 325 ** | 329 ** |
| 326 ** Invoke the sqlite3_exec() on a string that is obtained by translating | 330 ** Invoke the sqlite3_exec() on a string that is obtained by translating |
| 327 ** HEX into ASCII. Most characters are translated as is. %HH becomes | 331 ** HEX into ASCII. Most characters are translated as is. %HH becomes |
| 328 ** a hex character. | 332 ** a hex character. |
| 329 */ | 333 */ |
| 330 static int test_exec_hex( | 334 static int SQLITE_TCLAPI test_exec_hex( |
| 331 void *NotUsed, | 335 void *NotUsed, |
| 332 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 336 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 333 int argc, /* Number of arguments */ | 337 int argc, /* Number of arguments */ |
| 334 char **argv /* Text of each argument */ | 338 char **argv /* Text of each argument */ |
| 335 ){ | 339 ){ |
| 336 sqlite3 *db; | 340 sqlite3 *db; |
| 337 Tcl_DString str; | 341 Tcl_DString str; |
| 338 int rc, i, j; | 342 int rc, i, j; |
| 339 char *zErr = 0; | 343 char *zErr = 0; |
| 340 char *zHex; | 344 char *zHex; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 366 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; | 370 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; |
| 367 return TCL_OK; | 371 return TCL_OK; |
| 368 } | 372 } |
| 369 | 373 |
| 370 /* | 374 /* |
| 371 ** Usage: db_enter DB | 375 ** Usage: db_enter DB |
| 372 ** db_leave DB | 376 ** db_leave DB |
| 373 ** | 377 ** |
| 374 ** Enter or leave the mutex on a database connection. | 378 ** Enter or leave the mutex on a database connection. |
| 375 */ | 379 */ |
| 376 static int db_enter( | 380 static int SQLITE_TCLAPI db_enter( |
| 377 void *NotUsed, | 381 void *NotUsed, |
| 378 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 382 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 379 int argc, /* Number of arguments */ | 383 int argc, /* Number of arguments */ |
| 380 char **argv /* Text of each argument */ | 384 char **argv /* Text of each argument */ |
| 381 ){ | 385 ){ |
| 382 sqlite3 *db; | 386 sqlite3 *db; |
| 383 if( argc!=2 ){ | 387 if( argc!=2 ){ |
| 384 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 388 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 385 " DB", 0); | 389 " DB", 0); |
| 386 return TCL_ERROR; | 390 return TCL_ERROR; |
| 387 } | 391 } |
| 388 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 392 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
| 389 sqlite3_mutex_enter(db->mutex); | 393 sqlite3_mutex_enter(db->mutex); |
| 390 return TCL_OK; | 394 return TCL_OK; |
| 391 } | 395 } |
| 392 static int db_leave( | 396 static int SQLITE_TCLAPI db_leave( |
| 393 void *NotUsed, | 397 void *NotUsed, |
| 394 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 398 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 395 int argc, /* Number of arguments */ | 399 int argc, /* Number of arguments */ |
| 396 char **argv /* Text of each argument */ | 400 char **argv /* Text of each argument */ |
| 397 ){ | 401 ){ |
| 398 sqlite3 *db; | 402 sqlite3 *db; |
| 399 if( argc!=2 ){ | 403 if( argc!=2 ){ |
| 400 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 404 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 401 " DB", 0); | 405 " DB", 0); |
| 402 return TCL_ERROR; | 406 return TCL_ERROR; |
| 403 } | 407 } |
| 404 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 408 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
| 405 sqlite3_mutex_leave(db->mutex); | 409 sqlite3_mutex_leave(db->mutex); |
| 406 return TCL_OK; | 410 return TCL_OK; |
| 407 } | 411 } |
| 408 | 412 |
| 409 /* | 413 /* |
| 410 ** Usage: sqlite3_exec DB SQL | 414 ** Usage: sqlite3_exec DB SQL |
| 411 ** | 415 ** |
| 412 ** Invoke the sqlite3_exec interface using the open database DB | 416 ** Invoke the sqlite3_exec interface using the open database DB |
| 413 */ | 417 */ |
| 414 static int test_exec( | 418 static int SQLITE_TCLAPI test_exec( |
| 415 void *NotUsed, | 419 void *NotUsed, |
| 416 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 420 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 417 int argc, /* Number of arguments */ | 421 int argc, /* Number of arguments */ |
| 418 char **argv /* Text of each argument */ | 422 char **argv /* Text of each argument */ |
| 419 ){ | 423 ){ |
| 420 sqlite3 *db; | 424 sqlite3 *db; |
| 421 Tcl_DString str; | 425 Tcl_DString str; |
| 422 int rc; | 426 int rc; |
| 423 char *zErr = 0; | 427 char *zErr = 0; |
| 424 char *zSql; | 428 char *zSql; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 451 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; | 455 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; |
| 452 return TCL_OK; | 456 return TCL_OK; |
| 453 } | 457 } |
| 454 | 458 |
| 455 /* | 459 /* |
| 456 ** Usage: sqlite3_exec_nr DB SQL | 460 ** Usage: sqlite3_exec_nr DB SQL |
| 457 ** | 461 ** |
| 458 ** Invoke the sqlite3_exec interface using the open database DB. Discard | 462 ** Invoke the sqlite3_exec interface using the open database DB. Discard |
| 459 ** all results | 463 ** all results |
| 460 */ | 464 */ |
| 461 static int test_exec_nr( | 465 static int SQLITE_TCLAPI test_exec_nr( |
| 462 void *NotUsed, | 466 void *NotUsed, |
| 463 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 467 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 464 int argc, /* Number of arguments */ | 468 int argc, /* Number of arguments */ |
| 465 char **argv /* Text of each argument */ | 469 char **argv /* Text of each argument */ |
| 466 ){ | 470 ){ |
| 467 sqlite3 *db; | 471 sqlite3 *db; |
| 468 int rc; | 472 int rc; |
| 469 char *zErr = 0; | 473 char *zErr = 0; |
| 470 if( argc!=3 ){ | 474 if( argc!=3 ){ |
| 471 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 475 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 472 " DB SQL", 0); | 476 " DB SQL", 0); |
| 473 return TCL_ERROR; | 477 return TCL_ERROR; |
| 474 } | 478 } |
| 475 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 479 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
| 476 rc = sqlite3_exec(db, argv[2], 0, 0, &zErr); | 480 rc = sqlite3_exec(db, argv[2], 0, 0, &zErr); |
| 477 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; | 481 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; |
| 478 return TCL_OK; | 482 return TCL_OK; |
| 479 } | 483 } |
| 480 | 484 |
| 481 /* | 485 /* |
| 482 ** Usage: sqlite3_mprintf_z_test SEPARATOR ARG0 ARG1 ... | 486 ** Usage: sqlite3_mprintf_z_test SEPARATOR ARG0 ARG1 ... |
| 483 ** | 487 ** |
| 484 ** Test the %z format of sqlite_mprintf(). Use multiple mprintf() calls to | 488 ** Test the %z format of sqlite_mprintf(). Use multiple mprintf() calls to |
| 485 ** concatenate arg0 through argn using separator as the separator. | 489 ** concatenate arg0 through argn using separator as the separator. |
| 486 ** Return the result. | 490 ** Return the result. |
| 487 */ | 491 */ |
| 488 static int test_mprintf_z( | 492 static int SQLITE_TCLAPI test_mprintf_z( |
| 489 void *NotUsed, | 493 void *NotUsed, |
| 490 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 494 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 491 int argc, /* Number of arguments */ | 495 int argc, /* Number of arguments */ |
| 492 char **argv /* Text of each argument */ | 496 char **argv /* Text of each argument */ |
| 493 ){ | 497 ){ |
| 494 char *zResult = 0; | 498 char *zResult = 0; |
| 495 int i; | 499 int i; |
| 496 | 500 |
| 497 for(i=2; i<argc && (i==2 || zResult); i++){ | 501 for(i=2; i<argc && (i==2 || zResult); i++){ |
| 498 zResult = sqlite3_mprintf("%z%s%s", zResult, argv[1], argv[i]); | 502 zResult = sqlite3_mprintf("%z%s%s", zResult, argv[1], argv[i]); |
| 499 } | 503 } |
| 500 Tcl_AppendResult(interp, zResult, 0); | 504 Tcl_AppendResult(interp, zResult, 0); |
| 501 sqlite3_free(zResult); | 505 sqlite3_free(zResult); |
| 502 return TCL_OK; | 506 return TCL_OK; |
| 503 } | 507 } |
| 504 | 508 |
| 505 /* | 509 /* |
| 506 ** Usage: sqlite3_mprintf_n_test STRING | 510 ** Usage: sqlite3_mprintf_n_test STRING |
| 507 ** | 511 ** |
| 508 ** Test the %n format of sqlite_mprintf(). Return the length of the | 512 ** Test the %n format of sqlite_mprintf(). Return the length of the |
| 509 ** input string. | 513 ** input string. |
| 510 */ | 514 */ |
| 511 static int test_mprintf_n( | 515 static int SQLITE_TCLAPI test_mprintf_n( |
| 512 void *NotUsed, | 516 void *NotUsed, |
| 513 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 517 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 514 int argc, /* Number of arguments */ | 518 int argc, /* Number of arguments */ |
| 515 char **argv /* Text of each argument */ | 519 char **argv /* Text of each argument */ |
| 516 ){ | 520 ){ |
| 517 char *zStr; | 521 char *zStr; |
| 518 int n = 0; | 522 int n = 0; |
| 519 zStr = sqlite3_mprintf("%s%n", argv[1], &n); | 523 zStr = sqlite3_mprintf("%s%n", argv[1], &n); |
| 520 sqlite3_free(zStr); | 524 sqlite3_free(zStr); |
| 521 Tcl_SetObjResult(interp, Tcl_NewIntObj(n)); | 525 Tcl_SetObjResult(interp, Tcl_NewIntObj(n)); |
| 522 return TCL_OK; | 526 return TCL_OK; |
| 523 } | 527 } |
| 524 | 528 |
| 525 /* | 529 /* |
| 526 ** Usage: sqlite3_snprintf_int SIZE FORMAT INT | 530 ** Usage: sqlite3_snprintf_int SIZE FORMAT INT |
| 527 ** | 531 ** |
| 528 ** Test the of sqlite3_snprintf() routine. SIZE is the size of the | 532 ** Test the of sqlite3_snprintf() routine. SIZE is the size of the |
| 529 ** output buffer in bytes. The maximum size is 100. FORMAT is the | 533 ** output buffer in bytes. The maximum size is 100. FORMAT is the |
| 530 ** format string. INT is a single integer argument. The FORMAT | 534 ** format string. INT is a single integer argument. The FORMAT |
| 531 ** string must require no more than this one integer argument. If | 535 ** string must require no more than this one integer argument. If |
| 532 ** You pass in a format string that requires more than one argument, | 536 ** You pass in a format string that requires more than one argument, |
| 533 ** bad things will happen. | 537 ** bad things will happen. |
| 534 */ | 538 */ |
| 535 static int test_snprintf_int( | 539 static int SQLITE_TCLAPI test_snprintf_int( |
| 536 void *NotUsed, | 540 void *NotUsed, |
| 537 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 541 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 538 int argc, /* Number of arguments */ | 542 int argc, /* Number of arguments */ |
| 539 char **argv /* Text of each argument */ | 543 char **argv /* Text of each argument */ |
| 540 ){ | 544 ){ |
| 541 char zStr[100]; | 545 char zStr[100]; |
| 542 int n = atoi(argv[1]); | 546 int n = atoi(argv[1]); |
| 543 const char *zFormat = argv[2]; | 547 const char *zFormat = argv[2]; |
| 544 int a1 = atoi(argv[3]); | 548 int a1 = atoi(argv[3]); |
| 545 if( n>sizeof(zStr) ) n = sizeof(zStr); | 549 if( n>sizeof(zStr) ) n = sizeof(zStr); |
| 546 sqlite3_snprintf(sizeof(zStr), zStr, "abcdefghijklmnopqrstuvwxyz"); | 550 sqlite3_snprintf(sizeof(zStr), zStr, "abcdefghijklmnopqrstuvwxyz"); |
| 547 sqlite3_snprintf(n, zStr, zFormat, a1); | 551 sqlite3_snprintf(n, zStr, zFormat, a1); |
| 548 Tcl_AppendResult(interp, zStr, 0); | 552 Tcl_AppendResult(interp, zStr, 0); |
| 549 return TCL_OK; | 553 return TCL_OK; |
| 550 } | 554 } |
| 551 | 555 |
| 552 #ifndef SQLITE_OMIT_GET_TABLE | 556 #ifndef SQLITE_OMIT_GET_TABLE |
| 553 | 557 |
| 554 /* | 558 /* |
| 555 ** Usage: sqlite3_get_table_printf DB FORMAT STRING ?--no-counts? | 559 ** Usage: sqlite3_get_table_printf DB FORMAT STRING ?--no-counts? |
| 556 ** | 560 ** |
| 557 ** Invoke the sqlite3_get_table_printf() interface using the open database | 561 ** Invoke the sqlite3_get_table_printf() interface using the open database |
| 558 ** DB. The SQL is the string FORMAT. The format string should contain | 562 ** DB. The SQL is the string FORMAT. The format string should contain |
| 559 ** one %s or %q. STRING is the value inserted into %s or %q. | 563 ** one %s or %q. STRING is the value inserted into %s or %q. |
| 560 */ | 564 */ |
| 561 static int test_get_table_printf( | 565 static int SQLITE_TCLAPI test_get_table_printf( |
| 562 void *NotUsed, | 566 void *NotUsed, |
| 563 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 567 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 564 int argc, /* Number of arguments */ | 568 int argc, /* Number of arguments */ |
| 565 char **argv /* Text of each argument */ | 569 char **argv /* Text of each argument */ |
| 566 ){ | 570 ){ |
| 567 sqlite3 *db; | 571 sqlite3 *db; |
| 568 Tcl_DString str; | 572 Tcl_DString str; |
| 569 int rc; | 573 int rc; |
| 570 char *zErr = 0; | 574 char *zErr = 0; |
| 571 int nRow = 0, nCol = 0; | 575 int nRow = 0, nCol = 0; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 } | 618 } |
| 615 | 619 |
| 616 #endif /* SQLITE_OMIT_GET_TABLE */ | 620 #endif /* SQLITE_OMIT_GET_TABLE */ |
| 617 | 621 |
| 618 | 622 |
| 619 /* | 623 /* |
| 620 ** Usage: sqlite3_last_insert_rowid DB | 624 ** Usage: sqlite3_last_insert_rowid DB |
| 621 ** | 625 ** |
| 622 ** Returns the integer ROWID of the most recent insert. | 626 ** Returns the integer ROWID of the most recent insert. |
| 623 */ | 627 */ |
| 624 static int test_last_rowid( | 628 static int SQLITE_TCLAPI test_last_rowid( |
| 625 void *NotUsed, | 629 void *NotUsed, |
| 626 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 630 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 627 int argc, /* Number of arguments */ | 631 int argc, /* Number of arguments */ |
| 628 char **argv /* Text of each argument */ | 632 char **argv /* Text of each argument */ |
| 629 ){ | 633 ){ |
| 630 sqlite3 *db; | 634 sqlite3 *db; |
| 631 char zBuf[30]; | 635 char zBuf[30]; |
| 632 | 636 |
| 633 if( argc!=2 ){ | 637 if( argc!=2 ){ |
| 634 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB\"", 0); | 638 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB\"", 0); |
| 635 return TCL_ERROR; | 639 return TCL_ERROR; |
| 636 } | 640 } |
| 637 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 641 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
| 638 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", sqlite3_last_insert_rowid(db)); | 642 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", sqlite3_last_insert_rowid(db)); |
| 639 Tcl_AppendResult(interp, zBuf, 0); | 643 Tcl_AppendResult(interp, zBuf, 0); |
| 640 return SQLITE_OK; | 644 return SQLITE_OK; |
| 641 } | 645 } |
| 642 | 646 |
| 643 /* | 647 /* |
| 644 ** Usage: sqlite3_key DB KEY | 648 ** Usage: sqlite3_key DB KEY |
| 645 ** | 649 ** |
| 646 ** Set the codec key. | 650 ** Set the codec key. |
| 647 */ | 651 */ |
| 648 static int test_key( | 652 static int SQLITE_TCLAPI test_key( |
| 649 void *NotUsed, | 653 void *NotUsed, |
| 650 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 654 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 651 int argc, /* Number of arguments */ | 655 int argc, /* Number of arguments */ |
| 652 char **argv /* Text of each argument */ | 656 char **argv /* Text of each argument */ |
| 653 ){ | 657 ){ |
| 654 #ifdef SQLITE_HAS_CODEC | 658 #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_CODEC_FROM_TCL) |
| 655 sqlite3 *db; | 659 sqlite3 *db; |
| 656 const char *zKey; | 660 const char *zKey; |
| 657 int nKey; | 661 int nKey; |
| 658 if( argc!=3 ){ | 662 if( argc!=3 ){ |
| 659 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 663 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 660 " FILENAME\"", 0); | 664 " FILENAME\"", 0); |
| 661 return TCL_ERROR; | 665 return TCL_ERROR; |
| 662 } | 666 } |
| 663 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 667 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
| 664 zKey = argv[2]; | 668 zKey = argv[2]; |
| 665 nKey = strlen(zKey); | 669 nKey = strlen(zKey); |
| 666 sqlite3_key(db, zKey, nKey); | 670 sqlite3_key(db, zKey, nKey); |
| 667 #endif | 671 #endif |
| 668 return TCL_OK; | 672 return TCL_OK; |
| 669 } | 673 } |
| 670 | 674 |
| 671 /* | 675 /* |
| 672 ** Usage: sqlite3_rekey DB KEY | 676 ** Usage: sqlite3_rekey DB KEY |
| 673 ** | 677 ** |
| 674 ** Change the codec key. | 678 ** Change the codec key. |
| 675 */ | 679 */ |
| 676 static int test_rekey( | 680 static int SQLITE_TCLAPI test_rekey( |
| 677 void *NotUsed, | 681 void *NotUsed, |
| 678 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 682 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 679 int argc, /* Number of arguments */ | 683 int argc, /* Number of arguments */ |
| 680 char **argv /* Text of each argument */ | 684 char **argv /* Text of each argument */ |
| 681 ){ | 685 ){ |
| 682 #ifdef SQLITE_HAS_CODEC | 686 #ifdef SQLITE_HAS_CODEC |
| 683 sqlite3 *db; | 687 sqlite3 *db; |
| 684 const char *zKey; | 688 const char *zKey; |
| 685 int nKey; | 689 int nKey; |
| 686 if( argc!=3 ){ | 690 if( argc!=3 ){ |
| 687 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 691 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 688 " FILENAME\"", 0); | 692 " FILENAME\"", 0); |
| 689 return TCL_ERROR; | 693 return TCL_ERROR; |
| 690 } | 694 } |
| 691 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 695 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
| 692 zKey = argv[2]; | 696 zKey = argv[2]; |
| 693 nKey = strlen(zKey); | 697 nKey = strlen(zKey); |
| 694 sqlite3_rekey(db, zKey, nKey); | 698 sqlite3_rekey(db, zKey, nKey); |
| 695 #endif | 699 #endif |
| 696 return TCL_OK; | 700 return TCL_OK; |
| 697 } | 701 } |
| 698 | 702 |
| 699 /* | 703 /* |
| 700 ** Usage: sqlite3_close DB | 704 ** Usage: sqlite3_close DB |
| 701 ** | 705 ** |
| 702 ** Closes the database opened by sqlite3_open. | 706 ** Closes the database opened by sqlite3_open. |
| 703 */ | 707 */ |
| 704 static int sqlite_test_close( | 708 static int SQLITE_TCLAPI sqlite_test_close( |
| 705 void *NotUsed, | 709 void *NotUsed, |
| 706 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 710 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 707 int argc, /* Number of arguments */ | 711 int argc, /* Number of arguments */ |
| 708 char **argv /* Text of each argument */ | 712 char **argv /* Text of each argument */ |
| 709 ){ | 713 ){ |
| 710 sqlite3 *db; | 714 sqlite3 *db; |
| 711 int rc; | 715 int rc; |
| 712 if( argc!=2 ){ | 716 if( argc!=2 ){ |
| 713 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 717 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 714 " FILENAME\"", 0); | 718 " FILENAME\"", 0); |
| 715 return TCL_ERROR; | 719 return TCL_ERROR; |
| 716 } | 720 } |
| 717 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 721 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
| 718 rc = sqlite3_close(db); | 722 rc = sqlite3_close(db); |
| 719 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); | 723 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); |
| 720 return TCL_OK; | 724 return TCL_OK; |
| 721 } | 725 } |
| 722 | 726 |
| 723 /* | 727 /* |
| 724 ** Usage: sqlite3_close_v2 DB | 728 ** Usage: sqlite3_close_v2 DB |
| 725 ** | 729 ** |
| 726 ** Closes the database opened by sqlite3_open. | 730 ** Closes the database opened by sqlite3_open. |
| 727 */ | 731 */ |
| 728 static int sqlite_test_close_v2( | 732 static int SQLITE_TCLAPI sqlite_test_close_v2( |
| 729 void *NotUsed, | 733 void *NotUsed, |
| 730 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 734 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 731 int argc, /* Number of arguments */ | 735 int argc, /* Number of arguments */ |
| 732 char **argv /* Text of each argument */ | 736 char **argv /* Text of each argument */ |
| 733 ){ | 737 ){ |
| 734 sqlite3 *db; | 738 sqlite3 *db; |
| 735 int rc; | 739 int rc; |
| 736 if( argc!=2 ){ | 740 if( argc!=2 ){ |
| 737 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 741 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 738 " FILENAME\"", 0); | 742 " FILENAME\"", 0); |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 ** as the "coalesce" function. This function also registers an SQL function | 1006 ** as the "coalesce" function. This function also registers an SQL function |
| 1003 ** named "x_sqlite_exec" that invokes sqlite3_exec(). Invoking sqlite3_exec() | 1007 ** named "x_sqlite_exec" that invokes sqlite3_exec(). Invoking sqlite3_exec() |
| 1004 ** in this way is illegal recursion and should raise an SQLITE_MISUSE error. | 1008 ** in this way is illegal recursion and should raise an SQLITE_MISUSE error. |
| 1005 ** The effect is similar to trying to use the same database connection from | 1009 ** The effect is similar to trying to use the same database connection from |
| 1006 ** two threads at the same time. | 1010 ** two threads at the same time. |
| 1007 ** | 1011 ** |
| 1008 ** The original motivation for this routine was to be able to call the | 1012 ** The original motivation for this routine was to be able to call the |
| 1009 ** sqlite3_create_function function while a query is in progress in order | 1013 ** sqlite3_create_function function while a query is in progress in order |
| 1010 ** to test the SQLITE_MISUSE detection logic. | 1014 ** to test the SQLITE_MISUSE detection logic. |
| 1011 */ | 1015 */ |
| 1012 static int test_create_function( | 1016 static int SQLITE_TCLAPI test_create_function( |
| 1013 void *NotUsed, | 1017 void *NotUsed, |
| 1014 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1018 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1015 int argc, /* Number of arguments */ | 1019 int argc, /* Number of arguments */ |
| 1016 char **argv /* Text of each argument */ | 1020 char **argv /* Text of each argument */ |
| 1017 ){ | 1021 ){ |
| 1018 int rc; | 1022 int rc; |
| 1019 sqlite3 *db; | 1023 sqlite3 *db; |
| 1020 | 1024 |
| 1021 if( argc!=2 ){ | 1025 if( argc!=2 ){ |
| 1022 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 1026 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 ** sqlite3_create_aggregate function while a query is in progress in order | 1163 ** sqlite3_create_aggregate function while a query is in progress in order |
| 1160 ** to test the SQLITE_MISUSE detection logic. See misuse.test. | 1164 ** to test the SQLITE_MISUSE detection logic. See misuse.test. |
| 1161 ** | 1165 ** |
| 1162 ** This routine was later extended to test the use of sqlite3_result_error() | 1166 ** This routine was later extended to test the use of sqlite3_result_error() |
| 1163 ** within aggregate functions. | 1167 ** within aggregate functions. |
| 1164 ** | 1168 ** |
| 1165 ** Later: It is now also extended to register the aggregate function | 1169 ** Later: It is now also extended to register the aggregate function |
| 1166 ** "legacy_count()" with the supplied database handle. This is used | 1170 ** "legacy_count()" with the supplied database handle. This is used |
| 1167 ** to test the deprecated sqlite3_aggregate_count() API. | 1171 ** to test the deprecated sqlite3_aggregate_count() API. |
| 1168 */ | 1172 */ |
| 1169 static int test_create_aggregate( | 1173 static int SQLITE_TCLAPI test_create_aggregate( |
| 1170 void *NotUsed, | 1174 void *NotUsed, |
| 1171 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1175 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1172 int argc, /* Number of arguments */ | 1176 int argc, /* Number of arguments */ |
| 1173 char **argv /* Text of each argument */ | 1177 char **argv /* Text of each argument */ |
| 1174 ){ | 1178 ){ |
| 1175 sqlite3 *db; | 1179 sqlite3 *db; |
| 1176 int rc; | 1180 int rc; |
| 1177 if( argc!=2 ){ | 1181 if( argc!=2 ){ |
| 1178 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 1182 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 1179 " FILENAME\"", 0); | 1183 " FILENAME\"", 0); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1200 | 1204 |
| 1201 | 1205 |
| 1202 /* | 1206 /* |
| 1203 ** Usage: printf TEXT | 1207 ** Usage: printf TEXT |
| 1204 ** | 1208 ** |
| 1205 ** Send output to printf. Use this rather than puts to merge the output | 1209 ** Send output to printf. Use this rather than puts to merge the output |
| 1206 ** in the correct sequence with debugging printfs inserted into C code. | 1210 ** in the correct sequence with debugging printfs inserted into C code. |
| 1207 ** Puts uses a separate buffer and debugging statements will be out of | 1211 ** Puts uses a separate buffer and debugging statements will be out of |
| 1208 ** sequence if it is used. | 1212 ** sequence if it is used. |
| 1209 */ | 1213 */ |
| 1210 static int test_printf( | 1214 static int SQLITE_TCLAPI test_printf( |
| 1211 void *NotUsed, | 1215 void *NotUsed, |
| 1212 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1216 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1213 int argc, /* Number of arguments */ | 1217 int argc, /* Number of arguments */ |
| 1214 char **argv /* Text of each argument */ | 1218 char **argv /* Text of each argument */ |
| 1215 ){ | 1219 ){ |
| 1216 if( argc!=2 ){ | 1220 if( argc!=2 ){ |
| 1217 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 1221 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 1218 " TEXT\"", 0); | 1222 " TEXT\"", 0); |
| 1219 return TCL_ERROR; | 1223 return TCL_ERROR; |
| 1220 } | 1224 } |
| 1221 printf("%s\n", argv[1]); | 1225 printf("%s\n", argv[1]); |
| 1222 return TCL_OK; | 1226 return TCL_OK; |
| 1223 } | 1227 } |
| 1224 | 1228 |
| 1225 | 1229 |
| 1226 | 1230 |
| 1227 /* | 1231 /* |
| 1228 ** Usage: sqlite3_mprintf_int FORMAT INTEGER INTEGER INTEGER | 1232 ** Usage: sqlite3_mprintf_int FORMAT INTEGER INTEGER INTEGER |
| 1229 ** | 1233 ** |
| 1230 ** Call mprintf with three integer arguments | 1234 ** Call mprintf with three integer arguments |
| 1231 */ | 1235 */ |
| 1232 static int sqlite3_mprintf_int( | 1236 static int SQLITE_TCLAPI sqlite3_mprintf_int( |
| 1233 void *NotUsed, | 1237 void *NotUsed, |
| 1234 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1238 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1235 int argc, /* Number of arguments */ | 1239 int argc, /* Number of arguments */ |
| 1236 char **argv /* Text of each argument */ | 1240 char **argv /* Text of each argument */ |
| 1237 ){ | 1241 ){ |
| 1238 int a[3], i; | 1242 int a[3], i; |
| 1239 char *z; | 1243 char *z; |
| 1240 if( argc!=5 ){ | 1244 if( argc!=5 ){ |
| 1241 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 1245 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 1242 " FORMAT INT INT INT\"", 0); | 1246 " FORMAT INT INT INT\"", 0); |
| 1243 return TCL_ERROR; | 1247 return TCL_ERROR; |
| 1244 } | 1248 } |
| 1245 for(i=2; i<5; i++){ | 1249 for(i=2; i<5; i++){ |
| 1246 if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; | 1250 if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; |
| 1247 } | 1251 } |
| 1248 z = sqlite3_mprintf(argv[1], a[0], a[1], a[2]); | 1252 z = sqlite3_mprintf(argv[1], a[0], a[1], a[2]); |
| 1249 Tcl_AppendResult(interp, z, 0); | 1253 Tcl_AppendResult(interp, z, 0); |
| 1250 sqlite3_free(z); | 1254 sqlite3_free(z); |
| 1251 return TCL_OK; | 1255 return TCL_OK; |
| 1252 } | 1256 } |
| 1253 | 1257 |
| 1254 /* | 1258 /* |
| 1255 ** Usage: sqlite3_mprintf_int64 FORMAT INTEGER INTEGER INTEGER | 1259 ** Usage: sqlite3_mprintf_int64 FORMAT INTEGER INTEGER INTEGER |
| 1256 ** | 1260 ** |
| 1257 ** Call mprintf with three 64-bit integer arguments | 1261 ** Call mprintf with three 64-bit integer arguments |
| 1258 */ | 1262 */ |
| 1259 static int sqlite3_mprintf_int64( | 1263 static int SQLITE_TCLAPI sqlite3_mprintf_int64( |
| 1260 void *NotUsed, | 1264 void *NotUsed, |
| 1261 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1265 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1262 int argc, /* Number of arguments */ | 1266 int argc, /* Number of arguments */ |
| 1263 char **argv /* Text of each argument */ | 1267 char **argv /* Text of each argument */ |
| 1264 ){ | 1268 ){ |
| 1265 int i; | 1269 int i; |
| 1266 sqlite_int64 a[3]; | 1270 sqlite_int64 a[3]; |
| 1267 char *z; | 1271 char *z; |
| 1268 if( argc!=5 ){ | 1272 if( argc!=5 ){ |
| 1269 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 1273 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 1270 " FORMAT INT INT INT\"", 0); | 1274 " FORMAT INT INT INT\"", 0); |
| 1271 return TCL_ERROR; | 1275 return TCL_ERROR; |
| 1272 } | 1276 } |
| 1273 for(i=2; i<5; i++){ | 1277 for(i=2; i<5; i++){ |
| 1274 if( sqlite3Atoi64(argv[i], &a[i-2], 1000000, SQLITE_UTF8) ){ | 1278 if( sqlite3Atoi64(argv[i], &a[i-2], sqlite3Strlen30(argv[i]), SQLITE_UTF8) )
{ |
| 1275 Tcl_AppendResult(interp, "argument is not a valid 64-bit integer", 0); | 1279 Tcl_AppendResult(interp, "argument is not a valid 64-bit integer", 0); |
| 1276 return TCL_ERROR; | 1280 return TCL_ERROR; |
| 1277 } | 1281 } |
| 1278 } | 1282 } |
| 1279 z = sqlite3_mprintf(argv[1], a[0], a[1], a[2]); | 1283 z = sqlite3_mprintf(argv[1], a[0], a[1], a[2]); |
| 1280 Tcl_AppendResult(interp, z, 0); | 1284 Tcl_AppendResult(interp, z, 0); |
| 1281 sqlite3_free(z); | 1285 sqlite3_free(z); |
| 1282 return TCL_OK; | 1286 return TCL_OK; |
| 1283 } | 1287 } |
| 1284 | 1288 |
| 1285 /* | 1289 /* |
| 1286 ** Usage: sqlite3_mprintf_long FORMAT INTEGER INTEGER INTEGER | 1290 ** Usage: sqlite3_mprintf_long FORMAT INTEGER INTEGER INTEGER |
| 1287 ** | 1291 ** |
| 1288 ** Call mprintf with three long integer arguments. This might be the | 1292 ** Call mprintf with three long integer arguments. This might be the |
| 1289 ** same as sqlite3_mprintf_int or sqlite3_mprintf_int64, depending on | 1293 ** same as sqlite3_mprintf_int or sqlite3_mprintf_int64, depending on |
| 1290 ** platform. | 1294 ** platform. |
| 1291 */ | 1295 */ |
| 1292 static int sqlite3_mprintf_long( | 1296 static int SQLITE_TCLAPI sqlite3_mprintf_long( |
| 1293 void *NotUsed, | 1297 void *NotUsed, |
| 1294 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1298 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1295 int argc, /* Number of arguments */ | 1299 int argc, /* Number of arguments */ |
| 1296 char **argv /* Text of each argument */ | 1300 char **argv /* Text of each argument */ |
| 1297 ){ | 1301 ){ |
| 1298 int i; | 1302 int i; |
| 1299 long int a[3]; | 1303 long int a[3]; |
| 1300 int b[3]; | 1304 int b[3]; |
| 1301 char *z; | 1305 char *z; |
| 1302 if( argc!=5 ){ | 1306 if( argc!=5 ){ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1313 Tcl_AppendResult(interp, z, 0); | 1317 Tcl_AppendResult(interp, z, 0); |
| 1314 sqlite3_free(z); | 1318 sqlite3_free(z); |
| 1315 return TCL_OK; | 1319 return TCL_OK; |
| 1316 } | 1320 } |
| 1317 | 1321 |
| 1318 /* | 1322 /* |
| 1319 ** Usage: sqlite3_mprintf_str FORMAT INTEGER INTEGER STRING | 1323 ** Usage: sqlite3_mprintf_str FORMAT INTEGER INTEGER STRING |
| 1320 ** | 1324 ** |
| 1321 ** Call mprintf with two integer arguments and one string argument | 1325 ** Call mprintf with two integer arguments and one string argument |
| 1322 */ | 1326 */ |
| 1323 static int sqlite3_mprintf_str( | 1327 static int SQLITE_TCLAPI sqlite3_mprintf_str( |
| 1324 void *NotUsed, | 1328 void *NotUsed, |
| 1325 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1329 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1326 int argc, /* Number of arguments */ | 1330 int argc, /* Number of arguments */ |
| 1327 char **argv /* Text of each argument */ | 1331 char **argv /* Text of each argument */ |
| 1328 ){ | 1332 ){ |
| 1329 int a[3], i; | 1333 int a[3], i; |
| 1330 char *z; | 1334 char *z; |
| 1331 if( argc<4 || argc>5 ){ | 1335 if( argc<4 || argc>5 ){ |
| 1332 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 1336 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 1333 " FORMAT INT INT ?STRING?\"", 0); | 1337 " FORMAT INT INT ?STRING?\"", 0); |
| 1334 return TCL_ERROR; | 1338 return TCL_ERROR; |
| 1335 } | 1339 } |
| 1336 for(i=2; i<4; i++){ | 1340 for(i=2; i<4; i++){ |
| 1337 if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; | 1341 if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; |
| 1338 } | 1342 } |
| 1339 z = sqlite3_mprintf(argv[1], a[0], a[1], argc>4 ? argv[4] : NULL); | 1343 z = sqlite3_mprintf(argv[1], a[0], a[1], argc>4 ? argv[4] : NULL); |
| 1340 Tcl_AppendResult(interp, z, 0); | 1344 Tcl_AppendResult(interp, z, 0); |
| 1341 sqlite3_free(z); | 1345 sqlite3_free(z); |
| 1342 return TCL_OK; | 1346 return TCL_OK; |
| 1343 } | 1347 } |
| 1344 | 1348 |
| 1345 /* | 1349 /* |
| 1346 ** Usage: sqlite3_snprintf_str INTEGER FORMAT INTEGER INTEGER STRING | 1350 ** Usage: sqlite3_snprintf_str INTEGER FORMAT INTEGER INTEGER STRING |
| 1347 ** | 1351 ** |
| 1348 ** Call mprintf with two integer arguments and one string argument | 1352 ** Call mprintf with two integer arguments and one string argument |
| 1349 */ | 1353 */ |
| 1350 static int sqlite3_snprintf_str( | 1354 static int SQLITE_TCLAPI sqlite3_snprintf_str( |
| 1351 void *NotUsed, | 1355 void *NotUsed, |
| 1352 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1356 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1353 int argc, /* Number of arguments */ | 1357 int argc, /* Number of arguments */ |
| 1354 char **argv /* Text of each argument */ | 1358 char **argv /* Text of each argument */ |
| 1355 ){ | 1359 ){ |
| 1356 int a[3], i; | 1360 int a[3], i; |
| 1357 int n; | 1361 int n; |
| 1358 char *z; | 1362 char *z; |
| 1359 if( argc<5 || argc>6 ){ | 1363 if( argc<5 || argc>6 ){ |
| 1360 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 1364 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1374 Tcl_AppendResult(interp, z, 0); | 1378 Tcl_AppendResult(interp, z, 0); |
| 1375 sqlite3_free(z); | 1379 sqlite3_free(z); |
| 1376 return TCL_OK; | 1380 return TCL_OK; |
| 1377 } | 1381 } |
| 1378 | 1382 |
| 1379 /* | 1383 /* |
| 1380 ** Usage: sqlite3_mprintf_double FORMAT INTEGER INTEGER DOUBLE | 1384 ** Usage: sqlite3_mprintf_double FORMAT INTEGER INTEGER DOUBLE |
| 1381 ** | 1385 ** |
| 1382 ** Call mprintf with two integer arguments and one double argument | 1386 ** Call mprintf with two integer arguments and one double argument |
| 1383 */ | 1387 */ |
| 1384 static int sqlite3_mprintf_double( | 1388 static int SQLITE_TCLAPI sqlite3_mprintf_double( |
| 1385 void *NotUsed, | 1389 void *NotUsed, |
| 1386 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1390 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1387 int argc, /* Number of arguments */ | 1391 int argc, /* Number of arguments */ |
| 1388 char **argv /* Text of each argument */ | 1392 char **argv /* Text of each argument */ |
| 1389 ){ | 1393 ){ |
| 1390 int a[3], i; | 1394 int a[3], i; |
| 1391 double r; | 1395 double r; |
| 1392 char *z; | 1396 char *z; |
| 1393 if( argc!=5 ){ | 1397 if( argc!=5 ){ |
| 1394 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 1398 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1405 return TCL_OK; | 1409 return TCL_OK; |
| 1406 } | 1410 } |
| 1407 | 1411 |
| 1408 /* | 1412 /* |
| 1409 ** Usage: sqlite3_mprintf_scaled FORMAT DOUBLE DOUBLE | 1413 ** Usage: sqlite3_mprintf_scaled FORMAT DOUBLE DOUBLE |
| 1410 ** | 1414 ** |
| 1411 ** Call mprintf with a single double argument which is the product of the | 1415 ** Call mprintf with a single double argument which is the product of the |
| 1412 ** two arguments given above. This is used to generate overflow and underflow | 1416 ** two arguments given above. This is used to generate overflow and underflow |
| 1413 ** doubles to test that they are converted properly. | 1417 ** doubles to test that they are converted properly. |
| 1414 */ | 1418 */ |
| 1415 static int sqlite3_mprintf_scaled( | 1419 static int SQLITE_TCLAPI sqlite3_mprintf_scaled( |
| 1416 void *NotUsed, | 1420 void *NotUsed, |
| 1417 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1421 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1418 int argc, /* Number of arguments */ | 1422 int argc, /* Number of arguments */ |
| 1419 char **argv /* Text of each argument */ | 1423 char **argv /* Text of each argument */ |
| 1420 ){ | 1424 ){ |
| 1421 int i; | 1425 int i; |
| 1422 double r[2]; | 1426 double r[2]; |
| 1423 char *z; | 1427 char *z; |
| 1424 if( argc!=4 ){ | 1428 if( argc!=4 ){ |
| 1425 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 1429 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 1426 " FORMAT DOUBLE DOUBLE\"", 0); | 1430 " FORMAT DOUBLE DOUBLE\"", 0); |
| 1427 return TCL_ERROR; | 1431 return TCL_ERROR; |
| 1428 } | 1432 } |
| 1429 for(i=2; i<4; i++){ | 1433 for(i=2; i<4; i++){ |
| 1430 if( Tcl_GetDouble(interp, argv[i], &r[i-2]) ) return TCL_ERROR; | 1434 if( Tcl_GetDouble(interp, argv[i], &r[i-2]) ) return TCL_ERROR; |
| 1431 } | 1435 } |
| 1432 z = sqlite3_mprintf(argv[1], r[0]*r[1]); | 1436 z = sqlite3_mprintf(argv[1], r[0]*r[1]); |
| 1433 Tcl_AppendResult(interp, z, 0); | 1437 Tcl_AppendResult(interp, z, 0); |
| 1434 sqlite3_free(z); | 1438 sqlite3_free(z); |
| 1435 return TCL_OK; | 1439 return TCL_OK; |
| 1436 } | 1440 } |
| 1437 | 1441 |
| 1438 /* | 1442 /* |
| 1439 ** Usage: sqlite3_mprintf_stronly FORMAT STRING | 1443 ** Usage: sqlite3_mprintf_stronly FORMAT STRING |
| 1440 ** | 1444 ** |
| 1441 ** Call mprintf with a single double argument which is the product of the | 1445 ** Call mprintf with a single double argument which is the product of the |
| 1442 ** two arguments given above. This is used to generate overflow and underflow | 1446 ** two arguments given above. This is used to generate overflow and underflow |
| 1443 ** doubles to test that they are converted properly. | 1447 ** doubles to test that they are converted properly. |
| 1444 */ | 1448 */ |
| 1445 static int sqlite3_mprintf_stronly( | 1449 static int SQLITE_TCLAPI sqlite3_mprintf_stronly( |
| 1446 void *NotUsed, | 1450 void *NotUsed, |
| 1447 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1451 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1448 int argc, /* Number of arguments */ | 1452 int argc, /* Number of arguments */ |
| 1449 char **argv /* Text of each argument */ | 1453 char **argv /* Text of each argument */ |
| 1450 ){ | 1454 ){ |
| 1451 char *z; | 1455 char *z; |
| 1452 if( argc!=3 ){ | 1456 if( argc!=3 ){ |
| 1453 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 1457 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 1454 " FORMAT STRING\"", 0); | 1458 " FORMAT STRING\"", 0); |
| 1455 return TCL_ERROR; | 1459 return TCL_ERROR; |
| 1456 } | 1460 } |
| 1457 z = sqlite3_mprintf(argv[1], argv[2]); | 1461 z = sqlite3_mprintf(argv[1], argv[2]); |
| 1458 Tcl_AppendResult(interp, z, 0); | 1462 Tcl_AppendResult(interp, z, 0); |
| 1459 sqlite3_free(z); | 1463 sqlite3_free(z); |
| 1460 return TCL_OK; | 1464 return TCL_OK; |
| 1461 } | 1465 } |
| 1462 | 1466 |
| 1463 /* | 1467 /* |
| 1464 ** Usage: sqlite3_mprintf_hexdouble FORMAT HEX | 1468 ** Usage: sqlite3_mprintf_hexdouble FORMAT HEX |
| 1465 ** | 1469 ** |
| 1466 ** Call mprintf with a single double argument which is derived from the | 1470 ** Call mprintf with a single double argument which is derived from the |
| 1467 ** hexadecimal encoding of an IEEE double. | 1471 ** hexadecimal encoding of an IEEE double. |
| 1468 */ | 1472 */ |
| 1469 static int sqlite3_mprintf_hexdouble( | 1473 static int SQLITE_TCLAPI sqlite3_mprintf_hexdouble( |
| 1470 void *NotUsed, | 1474 void *NotUsed, |
| 1471 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1475 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1472 int argc, /* Number of arguments */ | 1476 int argc, /* Number of arguments */ |
| 1473 char **argv /* Text of each argument */ | 1477 char **argv /* Text of each argument */ |
| 1474 ){ | 1478 ){ |
| 1475 char *z; | 1479 char *z; |
| 1476 double r; | 1480 double r; |
| 1477 unsigned int x1, x2; | 1481 unsigned int x1, x2; |
| 1478 sqlite_uint64 d; | 1482 sqlite_uint64 d; |
| 1479 if( argc!=3 ){ | 1483 if( argc!=3 ){ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1492 Tcl_AppendResult(interp, z, 0); | 1496 Tcl_AppendResult(interp, z, 0); |
| 1493 sqlite3_free(z); | 1497 sqlite3_free(z); |
| 1494 return TCL_OK; | 1498 return TCL_OK; |
| 1495 } | 1499 } |
| 1496 | 1500 |
| 1497 /* | 1501 /* |
| 1498 ** Usage: sqlite3_enable_shared_cache ?BOOLEAN? | 1502 ** Usage: sqlite3_enable_shared_cache ?BOOLEAN? |
| 1499 ** | 1503 ** |
| 1500 */ | 1504 */ |
| 1501 #if !defined(SQLITE_OMIT_SHARED_CACHE) | 1505 #if !defined(SQLITE_OMIT_SHARED_CACHE) |
| 1502 static int test_enable_shared( | 1506 static int SQLITE_TCLAPI test_enable_shared( |
| 1503 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 1507 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 1504 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1508 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1505 int objc, /* Number of arguments */ | 1509 int objc, /* Number of arguments */ |
| 1506 Tcl_Obj *CONST objv[] /* Command arguments */ | 1510 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 1507 ){ | 1511 ){ |
| 1508 int rc; | 1512 int rc; |
| 1509 int enable; | 1513 int enable; |
| 1510 int ret = 0; | 1514 int ret = 0; |
| 1511 | 1515 |
| 1512 if( objc!=2 && objc!=1 ){ | 1516 if( objc!=2 && objc!=1 ){ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1529 return TCL_OK; | 1533 return TCL_OK; |
| 1530 } | 1534 } |
| 1531 #endif | 1535 #endif |
| 1532 | 1536 |
| 1533 | 1537 |
| 1534 | 1538 |
| 1535 /* | 1539 /* |
| 1536 ** Usage: sqlite3_extended_result_codes DB BOOLEAN | 1540 ** Usage: sqlite3_extended_result_codes DB BOOLEAN |
| 1537 ** | 1541 ** |
| 1538 */ | 1542 */ |
| 1539 static int test_extended_result_codes( | 1543 static int SQLITE_TCLAPI test_extended_result_codes( |
| 1540 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 1544 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 1541 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1545 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1542 int objc, /* Number of arguments */ | 1546 int objc, /* Number of arguments */ |
| 1543 Tcl_Obj *CONST objv[] /* Command arguments */ | 1547 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 1544 ){ | 1548 ){ |
| 1545 int enable; | 1549 int enable; |
| 1546 sqlite3 *db; | 1550 sqlite3 *db; |
| 1547 | 1551 |
| 1548 if( objc!=3 ){ | 1552 if( objc!=3 ){ |
| 1549 Tcl_WrongNumArgs(interp, 1, objv, "DB BOOLEAN"); | 1553 Tcl_WrongNumArgs(interp, 1, objv, "DB BOOLEAN"); |
| 1550 return TCL_ERROR; | 1554 return TCL_ERROR; |
| 1551 } | 1555 } |
| 1552 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 1556 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 1553 if( Tcl_GetBooleanFromObj(interp, objv[2], &enable) ) return TCL_ERROR; | 1557 if( Tcl_GetBooleanFromObj(interp, objv[2], &enable) ) return TCL_ERROR; |
| 1554 sqlite3_extended_result_codes(db, enable); | 1558 sqlite3_extended_result_codes(db, enable); |
| 1555 return TCL_OK; | 1559 return TCL_OK; |
| 1556 } | 1560 } |
| 1557 | 1561 |
| 1558 /* | 1562 /* |
| 1559 ** Usage: sqlite3_libversion_number | 1563 ** Usage: sqlite3_libversion_number |
| 1560 ** | 1564 ** |
| 1561 */ | 1565 */ |
| 1562 static int test_libversion_number( | 1566 static int SQLITE_TCLAPI test_libversion_number( |
| 1563 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 1567 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 1564 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1568 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1565 int objc, /* Number of arguments */ | 1569 int objc, /* Number of arguments */ |
| 1566 Tcl_Obj *CONST objv[] /* Command arguments */ | 1570 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 1567 ){ | 1571 ){ |
| 1568 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_libversion_number())); | 1572 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_libversion_number())); |
| 1569 return TCL_OK; | 1573 return TCL_OK; |
| 1570 } | 1574 } |
| 1571 | 1575 |
| 1572 /* | 1576 /* |
| 1573 ** Usage: sqlite3_table_column_metadata DB dbname tblname colname | 1577 ** Usage: sqlite3_table_column_metadata DB dbname tblname colname |
| 1574 ** | 1578 ** |
| 1575 */ | 1579 */ |
| 1576 static int test_table_column_metadata( | 1580 static int SQLITE_TCLAPI test_table_column_metadata( |
| 1577 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 1581 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 1578 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1582 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1579 int objc, /* Number of arguments */ | 1583 int objc, /* Number of arguments */ |
| 1580 Tcl_Obj *CONST objv[] /* Command arguments */ | 1584 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 1581 ){ | 1585 ){ |
| 1582 sqlite3 *db; | 1586 sqlite3 *db; |
| 1583 const char *zDb; | 1587 const char *zDb; |
| 1584 const char *zTbl; | 1588 const char *zTbl; |
| 1585 const char *zCol; | 1589 const char *zCol; |
| 1586 int rc; | 1590 int rc; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1617 Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(notnull)); | 1621 Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(notnull)); |
| 1618 Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(primarykey)); | 1622 Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(primarykey)); |
| 1619 Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(autoincrement)); | 1623 Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(autoincrement)); |
| 1620 Tcl_SetObjResult(interp, pRet); | 1624 Tcl_SetObjResult(interp, pRet); |
| 1621 | 1625 |
| 1622 return TCL_OK; | 1626 return TCL_OK; |
| 1623 } | 1627 } |
| 1624 | 1628 |
| 1625 #ifndef SQLITE_OMIT_INCRBLOB | 1629 #ifndef SQLITE_OMIT_INCRBLOB |
| 1626 | 1630 |
| 1627 static int blobHandleFromObj( | 1631 static int SQLITE_TCLAPI blobHandleFromObj( |
| 1628 Tcl_Interp *interp, | 1632 Tcl_Interp *interp, |
| 1629 Tcl_Obj *pObj, | 1633 Tcl_Obj *pObj, |
| 1630 sqlite3_blob **ppBlob | 1634 sqlite3_blob **ppBlob |
| 1631 ){ | 1635 ){ |
| 1632 char *z; | 1636 char *z; |
| 1633 int n; | 1637 int n; |
| 1634 | 1638 |
| 1635 z = Tcl_GetStringFromObj(pObj, &n); | 1639 z = Tcl_GetStringFromObj(pObj, &n); |
| 1636 if( n==0 ){ | 1640 if( n==0 ){ |
| 1637 *ppBlob = 0; | 1641 *ppBlob = 0; |
| 1638 }else{ | 1642 }else{ |
| 1639 int notUsed; | 1643 int notUsed; |
| 1640 Tcl_Channel channel; | 1644 Tcl_Channel channel; |
| 1641 ClientData instanceData; | 1645 ClientData instanceData; |
| 1642 | 1646 |
| 1643 channel = Tcl_GetChannel(interp, z, ¬Used); | 1647 channel = Tcl_GetChannel(interp, z, ¬Used); |
| 1644 if( !channel ) return TCL_ERROR; | 1648 if( !channel ) return TCL_ERROR; |
| 1645 | 1649 |
| 1646 Tcl_Flush(channel); | 1650 Tcl_Flush(channel); |
| 1647 Tcl_Seek(channel, 0, SEEK_SET); | 1651 Tcl_Seek(channel, 0, SEEK_SET); |
| 1648 | 1652 |
| 1649 instanceData = Tcl_GetChannelInstanceData(channel); | 1653 instanceData = Tcl_GetChannelInstanceData(channel); |
| 1650 *ppBlob = *((sqlite3_blob **)instanceData); | 1654 *ppBlob = *((sqlite3_blob **)instanceData); |
| 1651 } | 1655 } |
| 1652 | 1656 |
| 1653 return TCL_OK; | 1657 return TCL_OK; |
| 1654 } | 1658 } |
| 1655 | 1659 |
| 1656 static int test_blob_reopen( | 1660 static int SQLITE_TCLAPI test_blob_reopen( |
| 1657 ClientData clientData, /* Not used */ | 1661 ClientData clientData, /* Not used */ |
| 1658 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1662 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1659 int objc, /* Number of arguments */ | 1663 int objc, /* Number of arguments */ |
| 1660 Tcl_Obj *CONST objv[] /* Command arguments */ | 1664 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 1661 ){ | 1665 ){ |
| 1662 Tcl_WideInt iRowid; | 1666 Tcl_WideInt iRowid; |
| 1663 sqlite3_blob *pBlob; | 1667 sqlite3_blob *pBlob; |
| 1664 int rc; | 1668 int rc; |
| 1665 | 1669 |
| 1666 if( objc!=3 ){ | 1670 if( objc!=3 ){ |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1722 | 1726 |
| 1723 if( TCL_OK!=Tcl_EvalObjEx(p->interp, pScript, TCL_EVAL_DIRECT|TCL_EVAL_GLOBAL) | 1727 if( TCL_OK!=Tcl_EvalObjEx(p->interp, pScript, TCL_EVAL_DIRECT|TCL_EVAL_GLOBAL) |
| 1724 || TCL_OK!=Tcl_GetIntFromObj(p->interp, Tcl_GetObjResult(p->interp), &iRes) | 1728 || TCL_OK!=Tcl_GetIntFromObj(p->interp, Tcl_GetObjResult(p->interp), &iRes) |
| 1725 ){ | 1729 ){ |
| 1726 Tcl_BackgroundError(p->interp); | 1730 Tcl_BackgroundError(p->interp); |
| 1727 } | 1731 } |
| 1728 Tcl_DecrRefCount(pScript); | 1732 Tcl_DecrRefCount(pScript); |
| 1729 | 1733 |
| 1730 return iRes; | 1734 return iRes; |
| 1731 } | 1735 } |
| 1732 static int test_create_collation_v2( | 1736 static int SQLITE_TCLAPI test_create_collation_v2( |
| 1733 ClientData clientData, /* Not used */ | 1737 ClientData clientData, /* Not used */ |
| 1734 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1738 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1735 int objc, /* Number of arguments */ | 1739 int objc, /* Number of arguments */ |
| 1736 Tcl_Obj *CONST objv[] /* Command arguments */ | 1740 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 1737 ){ | 1741 ){ |
| 1738 TestCollationX *p; | 1742 TestCollationX *p; |
| 1739 sqlite3 *db; | 1743 sqlite3 *db; |
| 1740 int rc; | 1744 int rc; |
| 1741 | 1745 |
| 1742 if( objc!=5 ){ | 1746 if( objc!=5 ){ |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 int rc = Tcl_EvalObjEx(p->interp, p->pDestroy, 0); | 1801 int rc = Tcl_EvalObjEx(p->interp, p->pDestroy, 0); |
| 1798 if( rc!=TCL_OK ) Tcl_BackgroundError(p->interp); | 1802 if( rc!=TCL_OK ) Tcl_BackgroundError(p->interp); |
| 1799 } | 1803 } |
| 1800 | 1804 |
| 1801 if( p->pFunc ) Tcl_DecrRefCount(p->pFunc); | 1805 if( p->pFunc ) Tcl_DecrRefCount(p->pFunc); |
| 1802 if( p->pStep ) Tcl_DecrRefCount(p->pStep); | 1806 if( p->pStep ) Tcl_DecrRefCount(p->pStep); |
| 1803 if( p->pFinal ) Tcl_DecrRefCount(p->pFinal); | 1807 if( p->pFinal ) Tcl_DecrRefCount(p->pFinal); |
| 1804 if( p->pDestroy ) Tcl_DecrRefCount(p->pDestroy); | 1808 if( p->pDestroy ) Tcl_DecrRefCount(p->pDestroy); |
| 1805 sqlite3_free(p); | 1809 sqlite3_free(p); |
| 1806 } | 1810 } |
| 1807 static int test_create_function_v2( | 1811 static int SQLITE_TCLAPI test_create_function_v2( |
| 1808 ClientData clientData, /* Not used */ | 1812 ClientData clientData, /* Not used */ |
| 1809 Tcl_Interp *interp, /* The invoking TCL interpreter */ | 1813 Tcl_Interp *interp, /* The invoking TCL interpreter */ |
| 1810 int objc, /* Number of arguments */ | 1814 int objc, /* Number of arguments */ |
| 1811 Tcl_Obj *CONST objv[] /* Command arguments */ | 1815 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 1812 ){ | 1816 ){ |
| 1813 sqlite3 *db; | 1817 sqlite3 *db; |
| 1814 const char *zFunc; | 1818 const char *zFunc; |
| 1815 int nArg; | 1819 int nArg; |
| 1816 int enc; | 1820 int enc; |
| 1817 CreateFunctionV2 *p; | 1821 CreateFunctionV2 *p; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1885 Tcl_ResetResult(interp); | 1889 Tcl_ResetResult(interp); |
| 1886 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); | 1890 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); |
| 1887 return TCL_ERROR; | 1891 return TCL_ERROR; |
| 1888 } | 1892 } |
| 1889 return TCL_OK; | 1893 return TCL_OK; |
| 1890 } | 1894 } |
| 1891 | 1895 |
| 1892 /* | 1896 /* |
| 1893 ** Usage: sqlite3_load_extension DB-HANDLE FILE ?PROC? | 1897 ** Usage: sqlite3_load_extension DB-HANDLE FILE ?PROC? |
| 1894 */ | 1898 */ |
| 1895 static int test_load_extension( | 1899 static int SQLITE_TCLAPI test_load_extension( |
| 1896 ClientData clientData, /* Not used */ | 1900 ClientData clientData, /* Not used */ |
| 1897 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1901 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1898 int objc, /* Number of arguments */ | 1902 int objc, /* Number of arguments */ |
| 1899 Tcl_Obj *CONST objv[] /* Command arguments */ | 1903 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 1900 ){ | 1904 ){ |
| 1901 Tcl_CmdInfo cmdInfo; | 1905 Tcl_CmdInfo cmdInfo; |
| 1902 sqlite3 *db; | 1906 sqlite3 *db; |
| 1903 int rc; | 1907 int rc; |
| 1904 char *zDb; | 1908 char *zDb; |
| 1905 char *zFile; | 1909 char *zFile; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1924 db = ((struct SqliteDb*)cmdInfo.objClientData)->db; | 1928 db = ((struct SqliteDb*)cmdInfo.objClientData)->db; |
| 1925 assert(db); | 1929 assert(db); |
| 1926 | 1930 |
| 1927 /* Call the underlying C function. If an error occurs, set rc to | 1931 /* Call the underlying C function. If an error occurs, set rc to |
| 1928 ** TCL_ERROR and load any error string into the interpreter. If no | 1932 ** TCL_ERROR and load any error string into the interpreter. If no |
| 1929 ** error occurs, set rc to TCL_OK. | 1933 ** error occurs, set rc to TCL_OK. |
| 1930 */ | 1934 */ |
| 1931 #ifdef SQLITE_OMIT_LOAD_EXTENSION | 1935 #ifdef SQLITE_OMIT_LOAD_EXTENSION |
| 1932 rc = SQLITE_ERROR; | 1936 rc = SQLITE_ERROR; |
| 1933 zErr = sqlite3_mprintf("this build omits sqlite3_load_extension()"); | 1937 zErr = sqlite3_mprintf("this build omits sqlite3_load_extension()"); |
| 1938 (void)zProc; |
| 1939 (void)zFile; |
| 1934 #else | 1940 #else |
| 1935 rc = sqlite3_load_extension(db, zFile, zProc, &zErr); | 1941 rc = sqlite3_load_extension(db, zFile, zProc, &zErr); |
| 1936 #endif | 1942 #endif |
| 1937 if( rc!=SQLITE_OK ){ | 1943 if( rc!=SQLITE_OK ){ |
| 1938 Tcl_SetResult(interp, zErr ? zErr : "", TCL_VOLATILE); | 1944 Tcl_SetResult(interp, zErr ? zErr : "", TCL_VOLATILE); |
| 1939 rc = TCL_ERROR; | 1945 rc = TCL_ERROR; |
| 1940 }else{ | 1946 }else{ |
| 1941 rc = TCL_OK; | 1947 rc = TCL_OK; |
| 1942 } | 1948 } |
| 1943 sqlite3_free(zErr); | 1949 sqlite3_free(zErr); |
| 1944 | 1950 |
| 1945 return rc; | 1951 return rc; |
| 1946 } | 1952 } |
| 1947 | 1953 |
| 1948 /* | 1954 /* |
| 1949 ** Usage: sqlite3_enable_load_extension DB-HANDLE ONOFF | 1955 ** Usage: sqlite3_enable_load_extension DB-HANDLE ONOFF |
| 1950 */ | 1956 */ |
| 1951 static int test_enable_load( | 1957 static int SQLITE_TCLAPI test_enable_load( |
| 1952 ClientData clientData, /* Not used */ | 1958 ClientData clientData, /* Not used */ |
| 1953 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 1959 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 1954 int objc, /* Number of arguments */ | 1960 int objc, /* Number of arguments */ |
| 1955 Tcl_Obj *CONST objv[] /* Command arguments */ | 1961 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 1956 ){ | 1962 ){ |
| 1957 Tcl_CmdInfo cmdInfo; | 1963 Tcl_CmdInfo cmdInfo; |
| 1958 sqlite3 *db; | 1964 sqlite3 *db; |
| 1959 char *zDb; | 1965 char *zDb; |
| 1960 int onoff; | 1966 int onoff; |
| 1961 | 1967 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1987 #endif | 1993 #endif |
| 1988 } | 1994 } |
| 1989 | 1995 |
| 1990 /* | 1996 /* |
| 1991 ** Usage: sqlite_abort | 1997 ** Usage: sqlite_abort |
| 1992 ** | 1998 ** |
| 1993 ** Shutdown the process immediately. This is not a clean shutdown. | 1999 ** Shutdown the process immediately. This is not a clean shutdown. |
| 1994 ** This command is used to test the recoverability of a database in | 2000 ** This command is used to test the recoverability of a database in |
| 1995 ** the event of a program crash. | 2001 ** the event of a program crash. |
| 1996 */ | 2002 */ |
| 1997 static int sqlite_abort( | 2003 static int SQLITE_TCLAPI sqlite_abort( |
| 1998 void *NotUsed, | 2004 void *NotUsed, |
| 1999 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 2005 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 2000 int argc, /* Number of arguments */ | 2006 int argc, /* Number of arguments */ |
| 2001 char **argv /* Text of each argument */ | 2007 char **argv /* Text of each argument */ |
| 2002 ){ | 2008 ){ |
| 2003 #if defined(_MSC_VER) | 2009 #if defined(_MSC_VER) |
| 2004 /* We do this, otherwise the test will halt with a popup message | 2010 /* We do this, otherwise the test will halt with a popup message |
| 2005 * that we have to click away before the test will continue. | 2011 * that we have to click away before the test will continue. |
| 2006 */ | 2012 */ |
| 2007 _set_abort_behavior( 0, _CALL_REPORTFAULT ); | 2013 _set_abort_behavior( 0, _CALL_REPORTFAULT ); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2046 error_out: | 2052 error_out: |
| 2047 sqlite3_result_error(context,"first argument should be one of: " | 2053 sqlite3_result_error(context,"first argument should be one of: " |
| 2048 "int int64 string double null value", -1); | 2054 "int int64 string double null value", -1); |
| 2049 } | 2055 } |
| 2050 | 2056 |
| 2051 /* | 2057 /* |
| 2052 ** Usage: sqlite_register_test_function DB NAME | 2058 ** Usage: sqlite_register_test_function DB NAME |
| 2053 ** | 2059 ** |
| 2054 ** Register the test SQL function on the database DB under the name NAME. | 2060 ** Register the test SQL function on the database DB under the name NAME. |
| 2055 */ | 2061 */ |
| 2056 static int test_register_func( | 2062 static int SQLITE_TCLAPI test_register_func( |
| 2057 void *NotUsed, | 2063 void *NotUsed, |
| 2058 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 2064 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 2059 int argc, /* Number of arguments */ | 2065 int argc, /* Number of arguments */ |
| 2060 char **argv /* Text of each argument */ | 2066 char **argv /* Text of each argument */ |
| 2061 ){ | 2067 ){ |
| 2062 sqlite3 *db; | 2068 sqlite3 *db; |
| 2063 int rc; | 2069 int rc; |
| 2064 if( argc!=3 ){ | 2070 if( argc!=3 ){ |
| 2065 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 2071 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 2066 " DB FUNCTION-NAME", 0); | 2072 " DB FUNCTION-NAME", 0); |
| 2067 return TCL_ERROR; | 2073 return TCL_ERROR; |
| 2068 } | 2074 } |
| 2069 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 2075 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
| 2070 rc = sqlite3_create_function(db, argv[2], -1, SQLITE_UTF8, 0, | 2076 rc = sqlite3_create_function(db, argv[2], -1, SQLITE_UTF8, 0, |
| 2071 testFunc, 0, 0); | 2077 testFunc, 0, 0); |
| 2072 if( rc!=0 ){ | 2078 if( rc!=0 ){ |
| 2073 Tcl_AppendResult(interp, sqlite3ErrStr(rc), 0); | 2079 Tcl_AppendResult(interp, sqlite3ErrStr(rc), 0); |
| 2074 return TCL_ERROR; | 2080 return TCL_ERROR; |
| 2075 } | 2081 } |
| 2076 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; | 2082 if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; |
| 2077 return TCL_OK; | 2083 return TCL_OK; |
| 2078 } | 2084 } |
| 2079 | 2085 |
| 2080 /* | 2086 /* |
| 2081 ** Usage: sqlite3_finalize STMT | 2087 ** Usage: sqlite3_finalize STMT |
| 2082 ** | 2088 ** |
| 2083 ** Finalize a statement handle. | 2089 ** Finalize a statement handle. |
| 2084 */ | 2090 */ |
| 2085 static int test_finalize( | 2091 static int SQLITE_TCLAPI test_finalize( |
| 2086 void * clientData, | 2092 void * clientData, |
| 2087 Tcl_Interp *interp, | 2093 Tcl_Interp *interp, |
| 2088 int objc, | 2094 int objc, |
| 2089 Tcl_Obj *CONST objv[] | 2095 Tcl_Obj *CONST objv[] |
| 2090 ){ | 2096 ){ |
| 2091 sqlite3_stmt *pStmt; | 2097 sqlite3_stmt *pStmt; |
| 2092 int rc; | 2098 int rc; |
| 2093 sqlite3 *db = 0; | 2099 sqlite3 *db = 0; |
| 2094 | 2100 |
| 2095 if( objc!=2 ){ | 2101 if( objc!=2 ){ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2107 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); | 2113 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); |
| 2108 if( db && sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; | 2114 if( db && sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; |
| 2109 return TCL_OK; | 2115 return TCL_OK; |
| 2110 } | 2116 } |
| 2111 | 2117 |
| 2112 /* | 2118 /* |
| 2113 ** Usage: sqlite3_stmt_status STMT CODE RESETFLAG | 2119 ** Usage: sqlite3_stmt_status STMT CODE RESETFLAG |
| 2114 ** | 2120 ** |
| 2115 ** Get the value of a status counter from a statement. | 2121 ** Get the value of a status counter from a statement. |
| 2116 */ | 2122 */ |
| 2117 static int test_stmt_status( | 2123 static int SQLITE_TCLAPI test_stmt_status( |
| 2118 void * clientData, | 2124 void * clientData, |
| 2119 Tcl_Interp *interp, | 2125 Tcl_Interp *interp, |
| 2120 int objc, | 2126 int objc, |
| 2121 Tcl_Obj *CONST objv[] | 2127 Tcl_Obj *CONST objv[] |
| 2122 ){ | 2128 ){ |
| 2123 int iValue; | 2129 int iValue; |
| 2124 int i, op = 0, resetFlag; | 2130 int i, op = 0, resetFlag; |
| 2125 const char *zOpName; | 2131 const char *zOpName; |
| 2126 sqlite3_stmt *pStmt; | 2132 sqlite3_stmt *pStmt; |
| 2127 | 2133 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2152 if( Tcl_GetBooleanFromObj(interp, objv[3], &resetFlag) ) return TCL_ERROR; | 2158 if( Tcl_GetBooleanFromObj(interp, objv[3], &resetFlag) ) return TCL_ERROR; |
| 2153 iValue = sqlite3_stmt_status(pStmt, op, resetFlag); | 2159 iValue = sqlite3_stmt_status(pStmt, op, resetFlag); |
| 2154 Tcl_SetObjResult(interp, Tcl_NewIntObj(iValue)); | 2160 Tcl_SetObjResult(interp, Tcl_NewIntObj(iValue)); |
| 2155 return TCL_OK; | 2161 return TCL_OK; |
| 2156 } | 2162 } |
| 2157 | 2163 |
| 2158 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS | 2164 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS |
| 2159 /* | 2165 /* |
| 2160 ** Usage: sqlite3_stmt_scanstatus STMT IDX | 2166 ** Usage: sqlite3_stmt_scanstatus STMT IDX |
| 2161 */ | 2167 */ |
| 2162 static int test_stmt_scanstatus( | 2168 static int SQLITE_TCLAPI test_stmt_scanstatus( |
| 2163 void * clientData, | 2169 void * clientData, |
| 2164 Tcl_Interp *interp, | 2170 Tcl_Interp *interp, |
| 2165 int objc, | 2171 int objc, |
| 2166 Tcl_Obj *CONST objv[] | 2172 Tcl_Obj *CONST objv[] |
| 2167 ){ | 2173 ){ |
| 2168 sqlite3_stmt *pStmt; /* First argument */ | 2174 sqlite3_stmt *pStmt; /* First argument */ |
| 2169 int idx; /* Second argument */ | 2175 int idx; /* Second argument */ |
| 2170 | 2176 |
| 2171 const char *zName; | 2177 const char *zName; |
| 2172 const char *zExplain; | 2178 const char *zExplain; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2202 Tcl_SetObjResult(interp, pRet); | 2208 Tcl_SetObjResult(interp, pRet); |
| 2203 }else{ | 2209 }else{ |
| 2204 Tcl_ResetResult(interp); | 2210 Tcl_ResetResult(interp); |
| 2205 } | 2211 } |
| 2206 return TCL_OK; | 2212 return TCL_OK; |
| 2207 } | 2213 } |
| 2208 | 2214 |
| 2209 /* | 2215 /* |
| 2210 ** Usage: sqlite3_stmt_scanstatus_reset STMT | 2216 ** Usage: sqlite3_stmt_scanstatus_reset STMT |
| 2211 */ | 2217 */ |
| 2212 static int test_stmt_scanstatus_reset( | 2218 static int SQLITE_TCLAPI test_stmt_scanstatus_reset( |
| 2213 void * clientData, | 2219 void * clientData, |
| 2214 Tcl_Interp *interp, | 2220 Tcl_Interp *interp, |
| 2215 int objc, | 2221 int objc, |
| 2216 Tcl_Obj *CONST objv[] | 2222 Tcl_Obj *CONST objv[] |
| 2217 ){ | 2223 ){ |
| 2218 sqlite3_stmt *pStmt; /* First argument */ | 2224 sqlite3_stmt *pStmt; /* First argument */ |
| 2219 if( objc!=2 ){ | 2225 if( objc!=2 ){ |
| 2220 Tcl_WrongNumArgs(interp, 1, objv, "STMT"); | 2226 Tcl_WrongNumArgs(interp, 1, objv, "STMT"); |
| 2221 return TCL_ERROR; | 2227 return TCL_ERROR; |
| 2222 } | 2228 } |
| 2223 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 2229 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 2224 sqlite3_stmt_scanstatus_reset(pStmt); | 2230 sqlite3_stmt_scanstatus_reset(pStmt); |
| 2225 return TCL_OK; | 2231 return TCL_OK; |
| 2226 } | 2232 } |
| 2227 #endif | 2233 #endif |
| 2228 | 2234 |
| 2229 #ifdef SQLITE_ENABLE_SQLLOG | 2235 #ifdef SQLITE_ENABLE_SQLLOG |
| 2230 /* | 2236 /* |
| 2231 ** Usage: sqlite3_config_sqllog | 2237 ** Usage: sqlite3_config_sqllog |
| 2232 ** | 2238 ** |
| 2233 ** Zero the SQLITE_CONFIG_SQLLOG configuration | 2239 ** Zero the SQLITE_CONFIG_SQLLOG configuration |
| 2234 */ | 2240 */ |
| 2235 static int test_config_sqllog( | 2241 static int SQLITE_TCLAPI test_config_sqllog( |
| 2236 void * clientData, | 2242 void * clientData, |
| 2237 Tcl_Interp *interp, | 2243 Tcl_Interp *interp, |
| 2238 int objc, | 2244 int objc, |
| 2239 Tcl_Obj *CONST objv[] | 2245 Tcl_Obj *CONST objv[] |
| 2240 ){ | 2246 ){ |
| 2241 if( objc!=1 ){ | 2247 if( objc!=1 ){ |
| 2242 Tcl_WrongNumArgs(interp, 1, objv, ""); | 2248 Tcl_WrongNumArgs(interp, 1, objv, ""); |
| 2243 return TCL_ERROR; | 2249 return TCL_ERROR; |
| 2244 } | 2250 } |
| 2245 sqlite3_config(SQLITE_CONFIG_SQLLOG, 0, 0); | 2251 sqlite3_config(SQLITE_CONFIG_SQLLOG, 0, 0); |
| 2246 return TCL_OK; | 2252 return TCL_OK; |
| 2247 } | 2253 } |
| 2248 #endif | 2254 #endif |
| 2249 | 2255 |
| 2250 /* | 2256 /* |
| 2251 ** Usage: vfs_current_time_int64 | 2257 ** Usage: vfs_current_time_int64 |
| 2252 ** | 2258 ** |
| 2253 ** Return the value returned by the default VFS's xCurrentTimeInt64 method. | 2259 ** Return the value returned by the default VFS's xCurrentTimeInt64 method. |
| 2254 */ | 2260 */ |
| 2255 static int vfsCurrentTimeInt64( | 2261 static int SQLITE_TCLAPI vfsCurrentTimeInt64( |
| 2256 void * clientData, | 2262 void * clientData, |
| 2257 Tcl_Interp *interp, | 2263 Tcl_Interp *interp, |
| 2258 int objc, | 2264 int objc, |
| 2259 Tcl_Obj *CONST objv[] | 2265 Tcl_Obj *CONST objv[] |
| 2260 ){ | 2266 ){ |
| 2261 i64 t; | 2267 i64 t; |
| 2262 sqlite3_vfs *pVfs = sqlite3_vfs_find(0); | 2268 sqlite3_vfs *pVfs = sqlite3_vfs_find(0); |
| 2263 if( objc!=1 ){ | 2269 if( objc!=1 ){ |
| 2264 Tcl_WrongNumArgs(interp, 1, objv, ""); | 2270 Tcl_WrongNumArgs(interp, 1, objv, ""); |
| 2265 return TCL_ERROR; | 2271 return TCL_ERROR; |
| 2266 } | 2272 } |
| 2267 pVfs->xCurrentTimeInt64(pVfs, &t); | 2273 pVfs->xCurrentTimeInt64(pVfs, &t); |
| 2268 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(t)); | 2274 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(t)); |
| 2269 return TCL_OK; | 2275 return TCL_OK; |
| 2270 } | 2276 } |
| 2271 | 2277 |
| 2272 #ifdef SQLITE_ENABLE_SNAPSHOT | 2278 #ifdef SQLITE_ENABLE_SNAPSHOT |
| 2273 /* | 2279 /* |
| 2274 ** Usage: sqlite3_snapshot_get DB DBNAME | 2280 ** Usage: sqlite3_snapshot_get DB DBNAME |
| 2275 */ | 2281 */ |
| 2276 static int test_snapshot_get( | 2282 static int SQLITE_TCLAPI test_snapshot_get( |
| 2277 void * clientData, | 2283 void * clientData, |
| 2278 Tcl_Interp *interp, | 2284 Tcl_Interp *interp, |
| 2279 int objc, | 2285 int objc, |
| 2280 Tcl_Obj *CONST objv[] | 2286 Tcl_Obj *CONST objv[] |
| 2281 ){ | 2287 ){ |
| 2282 int rc; | 2288 int rc; |
| 2283 sqlite3 *db; | 2289 sqlite3 *db; |
| 2284 char *zName; | 2290 char *zName; |
| 2285 sqlite3_snapshot *pSnapshot = 0; | 2291 sqlite3_snapshot *pSnapshot = 0; |
| 2286 | 2292 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2299 char zBuf[100]; | 2305 char zBuf[100]; |
| 2300 if( sqlite3TestMakePointerStr(interp, zBuf, pSnapshot) ) return TCL_ERROR; | 2306 if( sqlite3TestMakePointerStr(interp, zBuf, pSnapshot) ) return TCL_ERROR; |
| 2301 Tcl_SetObjResult(interp, Tcl_NewStringObj(zBuf, -1)); | 2307 Tcl_SetObjResult(interp, Tcl_NewStringObj(zBuf, -1)); |
| 2302 } | 2308 } |
| 2303 return TCL_OK; | 2309 return TCL_OK; |
| 2304 } | 2310 } |
| 2305 #endif /* SQLITE_ENABLE_SNAPSHOT */ | 2311 #endif /* SQLITE_ENABLE_SNAPSHOT */ |
| 2306 | 2312 |
| 2307 #ifdef SQLITE_ENABLE_SNAPSHOT | 2313 #ifdef SQLITE_ENABLE_SNAPSHOT |
| 2308 /* | 2314 /* |
| 2315 ** Usage: sqlite3_snapshot_recover DB DBNAME |
| 2316 */ |
| 2317 static int SQLITE_TCLAPI test_snapshot_recover( |
| 2318 void * clientData, |
| 2319 Tcl_Interp *interp, |
| 2320 int objc, |
| 2321 Tcl_Obj *CONST objv[] |
| 2322 ){ |
| 2323 int rc; |
| 2324 sqlite3 *db; |
| 2325 char *zName; |
| 2326 |
| 2327 if( objc!=3 ){ |
| 2328 Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME"); |
| 2329 return TCL_ERROR; |
| 2330 } |
| 2331 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 2332 zName = Tcl_GetString(objv[2]); |
| 2333 |
| 2334 rc = sqlite3_snapshot_recover(db, zName); |
| 2335 if( rc!=SQLITE_OK ){ |
| 2336 Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); |
| 2337 return TCL_ERROR; |
| 2338 }else{ |
| 2339 Tcl_ResetResult(interp); |
| 2340 } |
| 2341 return TCL_OK; |
| 2342 } |
| 2343 #endif /* SQLITE_ENABLE_SNAPSHOT */ |
| 2344 |
| 2345 #ifdef SQLITE_ENABLE_SNAPSHOT |
| 2346 /* |
| 2309 ** Usage: sqlite3_snapshot_open DB DBNAME SNAPSHOT | 2347 ** Usage: sqlite3_snapshot_open DB DBNAME SNAPSHOT |
| 2310 */ | 2348 */ |
| 2311 static int test_snapshot_open( | 2349 static int SQLITE_TCLAPI test_snapshot_open( |
| 2312 void * clientData, | 2350 void * clientData, |
| 2313 Tcl_Interp *interp, | 2351 Tcl_Interp *interp, |
| 2314 int objc, | 2352 int objc, |
| 2315 Tcl_Obj *CONST objv[] | 2353 Tcl_Obj *CONST objv[] |
| 2316 ){ | 2354 ){ |
| 2317 int rc; | 2355 int rc; |
| 2318 sqlite3 *db; | 2356 sqlite3 *db; |
| 2319 char *zName; | 2357 char *zName; |
| 2320 sqlite3_snapshot *pSnapshot; | 2358 sqlite3_snapshot *pSnapshot; |
| 2321 | 2359 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2333 return TCL_ERROR; | 2371 return TCL_ERROR; |
| 2334 } | 2372 } |
| 2335 return TCL_OK; | 2373 return TCL_OK; |
| 2336 } | 2374 } |
| 2337 #endif /* SQLITE_ENABLE_SNAPSHOT */ | 2375 #endif /* SQLITE_ENABLE_SNAPSHOT */ |
| 2338 | 2376 |
| 2339 #ifdef SQLITE_ENABLE_SNAPSHOT | 2377 #ifdef SQLITE_ENABLE_SNAPSHOT |
| 2340 /* | 2378 /* |
| 2341 ** Usage: sqlite3_snapshot_free SNAPSHOT | 2379 ** Usage: sqlite3_snapshot_free SNAPSHOT |
| 2342 */ | 2380 */ |
| 2343 static int test_snapshot_free( | 2381 static int SQLITE_TCLAPI test_snapshot_free( |
| 2344 void * clientData, | 2382 void * clientData, |
| 2345 Tcl_Interp *interp, | 2383 Tcl_Interp *interp, |
| 2346 int objc, | 2384 int objc, |
| 2347 Tcl_Obj *CONST objv[] | 2385 Tcl_Obj *CONST objv[] |
| 2348 ){ | 2386 ){ |
| 2349 sqlite3_snapshot *pSnapshot; | 2387 sqlite3_snapshot *pSnapshot; |
| 2350 if( objc!=2 ){ | 2388 if( objc!=2 ){ |
| 2351 Tcl_WrongNumArgs(interp, 1, objv, "SNAPSHOT"); | 2389 Tcl_WrongNumArgs(interp, 1, objv, "SNAPSHOT"); |
| 2352 return TCL_ERROR; | 2390 return TCL_ERROR; |
| 2353 } | 2391 } |
| 2354 pSnapshot = (sqlite3_snapshot*)sqlite3TestTextToPtr(Tcl_GetString(objv[1])); | 2392 pSnapshot = (sqlite3_snapshot*)sqlite3TestTextToPtr(Tcl_GetString(objv[1])); |
| 2355 sqlite3_snapshot_free(pSnapshot); | 2393 sqlite3_snapshot_free(pSnapshot); |
| 2356 return TCL_OK; | 2394 return TCL_OK; |
| 2357 } | 2395 } |
| 2358 #endif /* SQLITE_ENABLE_SNAPSHOT */ | 2396 #endif /* SQLITE_ENABLE_SNAPSHOT */ |
| 2359 | 2397 |
| 2398 #ifdef SQLITE_ENABLE_SNAPSHOT |
| 2399 /* |
| 2400 ** Usage: sqlite3_snapshot_cmp SNAPSHOT1 SNAPSHOT2 |
| 2401 */ |
| 2402 static int SQLITE_TCLAPI test_snapshot_cmp( |
| 2403 void * clientData, |
| 2404 Tcl_Interp *interp, |
| 2405 int objc, |
| 2406 Tcl_Obj *CONST objv[] |
| 2407 ){ |
| 2408 int res; |
| 2409 sqlite3_snapshot *p1; |
| 2410 sqlite3_snapshot *p2; |
| 2411 if( objc!=3 ){ |
| 2412 Tcl_WrongNumArgs(interp, 1, objv, "SNAPSHOT1 SNAPSHOT2"); |
| 2413 return TCL_ERROR; |
| 2414 } |
| 2415 p1 = (sqlite3_snapshot*)sqlite3TestTextToPtr(Tcl_GetString(objv[1])); |
| 2416 p2 = (sqlite3_snapshot*)sqlite3TestTextToPtr(Tcl_GetString(objv[2])); |
| 2417 res = sqlite3_snapshot_cmp(p1, p2); |
| 2418 Tcl_SetObjResult(interp, Tcl_NewIntObj(res)); |
| 2419 return TCL_OK; |
| 2420 } |
| 2421 #endif /* SQLITE_ENABLE_SNAPSHOT */ |
| 2422 |
| 2423 #ifdef SQLITE_ENABLE_SNAPSHOT |
| 2424 /* |
| 2425 ** Usage: sqlite3_snapshot_get_blob DB DBNAME |
| 2426 */ |
| 2427 static int SQLITE_TCLAPI test_snapshot_get_blob( |
| 2428 void * clientData, |
| 2429 Tcl_Interp *interp, |
| 2430 int objc, |
| 2431 Tcl_Obj *CONST objv[] |
| 2432 ){ |
| 2433 int rc; |
| 2434 sqlite3 *db; |
| 2435 char *zName; |
| 2436 sqlite3_snapshot *pSnapshot = 0; |
| 2437 |
| 2438 if( objc!=3 ){ |
| 2439 Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME"); |
| 2440 return TCL_ERROR; |
| 2441 } |
| 2442 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 2443 zName = Tcl_GetString(objv[2]); |
| 2444 |
| 2445 rc = sqlite3_snapshot_get(db, zName, &pSnapshot); |
| 2446 if( rc!=SQLITE_OK ){ |
| 2447 Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); |
| 2448 return TCL_ERROR; |
| 2449 }else{ |
| 2450 Tcl_SetObjResult(interp, |
| 2451 Tcl_NewByteArrayObj((unsigned char*)pSnapshot, sizeof(sqlite3_snapshot)) |
| 2452 ); |
| 2453 sqlite3_snapshot_free(pSnapshot); |
| 2454 } |
| 2455 return TCL_OK; |
| 2456 } |
| 2457 #endif /* SQLITE_ENABLE_SNAPSHOT */ |
| 2458 |
| 2459 #ifdef SQLITE_ENABLE_SNAPSHOT |
| 2460 /* |
| 2461 ** Usage: sqlite3_snapshot_open_blob DB DBNAME SNAPSHOT |
| 2462 */ |
| 2463 static int SQLITE_TCLAPI test_snapshot_open_blob( |
| 2464 void * clientData, |
| 2465 Tcl_Interp *interp, |
| 2466 int objc, |
| 2467 Tcl_Obj *CONST objv[] |
| 2468 ){ |
| 2469 int rc; |
| 2470 sqlite3 *db; |
| 2471 char *zName; |
| 2472 unsigned char *pBlob; |
| 2473 int nBlob; |
| 2474 |
| 2475 if( objc!=4 ){ |
| 2476 Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME SNAPSHOT"); |
| 2477 return TCL_ERROR; |
| 2478 } |
| 2479 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 2480 zName = Tcl_GetString(objv[2]); |
| 2481 pBlob = Tcl_GetByteArrayFromObj(objv[3], &nBlob); |
| 2482 if( nBlob!=sizeof(sqlite3_snapshot) ){ |
| 2483 Tcl_AppendResult(interp, "bad SNAPSHOT", 0); |
| 2484 return TCL_ERROR; |
| 2485 } |
| 2486 rc = sqlite3_snapshot_open(db, zName, (sqlite3_snapshot*)pBlob); |
| 2487 if( rc!=SQLITE_OK ){ |
| 2488 Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); |
| 2489 return TCL_ERROR; |
| 2490 } |
| 2491 return TCL_OK; |
| 2492 } |
| 2493 #endif /* SQLITE_ENABLE_SNAPSHOT */ |
| 2494 |
| 2495 #ifdef SQLITE_ENABLE_SNAPSHOT |
| 2496 /* |
| 2497 ** Usage: sqlite3_snapshot_cmp_blob SNAPSHOT1 SNAPSHOT2 |
| 2498 */ |
| 2499 static int SQLITE_TCLAPI test_snapshot_cmp_blob( |
| 2500 void * clientData, |
| 2501 Tcl_Interp *interp, |
| 2502 int objc, |
| 2503 Tcl_Obj *CONST objv[] |
| 2504 ){ |
| 2505 int res; |
| 2506 unsigned char *p1; |
| 2507 unsigned char *p2; |
| 2508 int n1; |
| 2509 int n2; |
| 2510 |
| 2511 if( objc!=3 ){ |
| 2512 Tcl_WrongNumArgs(interp, 1, objv, "SNAPSHOT1 SNAPSHOT2"); |
| 2513 return TCL_ERROR; |
| 2514 } |
| 2515 |
| 2516 p1 = Tcl_GetByteArrayFromObj(objv[1], &n1); |
| 2517 p2 = Tcl_GetByteArrayFromObj(objv[2], &n2); |
| 2518 |
| 2519 if( n1!=sizeof(sqlite3_snapshot) || n1!=n2 ){ |
| 2520 Tcl_AppendResult(interp, "bad SNAPSHOT", 0); |
| 2521 return TCL_ERROR; |
| 2522 } |
| 2523 |
| 2524 res = sqlite3_snapshot_cmp((sqlite3_snapshot*)p1, (sqlite3_snapshot*)p2); |
| 2525 Tcl_SetObjResult(interp, Tcl_NewIntObj(res)); |
| 2526 return TCL_OK; |
| 2527 } |
| 2528 #endif /* SQLITE_ENABLE_SNAPSHOT */ |
| 2529 |
| 2530 /* |
| 2531 ** Usage: sqlite3_delete_database FILENAME |
| 2532 */ |
| 2533 int sqlite3_delete_database(const char*); /* in test_delete.c */ |
| 2534 static int SQLITE_TCLAPI test_delete_database( |
| 2535 void * clientData, |
| 2536 Tcl_Interp *interp, |
| 2537 int objc, |
| 2538 Tcl_Obj *CONST objv[] |
| 2539 ){ |
| 2540 int rc; |
| 2541 const char *zFile; |
| 2542 if( objc!=2 ){ |
| 2543 Tcl_WrongNumArgs(interp, 1, objv, "FILE"); |
| 2544 return TCL_ERROR; |
| 2545 } |
| 2546 zFile = (const char*)Tcl_GetString(objv[1]); |
| 2547 rc = sqlite3_delete_database(zFile); |
| 2548 |
| 2549 Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); |
| 2550 return TCL_OK; |
| 2551 } |
| 2552 |
| 2360 /* | 2553 /* |
| 2361 ** Usage: sqlite3_next_stmt DB STMT | 2554 ** Usage: sqlite3_next_stmt DB STMT |
| 2362 ** | 2555 ** |
| 2363 ** Return the next statment in sequence after STMT. | 2556 ** Return the next statment in sequence after STMT. |
| 2364 */ | 2557 */ |
| 2365 static int test_next_stmt( | 2558 static int SQLITE_TCLAPI test_next_stmt( |
| 2366 void * clientData, | 2559 void * clientData, |
| 2367 Tcl_Interp *interp, | 2560 Tcl_Interp *interp, |
| 2368 int objc, | 2561 int objc, |
| 2369 Tcl_Obj *CONST objv[] | 2562 Tcl_Obj *CONST objv[] |
| 2370 ){ | 2563 ){ |
| 2371 sqlite3_stmt *pStmt; | 2564 sqlite3_stmt *pStmt; |
| 2372 sqlite3 *db = 0; | 2565 sqlite3 *db = 0; |
| 2373 char zBuf[50]; | 2566 char zBuf[50]; |
| 2374 | 2567 |
| 2375 if( objc!=3 ){ | 2568 if( objc!=3 ){ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2387 } | 2580 } |
| 2388 return TCL_OK; | 2581 return TCL_OK; |
| 2389 } | 2582 } |
| 2390 | 2583 |
| 2391 /* | 2584 /* |
| 2392 ** Usage: sqlite3_stmt_readonly STMT | 2585 ** Usage: sqlite3_stmt_readonly STMT |
| 2393 ** | 2586 ** |
| 2394 ** Return true if STMT is a NULL pointer or a pointer to a statement | 2587 ** Return true if STMT is a NULL pointer or a pointer to a statement |
| 2395 ** that is guaranteed to leave the database unmodified. | 2588 ** that is guaranteed to leave the database unmodified. |
| 2396 */ | 2589 */ |
| 2397 static int test_stmt_readonly( | 2590 static int SQLITE_TCLAPI test_stmt_readonly( |
| 2398 void * clientData, | 2591 void * clientData, |
| 2399 Tcl_Interp *interp, | 2592 Tcl_Interp *interp, |
| 2400 int objc, | 2593 int objc, |
| 2401 Tcl_Obj *CONST objv[] | 2594 Tcl_Obj *CONST objv[] |
| 2402 ){ | 2595 ){ |
| 2403 sqlite3_stmt *pStmt; | 2596 sqlite3_stmt *pStmt; |
| 2404 int rc; | 2597 int rc; |
| 2405 | 2598 |
| 2406 if( objc!=2 ){ | 2599 if( objc!=2 ){ |
| 2407 Tcl_AppendResult(interp, "wrong # args: should be \"", | 2600 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 2408 Tcl_GetStringFromObj(objv[0], 0), " STMT", 0); | 2601 Tcl_GetStringFromObj(objv[0], 0), " STMT", 0); |
| 2409 return TCL_ERROR; | 2602 return TCL_ERROR; |
| 2410 } | 2603 } |
| 2411 | 2604 |
| 2412 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 2605 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 2413 rc = sqlite3_stmt_readonly(pStmt); | 2606 rc = sqlite3_stmt_readonly(pStmt); |
| 2414 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(rc)); | 2607 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(rc)); |
| 2415 return TCL_OK; | 2608 return TCL_OK; |
| 2416 } | 2609 } |
| 2417 | 2610 |
| 2418 /* | 2611 /* |
| 2419 ** Usage: sqlite3_stmt_busy STMT | 2612 ** Usage: sqlite3_stmt_busy STMT |
| 2420 ** | 2613 ** |
| 2421 ** Return true if STMT is a non-NULL pointer to a statement | 2614 ** Return true if STMT is a non-NULL pointer to a statement |
| 2422 ** that has been stepped but not to completion. | 2615 ** that has been stepped but not to completion. |
| 2423 */ | 2616 */ |
| 2424 static int test_stmt_busy( | 2617 static int SQLITE_TCLAPI test_stmt_busy( |
| 2425 void * clientData, | 2618 void * clientData, |
| 2426 Tcl_Interp *interp, | 2619 Tcl_Interp *interp, |
| 2427 int objc, | 2620 int objc, |
| 2428 Tcl_Obj *CONST objv[] | 2621 Tcl_Obj *CONST objv[] |
| 2429 ){ | 2622 ){ |
| 2430 sqlite3_stmt *pStmt; | 2623 sqlite3_stmt *pStmt; |
| 2431 int rc; | 2624 int rc; |
| 2432 | 2625 |
| 2433 if( objc!=2 ){ | 2626 if( objc!=2 ){ |
| 2434 Tcl_AppendResult(interp, "wrong # args: should be \"", | 2627 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 2435 Tcl_GetStringFromObj(objv[0], 0), " STMT", 0); | 2628 Tcl_GetStringFromObj(objv[0], 0), " STMT", 0); |
| 2436 return TCL_ERROR; | 2629 return TCL_ERROR; |
| 2437 } | 2630 } |
| 2438 | 2631 |
| 2439 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 2632 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 2440 rc = sqlite3_stmt_busy(pStmt); | 2633 rc = sqlite3_stmt_busy(pStmt); |
| 2441 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(rc)); | 2634 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(rc)); |
| 2442 return TCL_OK; | 2635 return TCL_OK; |
| 2443 } | 2636 } |
| 2444 | 2637 |
| 2445 /* | 2638 /* |
| 2446 ** Usage: uses_stmt_journal STMT | 2639 ** Usage: uses_stmt_journal STMT |
| 2447 ** | 2640 ** |
| 2448 ** Return true if STMT uses a statement journal. | 2641 ** Return true if STMT uses a statement journal. |
| 2449 */ | 2642 */ |
| 2450 static int uses_stmt_journal( | 2643 static int SQLITE_TCLAPI uses_stmt_journal( |
| 2451 void * clientData, | 2644 void * clientData, |
| 2452 Tcl_Interp *interp, | 2645 Tcl_Interp *interp, |
| 2453 int objc, | 2646 int objc, |
| 2454 Tcl_Obj *CONST objv[] | 2647 Tcl_Obj *CONST objv[] |
| 2455 ){ | 2648 ){ |
| 2456 sqlite3_stmt *pStmt; | 2649 sqlite3_stmt *pStmt; |
| 2457 | 2650 |
| 2458 if( objc!=2 ){ | 2651 if( objc!=2 ){ |
| 2459 Tcl_AppendResult(interp, "wrong # args: should be \"", | 2652 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 2460 Tcl_GetStringFromObj(objv[0], 0), " STMT", 0); | 2653 Tcl_GetStringFromObj(objv[0], 0), " STMT", 0); |
| 2461 return TCL_ERROR; | 2654 return TCL_ERROR; |
| 2462 } | 2655 } |
| 2463 | 2656 |
| 2464 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 2657 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 2465 sqlite3_stmt_readonly(pStmt); | 2658 sqlite3_stmt_readonly(pStmt); |
| 2466 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(((Vdbe *)pStmt)->usesStmtJournal)); | 2659 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(((Vdbe *)pStmt)->usesStmtJournal)); |
| 2467 return TCL_OK; | 2660 return TCL_OK; |
| 2468 } | 2661 } |
| 2469 | 2662 |
| 2470 | 2663 |
| 2471 /* | 2664 /* |
| 2472 ** Usage: sqlite3_reset STMT | 2665 ** Usage: sqlite3_reset STMT |
| 2473 ** | 2666 ** |
| 2474 ** Reset a statement handle. | 2667 ** Reset a statement handle. |
| 2475 */ | 2668 */ |
| 2476 static int test_reset( | 2669 static int SQLITE_TCLAPI test_reset( |
| 2477 void * clientData, | 2670 void * clientData, |
| 2478 Tcl_Interp *interp, | 2671 Tcl_Interp *interp, |
| 2479 int objc, | 2672 int objc, |
| 2480 Tcl_Obj *CONST objv[] | 2673 Tcl_Obj *CONST objv[] |
| 2481 ){ | 2674 ){ |
| 2482 sqlite3_stmt *pStmt; | 2675 sqlite3_stmt *pStmt; |
| 2483 int rc; | 2676 int rc; |
| 2484 | 2677 |
| 2485 if( objc!=2 ){ | 2678 if( objc!=2 ){ |
| 2486 Tcl_AppendResult(interp, "wrong # args: should be \"", | 2679 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2501 } | 2694 } |
| 2502 */ | 2695 */ |
| 2503 return TCL_OK; | 2696 return TCL_OK; |
| 2504 } | 2697 } |
| 2505 | 2698 |
| 2506 /* | 2699 /* |
| 2507 ** Usage: sqlite3_expired STMT | 2700 ** Usage: sqlite3_expired STMT |
| 2508 ** | 2701 ** |
| 2509 ** Return TRUE if a recompilation of the statement is recommended. | 2702 ** Return TRUE if a recompilation of the statement is recommended. |
| 2510 */ | 2703 */ |
| 2511 static int test_expired( | 2704 static int SQLITE_TCLAPI test_expired( |
| 2512 void * clientData, | 2705 void * clientData, |
| 2513 Tcl_Interp *interp, | 2706 Tcl_Interp *interp, |
| 2514 int objc, | 2707 int objc, |
| 2515 Tcl_Obj *CONST objv[] | 2708 Tcl_Obj *CONST objv[] |
| 2516 ){ | 2709 ){ |
| 2517 #ifndef SQLITE_OMIT_DEPRECATED | 2710 #ifndef SQLITE_OMIT_DEPRECATED |
| 2518 sqlite3_stmt *pStmt; | 2711 sqlite3_stmt *pStmt; |
| 2519 if( objc!=2 ){ | 2712 if( objc!=2 ){ |
| 2520 Tcl_AppendResult(interp, "wrong # args: should be \"", | 2713 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 2521 Tcl_GetStringFromObj(objv[0], 0), " <STMT>", 0); | 2714 Tcl_GetStringFromObj(objv[0], 0), " <STMT>", 0); |
| 2522 return TCL_ERROR; | 2715 return TCL_ERROR; |
| 2523 } | 2716 } |
| 2524 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 2717 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 2525 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(sqlite3_expired(pStmt))); | 2718 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(sqlite3_expired(pStmt))); |
| 2526 #endif | 2719 #endif |
| 2527 return TCL_OK; | 2720 return TCL_OK; |
| 2528 } | 2721 } |
| 2529 | 2722 |
| 2530 /* | 2723 /* |
| 2531 ** Usage: sqlite3_transfer_bindings FROMSTMT TOSTMT | 2724 ** Usage: sqlite3_transfer_bindings FROMSTMT TOSTMT |
| 2532 ** | 2725 ** |
| 2533 ** Transfer all bindings from FROMSTMT over to TOSTMT | 2726 ** Transfer all bindings from FROMSTMT over to TOSTMT |
| 2534 */ | 2727 */ |
| 2535 static int test_transfer_bind( | 2728 static int SQLITE_TCLAPI test_transfer_bind( |
| 2536 void * clientData, | 2729 void * clientData, |
| 2537 Tcl_Interp *interp, | 2730 Tcl_Interp *interp, |
| 2538 int objc, | 2731 int objc, |
| 2539 Tcl_Obj *CONST objv[] | 2732 Tcl_Obj *CONST objv[] |
| 2540 ){ | 2733 ){ |
| 2541 #ifndef SQLITE_OMIT_DEPRECATED | 2734 #ifndef SQLITE_OMIT_DEPRECATED |
| 2542 sqlite3_stmt *pStmt1, *pStmt2; | 2735 sqlite3_stmt *pStmt1, *pStmt2; |
| 2543 if( objc!=3 ){ | 2736 if( objc!=3 ){ |
| 2544 Tcl_AppendResult(interp, "wrong # args: should be \"", | 2737 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 2545 Tcl_GetStringFromObj(objv[0], 0), " FROM-STMT TO-STMT", 0); | 2738 Tcl_GetStringFromObj(objv[0], 0), " FROM-STMT TO-STMT", 0); |
| 2546 return TCL_ERROR; | 2739 return TCL_ERROR; |
| 2547 } | 2740 } |
| 2548 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt1)) return TCL_ERROR; | 2741 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt1)) return TCL_ERROR; |
| 2549 if( getStmtPointer(interp, Tcl_GetString(objv[2]), &pStmt2)) return TCL_ERROR; | 2742 if( getStmtPointer(interp, Tcl_GetString(objv[2]), &pStmt2)) return TCL_ERROR; |
| 2550 Tcl_SetObjResult(interp, | 2743 Tcl_SetObjResult(interp, |
| 2551 Tcl_NewIntObj(sqlite3_transfer_bindings(pStmt1,pStmt2))); | 2744 Tcl_NewIntObj(sqlite3_transfer_bindings(pStmt1,pStmt2))); |
| 2552 #endif | 2745 #endif |
| 2553 return TCL_OK; | 2746 return TCL_OK; |
| 2554 } | 2747 } |
| 2555 | 2748 |
| 2556 /* | 2749 /* |
| 2557 ** Usage: sqlite3_changes DB | 2750 ** Usage: sqlite3_changes DB |
| 2558 ** | 2751 ** |
| 2559 ** Return the number of changes made to the database by the last SQL | 2752 ** Return the number of changes made to the database by the last SQL |
| 2560 ** execution. | 2753 ** execution. |
| 2561 */ | 2754 */ |
| 2562 static int test_changes( | 2755 static int SQLITE_TCLAPI test_changes( |
| 2563 void * clientData, | 2756 void * clientData, |
| 2564 Tcl_Interp *interp, | 2757 Tcl_Interp *interp, |
| 2565 int objc, | 2758 int objc, |
| 2566 Tcl_Obj *CONST objv[] | 2759 Tcl_Obj *CONST objv[] |
| 2567 ){ | 2760 ){ |
| 2568 sqlite3 *db; | 2761 sqlite3 *db; |
| 2569 if( objc!=2 ){ | 2762 if( objc!=2 ){ |
| 2570 Tcl_AppendResult(interp, "wrong # args: should be \"", | 2763 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 2571 Tcl_GetString(objv[0]), " DB", 0); | 2764 Tcl_GetString(objv[0]), " DB", 0); |
| 2572 return TCL_ERROR; | 2765 return TCL_ERROR; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2587 ** Usage: sqlite3_bind VM IDX VALUE FLAGS | 2780 ** Usage: sqlite3_bind VM IDX VALUE FLAGS |
| 2588 ** | 2781 ** |
| 2589 ** Sets the value of the IDX-th occurrence of "?" in the original SQL | 2782 ** Sets the value of the IDX-th occurrence of "?" in the original SQL |
| 2590 ** string. VALUE is the new value. If FLAGS=="null" then VALUE is | 2783 ** string. VALUE is the new value. If FLAGS=="null" then VALUE is |
| 2591 ** ignored and the value is set to NULL. If FLAGS=="static" then | 2784 ** ignored and the value is set to NULL. If FLAGS=="static" then |
| 2592 ** the value is set to the value of a static variable named | 2785 ** the value is set to the value of a static variable named |
| 2593 ** "sqlite_static_bind_value". If FLAGS=="normal" then a copy | 2786 ** "sqlite_static_bind_value". If FLAGS=="normal" then a copy |
| 2594 ** of the VALUE is made. If FLAGS=="blob10" then a VALUE is ignored | 2787 ** of the VALUE is made. If FLAGS=="blob10" then a VALUE is ignored |
| 2595 ** an a 10-byte blob "abc\000xyz\000pq" is inserted. | 2788 ** an a 10-byte blob "abc\000xyz\000pq" is inserted. |
| 2596 */ | 2789 */ |
| 2597 static int test_bind( | 2790 static int SQLITE_TCLAPI test_bind( |
| 2598 void *NotUsed, | 2791 void *NotUsed, |
| 2599 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 2792 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 2600 int argc, /* Number of arguments */ | 2793 int argc, /* Number of arguments */ |
| 2601 char **argv /* Text of each argument */ | 2794 char **argv /* Text of each argument */ |
| 2602 ){ | 2795 ){ |
| 2603 sqlite3_stmt *pStmt; | 2796 sqlite3_stmt *pStmt; |
| 2604 int rc; | 2797 int rc; |
| 2605 int idx; | 2798 int idx; |
| 2606 if( argc!=5 ){ | 2799 if( argc!=5 ){ |
| 2607 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 2800 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2709 Tcl_NewStringObj((char*)sqlite3_value_text(pVal),n)); | 2902 Tcl_NewStringObj((char*)sqlite3_value_text(pVal),n)); |
| 2710 sqlite3ValueFree(pVal); | 2903 sqlite3ValueFree(pVal); |
| 2711 } | 2904 } |
| 2712 sqlite3EndBenignMalloc(); | 2905 sqlite3EndBenignMalloc(); |
| 2713 | 2906 |
| 2714 Tcl_EvalObjEx(i, pX, 0); | 2907 Tcl_EvalObjEx(i, pX, 0); |
| 2715 Tcl_DecrRefCount(pX); | 2908 Tcl_DecrRefCount(pX); |
| 2716 Tcl_GetIntFromObj(i, Tcl_GetObjResult(i), &res); | 2909 Tcl_GetIntFromObj(i, Tcl_GetObjResult(i), &res); |
| 2717 return res; | 2910 return res; |
| 2718 } | 2911 } |
| 2719 static int test_collate( | 2912 static int SQLITE_TCLAPI test_collate( |
| 2720 void * clientData, | 2913 void * clientData, |
| 2721 Tcl_Interp *interp, | 2914 Tcl_Interp *interp, |
| 2722 int objc, | 2915 int objc, |
| 2723 Tcl_Obj *CONST objv[] | 2916 Tcl_Obj *CONST objv[] |
| 2724 ){ | 2917 ){ |
| 2725 sqlite3 *db; | 2918 sqlite3 *db; |
| 2726 int val; | 2919 int val; |
| 2727 sqlite3_value *pVal; | 2920 sqlite3_value *pVal; |
| 2728 int rc; | 2921 int rc; |
| 2729 | 2922 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2783 static int test_utf16bin_collate_func( | 2976 static int test_utf16bin_collate_func( |
| 2784 void *pCtx, | 2977 void *pCtx, |
| 2785 int nA, const void *zA, | 2978 int nA, const void *zA, |
| 2786 int nB, const void *zB | 2979 int nB, const void *zB |
| 2787 ){ | 2980 ){ |
| 2788 int nCmp = (nA>nB ? nB : nA); | 2981 int nCmp = (nA>nB ? nB : nA); |
| 2789 int res = memcmp(zA, zB, nCmp); | 2982 int res = memcmp(zA, zB, nCmp); |
| 2790 if( res==0 ) res = nA - nB; | 2983 if( res==0 ) res = nA - nB; |
| 2791 return res; | 2984 return res; |
| 2792 } | 2985 } |
| 2793 static int test_utf16bin_collate( | 2986 static int SQLITE_TCLAPI test_utf16bin_collate( |
| 2794 void * clientData, | 2987 void * clientData, |
| 2795 Tcl_Interp *interp, | 2988 Tcl_Interp *interp, |
| 2796 int objc, | 2989 int objc, |
| 2797 Tcl_Obj *CONST objv[] | 2990 Tcl_Obj *CONST objv[] |
| 2798 ){ | 2991 ){ |
| 2799 sqlite3 *db; | 2992 sqlite3 *db; |
| 2800 int rc; | 2993 int rc; |
| 2801 | 2994 |
| 2802 if( objc!=2 ) goto bad_args; | 2995 if( objc!=2 ) goto bad_args; |
| 2803 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 2996 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2840 if( *z ) zNeededCollation[i++] = *z; | 3033 if( *z ) zNeededCollation[i++] = *z; |
| 2841 } | 3034 } |
| 2842 zNeededCollation[i] = 0; | 3035 zNeededCollation[i] = 0; |
| 2843 sqlite3_create_collation( | 3036 sqlite3_create_collation( |
| 2844 db, "test_collate", ENC(db), SQLITE_INT_TO_PTR(enc), test_collate_func); | 3037 db, "test_collate", ENC(db), SQLITE_INT_TO_PTR(enc), test_collate_func); |
| 2845 } | 3038 } |
| 2846 | 3039 |
| 2847 /* | 3040 /* |
| 2848 ** Usage: add_test_collate_needed DB | 3041 ** Usage: add_test_collate_needed DB |
| 2849 */ | 3042 */ |
| 2850 static int test_collate_needed( | 3043 static int SQLITE_TCLAPI test_collate_needed( |
| 2851 void * clientData, | 3044 void * clientData, |
| 2852 Tcl_Interp *interp, | 3045 Tcl_Interp *interp, |
| 2853 int objc, | 3046 int objc, |
| 2854 Tcl_Obj *CONST objv[] | 3047 Tcl_Obj *CONST objv[] |
| 2855 ){ | 3048 ){ |
| 2856 sqlite3 *db; | 3049 sqlite3 *db; |
| 2857 int rc; | 3050 int rc; |
| 2858 | 3051 |
| 2859 if( objc!=2 ) goto bad_args; | 3052 if( objc!=2 ) goto bad_args; |
| 2860 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 3053 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2891 int rc, n; | 3084 int rc, n; |
| 2892 n = nKey1<nKey2 ? nKey1 : nKey2; | 3085 n = nKey1<nKey2 ? nKey1 : nKey2; |
| 2893 if( nKey1>0 && 1==(1&(SQLITE_PTR_TO_INT(pKey1))) ) unaligned_string_counter++; | 3086 if( nKey1>0 && 1==(1&(SQLITE_PTR_TO_INT(pKey1))) ) unaligned_string_counter++; |
| 2894 if( nKey2>0 && 1==(1&(SQLITE_PTR_TO_INT(pKey2))) ) unaligned_string_counter++; | 3087 if( nKey2>0 && 1==(1&(SQLITE_PTR_TO_INT(pKey2))) ) unaligned_string_counter++; |
| 2895 rc = memcmp(pKey1, pKey2, n); | 3088 rc = memcmp(pKey1, pKey2, n); |
| 2896 if( rc==0 ){ | 3089 if( rc==0 ){ |
| 2897 rc = nKey1 - nKey2; | 3090 rc = nKey1 - nKey2; |
| 2898 } | 3091 } |
| 2899 return rc; | 3092 return rc; |
| 2900 } | 3093 } |
| 2901 static int add_alignment_test_collations( | 3094 static int SQLITE_TCLAPI add_alignment_test_collations( |
| 2902 void * clientData, | 3095 void * clientData, |
| 2903 Tcl_Interp *interp, | 3096 Tcl_Interp *interp, |
| 2904 int objc, | 3097 int objc, |
| 2905 Tcl_Obj *CONST objv[] | 3098 Tcl_Obj *CONST objv[] |
| 2906 ){ | 3099 ){ |
| 2907 sqlite3 *db; | 3100 sqlite3 *db; |
| 2908 if( objc>=2 ){ | 3101 if( objc>=2 ){ |
| 2909 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 3102 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 2910 sqlite3_create_collation(db, "utf16_unaligned", SQLITE_UTF16, | 3103 sqlite3_create_collation(db, "utf16_unaligned", SQLITE_UTF16, |
| 2911 0, alignmentCollFunc); | 3104 0, alignmentCollFunc); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3009 SQLITE_UTF8, SQLITE_STATIC); | 3202 SQLITE_UTF8, SQLITE_STATIC); |
| 3010 sqlite3_result_text16(pCtx, sqlite3_value_text16le(pVal), | 3203 sqlite3_result_text16(pCtx, sqlite3_value_text16le(pVal), |
| 3011 -1, SQLITE_TRANSIENT); | 3204 -1, SQLITE_TRANSIENT); |
| 3012 sqlite3_result_text16be(pCtx, sqlite3_value_text16le(pVal), | 3205 sqlite3_result_text16be(pCtx, sqlite3_value_text16le(pVal), |
| 3013 -1, SQLITE_TRANSIENT); | 3206 -1, SQLITE_TRANSIENT); |
| 3014 sqlite3_result_text16le(pCtx, sqlite3_value_text16le(pVal), | 3207 sqlite3_result_text16le(pCtx, sqlite3_value_text16le(pVal), |
| 3015 -1, SQLITE_TRANSIENT); | 3208 -1, SQLITE_TRANSIENT); |
| 3016 sqlite3ValueFree(pVal); | 3209 sqlite3ValueFree(pVal); |
| 3017 } | 3210 } |
| 3018 #endif /* SQLITE_OMIT_UTF16 */ | 3211 #endif /* SQLITE_OMIT_UTF16 */ |
| 3019 static int test_function( | 3212 static int SQLITE_TCLAPI test_function( |
| 3020 void * clientData, | 3213 void * clientData, |
| 3021 Tcl_Interp *interp, | 3214 Tcl_Interp *interp, |
| 3022 int objc, | 3215 int objc, |
| 3023 Tcl_Obj *CONST objv[] | 3216 Tcl_Obj *CONST objv[] |
| 3024 ){ | 3217 ){ |
| 3025 #ifndef SQLITE_OMIT_UTF16 | 3218 #ifndef SQLITE_OMIT_UTF16 |
| 3026 sqlite3 *db; | 3219 sqlite3 *db; |
| 3027 int val; | 3220 int val; |
| 3028 | 3221 |
| 3029 if( objc!=5 ) goto bad_args; | 3222 if( objc!=5 ) goto bad_args; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3054 } | 3247 } |
| 3055 | 3248 |
| 3056 /* | 3249 /* |
| 3057 ** Usage: sqlite3_test_errstr <err code> | 3250 ** Usage: sqlite3_test_errstr <err code> |
| 3058 ** | 3251 ** |
| 3059 ** Test that the english language string equivalents for sqlite error codes | 3252 ** Test that the english language string equivalents for sqlite error codes |
| 3060 ** are sane. The parameter is an integer representing an sqlite error code. | 3253 ** are sane. The parameter is an integer representing an sqlite error code. |
| 3061 ** The result is a list of two elements, the string representation of the | 3254 ** The result is a list of two elements, the string representation of the |
| 3062 ** error code and the english language explanation. | 3255 ** error code and the english language explanation. |
| 3063 */ | 3256 */ |
| 3064 static int test_errstr( | 3257 static int SQLITE_TCLAPI test_errstr( |
| 3065 void * clientData, | 3258 void * clientData, |
| 3066 Tcl_Interp *interp, | 3259 Tcl_Interp *interp, |
| 3067 int objc, | 3260 int objc, |
| 3068 Tcl_Obj *CONST objv[] | 3261 Tcl_Obj *CONST objv[] |
| 3069 ){ | 3262 ){ |
| 3070 char *zCode; | 3263 char *zCode; |
| 3071 int i; | 3264 int i; |
| 3072 if( objc!=1 ){ | 3265 if( objc!=1 ){ |
| 3073 Tcl_WrongNumArgs(interp, 1, objv, "<error code>"); | 3266 Tcl_WrongNumArgs(interp, 1, objv, "<error code>"); |
| 3074 } | 3267 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3087 ** This routine exists for one purpose - to provide a place to put a | 3280 ** This routine exists for one purpose - to provide a place to put a |
| 3088 ** breakpoint with GDB that can be triggered using TCL code. The use | 3281 ** breakpoint with GDB that can be triggered using TCL code. The use |
| 3089 ** for this is when a particular test fails on (say) the 1485th iteration. | 3282 ** for this is when a particular test fails on (say) the 1485th iteration. |
| 3090 ** In the TCL test script, we can add code like this: | 3283 ** In the TCL test script, we can add code like this: |
| 3091 ** | 3284 ** |
| 3092 ** if {$i==1485} breakpoint | 3285 ** if {$i==1485} breakpoint |
| 3093 ** | 3286 ** |
| 3094 ** Then run testfixture in the debugger and wait for the breakpoint to | 3287 ** Then run testfixture in the debugger and wait for the breakpoint to |
| 3095 ** fire. Then additional breakpoints can be set to trace down the bug. | 3288 ** fire. Then additional breakpoints can be set to trace down the bug. |
| 3096 */ | 3289 */ |
| 3097 static int test_breakpoint( | 3290 static int SQLITE_TCLAPI test_breakpoint( |
| 3098 void *NotUsed, | 3291 void *NotUsed, |
| 3099 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 3292 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 3100 int argc, /* Number of arguments */ | 3293 int argc, /* Number of arguments */ |
| 3101 char **argv /* Text of each argument */ | 3294 char **argv /* Text of each argument */ |
| 3102 ){ | 3295 ){ |
| 3103 return TCL_OK; /* Do nothing */ | 3296 return TCL_OK; /* Do nothing */ |
| 3104 } | 3297 } |
| 3105 | 3298 |
| 3106 /* | 3299 /* |
| 3107 ** Usage: sqlite3_bind_zeroblob STMT IDX N | 3300 ** Usage: sqlite3_bind_zeroblob STMT IDX N |
| 3108 ** | 3301 ** |
| 3109 ** Test the sqlite3_bind_zeroblob interface. STMT is a prepared statement. | 3302 ** Test the sqlite3_bind_zeroblob interface. STMT is a prepared statement. |
| 3110 ** IDX is the index of a wildcard in the prepared statement. This command | 3303 ** IDX is the index of a wildcard in the prepared statement. This command |
| 3111 ** binds a N-byte zero-filled BLOB to the wildcard. | 3304 ** binds a N-byte zero-filled BLOB to the wildcard. |
| 3112 */ | 3305 */ |
| 3113 static int test_bind_zeroblob( | 3306 static int SQLITE_TCLAPI test_bind_zeroblob( |
| 3114 void * clientData, | 3307 void * clientData, |
| 3115 Tcl_Interp *interp, | 3308 Tcl_Interp *interp, |
| 3116 int objc, | 3309 int objc, |
| 3117 Tcl_Obj *CONST objv[] | 3310 Tcl_Obj *CONST objv[] |
| 3118 ){ | 3311 ){ |
| 3119 sqlite3_stmt *pStmt; | 3312 sqlite3_stmt *pStmt; |
| 3120 int idx; | 3313 int idx; |
| 3121 int n; | 3314 int n; |
| 3122 int rc; | 3315 int rc; |
| 3123 | 3316 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3139 return TCL_OK; | 3332 return TCL_OK; |
| 3140 } | 3333 } |
| 3141 | 3334 |
| 3142 /* | 3335 /* |
| 3143 ** Usage: sqlite3_bind_zeroblob64 STMT IDX N | 3336 ** Usage: sqlite3_bind_zeroblob64 STMT IDX N |
| 3144 ** | 3337 ** |
| 3145 ** Test the sqlite3_bind_zeroblob64 interface. STMT is a prepared statement. | 3338 ** Test the sqlite3_bind_zeroblob64 interface. STMT is a prepared statement. |
| 3146 ** IDX is the index of a wildcard in the prepared statement. This command | 3339 ** IDX is the index of a wildcard in the prepared statement. This command |
| 3147 ** binds a N-byte zero-filled BLOB to the wildcard. | 3340 ** binds a N-byte zero-filled BLOB to the wildcard. |
| 3148 */ | 3341 */ |
| 3149 static int test_bind_zeroblob64( | 3342 static int SQLITE_TCLAPI test_bind_zeroblob64( |
| 3150 void * clientData, | 3343 void * clientData, |
| 3151 Tcl_Interp *interp, | 3344 Tcl_Interp *interp, |
| 3152 int objc, | 3345 int objc, |
| 3153 Tcl_Obj *CONST objv[] | 3346 Tcl_Obj *CONST objv[] |
| 3154 ){ | 3347 ){ |
| 3155 sqlite3_stmt *pStmt; | 3348 sqlite3_stmt *pStmt; |
| 3156 int idx; | 3349 int idx; |
| 3157 i64 n; | 3350 Tcl_WideInt n; |
| 3158 int rc; | 3351 int rc; |
| 3159 | 3352 |
| 3160 if( objc!=4 ){ | 3353 if( objc!=4 ){ |
| 3161 Tcl_WrongNumArgs(interp, 1, objv, "STMT IDX N"); | 3354 Tcl_WrongNumArgs(interp, 1, objv, "STMT IDX N"); |
| 3162 return TCL_ERROR; | 3355 return TCL_ERROR; |
| 3163 } | 3356 } |
| 3164 | 3357 |
| 3165 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 3358 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 3166 if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; | 3359 if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; |
| 3167 if( Tcl_GetWideIntFromObj(interp, objv[3], &n) ) return TCL_ERROR; | 3360 if( Tcl_GetWideIntFromObj(interp, objv[3], &n) ) return TCL_ERROR; |
| 3168 | 3361 |
| 3169 rc = sqlite3_bind_zeroblob64(pStmt, idx, n); | 3362 rc = sqlite3_bind_zeroblob64(pStmt, idx, n); |
| 3170 if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; | 3363 if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; |
| 3171 if( rc!=SQLITE_OK ){ | 3364 if( rc!=SQLITE_OK ){ |
| 3172 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); | 3365 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); |
| 3173 return TCL_ERROR; | 3366 return TCL_ERROR; |
| 3174 } | 3367 } |
| 3175 | 3368 |
| 3176 return TCL_OK; | 3369 return TCL_OK; |
| 3177 } | 3370 } |
| 3178 | 3371 |
| 3179 /* | 3372 /* |
| 3180 ** Usage: sqlite3_bind_int STMT N VALUE | 3373 ** Usage: sqlite3_bind_int STMT N VALUE |
| 3181 ** | 3374 ** |
| 3182 ** Test the sqlite3_bind_int interface. STMT is a prepared statement. | 3375 ** Test the sqlite3_bind_int interface. STMT is a prepared statement. |
| 3183 ** N is the index of a wildcard in the prepared statement. This command | 3376 ** N is the index of a wildcard in the prepared statement. This command |
| 3184 ** binds a 32-bit integer VALUE to that wildcard. | 3377 ** binds a 32-bit integer VALUE to that wildcard. |
| 3185 */ | 3378 */ |
| 3186 static int test_bind_int( | 3379 static int SQLITE_TCLAPI test_bind_int( |
| 3187 void * clientData, | 3380 void * clientData, |
| 3188 Tcl_Interp *interp, | 3381 Tcl_Interp *interp, |
| 3189 int objc, | 3382 int objc, |
| 3190 Tcl_Obj *CONST objv[] | 3383 Tcl_Obj *CONST objv[] |
| 3191 ){ | 3384 ){ |
| 3192 sqlite3_stmt *pStmt; | 3385 sqlite3_stmt *pStmt; |
| 3193 int idx; | 3386 int idx; |
| 3194 int value; | 3387 int value; |
| 3195 int rc; | 3388 int rc; |
| 3196 | 3389 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3208 if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; | 3401 if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; |
| 3209 if( rc!=SQLITE_OK ){ | 3402 if( rc!=SQLITE_OK ){ |
| 3210 return TCL_ERROR; | 3403 return TCL_ERROR; |
| 3211 } | 3404 } |
| 3212 | 3405 |
| 3213 return TCL_OK; | 3406 return TCL_OK; |
| 3214 } | 3407 } |
| 3215 | 3408 |
| 3216 | 3409 |
| 3217 /* | 3410 /* |
| 3411 ** Usage: intarray_addr INT ... |
| 3412 ** |
| 3413 ** Return the address of a C-language array of 32-bit integers. |
| 3414 ** |
| 3415 ** Space to hold the array is obtained from malloc(). Call this procedure once |
| 3416 ** with no arguments in order to release memory. Each call to this procedure |
| 3417 ** overwrites the previous array. |
| 3418 */ |
| 3419 static int SQLITE_TCLAPI test_intarray_addr( |
| 3420 void * clientData, |
| 3421 Tcl_Interp *interp, |
| 3422 int objc, |
| 3423 Tcl_Obj *CONST objv[] |
| 3424 ){ |
| 3425 int i; |
| 3426 static int *p = 0; |
| 3427 |
| 3428 sqlite3_free(p); |
| 3429 p = 0; |
| 3430 if( objc>1 ){ |
| 3431 p = sqlite3_malloc( sizeof(p[0])*(objc-1) ); |
| 3432 if( p==0 ) return TCL_ERROR; |
| 3433 for(i=0; i<objc-1; i++){ |
| 3434 if( Tcl_GetIntFromObj(interp, objv[1+i], &p[i]) ){ |
| 3435 sqlite3_free(p); |
| 3436 p = 0; |
| 3437 return TCL_ERROR; |
| 3438 } |
| 3439 } |
| 3440 } |
| 3441 Tcl_SetObjResult(interp, Tcl_NewWideIntObj((sqlite3_int64)p)); |
| 3442 return TCL_OK; |
| 3443 } |
| 3444 /* |
| 3445 ** Usage: intarray_addr INT ... |
| 3446 ** |
| 3447 ** Return the address of a C-language array of 32-bit integers. |
| 3448 ** |
| 3449 ** Space to hold the array is obtained from malloc(). Call this procedure once |
| 3450 ** with no arguments in order to release memory. Each call to this procedure |
| 3451 ** overwrites the previous array. |
| 3452 */ |
| 3453 static int SQLITE_TCLAPI test_int64array_addr( |
| 3454 void * clientData, |
| 3455 Tcl_Interp *interp, |
| 3456 int objc, |
| 3457 Tcl_Obj *CONST objv[] |
| 3458 ){ |
| 3459 int i; |
| 3460 static sqlite3_int64 *p = 0; |
| 3461 |
| 3462 sqlite3_free(p); |
| 3463 p = 0; |
| 3464 if( objc>1 ){ |
| 3465 p = sqlite3_malloc( sizeof(p[0])*(objc-1) ); |
| 3466 if( p==0 ) return TCL_ERROR; |
| 3467 for(i=0; i<objc-1; i++){ |
| 3468 Tcl_WideInt v; |
| 3469 if( Tcl_GetWideIntFromObj(interp, objv[1+i], &v) ){ |
| 3470 sqlite3_free(p); |
| 3471 p = 0; |
| 3472 return TCL_ERROR; |
| 3473 } |
| 3474 p[i] = v; |
| 3475 } |
| 3476 } |
| 3477 Tcl_SetObjResult(interp, Tcl_NewWideIntObj((sqlite3_int64)p)); |
| 3478 return TCL_OK; |
| 3479 } |
| 3480 /* |
| 3481 ** Usage: doublearray_addr INT ... |
| 3482 ** |
| 3483 ** Return the address of a C-language array of doubles. |
| 3484 ** |
| 3485 ** Space to hold the array is obtained from malloc(). Call this procedure once |
| 3486 ** with no arguments in order to release memory. Each call to this procedure |
| 3487 ** overwrites the previous array. |
| 3488 */ |
| 3489 static int SQLITE_TCLAPI test_doublearray_addr( |
| 3490 void * clientData, |
| 3491 Tcl_Interp *interp, |
| 3492 int objc, |
| 3493 Tcl_Obj *CONST objv[] |
| 3494 ){ |
| 3495 int i; |
| 3496 static double *p = 0; |
| 3497 |
| 3498 sqlite3_free(p); |
| 3499 p = 0; |
| 3500 if( objc>1 ){ |
| 3501 p = sqlite3_malloc( sizeof(p[0])*(objc-1) ); |
| 3502 if( p==0 ) return TCL_ERROR; |
| 3503 for(i=0; i<objc-1; i++){ |
| 3504 if( Tcl_GetDoubleFromObj(interp, objv[1+i], &p[i]) ){ |
| 3505 sqlite3_free(p); |
| 3506 p = 0; |
| 3507 return TCL_ERROR; |
| 3508 } |
| 3509 } |
| 3510 } |
| 3511 Tcl_SetObjResult(interp, Tcl_NewWideIntObj((sqlite3_int64)p)); |
| 3512 return TCL_OK; |
| 3513 } |
| 3514 /* |
| 3515 ** Usage: textarray_addr TEXT ... |
| 3516 ** |
| 3517 ** Return the address of a C-language array of strings. |
| 3518 ** |
| 3519 ** Space to hold the array is obtained from malloc(). Call this procedure once |
| 3520 ** with no arguments in order to release memory. Each call to this procedure |
| 3521 ** overwrites the previous array. |
| 3522 */ |
| 3523 static int SQLITE_TCLAPI test_textarray_addr( |
| 3524 void * clientData, |
| 3525 Tcl_Interp *interp, |
| 3526 int objc, |
| 3527 Tcl_Obj *CONST objv[] |
| 3528 ){ |
| 3529 int i; |
| 3530 static int n = 0; |
| 3531 static char **p = 0; |
| 3532 |
| 3533 for(i=0; i<n; i++) sqlite3_free(p[i]); |
| 3534 sqlite3_free(p); |
| 3535 p = 0; |
| 3536 if( objc>1 ){ |
| 3537 p = sqlite3_malloc( sizeof(p[0])*(objc-1) ); |
| 3538 if( p==0 ) return TCL_ERROR; |
| 3539 for(i=0; i<objc-1; i++){ |
| 3540 p[i] = sqlite3_mprintf("%s", Tcl_GetString(objv[1+i])); |
| 3541 } |
| 3542 } |
| 3543 n = objc-1; |
| 3544 Tcl_SetObjResult(interp, Tcl_NewWideIntObj((sqlite3_int64)p)); |
| 3545 return TCL_OK; |
| 3546 } |
| 3547 |
| 3548 |
| 3549 /* |
| 3218 ** Usage: sqlite3_bind_int64 STMT N VALUE | 3550 ** Usage: sqlite3_bind_int64 STMT N VALUE |
| 3219 ** | 3551 ** |
| 3220 ** Test the sqlite3_bind_int64 interface. STMT is a prepared statement. | 3552 ** Test the sqlite3_bind_int64 interface. STMT is a prepared statement. |
| 3221 ** N is the index of a wildcard in the prepared statement. This command | 3553 ** N is the index of a wildcard in the prepared statement. This command |
| 3222 ** binds a 64-bit integer VALUE to that wildcard. | 3554 ** binds a 64-bit integer VALUE to that wildcard. |
| 3223 */ | 3555 */ |
| 3224 static int test_bind_int64( | 3556 static int SQLITE_TCLAPI test_bind_int64( |
| 3225 void * clientData, | 3557 void * clientData, |
| 3226 Tcl_Interp *interp, | 3558 Tcl_Interp *interp, |
| 3227 int objc, | 3559 int objc, |
| 3228 Tcl_Obj *CONST objv[] | 3560 Tcl_Obj *CONST objv[] |
| 3229 ){ | 3561 ){ |
| 3230 sqlite3_stmt *pStmt; | 3562 sqlite3_stmt *pStmt; |
| 3231 int idx; | 3563 int idx; |
| 3232 Tcl_WideInt value; | 3564 Tcl_WideInt value; |
| 3233 int rc; | 3565 int rc; |
| 3234 | 3566 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3252 } | 3584 } |
| 3253 | 3585 |
| 3254 | 3586 |
| 3255 /* | 3587 /* |
| 3256 ** Usage: sqlite3_bind_double STMT N VALUE | 3588 ** Usage: sqlite3_bind_double STMT N VALUE |
| 3257 ** | 3589 ** |
| 3258 ** Test the sqlite3_bind_double interface. STMT is a prepared statement. | 3590 ** Test the sqlite3_bind_double interface. STMT is a prepared statement. |
| 3259 ** N is the index of a wildcard in the prepared statement. This command | 3591 ** N is the index of a wildcard in the prepared statement. This command |
| 3260 ** binds a 64-bit integer VALUE to that wildcard. | 3592 ** binds a 64-bit integer VALUE to that wildcard. |
| 3261 */ | 3593 */ |
| 3262 static int test_bind_double( | 3594 static int SQLITE_TCLAPI test_bind_double( |
| 3263 void * clientData, | 3595 void * clientData, |
| 3264 Tcl_Interp *interp, | 3596 Tcl_Interp *interp, |
| 3265 int objc, | 3597 int objc, |
| 3266 Tcl_Obj *CONST objv[] | 3598 Tcl_Obj *CONST objv[] |
| 3267 ){ | 3599 ){ |
| 3268 sqlite3_stmt *pStmt; | 3600 sqlite3_stmt *pStmt; |
| 3269 int idx; | 3601 int idx; |
| 3270 double value = 0; | 3602 double value = 0; |
| 3271 int rc; | 3603 int rc; |
| 3272 const char *zVal; | 3604 const char *zVal; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3328 return TCL_OK; | 3660 return TCL_OK; |
| 3329 } | 3661 } |
| 3330 | 3662 |
| 3331 /* | 3663 /* |
| 3332 ** Usage: sqlite3_bind_null STMT N | 3664 ** Usage: sqlite3_bind_null STMT N |
| 3333 ** | 3665 ** |
| 3334 ** Test the sqlite3_bind_null interface. STMT is a prepared statement. | 3666 ** Test the sqlite3_bind_null interface. STMT is a prepared statement. |
| 3335 ** N is the index of a wildcard in the prepared statement. This command | 3667 ** N is the index of a wildcard in the prepared statement. This command |
| 3336 ** binds a NULL to the wildcard. | 3668 ** binds a NULL to the wildcard. |
| 3337 */ | 3669 */ |
| 3338 static int test_bind_null( | 3670 static int SQLITE_TCLAPI test_bind_null( |
| 3339 void * clientData, | 3671 void * clientData, |
| 3340 Tcl_Interp *interp, | 3672 Tcl_Interp *interp, |
| 3341 int objc, | 3673 int objc, |
| 3342 Tcl_Obj *CONST objv[] | 3674 Tcl_Obj *CONST objv[] |
| 3343 ){ | 3675 ){ |
| 3344 sqlite3_stmt *pStmt; | 3676 sqlite3_stmt *pStmt; |
| 3345 int idx; | 3677 int idx; |
| 3346 int rc; | 3678 int rc; |
| 3347 | 3679 |
| 3348 if( objc!=3 ){ | 3680 if( objc!=3 ){ |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3364 } | 3696 } |
| 3365 | 3697 |
| 3366 /* | 3698 /* |
| 3367 ** Usage: sqlite3_bind_text STMT N STRING BYTES | 3699 ** Usage: sqlite3_bind_text STMT N STRING BYTES |
| 3368 ** | 3700 ** |
| 3369 ** Test the sqlite3_bind_text interface. STMT is a prepared statement. | 3701 ** Test the sqlite3_bind_text interface. STMT is a prepared statement. |
| 3370 ** N is the index of a wildcard in the prepared statement. This command | 3702 ** N is the index of a wildcard in the prepared statement. This command |
| 3371 ** binds a UTF-8 string STRING to the wildcard. The string is BYTES bytes | 3703 ** binds a UTF-8 string STRING to the wildcard. The string is BYTES bytes |
| 3372 ** long. | 3704 ** long. |
| 3373 */ | 3705 */ |
| 3374 static int test_bind_text( | 3706 static int SQLITE_TCLAPI test_bind_text( |
| 3375 void * clientData, | 3707 void * clientData, |
| 3376 Tcl_Interp *interp, | 3708 Tcl_Interp *interp, |
| 3377 int objc, | 3709 int objc, |
| 3378 Tcl_Obj *CONST objv[] | 3710 Tcl_Obj *CONST objv[] |
| 3379 ){ | 3711 ){ |
| 3380 sqlite3_stmt *pStmt; | 3712 sqlite3_stmt *pStmt; |
| 3381 int idx; | 3713 int idx; |
| 3382 int bytes; | 3714 int bytes; |
| 3383 char *value; | 3715 char *value; |
| 3384 int rc; | 3716 int rc; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3405 } | 3737 } |
| 3406 | 3738 |
| 3407 /* | 3739 /* |
| 3408 ** Usage: sqlite3_bind_text16 ?-static? STMT N STRING BYTES | 3740 ** Usage: sqlite3_bind_text16 ?-static? STMT N STRING BYTES |
| 3409 ** | 3741 ** |
| 3410 ** Test the sqlite3_bind_text16 interface. STMT is a prepared statement. | 3742 ** Test the sqlite3_bind_text16 interface. STMT is a prepared statement. |
| 3411 ** N is the index of a wildcard in the prepared statement. This command | 3743 ** N is the index of a wildcard in the prepared statement. This command |
| 3412 ** binds a UTF-16 string STRING to the wildcard. The string is BYTES bytes | 3744 ** binds a UTF-16 string STRING to the wildcard. The string is BYTES bytes |
| 3413 ** long. | 3745 ** long. |
| 3414 */ | 3746 */ |
| 3415 static int test_bind_text16( | 3747 static int SQLITE_TCLAPI test_bind_text16( |
| 3416 void * clientData, | 3748 void * clientData, |
| 3417 Tcl_Interp *interp, | 3749 Tcl_Interp *interp, |
| 3418 int objc, | 3750 int objc, |
| 3419 Tcl_Obj *CONST objv[] | 3751 Tcl_Obj *CONST objv[] |
| 3420 ){ | 3752 ){ |
| 3421 #ifndef SQLITE_OMIT_UTF16 | 3753 #ifndef SQLITE_OMIT_UTF16 |
| 3422 sqlite3_stmt *pStmt; | 3754 sqlite3_stmt *pStmt; |
| 3423 int idx; | 3755 int idx; |
| 3424 int bytes; | 3756 int bytes; |
| 3425 char *value; | 3757 char *value; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3453 return TCL_OK; | 3785 return TCL_OK; |
| 3454 } | 3786 } |
| 3455 | 3787 |
| 3456 /* | 3788 /* |
| 3457 ** Usage: sqlite3_bind_blob ?-static? STMT N DATA BYTES | 3789 ** Usage: sqlite3_bind_blob ?-static? STMT N DATA BYTES |
| 3458 ** | 3790 ** |
| 3459 ** Test the sqlite3_bind_blob interface. STMT is a prepared statement. | 3791 ** Test the sqlite3_bind_blob interface. STMT is a prepared statement. |
| 3460 ** N is the index of a wildcard in the prepared statement. This command | 3792 ** N is the index of a wildcard in the prepared statement. This command |
| 3461 ** binds a BLOB to the wildcard. The BLOB is BYTES bytes in size. | 3793 ** binds a BLOB to the wildcard. The BLOB is BYTES bytes in size. |
| 3462 */ | 3794 */ |
| 3463 static int test_bind_blob( | 3795 static int SQLITE_TCLAPI test_bind_blob( |
| 3464 void * clientData, | 3796 void * clientData, |
| 3465 Tcl_Interp *interp, | 3797 Tcl_Interp *interp, |
| 3466 int objc, | 3798 int objc, |
| 3467 Tcl_Obj *CONST objv[] | 3799 Tcl_Obj *CONST objv[] |
| 3468 ){ | 3800 ){ |
| 3469 sqlite3_stmt *pStmt; | 3801 sqlite3_stmt *pStmt; |
| 3470 int idx; | 3802 int len, idx; |
| 3471 int bytes; | 3803 int bytes; |
| 3472 char *value; | 3804 char *value; |
| 3473 int rc; | 3805 int rc; |
| 3474 sqlite3_destructor_type xDestructor = SQLITE_TRANSIENT; | 3806 sqlite3_destructor_type xDestructor = SQLITE_TRANSIENT; |
| 3475 | 3807 |
| 3476 if( objc!=5 && objc!=6 ){ | 3808 if( objc!=5 && objc!=6 ){ |
| 3477 Tcl_AppendResult(interp, "wrong # args: should be \"", | 3809 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 3478 Tcl_GetStringFromObj(objv[0], 0), " STMT N DATA BYTES", 0); | 3810 Tcl_GetStringFromObj(objv[0], 0), " STMT N DATA BYTES", 0); |
| 3479 return TCL_ERROR; | 3811 return TCL_ERROR; |
| 3480 } | 3812 } |
| 3481 | 3813 |
| 3482 if( objc==6 ){ | 3814 if( objc==6 ){ |
| 3483 xDestructor = SQLITE_STATIC; | 3815 xDestructor = SQLITE_STATIC; |
| 3484 objv++; | 3816 objv++; |
| 3485 } | 3817 } |
| 3486 | 3818 |
| 3487 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 3819 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 3488 if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; | 3820 if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; |
| 3489 value = Tcl_GetString(objv[3]); | 3821 |
| 3822 value = (char*)Tcl_GetByteArrayFromObj(objv[3], &len); |
| 3490 if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR; | 3823 if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR; |
| 3491 | 3824 |
| 3825 if( bytes>len ){ |
| 3826 char zBuf[200]; |
| 3827 sqlite3_snprintf(sizeof(zBuf), zBuf, |
| 3828 "cannot use %d blob bytes, have %d", bytes, len); |
| 3829 Tcl_AppendResult(interp, zBuf, -1); |
| 3830 return TCL_ERROR; |
| 3831 } |
| 3832 |
| 3492 rc = sqlite3_bind_blob(pStmt, idx, value, bytes, xDestructor); | 3833 rc = sqlite3_bind_blob(pStmt, idx, value, bytes, xDestructor); |
| 3493 if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; | 3834 if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; |
| 3494 if( rc!=SQLITE_OK ){ | 3835 if( rc!=SQLITE_OK ){ |
| 3495 return TCL_ERROR; | 3836 return TCL_ERROR; |
| 3496 } | 3837 } |
| 3497 | 3838 |
| 3498 return TCL_OK; | 3839 return TCL_OK; |
| 3499 } | 3840 } |
| 3500 | 3841 |
| 3501 /* | 3842 /* |
| 3502 ** Usage: sqlite3_bind_parameter_count STMT | 3843 ** Usage: sqlite3_bind_parameter_count STMT |
| 3503 ** | 3844 ** |
| 3504 ** Return the number of wildcards in the given statement. | 3845 ** Return the number of wildcards in the given statement. |
| 3505 */ | 3846 */ |
| 3506 static int test_bind_parameter_count( | 3847 static int SQLITE_TCLAPI test_bind_parameter_count( |
| 3507 void * clientData, | 3848 void * clientData, |
| 3508 Tcl_Interp *interp, | 3849 Tcl_Interp *interp, |
| 3509 int objc, | 3850 int objc, |
| 3510 Tcl_Obj *CONST objv[] | 3851 Tcl_Obj *CONST objv[] |
| 3511 ){ | 3852 ){ |
| 3512 sqlite3_stmt *pStmt; | 3853 sqlite3_stmt *pStmt; |
| 3513 | 3854 |
| 3514 if( objc!=2 ){ | 3855 if( objc!=2 ){ |
| 3515 Tcl_WrongNumArgs(interp, 1, objv, "STMT"); | 3856 Tcl_WrongNumArgs(interp, 1, objv, "STMT"); |
| 3516 return TCL_ERROR; | 3857 return TCL_ERROR; |
| 3517 } | 3858 } |
| 3518 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 3859 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 3519 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_bind_parameter_count(pStmt))); | 3860 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_bind_parameter_count(pStmt))); |
| 3520 return TCL_OK; | 3861 return TCL_OK; |
| 3521 } | 3862 } |
| 3522 | 3863 |
| 3523 /* | 3864 /* |
| 3524 ** Usage: sqlite3_bind_parameter_name STMT N | 3865 ** Usage: sqlite3_bind_parameter_name STMT N |
| 3525 ** | 3866 ** |
| 3526 ** Return the name of the Nth wildcard. The first wildcard is 1. | 3867 ** Return the name of the Nth wildcard. The first wildcard is 1. |
| 3527 ** An empty string is returned if N is out of range or if the wildcard | 3868 ** An empty string is returned if N is out of range or if the wildcard |
| 3528 ** is nameless. | 3869 ** is nameless. |
| 3529 */ | 3870 */ |
| 3530 static int test_bind_parameter_name( | 3871 static int SQLITE_TCLAPI test_bind_parameter_name( |
| 3531 void * clientData, | 3872 void * clientData, |
| 3532 Tcl_Interp *interp, | 3873 Tcl_Interp *interp, |
| 3533 int objc, | 3874 int objc, |
| 3534 Tcl_Obj *CONST objv[] | 3875 Tcl_Obj *CONST objv[] |
| 3535 ){ | 3876 ){ |
| 3536 sqlite3_stmt *pStmt; | 3877 sqlite3_stmt *pStmt; |
| 3537 int i; | 3878 int i; |
| 3538 | 3879 |
| 3539 if( objc!=3 ){ | 3880 if( objc!=3 ){ |
| 3540 Tcl_WrongNumArgs(interp, 1, objv, "STMT N"); | 3881 Tcl_WrongNumArgs(interp, 1, objv, "STMT N"); |
| 3541 return TCL_ERROR; | 3882 return TCL_ERROR; |
| 3542 } | 3883 } |
| 3543 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 3884 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 3544 if( Tcl_GetIntFromObj(interp, objv[2], &i) ) return TCL_ERROR; | 3885 if( Tcl_GetIntFromObj(interp, objv[2], &i) ) return TCL_ERROR; |
| 3545 Tcl_SetObjResult(interp, | 3886 Tcl_SetObjResult(interp, |
| 3546 Tcl_NewStringObj(sqlite3_bind_parameter_name(pStmt,i),-1) | 3887 Tcl_NewStringObj(sqlite3_bind_parameter_name(pStmt,i),-1) |
| 3547 ); | 3888 ); |
| 3548 return TCL_OK; | 3889 return TCL_OK; |
| 3549 } | 3890 } |
| 3550 | 3891 |
| 3551 /* | 3892 /* |
| 3552 ** Usage: sqlite3_bind_parameter_index STMT NAME | 3893 ** Usage: sqlite3_bind_parameter_index STMT NAME |
| 3553 ** | 3894 ** |
| 3554 ** Return the index of the wildcard called NAME. Return 0 if there is | 3895 ** Return the index of the wildcard called NAME. Return 0 if there is |
| 3555 ** no such wildcard. | 3896 ** no such wildcard. |
| 3556 */ | 3897 */ |
| 3557 static int test_bind_parameter_index( | 3898 static int SQLITE_TCLAPI test_bind_parameter_index( |
| 3558 void * clientData, | 3899 void * clientData, |
| 3559 Tcl_Interp *interp, | 3900 Tcl_Interp *interp, |
| 3560 int objc, | 3901 int objc, |
| 3561 Tcl_Obj *CONST objv[] | 3902 Tcl_Obj *CONST objv[] |
| 3562 ){ | 3903 ){ |
| 3563 sqlite3_stmt *pStmt; | 3904 sqlite3_stmt *pStmt; |
| 3564 | 3905 |
| 3565 if( objc!=3 ){ | 3906 if( objc!=3 ){ |
| 3566 Tcl_WrongNumArgs(interp, 1, objv, "STMT NAME"); | 3907 Tcl_WrongNumArgs(interp, 1, objv, "STMT NAME"); |
| 3567 return TCL_ERROR; | 3908 return TCL_ERROR; |
| 3568 } | 3909 } |
| 3569 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 3910 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 3570 Tcl_SetObjResult(interp, | 3911 Tcl_SetObjResult(interp, |
| 3571 Tcl_NewIntObj( | 3912 Tcl_NewIntObj( |
| 3572 sqlite3_bind_parameter_index(pStmt,Tcl_GetString(objv[2])) | 3913 sqlite3_bind_parameter_index(pStmt,Tcl_GetString(objv[2])) |
| 3573 ) | 3914 ) |
| 3574 ); | 3915 ); |
| 3575 return TCL_OK; | 3916 return TCL_OK; |
| 3576 } | 3917 } |
| 3577 | 3918 |
| 3578 /* | 3919 /* |
| 3579 ** Usage: sqlite3_clear_bindings STMT | 3920 ** Usage: sqlite3_clear_bindings STMT |
| 3580 ** | 3921 ** |
| 3581 */ | 3922 */ |
| 3582 static int test_clear_bindings( | 3923 static int SQLITE_TCLAPI test_clear_bindings( |
| 3583 void * clientData, | 3924 void * clientData, |
| 3584 Tcl_Interp *interp, | 3925 Tcl_Interp *interp, |
| 3585 int objc, | 3926 int objc, |
| 3586 Tcl_Obj *CONST objv[] | 3927 Tcl_Obj *CONST objv[] |
| 3587 ){ | 3928 ){ |
| 3588 sqlite3_stmt *pStmt; | 3929 sqlite3_stmt *pStmt; |
| 3589 | 3930 |
| 3590 if( objc!=2 ){ | 3931 if( objc!=2 ){ |
| 3591 Tcl_WrongNumArgs(interp, 1, objv, "STMT"); | 3932 Tcl_WrongNumArgs(interp, 1, objv, "STMT"); |
| 3592 return TCL_ERROR; | 3933 return TCL_ERROR; |
| 3593 } | 3934 } |
| 3594 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 3935 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 3595 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_clear_bindings(pStmt))); | 3936 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_clear_bindings(pStmt))); |
| 3596 return TCL_OK; | 3937 return TCL_OK; |
| 3597 } | 3938 } |
| 3598 | 3939 |
| 3599 /* | 3940 /* |
| 3600 ** Usage: sqlite3_sleep MILLISECONDS | 3941 ** Usage: sqlite3_sleep MILLISECONDS |
| 3601 */ | 3942 */ |
| 3602 static int test_sleep( | 3943 static int SQLITE_TCLAPI test_sleep( |
| 3603 void * clientData, | 3944 void * clientData, |
| 3604 Tcl_Interp *interp, | 3945 Tcl_Interp *interp, |
| 3605 int objc, | 3946 int objc, |
| 3606 Tcl_Obj *CONST objv[] | 3947 Tcl_Obj *CONST objv[] |
| 3607 ){ | 3948 ){ |
| 3608 int ms; | 3949 int ms; |
| 3609 | 3950 |
| 3610 if( objc!=2 ){ | 3951 if( objc!=2 ){ |
| 3611 Tcl_WrongNumArgs(interp, 1, objv, "MILLISECONDS"); | 3952 Tcl_WrongNumArgs(interp, 1, objv, "MILLISECONDS"); |
| 3612 return TCL_ERROR; | 3953 return TCL_ERROR; |
| 3613 } | 3954 } |
| 3614 if( Tcl_GetIntFromObj(interp, objv[1], &ms) ){ | 3955 if( Tcl_GetIntFromObj(interp, objv[1], &ms) ){ |
| 3615 return TCL_ERROR; | 3956 return TCL_ERROR; |
| 3616 } | 3957 } |
| 3617 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_sleep(ms))); | 3958 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_sleep(ms))); |
| 3618 return TCL_OK; | 3959 return TCL_OK; |
| 3619 } | 3960 } |
| 3620 | 3961 |
| 3621 /* | 3962 /* |
| 3622 ** Usage: sqlite3_extended_errcode DB | 3963 ** Usage: sqlite3_extended_errcode DB |
| 3623 ** | 3964 ** |
| 3624 ** Return the string representation of the most recent sqlite3_* API | 3965 ** Return the string representation of the most recent sqlite3_* API |
| 3625 ** error code. e.g. "SQLITE_ERROR". | 3966 ** error code. e.g. "SQLITE_ERROR". |
| 3626 */ | 3967 */ |
| 3627 static int test_ex_errcode( | 3968 static int SQLITE_TCLAPI test_ex_errcode( |
| 3628 void * clientData, | 3969 void * clientData, |
| 3629 Tcl_Interp *interp, | 3970 Tcl_Interp *interp, |
| 3630 int objc, | 3971 int objc, |
| 3631 Tcl_Obj *CONST objv[] | 3972 Tcl_Obj *CONST objv[] |
| 3632 ){ | 3973 ){ |
| 3633 sqlite3 *db; | 3974 sqlite3 *db; |
| 3634 int rc; | 3975 int rc; |
| 3635 | 3976 |
| 3636 if( objc!=2 ){ | 3977 if( objc!=2 ){ |
| 3637 Tcl_AppendResult(interp, "wrong # args: should be \"", | 3978 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 3638 Tcl_GetString(objv[0]), " DB", 0); | 3979 Tcl_GetString(objv[0]), " DB", 0); |
| 3639 return TCL_ERROR; | 3980 return TCL_ERROR; |
| 3640 } | 3981 } |
| 3641 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 3982 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 3642 rc = sqlite3_extended_errcode(db); | 3983 rc = sqlite3_extended_errcode(db); |
| 3643 Tcl_AppendResult(interp, (char *)t1ErrorName(rc), 0); | 3984 Tcl_AppendResult(interp, (char *)t1ErrorName(rc), 0); |
| 3644 return TCL_OK; | 3985 return TCL_OK; |
| 3645 } | 3986 } |
| 3646 | 3987 |
| 3647 | 3988 |
| 3648 /* | 3989 /* |
| 3649 ** Usage: sqlite3_errcode DB | 3990 ** Usage: sqlite3_errcode DB |
| 3650 ** | 3991 ** |
| 3651 ** Return the string representation of the most recent sqlite3_* API | 3992 ** Return the string representation of the most recent sqlite3_* API |
| 3652 ** error code. e.g. "SQLITE_ERROR". | 3993 ** error code. e.g. "SQLITE_ERROR". |
| 3653 */ | 3994 */ |
| 3654 static int test_errcode( | 3995 static int SQLITE_TCLAPI test_errcode( |
| 3655 void * clientData, | 3996 void * clientData, |
| 3656 Tcl_Interp *interp, | 3997 Tcl_Interp *interp, |
| 3657 int objc, | 3998 int objc, |
| 3658 Tcl_Obj *CONST objv[] | 3999 Tcl_Obj *CONST objv[] |
| 3659 ){ | 4000 ){ |
| 3660 sqlite3 *db; | 4001 sqlite3 *db; |
| 3661 int rc; | 4002 int rc; |
| 3662 | 4003 |
| 3663 if( objc!=2 ){ | 4004 if( objc!=2 ){ |
| 3664 Tcl_AppendResult(interp, "wrong # args: should be \"", | 4005 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 3665 Tcl_GetString(objv[0]), " DB", 0); | 4006 Tcl_GetString(objv[0]), " DB", 0); |
| 3666 return TCL_ERROR; | 4007 return TCL_ERROR; |
| 3667 } | 4008 } |
| 3668 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 4009 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 3669 rc = sqlite3_errcode(db); | 4010 rc = sqlite3_errcode(db); |
| 3670 Tcl_AppendResult(interp, (char *)t1ErrorName(rc), 0); | 4011 Tcl_AppendResult(interp, (char *)t1ErrorName(rc), 0); |
| 3671 return TCL_OK; | 4012 return TCL_OK; |
| 3672 } | 4013 } |
| 3673 | 4014 |
| 3674 /* | 4015 /* |
| 3675 ** Usage: sqlite3_errmsg DB | 4016 ** Usage: sqlite3_errmsg DB |
| 3676 ** | 4017 ** |
| 3677 ** Returns the UTF-8 representation of the error message string for the | 4018 ** Returns the UTF-8 representation of the error message string for the |
| 3678 ** most recent sqlite3_* API call. | 4019 ** most recent sqlite3_* API call. |
| 3679 */ | 4020 */ |
| 3680 static int test_errmsg( | 4021 static int SQLITE_TCLAPI test_errmsg( |
| 3681 void * clientData, | 4022 void * clientData, |
| 3682 Tcl_Interp *interp, | 4023 Tcl_Interp *interp, |
| 3683 int objc, | 4024 int objc, |
| 3684 Tcl_Obj *CONST objv[] | 4025 Tcl_Obj *CONST objv[] |
| 3685 ){ | 4026 ){ |
| 3686 sqlite3 *db; | 4027 sqlite3 *db; |
| 3687 const char *zErr; | 4028 const char *zErr; |
| 3688 | 4029 |
| 3689 if( objc!=2 ){ | 4030 if( objc!=2 ){ |
| 3690 Tcl_AppendResult(interp, "wrong # args: should be \"", | 4031 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 3691 Tcl_GetString(objv[0]), " DB", 0); | 4032 Tcl_GetString(objv[0]), " DB", 0); |
| 3692 return TCL_ERROR; | 4033 return TCL_ERROR; |
| 3693 } | 4034 } |
| 3694 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 4035 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 3695 | 4036 |
| 3696 zErr = sqlite3_errmsg(db); | 4037 zErr = sqlite3_errmsg(db); |
| 3697 Tcl_SetObjResult(interp, Tcl_NewStringObj(zErr, -1)); | 4038 Tcl_SetObjResult(interp, Tcl_NewStringObj(zErr, -1)); |
| 3698 return TCL_OK; | 4039 return TCL_OK; |
| 3699 } | 4040 } |
| 3700 | 4041 |
| 3701 /* | 4042 /* |
| 3702 ** Usage: test_errmsg16 DB | 4043 ** Usage: test_errmsg16 DB |
| 3703 ** | 4044 ** |
| 3704 ** Returns the UTF-16 representation of the error message string for the | 4045 ** Returns the UTF-16 representation of the error message string for the |
| 3705 ** most recent sqlite3_* API call. This is a byte array object at the TCL | 4046 ** most recent sqlite3_* API call. This is a byte array object at the TCL |
| 3706 ** level, and it includes the 0x00 0x00 terminator bytes at the end of the | 4047 ** level, and it includes the 0x00 0x00 terminator bytes at the end of the |
| 3707 ** UTF-16 string. | 4048 ** UTF-16 string. |
| 3708 */ | 4049 */ |
| 3709 static int test_errmsg16( | 4050 static int SQLITE_TCLAPI test_errmsg16( |
| 3710 void * clientData, | 4051 void * clientData, |
| 3711 Tcl_Interp *interp, | 4052 Tcl_Interp *interp, |
| 3712 int objc, | 4053 int objc, |
| 3713 Tcl_Obj *CONST objv[] | 4054 Tcl_Obj *CONST objv[] |
| 3714 ){ | 4055 ){ |
| 3715 #ifndef SQLITE_OMIT_UTF16 | 4056 #ifndef SQLITE_OMIT_UTF16 |
| 3716 sqlite3 *db; | 4057 sqlite3 *db; |
| 3717 const void *zErr; | 4058 const void *zErr; |
| 3718 const char *z; | 4059 const char *z; |
| 3719 int bytes = 0; | 4060 int bytes = 0; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3736 } | 4077 } |
| 3737 | 4078 |
| 3738 /* | 4079 /* |
| 3739 ** Usage: sqlite3_prepare DB sql bytes ?tailvar? | 4080 ** Usage: sqlite3_prepare DB sql bytes ?tailvar? |
| 3740 ** | 4081 ** |
| 3741 ** Compile up to <bytes> bytes of the supplied SQL string <sql> using | 4082 ** Compile up to <bytes> bytes of the supplied SQL string <sql> using |
| 3742 ** database handle <DB>. The parameter <tailval> is the name of a global | 4083 ** database handle <DB>. The parameter <tailval> is the name of a global |
| 3743 ** variable that is set to the unused portion of <sql> (if any). A | 4084 ** variable that is set to the unused portion of <sql> (if any). A |
| 3744 ** STMT handle is returned. | 4085 ** STMT handle is returned. |
| 3745 */ | 4086 */ |
| 3746 static int test_prepare( | 4087 static int SQLITE_TCLAPI test_prepare( |
| 3747 void * clientData, | 4088 void * clientData, |
| 3748 Tcl_Interp *interp, | 4089 Tcl_Interp *interp, |
| 3749 int objc, | 4090 int objc, |
| 3750 Tcl_Obj *CONST objv[] | 4091 Tcl_Obj *CONST objv[] |
| 3751 ){ | 4092 ){ |
| 3752 sqlite3 *db; | 4093 sqlite3 *db; |
| 3753 const char *zSql; | 4094 const char *zSql; |
| 3754 int bytes; | 4095 int bytes; |
| 3755 const char *zTail = 0; | 4096 const char *zTail = 0; |
| 3756 sqlite3_stmt *pStmt = 0; | 4097 sqlite3_stmt *pStmt = 0; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3793 } | 4134 } |
| 3794 | 4135 |
| 3795 /* | 4136 /* |
| 3796 ** Usage: sqlite3_prepare_v2 DB sql bytes ?tailvar? | 4137 ** Usage: sqlite3_prepare_v2 DB sql bytes ?tailvar? |
| 3797 ** | 4138 ** |
| 3798 ** Compile up to <bytes> bytes of the supplied SQL string <sql> using | 4139 ** Compile up to <bytes> bytes of the supplied SQL string <sql> using |
| 3799 ** database handle <DB>. The parameter <tailval> is the name of a global | 4140 ** database handle <DB>. The parameter <tailval> is the name of a global |
| 3800 ** variable that is set to the unused portion of <sql> (if any). A | 4141 ** variable that is set to the unused portion of <sql> (if any). A |
| 3801 ** STMT handle is returned. | 4142 ** STMT handle is returned. |
| 3802 */ | 4143 */ |
| 3803 static int test_prepare_v2( | 4144 static int SQLITE_TCLAPI test_prepare_v2( |
| 3804 void * clientData, | 4145 void * clientData, |
| 3805 Tcl_Interp *interp, | 4146 Tcl_Interp *interp, |
| 3806 int objc, | 4147 int objc, |
| 3807 Tcl_Obj *CONST objv[] | 4148 Tcl_Obj *CONST objv[] |
| 3808 ){ | 4149 ){ |
| 3809 sqlite3 *db; | 4150 sqlite3 *db; |
| 3810 const char *zSql; | 4151 const char *zSql; |
| 3811 char *zCopy = 0; /* malloc() copy of zSql */ | 4152 char *zCopy = 0; /* malloc() copy of zSql */ |
| 3812 int bytes; | 4153 int bytes; |
| 3813 const char *zTail = 0; | 4154 const char *zTail = 0; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3861 } | 4202 } |
| 3862 return TCL_OK; | 4203 return TCL_OK; |
| 3863 } | 4204 } |
| 3864 | 4205 |
| 3865 /* | 4206 /* |
| 3866 ** Usage: sqlite3_prepare_tkt3134 DB | 4207 ** Usage: sqlite3_prepare_tkt3134 DB |
| 3867 ** | 4208 ** |
| 3868 ** Generate a prepared statement for a zero-byte string as a test | 4209 ** Generate a prepared statement for a zero-byte string as a test |
| 3869 ** for ticket #3134. The string should be preceded by a zero byte. | 4210 ** for ticket #3134. The string should be preceded by a zero byte. |
| 3870 */ | 4211 */ |
| 3871 static int test_prepare_tkt3134( | 4212 static int SQLITE_TCLAPI test_prepare_tkt3134( |
| 3872 void * clientData, | 4213 void * clientData, |
| 3873 Tcl_Interp *interp, | 4214 Tcl_Interp *interp, |
| 3874 int objc, | 4215 int objc, |
| 3875 Tcl_Obj *CONST objv[] | 4216 Tcl_Obj *CONST objv[] |
| 3876 ){ | 4217 ){ |
| 3877 sqlite3 *db; | 4218 sqlite3 *db; |
| 3878 static const char zSql[] = "\000SELECT 1"; | 4219 static const char zSql[] = "\000SELECT 1"; |
| 3879 sqlite3_stmt *pStmt = 0; | 4220 sqlite3_stmt *pStmt = 0; |
| 3880 char zBuf[50]; | 4221 char zBuf[50]; |
| 3881 int rc; | 4222 int rc; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3904 } | 4245 } |
| 3905 | 4246 |
| 3906 /* | 4247 /* |
| 3907 ** Usage: sqlite3_prepare16 DB sql bytes tailvar | 4248 ** Usage: sqlite3_prepare16 DB sql bytes tailvar |
| 3908 ** | 4249 ** |
| 3909 ** Compile up to <bytes> bytes of the supplied SQL string <sql> using | 4250 ** Compile up to <bytes> bytes of the supplied SQL string <sql> using |
| 3910 ** database handle <DB>. The parameter <tailval> is the name of a global | 4251 ** database handle <DB>. The parameter <tailval> is the name of a global |
| 3911 ** variable that is set to the unused portion of <sql> (if any). A | 4252 ** variable that is set to the unused portion of <sql> (if any). A |
| 3912 ** STMT handle is returned. | 4253 ** STMT handle is returned. |
| 3913 */ | 4254 */ |
| 3914 static int test_prepare16( | 4255 static int SQLITE_TCLAPI test_prepare16( |
| 3915 void * clientData, | 4256 void * clientData, |
| 3916 Tcl_Interp *interp, | 4257 Tcl_Interp *interp, |
| 3917 int objc, | 4258 int objc, |
| 3918 Tcl_Obj *CONST objv[] | 4259 Tcl_Obj *CONST objv[] |
| 3919 ){ | 4260 ){ |
| 3920 #ifndef SQLITE_OMIT_UTF16 | 4261 #ifndef SQLITE_OMIT_UTF16 |
| 3921 sqlite3 *db; | 4262 sqlite3 *db; |
| 3922 const void *zSql; | 4263 const void *zSql; |
| 3923 const void *zTail = 0; | 4264 const void *zTail = 0; |
| 3924 Tcl_Obj *pTail = 0; | 4265 Tcl_Obj *pTail = 0; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3964 } | 4305 } |
| 3965 | 4306 |
| 3966 /* | 4307 /* |
| 3967 ** Usage: sqlite3_prepare16_v2 DB sql bytes ?tailvar? | 4308 ** Usage: sqlite3_prepare16_v2 DB sql bytes ?tailvar? |
| 3968 ** | 4309 ** |
| 3969 ** Compile up to <bytes> bytes of the supplied SQL string <sql> using | 4310 ** Compile up to <bytes> bytes of the supplied SQL string <sql> using |
| 3970 ** database handle <DB>. The parameter <tailval> is the name of a global | 4311 ** database handle <DB>. The parameter <tailval> is the name of a global |
| 3971 ** variable that is set to the unused portion of <sql> (if any). A | 4312 ** variable that is set to the unused portion of <sql> (if any). A |
| 3972 ** STMT handle is returned. | 4313 ** STMT handle is returned. |
| 3973 */ | 4314 */ |
| 3974 static int test_prepare16_v2( | 4315 static int SQLITE_TCLAPI test_prepare16_v2( |
| 3975 void * clientData, | 4316 void * clientData, |
| 3976 Tcl_Interp *interp, | 4317 Tcl_Interp *interp, |
| 3977 int objc, | 4318 int objc, |
| 3978 Tcl_Obj *CONST objv[] | 4319 Tcl_Obj *CONST objv[] |
| 3979 ){ | 4320 ){ |
| 3980 #ifndef SQLITE_OMIT_UTF16 | 4321 #ifndef SQLITE_OMIT_UTF16 |
| 3981 sqlite3 *db; | 4322 sqlite3 *db; |
| 3982 const void *zSql; | 4323 const void *zSql; |
| 3983 const void *zTail = 0; | 4324 const void *zTail = 0; |
| 3984 Tcl_Obj *pTail = 0; | 4325 Tcl_Obj *pTail = 0; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4019 if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; | 4360 if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; |
| 4020 } | 4361 } |
| 4021 Tcl_AppendResult(interp, zBuf, 0); | 4362 Tcl_AppendResult(interp, zBuf, 0); |
| 4022 #endif /* SQLITE_OMIT_UTF16 */ | 4363 #endif /* SQLITE_OMIT_UTF16 */ |
| 4023 return TCL_OK; | 4364 return TCL_OK; |
| 4024 } | 4365 } |
| 4025 | 4366 |
| 4026 /* | 4367 /* |
| 4027 ** Usage: sqlite3_open filename ?options-list? | 4368 ** Usage: sqlite3_open filename ?options-list? |
| 4028 */ | 4369 */ |
| 4029 static int test_open( | 4370 static int SQLITE_TCLAPI test_open( |
| 4030 void * clientData, | 4371 void * clientData, |
| 4031 Tcl_Interp *interp, | 4372 Tcl_Interp *interp, |
| 4032 int objc, | 4373 int objc, |
| 4033 Tcl_Obj *CONST objv[] | 4374 Tcl_Obj *CONST objv[] |
| 4034 ){ | 4375 ){ |
| 4035 const char *zFilename; | 4376 const char *zFilename; |
| 4036 sqlite3 *db; | 4377 sqlite3 *db; |
| 4037 char zBuf[100]; | 4378 char zBuf[100]; |
| 4038 | 4379 |
| 4039 if( objc!=3 && objc!=2 && objc!=1 ){ | 4380 if( objc!=3 && objc!=2 && objc!=1 ){ |
| 4040 Tcl_AppendResult(interp, "wrong # args: should be \"", | 4381 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 4041 Tcl_GetString(objv[0]), " filename options-list", 0); | 4382 Tcl_GetString(objv[0]), " filename options-list", 0); |
| 4042 return TCL_ERROR; | 4383 return TCL_ERROR; |
| 4043 } | 4384 } |
| 4044 | 4385 |
| 4045 zFilename = objc>1 ? Tcl_GetString(objv[1]) : 0; | 4386 zFilename = objc>1 ? Tcl_GetString(objv[1]) : 0; |
| 4046 sqlite3_open(zFilename, &db); | 4387 sqlite3_open(zFilename, &db); |
| 4047 | 4388 |
| 4048 if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR; | 4389 if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR; |
| 4049 Tcl_AppendResult(interp, zBuf, 0); | 4390 Tcl_AppendResult(interp, zBuf, 0); |
| 4050 return TCL_OK; | 4391 return TCL_OK; |
| 4051 } | 4392 } |
| 4052 | 4393 |
| 4053 /* | 4394 /* |
| 4054 ** Usage: sqlite3_open_v2 FILENAME FLAGS VFS | 4395 ** Usage: sqlite3_open_v2 FILENAME FLAGS VFS |
| 4055 */ | 4396 */ |
| 4056 static int test_open_v2( | 4397 static int SQLITE_TCLAPI test_open_v2( |
| 4057 void * clientData, | 4398 void * clientData, |
| 4058 Tcl_Interp *interp, | 4399 Tcl_Interp *interp, |
| 4059 int objc, | 4400 int objc, |
| 4060 Tcl_Obj *CONST objv[] | 4401 Tcl_Obj *CONST objv[] |
| 4061 ){ | 4402 ){ |
| 4062 const char *zFilename; | 4403 const char *zFilename; |
| 4063 const char *zVfs; | 4404 const char *zVfs; |
| 4064 int flags = 0; | 4405 int flags = 0; |
| 4065 sqlite3 *db; | 4406 sqlite3 *db; |
| 4066 int rc; | 4407 int rc; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4116 | 4457 |
| 4117 rc = sqlite3_open_v2(zFilename, &db, flags, zVfs); | 4458 rc = sqlite3_open_v2(zFilename, &db, flags, zVfs); |
| 4118 if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR; | 4459 if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR; |
| 4119 Tcl_AppendResult(interp, zBuf, 0); | 4460 Tcl_AppendResult(interp, zBuf, 0); |
| 4120 return TCL_OK; | 4461 return TCL_OK; |
| 4121 } | 4462 } |
| 4122 | 4463 |
| 4123 /* | 4464 /* |
| 4124 ** Usage: sqlite3_open16 filename options | 4465 ** Usage: sqlite3_open16 filename options |
| 4125 */ | 4466 */ |
| 4126 static int test_open16( | 4467 static int SQLITE_TCLAPI test_open16( |
| 4127 void * clientData, | 4468 void * clientData, |
| 4128 Tcl_Interp *interp, | 4469 Tcl_Interp *interp, |
| 4129 int objc, | 4470 int objc, |
| 4130 Tcl_Obj *CONST objv[] | 4471 Tcl_Obj *CONST objv[] |
| 4131 ){ | 4472 ){ |
| 4132 #ifndef SQLITE_OMIT_UTF16 | 4473 #ifndef SQLITE_OMIT_UTF16 |
| 4133 const void *zFilename; | 4474 const void *zFilename; |
| 4134 sqlite3 *db; | 4475 sqlite3 *db; |
| 4135 char zBuf[100]; | 4476 char zBuf[100]; |
| 4136 | 4477 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4148 #endif /* SQLITE_OMIT_UTF16 */ | 4489 #endif /* SQLITE_OMIT_UTF16 */ |
| 4149 return TCL_OK; | 4490 return TCL_OK; |
| 4150 } | 4491 } |
| 4151 | 4492 |
| 4152 /* | 4493 /* |
| 4153 ** Usage: sqlite3_complete16 <UTF-16 string> | 4494 ** Usage: sqlite3_complete16 <UTF-16 string> |
| 4154 ** | 4495 ** |
| 4155 ** Return 1 if the supplied argument is a complete SQL statement, or zero | 4496 ** Return 1 if the supplied argument is a complete SQL statement, or zero |
| 4156 ** otherwise. | 4497 ** otherwise. |
| 4157 */ | 4498 */ |
| 4158 static int test_complete16( | 4499 static int SQLITE_TCLAPI test_complete16( |
| 4159 void * clientData, | 4500 void * clientData, |
| 4160 Tcl_Interp *interp, | 4501 Tcl_Interp *interp, |
| 4161 int objc, | 4502 int objc, |
| 4162 Tcl_Obj *CONST objv[] | 4503 Tcl_Obj *CONST objv[] |
| 4163 ){ | 4504 ){ |
| 4164 #if !defined(SQLITE_OMIT_COMPLETE) && !defined(SQLITE_OMIT_UTF16) | 4505 #if !defined(SQLITE_OMIT_COMPLETE) && !defined(SQLITE_OMIT_UTF16) |
| 4165 char *zBuf; | 4506 char *zBuf; |
| 4166 | 4507 |
| 4167 if( objc!=2 ){ | 4508 if( objc!=2 ){ |
| 4168 Tcl_WrongNumArgs(interp, 1, objv, "<utf-16 sql>"); | 4509 Tcl_WrongNumArgs(interp, 1, objv, "<utf-16 sql>"); |
| 4169 return TCL_ERROR; | 4510 return TCL_ERROR; |
| 4170 } | 4511 } |
| 4171 | 4512 |
| 4172 zBuf = (char*)Tcl_GetByteArrayFromObj(objv[1], 0); | 4513 zBuf = (char*)Tcl_GetByteArrayFromObj(objv[1], 0); |
| 4173 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_complete16(zBuf))); | 4514 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_complete16(zBuf))); |
| 4174 #endif /* SQLITE_OMIT_COMPLETE && SQLITE_OMIT_UTF16 */ | 4515 #endif /* SQLITE_OMIT_COMPLETE && SQLITE_OMIT_UTF16 */ |
| 4175 return TCL_OK; | 4516 return TCL_OK; |
| 4176 } | 4517 } |
| 4177 | 4518 |
| 4178 /* | 4519 /* |
| 4179 ** Usage: sqlite3_step STMT | 4520 ** Usage: sqlite3_step STMT |
| 4180 ** | 4521 ** |
| 4181 ** Advance the statement to the next row. | 4522 ** Advance the statement to the next row. |
| 4182 */ | 4523 */ |
| 4183 static int test_step( | 4524 static int SQLITE_TCLAPI test_step( |
| 4184 void * clientData, | 4525 void * clientData, |
| 4185 Tcl_Interp *interp, | 4526 Tcl_Interp *interp, |
| 4186 int objc, | 4527 int objc, |
| 4187 Tcl_Obj *CONST objv[] | 4528 Tcl_Obj *CONST objv[] |
| 4188 ){ | 4529 ){ |
| 4189 sqlite3_stmt *pStmt; | 4530 sqlite3_stmt *pStmt; |
| 4190 int rc; | 4531 int rc; |
| 4191 | 4532 |
| 4192 if( objc!=2 ){ | 4533 if( objc!=2 ){ |
| 4193 Tcl_AppendResult(interp, "wrong # args: should be \"", | 4534 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 4194 Tcl_GetString(objv[0]), " STMT", 0); | 4535 Tcl_GetString(objv[0]), " STMT", 0); |
| 4195 return TCL_ERROR; | 4536 return TCL_ERROR; |
| 4196 } | 4537 } |
| 4197 | 4538 |
| 4198 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 4539 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 4199 rc = sqlite3_step(pStmt); | 4540 rc = sqlite3_step(pStmt); |
| 4200 | 4541 |
| 4201 /* if( rc!=SQLITE_DONE && rc!=SQLITE_ROW ) return TCL_ERROR; */ | 4542 /* if( rc!=SQLITE_DONE && rc!=SQLITE_ROW ) return TCL_ERROR; */ |
| 4202 Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0); | 4543 Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0); |
| 4203 return TCL_OK; | 4544 return TCL_OK; |
| 4204 } | 4545 } |
| 4205 | 4546 |
| 4206 static int test_sql( | 4547 static int SQLITE_TCLAPI test_sql( |
| 4207 void * clientData, | 4548 void * clientData, |
| 4208 Tcl_Interp *interp, | 4549 Tcl_Interp *interp, |
| 4209 int objc, | 4550 int objc, |
| 4210 Tcl_Obj *CONST objv[] | 4551 Tcl_Obj *CONST objv[] |
| 4211 ){ | 4552 ){ |
| 4212 sqlite3_stmt *pStmt; | 4553 sqlite3_stmt *pStmt; |
| 4213 | 4554 |
| 4214 if( objc!=2 ){ | 4555 if( objc!=2 ){ |
| 4215 Tcl_WrongNumArgs(interp, 1, objv, "STMT"); | 4556 Tcl_WrongNumArgs(interp, 1, objv, "STMT"); |
| 4216 return TCL_ERROR; | 4557 return TCL_ERROR; |
| 4217 } | 4558 } |
| 4218 | 4559 |
| 4219 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 4560 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 4220 Tcl_SetResult(interp, (char *)sqlite3_sql(pStmt), TCL_VOLATILE); | 4561 Tcl_SetResult(interp, (char *)sqlite3_sql(pStmt), TCL_VOLATILE); |
| 4221 return TCL_OK; | 4562 return TCL_OK; |
| 4222 } | 4563 } |
| 4564 static int SQLITE_TCLAPI test_ex_sql( |
| 4565 void * clientData, |
| 4566 Tcl_Interp *interp, |
| 4567 int objc, |
| 4568 Tcl_Obj *CONST objv[] |
| 4569 ){ |
| 4570 sqlite3_stmt *pStmt; |
| 4571 char *z; |
| 4572 |
| 4573 if( objc!=2 ){ |
| 4574 Tcl_WrongNumArgs(interp, 1, objv, "STMT"); |
| 4575 return TCL_ERROR; |
| 4576 } |
| 4577 |
| 4578 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 4579 z = sqlite3_expanded_sql(pStmt); |
| 4580 Tcl_SetResult(interp, z, TCL_VOLATILE); |
| 4581 sqlite3_free(z); |
| 4582 return TCL_OK; |
| 4583 } |
| 4223 | 4584 |
| 4224 /* | 4585 /* |
| 4225 ** Usage: sqlite3_column_count STMT | 4586 ** Usage: sqlite3_column_count STMT |
| 4226 ** | 4587 ** |
| 4227 ** Return the number of columns returned by the sql statement STMT. | 4588 ** Return the number of columns returned by the sql statement STMT. |
| 4228 */ | 4589 */ |
| 4229 static int test_column_count( | 4590 static int SQLITE_TCLAPI test_column_count( |
| 4230 void * clientData, | 4591 void * clientData, |
| 4231 Tcl_Interp *interp, | 4592 Tcl_Interp *interp, |
| 4232 int objc, | 4593 int objc, |
| 4233 Tcl_Obj *CONST objv[] | 4594 Tcl_Obj *CONST objv[] |
| 4234 ){ | 4595 ){ |
| 4235 sqlite3_stmt *pStmt; | 4596 sqlite3_stmt *pStmt; |
| 4236 | 4597 |
| 4237 if( objc!=2 ){ | 4598 if( objc!=2 ){ |
| 4238 Tcl_AppendResult(interp, "wrong # args: should be \"", | 4599 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 4239 Tcl_GetString(objv[0]), " STMT column", 0); | 4600 Tcl_GetString(objv[0]), " STMT column", 0); |
| 4240 return TCL_ERROR; | 4601 return TCL_ERROR; |
| 4241 } | 4602 } |
| 4242 | 4603 |
| 4243 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 4604 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 4244 | 4605 |
| 4245 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_column_count(pStmt))); | 4606 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_column_count(pStmt))); |
| 4246 return TCL_OK; | 4607 return TCL_OK; |
| 4247 } | 4608 } |
| 4248 | 4609 |
| 4249 /* | 4610 /* |
| 4250 ** Usage: sqlite3_column_type STMT column | 4611 ** Usage: sqlite3_column_type STMT column |
| 4251 ** | 4612 ** |
| 4252 ** Return the type of the data in column 'column' of the current row. | 4613 ** Return the type of the data in column 'column' of the current row. |
| 4253 */ | 4614 */ |
| 4254 static int test_column_type( | 4615 static int SQLITE_TCLAPI test_column_type( |
| 4255 void * clientData, | 4616 void * clientData, |
| 4256 Tcl_Interp *interp, | 4617 Tcl_Interp *interp, |
| 4257 int objc, | 4618 int objc, |
| 4258 Tcl_Obj *CONST objv[] | 4619 Tcl_Obj *CONST objv[] |
| 4259 ){ | 4620 ){ |
| 4260 sqlite3_stmt *pStmt; | 4621 sqlite3_stmt *pStmt; |
| 4261 int col; | 4622 int col; |
| 4262 int tp; | 4623 int tp; |
| 4263 | 4624 |
| 4264 if( objc!=3 ){ | 4625 if( objc!=3 ){ |
| (...skipping 28 matching lines...) Expand all Loading... |
| 4293 | 4654 |
| 4294 return TCL_OK; | 4655 return TCL_OK; |
| 4295 } | 4656 } |
| 4296 | 4657 |
| 4297 /* | 4658 /* |
| 4298 ** Usage: sqlite3_column_int64 STMT column | 4659 ** Usage: sqlite3_column_int64 STMT column |
| 4299 ** | 4660 ** |
| 4300 ** Return the data in column 'column' of the current row cast as an | 4661 ** Return the data in column 'column' of the current row cast as an |
| 4301 ** wide (64-bit) integer. | 4662 ** wide (64-bit) integer. |
| 4302 */ | 4663 */ |
| 4303 static int test_column_int64( | 4664 static int SQLITE_TCLAPI test_column_int64( |
| 4304 void * clientData, | 4665 void * clientData, |
| 4305 Tcl_Interp *interp, | 4666 Tcl_Interp *interp, |
| 4306 int objc, | 4667 int objc, |
| 4307 Tcl_Obj *CONST objv[] | 4668 Tcl_Obj *CONST objv[] |
| 4308 ){ | 4669 ){ |
| 4309 sqlite3_stmt *pStmt; | 4670 sqlite3_stmt *pStmt; |
| 4310 int col; | 4671 int col; |
| 4311 i64 iVal; | 4672 i64 iVal; |
| 4312 | 4673 |
| 4313 if( objc!=3 ){ | 4674 if( objc!=3 ){ |
| 4314 Tcl_AppendResult(interp, "wrong # args: should be \"", | 4675 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 4315 Tcl_GetString(objv[0]), " STMT column", 0); | 4676 Tcl_GetString(objv[0]), " STMT column", 0); |
| 4316 return TCL_ERROR; | 4677 return TCL_ERROR; |
| 4317 } | 4678 } |
| 4318 | 4679 |
| 4319 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 4680 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 4320 if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR; | 4681 if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR; |
| 4321 | 4682 |
| 4322 iVal = sqlite3_column_int64(pStmt, col); | 4683 iVal = sqlite3_column_int64(pStmt, col); |
| 4323 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(iVal)); | 4684 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(iVal)); |
| 4324 return TCL_OK; | 4685 return TCL_OK; |
| 4325 } | 4686 } |
| 4326 | 4687 |
| 4327 /* | 4688 /* |
| 4328 ** Usage: sqlite3_column_blob STMT column | 4689 ** Usage: sqlite3_column_blob STMT column |
| 4329 */ | 4690 */ |
| 4330 static int test_column_blob( | 4691 static int SQLITE_TCLAPI test_column_blob( |
| 4331 void * clientData, | 4692 void * clientData, |
| 4332 Tcl_Interp *interp, | 4693 Tcl_Interp *interp, |
| 4333 int objc, | 4694 int objc, |
| 4334 Tcl_Obj *CONST objv[] | 4695 Tcl_Obj *CONST objv[] |
| 4335 ){ | 4696 ){ |
| 4336 sqlite3_stmt *pStmt; | 4697 sqlite3_stmt *pStmt; |
| 4337 int col; | 4698 int col; |
| 4338 | 4699 |
| 4339 int len; | 4700 int len; |
| 4340 const void *pBlob; | 4701 const void *pBlob; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4352 pBlob = sqlite3_column_blob(pStmt, col); | 4713 pBlob = sqlite3_column_blob(pStmt, col); |
| 4353 Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(pBlob, len)); | 4714 Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(pBlob, len)); |
| 4354 return TCL_OK; | 4715 return TCL_OK; |
| 4355 } | 4716 } |
| 4356 | 4717 |
| 4357 /* | 4718 /* |
| 4358 ** Usage: sqlite3_column_double STMT column | 4719 ** Usage: sqlite3_column_double STMT column |
| 4359 ** | 4720 ** |
| 4360 ** Return the data in column 'column' of the current row cast as a double. | 4721 ** Return the data in column 'column' of the current row cast as a double. |
| 4361 */ | 4722 */ |
| 4362 static int test_column_double( | 4723 static int SQLITE_TCLAPI test_column_double( |
| 4363 void * clientData, | 4724 void * clientData, |
| 4364 Tcl_Interp *interp, | 4725 Tcl_Interp *interp, |
| 4365 int objc, | 4726 int objc, |
| 4366 Tcl_Obj *CONST objv[] | 4727 Tcl_Obj *CONST objv[] |
| 4367 ){ | 4728 ){ |
| 4368 sqlite3_stmt *pStmt; | 4729 sqlite3_stmt *pStmt; |
| 4369 int col; | 4730 int col; |
| 4370 double rVal; | 4731 double rVal; |
| 4371 | 4732 |
| 4372 if( objc!=3 ){ | 4733 if( objc!=3 ){ |
| 4373 Tcl_AppendResult(interp, "wrong # args: should be \"", | 4734 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 4374 Tcl_GetString(objv[0]), " STMT column", 0); | 4735 Tcl_GetString(objv[0]), " STMT column", 0); |
| 4375 return TCL_ERROR; | 4736 return TCL_ERROR; |
| 4376 } | 4737 } |
| 4377 | 4738 |
| 4378 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 4739 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 4379 if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR; | 4740 if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR; |
| 4380 | 4741 |
| 4381 rVal = sqlite3_column_double(pStmt, col); | 4742 rVal = sqlite3_column_double(pStmt, col); |
| 4382 Tcl_SetObjResult(interp, Tcl_NewDoubleObj(rVal)); | 4743 Tcl_SetObjResult(interp, Tcl_NewDoubleObj(rVal)); |
| 4383 return TCL_OK; | 4744 return TCL_OK; |
| 4384 } | 4745 } |
| 4385 | 4746 |
| 4386 /* | 4747 /* |
| 4387 ** Usage: sqlite3_data_count STMT | 4748 ** Usage: sqlite3_data_count STMT |
| 4388 ** | 4749 ** |
| 4389 ** Return the number of columns returned by the sql statement STMT. | 4750 ** Return the number of columns returned by the sql statement STMT. |
| 4390 */ | 4751 */ |
| 4391 static int test_data_count( | 4752 static int SQLITE_TCLAPI test_data_count( |
| 4392 void * clientData, | 4753 void * clientData, |
| 4393 Tcl_Interp *interp, | 4754 Tcl_Interp *interp, |
| 4394 int objc, | 4755 int objc, |
| 4395 Tcl_Obj *CONST objv[] | 4756 Tcl_Obj *CONST objv[] |
| 4396 ){ | 4757 ){ |
| 4397 sqlite3_stmt *pStmt; | 4758 sqlite3_stmt *pStmt; |
| 4398 | 4759 |
| 4399 if( objc!=2 ){ | 4760 if( objc!=2 ){ |
| 4400 Tcl_AppendResult(interp, "wrong # args: should be \"", | 4761 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 4401 Tcl_GetString(objv[0]), " STMT column", 0); | 4762 Tcl_GetString(objv[0]), " STMT column", 0); |
| 4402 return TCL_ERROR; | 4763 return TCL_ERROR; |
| 4403 } | 4764 } |
| 4404 | 4765 |
| 4405 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 4766 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 4406 | 4767 |
| 4407 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_data_count(pStmt))); | 4768 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_data_count(pStmt))); |
| 4408 return TCL_OK; | 4769 return TCL_OK; |
| 4409 } | 4770 } |
| 4410 | 4771 |
| 4411 /* | 4772 /* |
| 4412 ** Usage: sqlite3_column_text STMT column | 4773 ** Usage: sqlite3_column_text STMT column |
| 4413 ** | 4774 ** |
| 4414 ** Usage: sqlite3_column_decltype STMT column | 4775 ** Usage: sqlite3_column_decltype STMT column |
| 4415 ** | 4776 ** |
| 4416 ** Usage: sqlite3_column_name STMT column | 4777 ** Usage: sqlite3_column_name STMT column |
| 4417 */ | 4778 */ |
| 4418 static int test_stmt_utf8( | 4779 static int SQLITE_TCLAPI test_stmt_utf8( |
| 4419 void * clientData, /* Pointer to SQLite API function to be invoke */ | 4780 void * clientData, /* Pointer to SQLite API function to be invoke */ |
| 4420 Tcl_Interp *interp, | 4781 Tcl_Interp *interp, |
| 4421 int objc, | 4782 int objc, |
| 4422 Tcl_Obj *CONST objv[] | 4783 Tcl_Obj *CONST objv[] |
| 4423 ){ | 4784 ){ |
| 4424 sqlite3_stmt *pStmt; | 4785 sqlite3_stmt *pStmt; |
| 4425 int col; | 4786 int col; |
| 4426 const char *(*xFunc)(sqlite3_stmt*, int); | 4787 const char *(*xFunc)(sqlite3_stmt*, int); |
| 4427 const char *zRet; | 4788 const char *zRet; |
| 4428 | 4789 |
| 4429 xFunc = (const char *(*)(sqlite3_stmt*, int))clientData; | 4790 xFunc = (const char *(*)(sqlite3_stmt*, int))clientData; |
| 4430 if( objc!=3 ){ | 4791 if( objc!=3 ){ |
| 4431 Tcl_AppendResult(interp, "wrong # args: should be \"", | 4792 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 4432 Tcl_GetString(objv[0]), " STMT column", 0); | 4793 Tcl_GetString(objv[0]), " STMT column", 0); |
| 4433 return TCL_ERROR; | 4794 return TCL_ERROR; |
| 4434 } | 4795 } |
| 4435 | 4796 |
| 4436 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 4797 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 4437 if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR; | 4798 if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR; |
| 4438 zRet = xFunc(pStmt, col); | 4799 zRet = xFunc(pStmt, col); |
| 4439 if( zRet ){ | 4800 if( zRet ){ |
| 4440 Tcl_SetResult(interp, (char *)zRet, 0); | 4801 Tcl_SetResult(interp, (char *)zRet, 0); |
| 4441 } | 4802 } |
| 4442 return TCL_OK; | 4803 return TCL_OK; |
| 4443 } | 4804 } |
| 4444 | 4805 |
| 4445 static int test_global_recover( | 4806 static int SQLITE_TCLAPI test_global_recover( |
| 4446 void * clientData, | 4807 void * clientData, |
| 4447 Tcl_Interp *interp, | 4808 Tcl_Interp *interp, |
| 4448 int objc, | 4809 int objc, |
| 4449 Tcl_Obj *CONST objv[] | 4810 Tcl_Obj *CONST objv[] |
| 4450 ){ | 4811 ){ |
| 4451 #ifndef SQLITE_OMIT_DEPRECATED | 4812 #ifndef SQLITE_OMIT_DEPRECATED |
| 4452 int rc; | 4813 int rc; |
| 4453 if( objc!=1 ){ | 4814 if( objc!=1 ){ |
| 4454 Tcl_WrongNumArgs(interp, 1, objv, ""); | 4815 Tcl_WrongNumArgs(interp, 1, objv, ""); |
| 4455 return TCL_ERROR; | 4816 return TCL_ERROR; |
| 4456 } | 4817 } |
| 4457 rc = sqlite3_global_recover(); | 4818 rc = sqlite3_global_recover(); |
| 4458 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); | 4819 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); |
| 4459 #endif | 4820 #endif |
| 4460 return TCL_OK; | 4821 return TCL_OK; |
| 4461 } | 4822 } |
| 4462 | 4823 |
| 4463 /* | 4824 /* |
| 4464 ** Usage: sqlite3_column_text STMT column | 4825 ** Usage: sqlite3_column_text STMT column |
| 4465 ** | 4826 ** |
| 4466 ** Usage: sqlite3_column_decltype STMT column | 4827 ** Usage: sqlite3_column_decltype STMT column |
| 4467 ** | 4828 ** |
| 4468 ** Usage: sqlite3_column_name STMT column | 4829 ** Usage: sqlite3_column_name STMT column |
| 4469 */ | 4830 */ |
| 4470 static int test_stmt_utf16( | 4831 static int SQLITE_TCLAPI test_stmt_utf16( |
| 4471 void * clientData, /* Pointer to SQLite API function to be invoked */ | 4832 void * clientData, /* Pointer to SQLite API function to be invoked */ |
| 4472 Tcl_Interp *interp, | 4833 Tcl_Interp *interp, |
| 4473 int objc, | 4834 int objc, |
| 4474 Tcl_Obj *CONST objv[] | 4835 Tcl_Obj *CONST objv[] |
| 4475 ){ | 4836 ){ |
| 4476 #ifndef SQLITE_OMIT_UTF16 | 4837 #ifndef SQLITE_OMIT_UTF16 |
| 4477 sqlite3_stmt *pStmt; | 4838 sqlite3_stmt *pStmt; |
| 4478 int col; | 4839 int col; |
| 4479 Tcl_Obj *pRet; | 4840 Tcl_Obj *pRet; |
| 4480 const void *zName16; | 4841 const void *zName16; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4504 } | 4865 } |
| 4505 | 4866 |
| 4506 /* | 4867 /* |
| 4507 ** Usage: sqlite3_column_int STMT column | 4868 ** Usage: sqlite3_column_int STMT column |
| 4508 ** | 4869 ** |
| 4509 ** Usage: sqlite3_column_bytes STMT column | 4870 ** Usage: sqlite3_column_bytes STMT column |
| 4510 ** | 4871 ** |
| 4511 ** Usage: sqlite3_column_bytes16 STMT column | 4872 ** Usage: sqlite3_column_bytes16 STMT column |
| 4512 ** | 4873 ** |
| 4513 */ | 4874 */ |
| 4514 static int test_stmt_int( | 4875 static int SQLITE_TCLAPI test_stmt_int( |
| 4515 void * clientData, /* Pointer to SQLite API function to be invoked */ | 4876 void * clientData, /* Pointer to SQLite API function to be invoked */ |
| 4516 Tcl_Interp *interp, | 4877 Tcl_Interp *interp, |
| 4517 int objc, | 4878 int objc, |
| 4518 Tcl_Obj *CONST objv[] | 4879 Tcl_Obj *CONST objv[] |
| 4519 ){ | 4880 ){ |
| 4520 sqlite3_stmt *pStmt; | 4881 sqlite3_stmt *pStmt; |
| 4521 int col; | 4882 int col; |
| 4522 int (*xFunc)(sqlite3_stmt*, int); | 4883 int (*xFunc)(sqlite3_stmt*, int); |
| 4523 | 4884 |
| 4524 xFunc = (int (*)(sqlite3_stmt*, int))clientData; | 4885 xFunc = (int (*)(sqlite3_stmt*, int))clientData; |
| 4525 if( objc!=3 ){ | 4886 if( objc!=3 ){ |
| 4526 Tcl_AppendResult(interp, "wrong # args: should be \"", | 4887 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 4527 Tcl_GetString(objv[0]), " STMT column", 0); | 4888 Tcl_GetString(objv[0]), " STMT column", 0); |
| 4528 return TCL_ERROR; | 4889 return TCL_ERROR; |
| 4529 } | 4890 } |
| 4530 | 4891 |
| 4531 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 4892 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 4532 if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR; | 4893 if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR; |
| 4533 | 4894 |
| 4534 Tcl_SetObjResult(interp, Tcl_NewIntObj(xFunc(pStmt, col))); | 4895 Tcl_SetObjResult(interp, Tcl_NewIntObj(xFunc(pStmt, col))); |
| 4535 return TCL_OK; | 4896 return TCL_OK; |
| 4536 } | 4897 } |
| 4537 | 4898 |
| 4538 /* | 4899 /* |
| 4539 ** Usage: sqlite_set_magic DB MAGIC-NUMBER | 4900 ** Usage: sqlite_set_magic DB MAGIC-NUMBER |
| 4540 ** | 4901 ** |
| 4541 ** Set the db->magic value. This is used to test error recovery logic. | 4902 ** Set the db->magic value. This is used to test error recovery logic. |
| 4542 */ | 4903 */ |
| 4543 static int sqlite_set_magic( | 4904 static int SQLITE_TCLAPI sqlite_set_magic( |
| 4544 void * clientData, | 4905 void * clientData, |
| 4545 Tcl_Interp *interp, | 4906 Tcl_Interp *interp, |
| 4546 int argc, | 4907 int argc, |
| 4547 char **argv | 4908 char **argv |
| 4548 ){ | 4909 ){ |
| 4549 sqlite3 *db; | 4910 sqlite3 *db; |
| 4550 if( argc!=3 ){ | 4911 if( argc!=3 ){ |
| 4551 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 4912 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 4552 " DB MAGIC", 0); | 4913 " DB MAGIC", 0); |
| 4553 return TCL_ERROR; | 4914 return TCL_ERROR; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4565 return TCL_ERROR; | 4926 return TCL_ERROR; |
| 4566 } | 4927 } |
| 4567 return TCL_OK; | 4928 return TCL_OK; |
| 4568 } | 4929 } |
| 4569 | 4930 |
| 4570 /* | 4931 /* |
| 4571 ** Usage: sqlite3_interrupt DB | 4932 ** Usage: sqlite3_interrupt DB |
| 4572 ** | 4933 ** |
| 4573 ** Trigger an interrupt on DB | 4934 ** Trigger an interrupt on DB |
| 4574 */ | 4935 */ |
| 4575 static int test_interrupt( | 4936 static int SQLITE_TCLAPI test_interrupt( |
| 4576 void * clientData, | 4937 void * clientData, |
| 4577 Tcl_Interp *interp, | 4938 Tcl_Interp *interp, |
| 4578 int argc, | 4939 int argc, |
| 4579 char **argv | 4940 char **argv |
| 4580 ){ | 4941 ){ |
| 4581 sqlite3 *db; | 4942 sqlite3 *db; |
| 4582 if( argc!=2 ){ | 4943 if( argc!=2 ){ |
| 4583 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB", 0); | 4944 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB", 0); |
| 4584 return TCL_ERROR; | 4945 return TCL_ERROR; |
| 4585 } | 4946 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 4606 u64 sqlite3StackDepth(void){ | 4967 u64 sqlite3StackDepth(void){ |
| 4607 u8 x; | 4968 u8 x; |
| 4608 return (u64)(sqlite3_stack_baseline - &x); | 4969 return (u64)(sqlite3_stack_baseline - &x); |
| 4609 } | 4970 } |
| 4610 | 4971 |
| 4611 /* | 4972 /* |
| 4612 ** Usage: sqlite3_stack_used DB SQL | 4973 ** Usage: sqlite3_stack_used DB SQL |
| 4613 ** | 4974 ** |
| 4614 ** Try to measure the amount of stack space used by a call to sqlite3_exec | 4975 ** Try to measure the amount of stack space used by a call to sqlite3_exec |
| 4615 */ | 4976 */ |
| 4616 static int test_stack_used( | 4977 static int SQLITE_TCLAPI test_stack_used( |
| 4617 void * clientData, | 4978 void * clientData, |
| 4618 Tcl_Interp *interp, | 4979 Tcl_Interp *interp, |
| 4619 int argc, | 4980 int argc, |
| 4620 char **argv | 4981 char **argv |
| 4621 ){ | 4982 ){ |
| 4622 sqlite3 *db; | 4983 sqlite3 *db; |
| 4623 int i; | 4984 int i; |
| 4624 if( argc!=3 ){ | 4985 if( argc!=3 ){ |
| 4625 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 4986 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 4626 " DB SQL", 0); | 4987 " DB SQL", 0); |
| 4627 return TCL_ERROR; | 4988 return TCL_ERROR; |
| 4628 } | 4989 } |
| 4629 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 4990 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
| 4630 prepStack(); | 4991 prepStack(); |
| 4631 (void)sqlite3_exec(db, argv[2], 0, 0, 0); | 4992 (void)sqlite3_exec(db, argv[2], 0, 0, 0); |
| 4632 for(i=65535; i>=0 && ((u32*)sqlite3_stack_baseline)[-i]==0xdeadbeef; i--){} | 4993 for(i=65535; i>=0 && ((u32*)sqlite3_stack_baseline)[-i]==0xdeadbeef; i--){} |
| 4633 Tcl_SetObjResult(interp, Tcl_NewIntObj(i*4)); | 4994 Tcl_SetObjResult(interp, Tcl_NewIntObj(i*4)); |
| 4634 return TCL_OK; | 4995 return TCL_OK; |
| 4635 } | 4996 } |
| 4636 | 4997 |
| 4637 /* | 4998 /* |
| 4638 ** Usage: sqlite_delete_function DB function-name | 4999 ** Usage: sqlite_delete_function DB function-name |
| 4639 ** | 5000 ** |
| 4640 ** Delete the user function 'function-name' from database handle DB. It | 5001 ** Delete the user function 'function-name' from database handle DB. It |
| 4641 ** is assumed that the user function was created as UTF8, any number of | 5002 ** is assumed that the user function was created as UTF8, any number of |
| 4642 ** arguments (the way the TCL interface does it). | 5003 ** arguments (the way the TCL interface does it). |
| 4643 */ | 5004 */ |
| 4644 static int delete_function( | 5005 static int SQLITE_TCLAPI delete_function( |
| 4645 void * clientData, | 5006 void * clientData, |
| 4646 Tcl_Interp *interp, | 5007 Tcl_Interp *interp, |
| 4647 int argc, | 5008 int argc, |
| 4648 char **argv | 5009 char **argv |
| 4649 ){ | 5010 ){ |
| 4650 int rc; | 5011 int rc; |
| 4651 sqlite3 *db; | 5012 sqlite3 *db; |
| 4652 if( argc!=3 ){ | 5013 if( argc!=3 ){ |
| 4653 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 5014 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 4654 " DB function-name", 0); | 5015 " DB function-name", 0); |
| 4655 return TCL_ERROR; | 5016 return TCL_ERROR; |
| 4656 } | 5017 } |
| 4657 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 5018 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
| 4658 rc = sqlite3_create_function(db, argv[2], -1, SQLITE_UTF8, 0, 0, 0, 0); | 5019 rc = sqlite3_create_function(db, argv[2], -1, SQLITE_UTF8, 0, 0, 0, 0); |
| 4659 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); | 5020 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); |
| 4660 return TCL_OK; | 5021 return TCL_OK; |
| 4661 } | 5022 } |
| 4662 | 5023 |
| 4663 /* | 5024 /* |
| 4664 ** Usage: sqlite_delete_collation DB collation-name | 5025 ** Usage: sqlite_delete_collation DB collation-name |
| 4665 ** | 5026 ** |
| 4666 ** Delete the collation sequence 'collation-name' from database handle | 5027 ** Delete the collation sequence 'collation-name' from database handle |
| 4667 ** DB. It is assumed that the collation sequence was created as UTF8 (the | 5028 ** DB. It is assumed that the collation sequence was created as UTF8 (the |
| 4668 ** way the TCL interface does it). | 5029 ** way the TCL interface does it). |
| 4669 */ | 5030 */ |
| 4670 static int delete_collation( | 5031 static int SQLITE_TCLAPI delete_collation( |
| 4671 void * clientData, | 5032 void * clientData, |
| 4672 Tcl_Interp *interp, | 5033 Tcl_Interp *interp, |
| 4673 int argc, | 5034 int argc, |
| 4674 char **argv | 5035 char **argv |
| 4675 ){ | 5036 ){ |
| 4676 int rc; | 5037 int rc; |
| 4677 sqlite3 *db; | 5038 sqlite3 *db; |
| 4678 if( argc!=3 ){ | 5039 if( argc!=3 ){ |
| 4679 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 5040 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 4680 " DB function-name", 0); | 5041 " DB function-name", 0); |
| 4681 return TCL_ERROR; | 5042 return TCL_ERROR; |
| 4682 } | 5043 } |
| 4683 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 5044 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
| 4684 rc = sqlite3_create_collation(db, argv[2], SQLITE_UTF8, 0, 0); | 5045 rc = sqlite3_create_collation(db, argv[2], SQLITE_UTF8, 0, 0); |
| 4685 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); | 5046 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); |
| 4686 return TCL_OK; | 5047 return TCL_OK; |
| 4687 } | 5048 } |
| 4688 | 5049 |
| 4689 /* | 5050 /* |
| 4690 ** Usage: sqlite3_get_autocommit DB | 5051 ** Usage: sqlite3_get_autocommit DB |
| 4691 ** | 5052 ** |
| 4692 ** Return true if the database DB is currently in auto-commit mode. | 5053 ** Return true if the database DB is currently in auto-commit mode. |
| 4693 ** Return false if not. | 5054 ** Return false if not. |
| 4694 */ | 5055 */ |
| 4695 static int get_autocommit( | 5056 static int SQLITE_TCLAPI get_autocommit( |
| 4696 void * clientData, | 5057 void * clientData, |
| 4697 Tcl_Interp *interp, | 5058 Tcl_Interp *interp, |
| 4698 int argc, | 5059 int argc, |
| 4699 char **argv | 5060 char **argv |
| 4700 ){ | 5061 ){ |
| 4701 char zBuf[30]; | 5062 char zBuf[30]; |
| 4702 sqlite3 *db; | 5063 sqlite3 *db; |
| 4703 if( argc!=2 ){ | 5064 if( argc!=2 ){ |
| 4704 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 5065 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 4705 " DB", 0); | 5066 " DB", 0); |
| 4706 return TCL_ERROR; | 5067 return TCL_ERROR; |
| 4707 } | 5068 } |
| 4708 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 5069 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
| 4709 sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", sqlite3_get_autocommit(db)); | 5070 sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", sqlite3_get_autocommit(db)); |
| 4710 Tcl_AppendResult(interp, zBuf, 0); | 5071 Tcl_AppendResult(interp, zBuf, 0); |
| 4711 return TCL_OK; | 5072 return TCL_OK; |
| 4712 } | 5073 } |
| 4713 | 5074 |
| 4714 /* | 5075 /* |
| 4715 ** Usage: sqlite3_busy_timeout DB MS | 5076 ** Usage: sqlite3_busy_timeout DB MS |
| 4716 ** | 5077 ** |
| 4717 ** Set the busy timeout. This is more easily done using the timeout | 5078 ** Set the busy timeout. This is more easily done using the timeout |
| 4718 ** method of the TCL interface. But we need a way to test the case | 5079 ** method of the TCL interface. But we need a way to test the case |
| 4719 ** where it returns SQLITE_MISUSE. | 5080 ** where it returns SQLITE_MISUSE. |
| 4720 */ | 5081 */ |
| 4721 static int test_busy_timeout( | 5082 static int SQLITE_TCLAPI test_busy_timeout( |
| 4722 void * clientData, | 5083 void * clientData, |
| 4723 Tcl_Interp *interp, | 5084 Tcl_Interp *interp, |
| 4724 int argc, | 5085 int argc, |
| 4725 char **argv | 5086 char **argv |
| 4726 ){ | 5087 ){ |
| 4727 int rc, ms; | 5088 int rc, ms; |
| 4728 sqlite3 *db; | 5089 sqlite3 *db; |
| 4729 if( argc!=3 ){ | 5090 if( argc!=3 ){ |
| 4730 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], | 5091 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], |
| 4731 " DB", 0); | 5092 " DB", 0); |
| 4732 return TCL_ERROR; | 5093 return TCL_ERROR; |
| 4733 } | 5094 } |
| 4734 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | 5095 if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; |
| 4735 if( Tcl_GetInt(interp, argv[2], &ms) ) return TCL_ERROR; | 5096 if( Tcl_GetInt(interp, argv[2], &ms) ) return TCL_ERROR; |
| 4736 rc = sqlite3_busy_timeout(db, ms); | 5097 rc = sqlite3_busy_timeout(db, ms); |
| 4737 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); | 5098 Tcl_AppendResult(interp, sqlite3ErrName(rc), 0); |
| 4738 return TCL_OK; | 5099 return TCL_OK; |
| 4739 } | 5100 } |
| 4740 | 5101 |
| 4741 /* | 5102 /* |
| 4742 ** Usage: tcl_variable_type VARIABLENAME | 5103 ** Usage: tcl_variable_type VARIABLENAME |
| 4743 ** | 5104 ** |
| 4744 ** Return the name of the internal representation for the | 5105 ** Return the name of the internal representation for the |
| 4745 ** value of the given variable. | 5106 ** value of the given variable. |
| 4746 */ | 5107 */ |
| 4747 static int tcl_variable_type( | 5108 static int SQLITE_TCLAPI tcl_variable_type( |
| 4748 void * clientData, | 5109 void * clientData, |
| 4749 Tcl_Interp *interp, | 5110 Tcl_Interp *interp, |
| 4750 int objc, | 5111 int objc, |
| 4751 Tcl_Obj *CONST objv[] | 5112 Tcl_Obj *CONST objv[] |
| 4752 ){ | 5113 ){ |
| 4753 Tcl_Obj *pVar; | 5114 Tcl_Obj *pVar; |
| 4754 if( objc!=2 ){ | 5115 if( objc!=2 ){ |
| 4755 Tcl_WrongNumArgs(interp, 1, objv, "VARIABLE"); | 5116 Tcl_WrongNumArgs(interp, 1, objv, "VARIABLE"); |
| 4756 return TCL_ERROR; | 5117 return TCL_ERROR; |
| 4757 } | 5118 } |
| 4758 pVar = Tcl_GetVar2Ex(interp, Tcl_GetString(objv[1]), 0, TCL_LEAVE_ERR_MSG); | 5119 pVar = Tcl_GetVar2Ex(interp, Tcl_GetString(objv[1]), 0, TCL_LEAVE_ERR_MSG); |
| 4759 if( pVar==0 ) return TCL_ERROR; | 5120 if( pVar==0 ) return TCL_ERROR; |
| 4760 if( pVar->typePtr ){ | 5121 if( pVar->typePtr ){ |
| 4761 Tcl_SetObjResult(interp, Tcl_NewStringObj(pVar->typePtr->name, -1)); | 5122 Tcl_SetObjResult(interp, Tcl_NewStringObj(pVar->typePtr->name, -1)); |
| 4762 } | 5123 } |
| 4763 return TCL_OK; | 5124 return TCL_OK; |
| 4764 } | 5125 } |
| 4765 | 5126 |
| 4766 /* | 5127 /* |
| 4767 ** Usage: sqlite3_release_memory ?N? | 5128 ** Usage: sqlite3_release_memory ?N? |
| 4768 ** | 5129 ** |
| 4769 ** Attempt to release memory currently held but not actually required. | 5130 ** Attempt to release memory currently held but not actually required. |
| 4770 ** The integer N is the number of bytes we are trying to release. The | 5131 ** The integer N is the number of bytes we are trying to release. The |
| 4771 ** return value is the amount of memory actually released. | 5132 ** return value is the amount of memory actually released. |
| 4772 */ | 5133 */ |
| 4773 static int test_release_memory( | 5134 static int SQLITE_TCLAPI test_release_memory( |
| 4774 void * clientData, | 5135 void * clientData, |
| 4775 Tcl_Interp *interp, | 5136 Tcl_Interp *interp, |
| 4776 int objc, | 5137 int objc, |
| 4777 Tcl_Obj *CONST objv[] | 5138 Tcl_Obj *CONST objv[] |
| 4778 ){ | 5139 ){ |
| 4779 #if defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) && !defined(SQLITE_OMIT_DISKIO) | 5140 #if defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) && !defined(SQLITE_OMIT_DISKIO) |
| 4780 int N; | 5141 int N; |
| 4781 int amt; | 5142 int amt; |
| 4782 if( objc!=1 && objc!=2 ){ | 5143 if( objc!=1 && objc!=2 ){ |
| 4783 Tcl_WrongNumArgs(interp, 1, objv, "?N?"); | 5144 Tcl_WrongNumArgs(interp, 1, objv, "?N?"); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4794 return TCL_OK; | 5155 return TCL_OK; |
| 4795 } | 5156 } |
| 4796 | 5157 |
| 4797 | 5158 |
| 4798 /* | 5159 /* |
| 4799 ** Usage: sqlite3_db_release_memory DB | 5160 ** Usage: sqlite3_db_release_memory DB |
| 4800 ** | 5161 ** |
| 4801 ** Attempt to release memory currently held by database DB. Return the | 5162 ** Attempt to release memory currently held by database DB. Return the |
| 4802 ** result code (which in the current implementation is always zero). | 5163 ** result code (which in the current implementation is always zero). |
| 4803 */ | 5164 */ |
| 4804 static int test_db_release_memory( | 5165 static int SQLITE_TCLAPI test_db_release_memory( |
| 4805 void * clientData, | 5166 void * clientData, |
| 4806 Tcl_Interp *interp, | 5167 Tcl_Interp *interp, |
| 4807 int objc, | 5168 int objc, |
| 4808 Tcl_Obj *CONST objv[] | 5169 Tcl_Obj *CONST objv[] |
| 4809 ){ | 5170 ){ |
| 4810 sqlite3 *db; | 5171 sqlite3 *db; |
| 4811 int rc; | 5172 int rc; |
| 4812 if( objc!=2 ){ | 5173 if( objc!=2 ){ |
| 4813 Tcl_WrongNumArgs(interp, 1, objv, "DB"); | 5174 Tcl_WrongNumArgs(interp, 1, objv, "DB"); |
| 4814 return TCL_ERROR; | 5175 return TCL_ERROR; |
| 4815 } | 5176 } |
| 4816 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 5177 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 4817 rc = sqlite3_db_release_memory(db); | 5178 rc = sqlite3_db_release_memory(db); |
| 4818 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); | 5179 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); |
| 4819 return TCL_OK; | 5180 return TCL_OK; |
| 4820 } | 5181 } |
| 4821 | 5182 |
| 4822 /* | 5183 /* |
| 4823 ** Usage: sqlite3_db_cacheflush DB | 5184 ** Usage: sqlite3_db_cacheflush DB |
| 4824 ** | 5185 ** |
| 4825 ** Attempt to flush any dirty pages to disk. | 5186 ** Attempt to flush any dirty pages to disk. |
| 4826 */ | 5187 */ |
| 4827 static int test_db_cacheflush( | 5188 static int SQLITE_TCLAPI test_db_cacheflush( |
| 4828 void * clientData, | 5189 void * clientData, |
| 4829 Tcl_Interp *interp, | 5190 Tcl_Interp *interp, |
| 4830 int objc, | 5191 int objc, |
| 4831 Tcl_Obj *CONST objv[] | 5192 Tcl_Obj *CONST objv[] |
| 4832 ){ | 5193 ){ |
| 4833 sqlite3 *db; | 5194 sqlite3 *db; |
| 4834 int rc; | 5195 int rc; |
| 4835 if( objc!=2 ){ | 5196 if( objc!=2 ){ |
| 4836 Tcl_WrongNumArgs(interp, 1, objv, "DB"); | 5197 Tcl_WrongNumArgs(interp, 1, objv, "DB"); |
| 4837 return TCL_ERROR; | 5198 return TCL_ERROR; |
| 4838 } | 5199 } |
| 4839 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 5200 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 4840 rc = sqlite3_db_cacheflush(db); | 5201 rc = sqlite3_db_cacheflush(db); |
| 4841 if( rc ){ | 5202 if( rc ){ |
| 4842 Tcl_SetResult(interp, (char *)sqlite3ErrStr(rc), TCL_STATIC); | 5203 Tcl_SetResult(interp, (char *)sqlite3ErrStr(rc), TCL_STATIC); |
| 4843 return TCL_ERROR; | 5204 return TCL_ERROR; |
| 4844 } | 5205 } |
| 4845 | 5206 |
| 4846 Tcl_ResetResult(interp); | 5207 Tcl_ResetResult(interp); |
| 4847 return TCL_OK; | 5208 return TCL_OK; |
| 4848 } | 5209 } |
| 4849 | 5210 |
| 4850 /* | 5211 /* |
| 5212 ** Usage: sqlite3_system_errno DB |
| 5213 ** |
| 5214 ** Return the low-level system errno value. |
| 5215 */ |
| 5216 static int SQLITE_TCLAPI test_system_errno( |
| 5217 void * clientData, |
| 5218 Tcl_Interp *interp, |
| 5219 int objc, |
| 5220 Tcl_Obj *CONST objv[] |
| 5221 ){ |
| 5222 sqlite3 *db; |
| 5223 int iErrno; |
| 5224 if( objc!=2 ){ |
| 5225 Tcl_WrongNumArgs(interp, 1, objv, "DB"); |
| 5226 return TCL_ERROR; |
| 5227 } |
| 5228 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 5229 iErrno = sqlite3_system_errno(db); |
| 5230 Tcl_SetObjResult(interp, Tcl_NewIntObj(iErrno)); |
| 5231 return TCL_OK; |
| 5232 } |
| 5233 |
| 5234 /* |
| 4851 ** Usage: sqlite3_db_filename DB DBNAME | 5235 ** Usage: sqlite3_db_filename DB DBNAME |
| 4852 ** | 5236 ** |
| 4853 ** Return the name of a file associated with a database. | 5237 ** Return the name of a file associated with a database. |
| 4854 */ | 5238 */ |
| 4855 static int test_db_filename( | 5239 static int SQLITE_TCLAPI test_db_filename( |
| 4856 void * clientData, | 5240 void * clientData, |
| 4857 Tcl_Interp *interp, | 5241 Tcl_Interp *interp, |
| 4858 int objc, | 5242 int objc, |
| 4859 Tcl_Obj *CONST objv[] | 5243 Tcl_Obj *CONST objv[] |
| 4860 ){ | 5244 ){ |
| 4861 sqlite3 *db; | 5245 sqlite3 *db; |
| 4862 const char *zDbName; | 5246 const char *zDbName; |
| 4863 if( objc!=3 ){ | 5247 if( objc!=3 ){ |
| 4864 Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME"); | 5248 Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME"); |
| 4865 return TCL_ERROR; | 5249 return TCL_ERROR; |
| 4866 } | 5250 } |
| 4867 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 5251 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 4868 zDbName = Tcl_GetString(objv[2]); | 5252 zDbName = Tcl_GetString(objv[2]); |
| 4869 Tcl_AppendResult(interp, sqlite3_db_filename(db, zDbName), (void*)0); | 5253 Tcl_AppendResult(interp, sqlite3_db_filename(db, zDbName), (void*)0); |
| 4870 return TCL_OK; | 5254 return TCL_OK; |
| 4871 } | 5255 } |
| 4872 | 5256 |
| 4873 /* | 5257 /* |
| 4874 ** Usage: sqlite3_db_readonly DB DBNAME | 5258 ** Usage: sqlite3_db_readonly DB DBNAME |
| 4875 ** | 5259 ** |
| 4876 ** Return 1 or 0 if DBNAME is readonly or not. Return -1 if DBNAME does | 5260 ** Return 1 or 0 if DBNAME is readonly or not. Return -1 if DBNAME does |
| 4877 ** not exist. | 5261 ** not exist. |
| 4878 */ | 5262 */ |
| 4879 static int test_db_readonly( | 5263 static int SQLITE_TCLAPI test_db_readonly( |
| 4880 void * clientData, | 5264 void * clientData, |
| 4881 Tcl_Interp *interp, | 5265 Tcl_Interp *interp, |
| 4882 int objc, | 5266 int objc, |
| 4883 Tcl_Obj *CONST objv[] | 5267 Tcl_Obj *CONST objv[] |
| 4884 ){ | 5268 ){ |
| 4885 sqlite3 *db; | 5269 sqlite3 *db; |
| 4886 const char *zDbName; | 5270 const char *zDbName; |
| 4887 if( objc!=3 ){ | 5271 if( objc!=3 ){ |
| 4888 Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME"); | 5272 Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME"); |
| 4889 return TCL_ERROR; | 5273 return TCL_ERROR; |
| 4890 } | 5274 } |
| 4891 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 5275 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 4892 zDbName = Tcl_GetString(objv[2]); | 5276 zDbName = Tcl_GetString(objv[2]); |
| 4893 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_db_readonly(db, zDbName))); | 5277 Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_db_readonly(db, zDbName))); |
| 4894 return TCL_OK; | 5278 return TCL_OK; |
| 4895 } | 5279 } |
| 4896 | 5280 |
| 4897 /* | 5281 /* |
| 4898 ** Usage: sqlite3_soft_heap_limit ?N? | 5282 ** Usage: sqlite3_soft_heap_limit ?N? |
| 4899 ** | 5283 ** |
| 4900 ** Query or set the soft heap limit for the current thread. The | 5284 ** Query or set the soft heap limit for the current thread. The |
| 4901 ** limit is only changed if the N is present. The previous limit | 5285 ** limit is only changed if the N is present. The previous limit |
| 4902 ** is returned. | 5286 ** is returned. |
| 4903 */ | 5287 */ |
| 4904 static int test_soft_heap_limit( | 5288 static int SQLITE_TCLAPI test_soft_heap_limit( |
| 4905 void * clientData, | 5289 void * clientData, |
| 4906 Tcl_Interp *interp, | 5290 Tcl_Interp *interp, |
| 4907 int objc, | 5291 int objc, |
| 4908 Tcl_Obj *CONST objv[] | 5292 Tcl_Obj *CONST objv[] |
| 4909 ){ | 5293 ){ |
| 4910 sqlite3_int64 amt; | 5294 sqlite3_int64 amt; |
| 4911 Tcl_WideInt N = -1; | 5295 Tcl_WideInt N = -1; |
| 4912 if( objc!=1 && objc!=2 ){ | 5296 if( objc!=1 && objc!=2 ){ |
| 4913 Tcl_WrongNumArgs(interp, 1, objv, "?N?"); | 5297 Tcl_WrongNumArgs(interp, 1, objv, "?N?"); |
| 4914 return TCL_ERROR; | 5298 return TCL_ERROR; |
| 4915 } | 5299 } |
| 4916 if( objc==2 ){ | 5300 if( objc==2 ){ |
| 4917 if( Tcl_GetWideIntFromObj(interp, objv[1], &N) ) return TCL_ERROR; | 5301 if( Tcl_GetWideIntFromObj(interp, objv[1], &N) ) return TCL_ERROR; |
| 4918 } | 5302 } |
| 4919 amt = sqlite3_soft_heap_limit64(N); | 5303 amt = sqlite3_soft_heap_limit64(N); |
| 4920 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(amt)); | 5304 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(amt)); |
| 4921 return TCL_OK; | 5305 return TCL_OK; |
| 4922 } | 5306 } |
| 4923 | 5307 |
| 4924 /* | 5308 /* |
| 4925 ** Usage: sqlite3_thread_cleanup | 5309 ** Usage: sqlite3_thread_cleanup |
| 4926 ** | 5310 ** |
| 4927 ** Call the sqlite3_thread_cleanup API. | 5311 ** Call the sqlite3_thread_cleanup API. |
| 4928 */ | 5312 */ |
| 4929 static int test_thread_cleanup( | 5313 static int SQLITE_TCLAPI test_thread_cleanup( |
| 4930 void * clientData, | 5314 void * clientData, |
| 4931 Tcl_Interp *interp, | 5315 Tcl_Interp *interp, |
| 4932 int objc, | 5316 int objc, |
| 4933 Tcl_Obj *CONST objv[] | 5317 Tcl_Obj *CONST objv[] |
| 4934 ){ | 5318 ){ |
| 4935 #ifndef SQLITE_OMIT_DEPRECATED | 5319 #ifndef SQLITE_OMIT_DEPRECATED |
| 4936 sqlite3_thread_cleanup(); | 5320 sqlite3_thread_cleanup(); |
| 4937 #endif | 5321 #endif |
| 4938 return TCL_OK; | 5322 return TCL_OK; |
| 4939 } | 5323 } |
| 4940 | 5324 |
| 4941 /* | 5325 /* |
| 4942 ** Usage: sqlite3_pager_refcounts DB | 5326 ** Usage: sqlite3_pager_refcounts DB |
| 4943 ** | 5327 ** |
| 4944 ** Return a list of numbers which are the PagerRefcount for all | 5328 ** Return a list of numbers which are the PagerRefcount for all |
| 4945 ** pagers on each database connection. | 5329 ** pagers on each database connection. |
| 4946 */ | 5330 */ |
| 4947 static int test_pager_refcounts( | 5331 static int SQLITE_TCLAPI test_pager_refcounts( |
| 4948 void * clientData, | 5332 void * clientData, |
| 4949 Tcl_Interp *interp, | 5333 Tcl_Interp *interp, |
| 4950 int objc, | 5334 int objc, |
| 4951 Tcl_Obj *CONST objv[] | 5335 Tcl_Obj *CONST objv[] |
| 4952 ){ | 5336 ){ |
| 4953 sqlite3 *db; | 5337 sqlite3 *db; |
| 4954 int i; | 5338 int i; |
| 4955 int v, *a; | 5339 int v, *a; |
| 4956 Tcl_Obj *pResult; | 5340 Tcl_Obj *pResult; |
| 4957 | 5341 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 4983 ** | 5367 ** |
| 4984 ** Some TCL builds (ex: cygwin) do not support 64-bit integers. This | 5368 ** Some TCL builds (ex: cygwin) do not support 64-bit integers. This |
| 4985 ** leads to a number of test failures. The present command checks the | 5369 ** leads to a number of test failures. The present command checks the |
| 4986 ** TCL build to see whether or not it supports 64-bit integers. It | 5370 ** TCL build to see whether or not it supports 64-bit integers. It |
| 4987 ** returns TRUE if it does and FALSE if not. | 5371 ** returns TRUE if it does and FALSE if not. |
| 4988 ** | 5372 ** |
| 4989 ** This command is used to warn users that their TCL build is defective | 5373 ** This command is used to warn users that their TCL build is defective |
| 4990 ** and that the errors they are seeing in the test scripts might be | 5374 ** and that the errors they are seeing in the test scripts might be |
| 4991 ** a result of their defective TCL rather than problems in SQLite. | 5375 ** a result of their defective TCL rather than problems in SQLite. |
| 4992 */ | 5376 */ |
| 4993 static int working_64bit_int( | 5377 static int SQLITE_TCLAPI working_64bit_int( |
| 4994 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5378 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 4995 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5379 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 4996 int objc, /* Number of arguments */ | 5380 int objc, /* Number of arguments */ |
| 4997 Tcl_Obj *CONST objv[] /* Command arguments */ | 5381 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 4998 ){ | 5382 ){ |
| 4999 Tcl_Obj *pTestObj; | 5383 Tcl_Obj *pTestObj; |
| 5000 int working = 0; | 5384 int working = 0; |
| 5001 | 5385 |
| 5002 pTestObj = Tcl_NewWideIntObj(1000000*(i64)1234567890); | 5386 pTestObj = Tcl_NewWideIntObj(1000000*(i64)1234567890); |
| 5003 working = strcmp(Tcl_GetString(pTestObj), "1234567890000000")==0; | 5387 working = strcmp(Tcl_GetString(pTestObj), "1234567890000000")==0; |
| 5004 Tcl_DecrRefCount(pTestObj); | 5388 Tcl_DecrRefCount(pTestObj); |
| 5005 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(working)); | 5389 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(working)); |
| 5006 return TCL_OK; | 5390 return TCL_OK; |
| 5007 } | 5391 } |
| 5008 | 5392 |
| 5009 | 5393 |
| 5010 /* | 5394 /* |
| 5011 ** tclcmd: vfs_unlink_test | 5395 ** tclcmd: vfs_unlink_test |
| 5012 ** | 5396 ** |
| 5013 ** This TCL command unregisters the primary VFS and then registers | 5397 ** This TCL command unregisters the primary VFS and then registers |
| 5014 ** it back again. This is used to test the ability to register a | 5398 ** it back again. This is used to test the ability to register a |
| 5015 ** VFS when none are previously registered, and the ability to | 5399 ** VFS when none are previously registered, and the ability to |
| 5016 ** unregister the only available VFS. Ticket #2738 | 5400 ** unregister the only available VFS. Ticket #2738 |
| 5017 */ | 5401 */ |
| 5018 static int vfs_unlink_test( | 5402 static int SQLITE_TCLAPI vfs_unlink_test( |
| 5019 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5403 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5020 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5404 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5021 int objc, /* Number of arguments */ | 5405 int objc, /* Number of arguments */ |
| 5022 Tcl_Obj *CONST objv[] /* Command arguments */ | 5406 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5023 ){ | 5407 ){ |
| 5024 int i; | 5408 int i; |
| 5025 sqlite3_vfs *pMain; | 5409 sqlite3_vfs *pMain; |
| 5026 sqlite3_vfs *apVfs[20]; | 5410 sqlite3_vfs *apVfs[20]; |
| 5027 sqlite3_vfs one, two; | 5411 sqlite3_vfs one, two; |
| 5028 | 5412 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5110 | 5494 |
| 5111 return TCL_OK; | 5495 return TCL_OK; |
| 5112 } | 5496 } |
| 5113 | 5497 |
| 5114 /* | 5498 /* |
| 5115 ** tclcmd: vfs_initfail_test | 5499 ** tclcmd: vfs_initfail_test |
| 5116 ** | 5500 ** |
| 5117 ** This TCL command attempts to vfs_find and vfs_register when the | 5501 ** This TCL command attempts to vfs_find and vfs_register when the |
| 5118 ** sqlite3_initialize() interface is failing. All calls should fail. | 5502 ** sqlite3_initialize() interface is failing. All calls should fail. |
| 5119 */ | 5503 */ |
| 5120 static int vfs_initfail_test( | 5504 static int SQLITE_TCLAPI vfs_initfail_test( |
| 5121 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5505 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5122 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5506 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5123 int objc, /* Number of arguments */ | 5507 int objc, /* Number of arguments */ |
| 5124 Tcl_Obj *CONST objv[] /* Command arguments */ | 5508 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5125 ){ | 5509 ){ |
| 5126 sqlite3_vfs one; | 5510 sqlite3_vfs one; |
| 5127 one.zName = "__one"; | 5511 one.zName = "__one"; |
| 5128 | 5512 |
| 5129 if( sqlite3_vfs_find(0) ) return TCL_ERROR; | 5513 if( sqlite3_vfs_find(0) ) return TCL_ERROR; |
| 5130 sqlite3_vfs_register(&one, 0); | 5514 sqlite3_vfs_register(&one, 0); |
| 5131 if( sqlite3_vfs_find(0) ) return TCL_ERROR; | 5515 if( sqlite3_vfs_find(0) ) return TCL_ERROR; |
| 5132 sqlite3_vfs_register(&one, 1); | 5516 sqlite3_vfs_register(&one, 1); |
| 5133 if( sqlite3_vfs_find(0) ) return TCL_ERROR; | 5517 if( sqlite3_vfs_find(0) ) return TCL_ERROR; |
| 5134 return TCL_OK; | 5518 return TCL_OK; |
| 5135 } | 5519 } |
| 5136 | 5520 |
| 5137 /* | 5521 /* |
| 5138 ** Saved VFSes | 5522 ** Saved VFSes |
| 5139 */ | 5523 */ |
| 5140 static sqlite3_vfs *apVfs[20]; | 5524 static sqlite3_vfs *apVfs[20]; |
| 5141 static int nVfs = 0; | 5525 static int nVfs = 0; |
| 5142 | 5526 |
| 5143 /* | 5527 /* |
| 5144 ** tclcmd: vfs_unregister_all | 5528 ** tclcmd: vfs_unregister_all |
| 5145 ** | 5529 ** |
| 5146 ** Unregister all VFSes. | 5530 ** Unregister all VFSes. |
| 5147 */ | 5531 */ |
| 5148 static int vfs_unregister_all( | 5532 static int SQLITE_TCLAPI vfs_unregister_all( |
| 5149 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5533 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5150 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5534 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5151 int objc, /* Number of arguments */ | 5535 int objc, /* Number of arguments */ |
| 5152 Tcl_Obj *CONST objv[] /* Command arguments */ | 5536 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5153 ){ | 5537 ){ |
| 5154 int i; | 5538 int i; |
| 5155 for(i=0; i<ArraySize(apVfs); i++){ | 5539 for(i=0; i<ArraySize(apVfs); i++){ |
| 5156 apVfs[i] = sqlite3_vfs_find(0); | 5540 apVfs[i] = sqlite3_vfs_find(0); |
| 5157 if( apVfs[i]==0 ) break; | 5541 if( apVfs[i]==0 ) break; |
| 5158 sqlite3_vfs_unregister(apVfs[i]); | 5542 sqlite3_vfs_unregister(apVfs[i]); |
| 5159 } | 5543 } |
| 5160 nVfs = i; | 5544 nVfs = i; |
| 5161 return TCL_OK; | 5545 return TCL_OK; |
| 5162 } | 5546 } |
| 5163 /* | 5547 /* |
| 5164 ** tclcmd: vfs_reregister_all | 5548 ** tclcmd: vfs_reregister_all |
| 5165 ** | 5549 ** |
| 5166 ** Restore all VFSes that were removed using vfs_unregister_all | 5550 ** Restore all VFSes that were removed using vfs_unregister_all. Taking |
| 5551 ** care to put the linked list back together in the same order as it was |
| 5552 ** in before vfs_unregister_all was invoked. |
| 5167 */ | 5553 */ |
| 5168 static int vfs_reregister_all( | 5554 static int SQLITE_TCLAPI vfs_reregister_all( |
| 5169 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5555 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5170 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5556 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5171 int objc, /* Number of arguments */ | 5557 int objc, /* Number of arguments */ |
| 5172 Tcl_Obj *CONST objv[] /* Command arguments */ | 5558 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5173 ){ | 5559 ){ |
| 5174 int i; | 5560 int i; |
| 5175 for(i=0; i<nVfs; i++){ | 5561 for(i=nVfs-1; i>=0; i--){ |
| 5176 sqlite3_vfs_register(apVfs[i], i==0); | 5562 sqlite3_vfs_register(apVfs[i], 1); |
| 5177 } | 5563 } |
| 5178 return TCL_OK; | 5564 return TCL_OK; |
| 5179 } | 5565 } |
| 5180 | 5566 |
| 5181 | 5567 |
| 5182 /* | 5568 /* |
| 5183 ** tclcmd: file_control_test DB | 5569 ** tclcmd: file_control_test DB |
| 5184 ** | 5570 ** |
| 5185 ** This TCL command runs the sqlite3_file_control interface and | 5571 ** This TCL command runs the sqlite3_file_control interface and |
| 5186 ** verifies correct operation of the same. | 5572 ** verifies correct operation of the same. |
| 5187 */ | 5573 */ |
| 5188 static int file_control_test( | 5574 static int SQLITE_TCLAPI file_control_test( |
| 5189 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5575 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5190 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5576 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5191 int objc, /* Number of arguments */ | 5577 int objc, /* Number of arguments */ |
| 5192 Tcl_Obj *CONST objv[] /* Command arguments */ | 5578 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5193 ){ | 5579 ){ |
| 5194 int iArg = 0; | 5580 int iArg = 0; |
| 5195 sqlite3 *db; | 5581 sqlite3 *db; |
| 5196 int rc; | 5582 int rc; |
| 5197 | 5583 |
| 5198 if( objc!=2 ){ | 5584 if( objc!=2 ){ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5213 return TCL_OK; | 5599 return TCL_OK; |
| 5214 } | 5600 } |
| 5215 | 5601 |
| 5216 | 5602 |
| 5217 /* | 5603 /* |
| 5218 ** tclcmd: file_control_lasterrno_test DB | 5604 ** tclcmd: file_control_lasterrno_test DB |
| 5219 ** | 5605 ** |
| 5220 ** This TCL command runs the sqlite3_file_control interface and | 5606 ** This TCL command runs the sqlite3_file_control interface and |
| 5221 ** verifies correct operation of the SQLITE_LAST_ERRNO verb. | 5607 ** verifies correct operation of the SQLITE_LAST_ERRNO verb. |
| 5222 */ | 5608 */ |
| 5223 static int file_control_lasterrno_test( | 5609 static int SQLITE_TCLAPI file_control_lasterrno_test( |
| 5224 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5610 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5225 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5611 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5226 int objc, /* Number of arguments */ | 5612 int objc, /* Number of arguments */ |
| 5227 Tcl_Obj *CONST objv[] /* Command arguments */ | 5613 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5228 ){ | 5614 ){ |
| 5229 int iArg = 0; | 5615 int iArg = 0; |
| 5230 sqlite3 *db; | 5616 sqlite3 *db; |
| 5231 int rc; | 5617 int rc; |
| 5232 | 5618 |
| 5233 if( objc!=2 ){ | 5619 if( objc!=2 ){ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 5251 return TCL_OK; | 5637 return TCL_OK; |
| 5252 } | 5638 } |
| 5253 | 5639 |
| 5254 /* | 5640 /* |
| 5255 ** tclcmd: file_control_chunksize_test DB DBNAME SIZE | 5641 ** tclcmd: file_control_chunksize_test DB DBNAME SIZE |
| 5256 ** | 5642 ** |
| 5257 ** This TCL command runs the sqlite3_file_control interface and | 5643 ** This TCL command runs the sqlite3_file_control interface and |
| 5258 ** verifies correct operation of the SQLITE_GET_LOCKPROXYFILE and | 5644 ** verifies correct operation of the SQLITE_GET_LOCKPROXYFILE and |
| 5259 ** SQLITE_SET_LOCKPROXYFILE verbs. | 5645 ** SQLITE_SET_LOCKPROXYFILE verbs. |
| 5260 */ | 5646 */ |
| 5261 static int file_control_chunksize_test( | 5647 static int SQLITE_TCLAPI file_control_chunksize_test( |
| 5262 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5648 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5263 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5649 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5264 int objc, /* Number of arguments */ | 5650 int objc, /* Number of arguments */ |
| 5265 Tcl_Obj *CONST objv[] /* Command arguments */ | 5651 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5266 ){ | 5652 ){ |
| 5267 int nSize; /* New chunk size */ | 5653 int nSize; /* New chunk size */ |
| 5268 char *zDb; /* Db name ("main", "temp" etc.) */ | 5654 char *zDb; /* Db name ("main", "temp" etc.) */ |
| 5269 sqlite3 *db; /* Database handle */ | 5655 sqlite3 *db; /* Database handle */ |
| 5270 int rc; /* file_control() return code */ | 5656 int rc; /* file_control() return code */ |
| 5271 | 5657 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5288 } | 5674 } |
| 5289 return TCL_OK; | 5675 return TCL_OK; |
| 5290 } | 5676 } |
| 5291 | 5677 |
| 5292 /* | 5678 /* |
| 5293 ** tclcmd: file_control_sizehint_test DB DBNAME SIZE | 5679 ** tclcmd: file_control_sizehint_test DB DBNAME SIZE |
| 5294 ** | 5680 ** |
| 5295 ** This TCL command runs the sqlite3_file_control interface | 5681 ** This TCL command runs the sqlite3_file_control interface |
| 5296 ** with SQLITE_FCNTL_SIZE_HINT | 5682 ** with SQLITE_FCNTL_SIZE_HINT |
| 5297 */ | 5683 */ |
| 5298 static int file_control_sizehint_test( | 5684 static int SQLITE_TCLAPI file_control_sizehint_test( |
| 5299 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5685 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5300 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5686 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5301 int objc, /* Number of arguments */ | 5687 int objc, /* Number of arguments */ |
| 5302 Tcl_Obj *CONST objv[] /* Command arguments */ | 5688 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5303 ){ | 5689 ){ |
| 5304 Tcl_WideInt nSize; /* Hinted size */ | 5690 Tcl_WideInt nSize; /* Hinted size */ |
| 5305 char *zDb; /* Db name ("main", "temp" etc.) */ | 5691 char *zDb; /* Db name ("main", "temp" etc.) */ |
| 5306 sqlite3 *db; /* Database handle */ | 5692 sqlite3 *db; /* Database handle */ |
| 5307 int rc; /* file_control() return code */ | 5693 int rc; /* file_control() return code */ |
| 5308 | 5694 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 5326 return TCL_OK; | 5712 return TCL_OK; |
| 5327 } | 5713 } |
| 5328 | 5714 |
| 5329 /* | 5715 /* |
| 5330 ** tclcmd: file_control_lockproxy_test DB PWD | 5716 ** tclcmd: file_control_lockproxy_test DB PWD |
| 5331 ** | 5717 ** |
| 5332 ** This TCL command runs the sqlite3_file_control interface and | 5718 ** This TCL command runs the sqlite3_file_control interface and |
| 5333 ** verifies correct operation of the SQLITE_GET_LOCKPROXYFILE and | 5719 ** verifies correct operation of the SQLITE_GET_LOCKPROXYFILE and |
| 5334 ** SQLITE_SET_LOCKPROXYFILE verbs. | 5720 ** SQLITE_SET_LOCKPROXYFILE verbs. |
| 5335 */ | 5721 */ |
| 5336 static int file_control_lockproxy_test( | 5722 static int SQLITE_TCLAPI file_control_lockproxy_test( |
| 5337 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5723 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5338 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5724 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5339 int objc, /* Number of arguments */ | 5725 int objc, /* Number of arguments */ |
| 5340 Tcl_Obj *CONST objv[] /* Command arguments */ | 5726 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5341 ){ | 5727 ){ |
| 5342 sqlite3 *db; | 5728 sqlite3 *db; |
| 5343 | 5729 |
| 5344 if( objc!=3 ){ | 5730 if( objc!=3 ){ |
| 5345 Tcl_AppendResult(interp, "wrong # args: should be \"", | 5731 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 5346 Tcl_GetStringFromObj(objv[0], 0), " DB PWD", 0); | 5732 Tcl_GetStringFromObj(objv[0], 0), " DB PWD", 0); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5396 return TCL_OK; | 5782 return TCL_OK; |
| 5397 } | 5783 } |
| 5398 | 5784 |
| 5399 #if SQLITE_OS_WIN | 5785 #if SQLITE_OS_WIN |
| 5400 /* | 5786 /* |
| 5401 ** tclcmd: file_control_win32_av_retry DB NRETRY DELAY | 5787 ** tclcmd: file_control_win32_av_retry DB NRETRY DELAY |
| 5402 ** | 5788 ** |
| 5403 ** This TCL command runs the sqlite3_file_control interface with | 5789 ** This TCL command runs the sqlite3_file_control interface with |
| 5404 ** the SQLITE_FCNTL_WIN32_AV_RETRY opcode. | 5790 ** the SQLITE_FCNTL_WIN32_AV_RETRY opcode. |
| 5405 */ | 5791 */ |
| 5406 static int file_control_win32_av_retry( | 5792 static int SQLITE_TCLAPI file_control_win32_av_retry( |
| 5407 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5793 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5408 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5794 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5409 int objc, /* Number of arguments */ | 5795 int objc, /* Number of arguments */ |
| 5410 Tcl_Obj *CONST objv[] /* Command arguments */ | 5796 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5411 ){ | 5797 ){ |
| 5412 sqlite3 *db; | 5798 sqlite3 *db; |
| 5413 int rc; | 5799 int rc; |
| 5414 int a[2]; | 5800 int a[2]; |
| 5415 char z[100]; | 5801 char z[100]; |
| 5416 | 5802 |
| 5417 if( objc!=4 ){ | 5803 if( objc!=4 ){ |
| 5418 Tcl_AppendResult(interp, "wrong # args: should be \"", | 5804 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 5419 Tcl_GetStringFromObj(objv[0], 0), " DB NRETRY DELAY", 0); | 5805 Tcl_GetStringFromObj(objv[0], 0), " DB NRETRY DELAY", 0); |
| 5420 return TCL_ERROR; | 5806 return TCL_ERROR; |
| 5421 } | 5807 } |
| 5422 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ | 5808 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ |
| 5423 return TCL_ERROR; | 5809 return TCL_ERROR; |
| 5424 } | 5810 } |
| 5425 if( Tcl_GetIntFromObj(interp, objv[2], &a[0]) ) return TCL_ERROR; | 5811 if( Tcl_GetIntFromObj(interp, objv[2], &a[0]) ) return TCL_ERROR; |
| 5426 if( Tcl_GetIntFromObj(interp, objv[3], &a[1]) ) return TCL_ERROR; | 5812 if( Tcl_GetIntFromObj(interp, objv[3], &a[1]) ) return TCL_ERROR; |
| 5427 rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_WIN32_AV_RETRY, (void*)a); | 5813 rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_WIN32_AV_RETRY, (void*)a); |
| 5428 sqlite3_snprintf(sizeof(z), z, "%d %d %d", rc, a[0], a[1]); | 5814 sqlite3_snprintf(sizeof(z), z, "%d %d %d", rc, a[0], a[1]); |
| 5429 Tcl_AppendResult(interp, z, (char*)0); | 5815 Tcl_AppendResult(interp, z, (char*)0); |
| 5430 return TCL_OK; | 5816 return TCL_OK; |
| 5431 } | 5817 } |
| 5432 | 5818 |
| 5433 /* | 5819 /* |
| 5820 ** tclcmd: file_control_win32_get_handle DB |
| 5821 ** |
| 5822 ** This TCL command runs the sqlite3_file_control interface with |
| 5823 ** the SQLITE_FCNTL_WIN32_GET_HANDLE opcode. |
| 5824 */ |
| 5825 static int file_control_win32_get_handle( |
| 5826 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5827 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5828 int objc, /* Number of arguments */ |
| 5829 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5830 ){ |
| 5831 sqlite3 *db; |
| 5832 int rc; |
| 5833 HANDLE hFile = NULL; |
| 5834 char z[100]; |
| 5835 |
| 5836 if( objc!=2 ){ |
| 5837 Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 5838 Tcl_GetStringFromObj(objv[0], 0), " DB", 0); |
| 5839 return TCL_ERROR; |
| 5840 } |
| 5841 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ |
| 5842 return TCL_ERROR; |
| 5843 } |
| 5844 rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_WIN32_GET_HANDLE, |
| 5845 (void*)&hFile); |
| 5846 sqlite3_snprintf(sizeof(z), z, "%d %p", rc, (void*)hFile); |
| 5847 Tcl_AppendResult(interp, z, (char*)0); |
| 5848 return TCL_OK; |
| 5849 } |
| 5850 |
| 5851 /* |
| 5434 ** tclcmd: file_control_win32_set_handle DB HANDLE | 5852 ** tclcmd: file_control_win32_set_handle DB HANDLE |
| 5435 ** | 5853 ** |
| 5436 ** This TCL command runs the sqlite3_file_control interface with | 5854 ** This TCL command runs the sqlite3_file_control interface with |
| 5437 ** the SQLITE_FCNTL_WIN32_SET_HANDLE opcode. | 5855 ** the SQLITE_FCNTL_WIN32_SET_HANDLE opcode. |
| 5438 */ | 5856 */ |
| 5439 static int file_control_win32_set_handle( | 5857 static int SQLITE_TCLAPI file_control_win32_set_handle( |
| 5440 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5858 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5441 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5859 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5442 int objc, /* Number of arguments */ | 5860 int objc, /* Number of arguments */ |
| 5443 Tcl_Obj *CONST objv[] /* Command arguments */ | 5861 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5444 ){ | 5862 ){ |
| 5445 sqlite3 *db; | 5863 sqlite3 *db; |
| 5446 int rc; | 5864 int rc; |
| 5447 HANDLE hFile = NULL; | 5865 HANDLE hFile = NULL; |
| 5448 char z[100]; | 5866 char z[100]; |
| 5449 | 5867 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5465 return TCL_OK; | 5883 return TCL_OK; |
| 5466 } | 5884 } |
| 5467 #endif | 5885 #endif |
| 5468 | 5886 |
| 5469 /* | 5887 /* |
| 5470 ** tclcmd: file_control_persist_wal DB PERSIST-FLAG | 5888 ** tclcmd: file_control_persist_wal DB PERSIST-FLAG |
| 5471 ** | 5889 ** |
| 5472 ** This TCL command runs the sqlite3_file_control interface with | 5890 ** This TCL command runs the sqlite3_file_control interface with |
| 5473 ** the SQLITE_FCNTL_PERSIST_WAL opcode. | 5891 ** the SQLITE_FCNTL_PERSIST_WAL opcode. |
| 5474 */ | 5892 */ |
| 5475 static int file_control_persist_wal( | 5893 static int SQLITE_TCLAPI file_control_persist_wal( |
| 5476 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5894 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5477 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5895 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5478 int objc, /* Number of arguments */ | 5896 int objc, /* Number of arguments */ |
| 5479 Tcl_Obj *CONST objv[] /* Command arguments */ | 5897 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5480 ){ | 5898 ){ |
| 5481 sqlite3 *db; | 5899 sqlite3 *db; |
| 5482 int rc; | 5900 int rc; |
| 5483 int bPersist; | 5901 int bPersist; |
| 5484 char z[100]; | 5902 char z[100]; |
| 5485 | 5903 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5497 Tcl_AppendResult(interp, z, (char*)0); | 5915 Tcl_AppendResult(interp, z, (char*)0); |
| 5498 return TCL_OK; | 5916 return TCL_OK; |
| 5499 } | 5917 } |
| 5500 | 5918 |
| 5501 /* | 5919 /* |
| 5502 ** tclcmd: file_control_powersafe_overwrite DB PSOW-FLAG | 5920 ** tclcmd: file_control_powersafe_overwrite DB PSOW-FLAG |
| 5503 ** | 5921 ** |
| 5504 ** This TCL command runs the sqlite3_file_control interface with | 5922 ** This TCL command runs the sqlite3_file_control interface with |
| 5505 ** the SQLITE_FCNTL_POWERSAFE_OVERWRITE opcode. | 5923 ** the SQLITE_FCNTL_POWERSAFE_OVERWRITE opcode. |
| 5506 */ | 5924 */ |
| 5507 static int file_control_powersafe_overwrite( | 5925 static int SQLITE_TCLAPI file_control_powersafe_overwrite( |
| 5508 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5926 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5509 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5927 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5510 int objc, /* Number of arguments */ | 5928 int objc, /* Number of arguments */ |
| 5511 Tcl_Obj *CONST objv[] /* Command arguments */ | 5929 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5512 ){ | 5930 ){ |
| 5513 sqlite3 *db; | 5931 sqlite3 *db; |
| 5514 int rc; | 5932 int rc; |
| 5515 int b; | 5933 int b; |
| 5516 char z[100]; | 5934 char z[100]; |
| 5517 | 5935 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5529 Tcl_AppendResult(interp, z, (char*)0); | 5947 Tcl_AppendResult(interp, z, (char*)0); |
| 5530 return TCL_OK; | 5948 return TCL_OK; |
| 5531 } | 5949 } |
| 5532 | 5950 |
| 5533 | 5951 |
| 5534 /* | 5952 /* |
| 5535 ** tclcmd: file_control_vfsname DB ?AUXDB? | 5953 ** tclcmd: file_control_vfsname DB ?AUXDB? |
| 5536 ** | 5954 ** |
| 5537 ** Return a string that describes the stack of VFSes. | 5955 ** Return a string that describes the stack of VFSes. |
| 5538 */ | 5956 */ |
| 5539 static int file_control_vfsname( | 5957 static int SQLITE_TCLAPI file_control_vfsname( |
| 5540 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5958 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5541 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5959 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5542 int objc, /* Number of arguments */ | 5960 int objc, /* Number of arguments */ |
| 5543 Tcl_Obj *CONST objv[] /* Command arguments */ | 5961 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5544 ){ | 5962 ){ |
| 5545 sqlite3 *db; | 5963 sqlite3 *db; |
| 5546 const char *zDbName = "main"; | 5964 const char *zDbName = "main"; |
| 5547 char *zVfsName = 0; | 5965 char *zVfsName = 0; |
| 5548 | 5966 |
| 5549 if( objc!=2 && objc!=3 ){ | 5967 if( objc!=2 && objc!=3 ){ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5561 Tcl_AppendResult(interp, zVfsName, (char*)0); | 5979 Tcl_AppendResult(interp, zVfsName, (char*)0); |
| 5562 sqlite3_free(zVfsName); | 5980 sqlite3_free(zVfsName); |
| 5563 return TCL_OK; | 5981 return TCL_OK; |
| 5564 } | 5982 } |
| 5565 | 5983 |
| 5566 /* | 5984 /* |
| 5567 ** tclcmd: file_control_tempfilename DB ?AUXDB? | 5985 ** tclcmd: file_control_tempfilename DB ?AUXDB? |
| 5568 ** | 5986 ** |
| 5569 ** Return a string that is a temporary filename | 5987 ** Return a string that is a temporary filename |
| 5570 */ | 5988 */ |
| 5571 static int file_control_tempfilename( | 5989 static int SQLITE_TCLAPI file_control_tempfilename( |
| 5572 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 5990 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5573 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 5991 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5574 int objc, /* Number of arguments */ | 5992 int objc, /* Number of arguments */ |
| 5575 Tcl_Obj *CONST objv[] /* Command arguments */ | 5993 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5576 ){ | 5994 ){ |
| 5577 sqlite3 *db; | 5995 sqlite3 *db; |
| 5578 const char *zDbName = "main"; | 5996 const char *zDbName = "main"; |
| 5579 char *zTName = 0; | 5997 char *zTName = 0; |
| 5580 | 5998 |
| 5581 if( objc!=2 && objc!=3 ){ | 5999 if( objc!=2 && objc!=3 ){ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5594 sqlite3_free(zTName); | 6012 sqlite3_free(zTName); |
| 5595 return TCL_OK; | 6013 return TCL_OK; |
| 5596 } | 6014 } |
| 5597 | 6015 |
| 5598 | 6016 |
| 5599 /* | 6017 /* |
| 5600 ** tclcmd: sqlite3_vfs_list | 6018 ** tclcmd: sqlite3_vfs_list |
| 5601 ** | 6019 ** |
| 5602 ** Return a tcl list containing the names of all registered vfs's. | 6020 ** Return a tcl list containing the names of all registered vfs's. |
| 5603 */ | 6021 */ |
| 5604 static int vfs_list( | 6022 static int SQLITE_TCLAPI vfs_list( |
| 5605 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 6023 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5606 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 6024 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5607 int objc, /* Number of arguments */ | 6025 int objc, /* Number of arguments */ |
| 5608 Tcl_Obj *CONST objv[] /* Command arguments */ | 6026 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5609 ){ | 6027 ){ |
| 5610 sqlite3_vfs *pVfs; | 6028 sqlite3_vfs *pVfs; |
| 5611 Tcl_Obj *pRet = Tcl_NewObj(); | 6029 Tcl_Obj *pRet = Tcl_NewObj(); |
| 5612 if( objc!=1 ){ | 6030 if( objc!=1 ){ |
| 5613 Tcl_WrongNumArgs(interp, 1, objv, ""); | 6031 Tcl_WrongNumArgs(interp, 1, objv, ""); |
| 5614 return TCL_ERROR; | 6032 return TCL_ERROR; |
| 5615 } | 6033 } |
| 5616 for(pVfs=sqlite3_vfs_find(0); pVfs; pVfs=pVfs->pNext){ | 6034 for(pVfs=sqlite3_vfs_find(0); pVfs; pVfs=pVfs->pNext){ |
| 5617 Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(pVfs->zName, -1)); | 6035 Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(pVfs->zName, -1)); |
| 5618 } | 6036 } |
| 5619 Tcl_SetObjResult(interp, pRet); | 6037 Tcl_SetObjResult(interp, pRet); |
| 5620 return TCL_OK; | 6038 return TCL_OK; |
| 5621 } | 6039 } |
| 5622 | 6040 |
| 5623 /* | 6041 /* |
| 5624 ** tclcmd: sqlite3_limit DB ID VALUE | 6042 ** tclcmd: sqlite3_limit DB ID VALUE |
| 5625 ** | 6043 ** |
| 5626 ** This TCL command runs the sqlite3_limit interface and | 6044 ** This TCL command runs the sqlite3_limit interface and |
| 5627 ** verifies correct operation of the same. | 6045 ** verifies correct operation of the same. |
| 5628 */ | 6046 */ |
| 5629 static int test_limit( | 6047 static int SQLITE_TCLAPI test_limit( |
| 5630 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 6048 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5631 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 6049 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5632 int objc, /* Number of arguments */ | 6050 int objc, /* Number of arguments */ |
| 5633 Tcl_Obj *CONST objv[] /* Command arguments */ | 6051 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5634 ){ | 6052 ){ |
| 5635 sqlite3 *db; | 6053 sqlite3 *db; |
| 5636 int rc; | 6054 int rc; |
| 5637 static const struct { | 6055 static const struct { |
| 5638 char *zName; | 6056 char *zName; |
| 5639 int id; | 6057 int id; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5682 return TCL_OK; | 6100 return TCL_OK; |
| 5683 } | 6101 } |
| 5684 | 6102 |
| 5685 /* | 6103 /* |
| 5686 ** tclcmd: save_prng_state | 6104 ** tclcmd: save_prng_state |
| 5687 ** | 6105 ** |
| 5688 ** Save the state of the pseudo-random number generator. | 6106 ** Save the state of the pseudo-random number generator. |
| 5689 ** At the same time, verify that sqlite3_test_control works even when | 6107 ** At the same time, verify that sqlite3_test_control works even when |
| 5690 ** called with an out-of-range opcode. | 6108 ** called with an out-of-range opcode. |
| 5691 */ | 6109 */ |
| 5692 static int save_prng_state( | 6110 static int SQLITE_TCLAPI save_prng_state( |
| 5693 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 6111 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5694 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 6112 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5695 int objc, /* Number of arguments */ | 6113 int objc, /* Number of arguments */ |
| 5696 Tcl_Obj *CONST objv[] /* Command arguments */ | 6114 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5697 ){ | 6115 ){ |
| 5698 int rc = sqlite3_test_control(9999); | 6116 int rc = sqlite3_test_control(9999); |
| 5699 assert( rc==0 ); | 6117 assert( rc==0 ); |
| 5700 rc = sqlite3_test_control(-1); | 6118 rc = sqlite3_test_control(-1); |
| 5701 assert( rc==0 ); | 6119 assert( rc==0 ); |
| 5702 sqlite3_test_control(SQLITE_TESTCTRL_PRNG_SAVE); | 6120 sqlite3_test_control(SQLITE_TESTCTRL_PRNG_SAVE); |
| 5703 return TCL_OK; | 6121 return TCL_OK; |
| 5704 } | 6122 } |
| 5705 /* | 6123 /* |
| 5706 ** tclcmd: restore_prng_state | 6124 ** tclcmd: restore_prng_state |
| 5707 */ | 6125 */ |
| 5708 static int restore_prng_state( | 6126 static int SQLITE_TCLAPI restore_prng_state( |
| 5709 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 6127 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5710 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 6128 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5711 int objc, /* Number of arguments */ | 6129 int objc, /* Number of arguments */ |
| 5712 Tcl_Obj *CONST objv[] /* Command arguments */ | 6130 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5713 ){ | 6131 ){ |
| 5714 sqlite3_test_control(SQLITE_TESTCTRL_PRNG_RESTORE); | 6132 sqlite3_test_control(SQLITE_TESTCTRL_PRNG_RESTORE); |
| 5715 return TCL_OK; | 6133 return TCL_OK; |
| 5716 } | 6134 } |
| 5717 /* | 6135 /* |
| 5718 ** tclcmd: reset_prng_state | 6136 ** tclcmd: reset_prng_state |
| 5719 */ | 6137 */ |
| 5720 static int reset_prng_state( | 6138 static int SQLITE_TCLAPI reset_prng_state( |
| 5721 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 6139 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5722 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 6140 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5723 int objc, /* Number of arguments */ | 6141 int objc, /* Number of arguments */ |
| 5724 Tcl_Obj *CONST objv[] /* Command arguments */ | 6142 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5725 ){ | 6143 ){ |
| 5726 sqlite3_test_control(SQLITE_TESTCTRL_PRNG_RESET); | 6144 sqlite3_test_control(SQLITE_TESTCTRL_PRNG_RESET); |
| 5727 return TCL_OK; | 6145 return TCL_OK; |
| 5728 } | 6146 } |
| 5729 | 6147 |
| 5730 /* | 6148 /* |
| 5731 ** tclcmd: database_may_be_corrupt | 6149 ** tclcmd: database_may_be_corrupt |
| 5732 ** | 6150 ** |
| 5733 ** Indicate that database files might be corrupt. In other words, set the norma
l | 6151 ** Indicate that database files might be corrupt. In other words, set the norma
l |
| 5734 ** state of operation. | 6152 ** state of operation. |
| 5735 */ | 6153 */ |
| 5736 static int database_may_be_corrupt( | 6154 static int SQLITE_TCLAPI database_may_be_corrupt( |
| 5737 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 6155 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5738 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 6156 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5739 int objc, /* Number of arguments */ | 6157 int objc, /* Number of arguments */ |
| 5740 Tcl_Obj *CONST objv[] /* Command arguments */ | 6158 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5741 ){ | 6159 ){ |
| 5742 sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, 0); | 6160 sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, 0); |
| 5743 return TCL_OK; | 6161 return TCL_OK; |
| 5744 } | 6162 } |
| 5745 /* | 6163 /* |
| 5746 ** tclcmd: database_never_corrupt | 6164 ** tclcmd: database_never_corrupt |
| 5747 ** | 6165 ** |
| 5748 ** Indicate that database files are always well-formed. This enables extra asse
rt() | 6166 ** Indicate that database files are always well-formed. This enables extra asse
rt() |
| 5749 ** statements that test conditions that are always true for well-formed database
s. | 6167 ** statements that test conditions that are always true for well-formed database
s. |
| 5750 */ | 6168 */ |
| 5751 static int database_never_corrupt( | 6169 static int SQLITE_TCLAPI database_never_corrupt( |
| 5752 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 6170 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5753 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 6171 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5754 int objc, /* Number of arguments */ | 6172 int objc, /* Number of arguments */ |
| 5755 Tcl_Obj *CONST objv[] /* Command arguments */ | 6173 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5756 ){ | 6174 ){ |
| 5757 sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, 1); | 6175 sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, 1); |
| 5758 return TCL_OK; | 6176 return TCL_OK; |
| 5759 } | 6177 } |
| 5760 | 6178 |
| 5761 /* | 6179 /* |
| 5762 ** tclcmd: pcache_stats | 6180 ** tclcmd: pcache_stats |
| 5763 */ | 6181 */ |
| 5764 static int test_pcache_stats( | 6182 static int SQLITE_TCLAPI test_pcache_stats( |
| 5765 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ | 6183 ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ |
| 5766 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 6184 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5767 int objc, /* Number of arguments */ | 6185 int objc, /* Number of arguments */ |
| 5768 Tcl_Obj *CONST objv[] /* Command arguments */ | 6186 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5769 ){ | 6187 ){ |
| 5770 int nMin; | 6188 int nMin; |
| 5771 int nMax; | 6189 int nMax; |
| 5772 int nCurrent; | 6190 int nCurrent; |
| 5773 int nRecyclable; | 6191 int nRecyclable; |
| 5774 Tcl_Obj *pRet; | 6192 Tcl_Obj *pRet; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5796 for(ii=0; ii<nArg; ii++){ | 6214 for(ii=0; ii<nArg; ii++){ |
| 5797 Tcl_EvalEx((Tcl_Interp *)aArg[ii], "unlock_notify", -1, TCL_EVAL_GLOBAL); | 6215 Tcl_EvalEx((Tcl_Interp *)aArg[ii], "unlock_notify", -1, TCL_EVAL_GLOBAL); |
| 5798 } | 6216 } |
| 5799 } | 6217 } |
| 5800 #endif /* SQLITE_ENABLE_UNLOCK_NOTIFY */ | 6218 #endif /* SQLITE_ENABLE_UNLOCK_NOTIFY */ |
| 5801 | 6219 |
| 5802 /* | 6220 /* |
| 5803 ** tclcmd: sqlite3_unlock_notify db | 6221 ** tclcmd: sqlite3_unlock_notify db |
| 5804 */ | 6222 */ |
| 5805 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY | 6223 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 5806 static int test_unlock_notify( | 6224 static int SQLITE_TCLAPI test_unlock_notify( |
| 5807 ClientData clientData, /* Unused */ | 6225 ClientData clientData, /* Unused */ |
| 5808 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 6226 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5809 int objc, /* Number of arguments */ | 6227 int objc, /* Number of arguments */ |
| 5810 Tcl_Obj *CONST objv[] /* Command arguments */ | 6228 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5811 ){ | 6229 ){ |
| 5812 sqlite3 *db; | 6230 sqlite3 *db; |
| 5813 int rc; | 6231 int rc; |
| 5814 | 6232 |
| 5815 if( objc!=2 ){ | 6233 if( objc!=2 ){ |
| 5816 Tcl_WrongNumArgs(interp, 1, objv, "DB"); | 6234 Tcl_WrongNumArgs(interp, 1, objv, "DB"); |
| 5817 return TCL_ERROR; | 6235 return TCL_ERROR; |
| 5818 } | 6236 } |
| 5819 | 6237 |
| 5820 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ | 6238 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ |
| 5821 return TCL_ERROR; | 6239 return TCL_ERROR; |
| 5822 } | 6240 } |
| 5823 rc = sqlite3_unlock_notify(db, test_unlock_notify_cb, (void *)interp); | 6241 rc = sqlite3_unlock_notify(db, test_unlock_notify_cb, (void *)interp); |
| 5824 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); | 6242 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); |
| 5825 return TCL_OK; | 6243 return TCL_OK; |
| 5826 } | 6244 } |
| 5827 #endif | 6245 #endif |
| 5828 | 6246 |
| 5829 /* | 6247 /* |
| 5830 ** tclcmd: sqlite3_wal_checkpoint db ?NAME? | 6248 ** tclcmd: sqlite3_wal_checkpoint db ?NAME? |
| 5831 */ | 6249 */ |
| 5832 static int test_wal_checkpoint( | 6250 static int SQLITE_TCLAPI test_wal_checkpoint( |
| 5833 ClientData clientData, /* Unused */ | 6251 ClientData clientData, /* Unused */ |
| 5834 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 6252 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5835 int objc, /* Number of arguments */ | 6253 int objc, /* Number of arguments */ |
| 5836 Tcl_Obj *CONST objv[] /* Command arguments */ | 6254 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5837 ){ | 6255 ){ |
| 5838 char *zDb = 0; | 6256 char *zDb = 0; |
| 5839 sqlite3 *db; | 6257 sqlite3 *db; |
| 5840 int rc; | 6258 int rc; |
| 5841 | 6259 |
| 5842 if( objc!=3 && objc!=2 ){ | 6260 if( objc!=3 && objc!=2 ){ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 5866 ** If wal_checkpoint_v2() returns any value other than SQLITE_BUSY or | 6284 ** If wal_checkpoint_v2() returns any value other than SQLITE_BUSY or |
| 5867 ** SQLITE_OK, then this command returns TCL_ERROR. The Tcl result is set | 6285 ** SQLITE_OK, then this command returns TCL_ERROR. The Tcl result is set |
| 5868 ** to the error message obtained from sqlite3_errmsg(). | 6286 ** to the error message obtained from sqlite3_errmsg(). |
| 5869 ** | 6287 ** |
| 5870 ** Otherwise, this command returns a list of three integers. The first integer | 6288 ** Otherwise, this command returns a list of three integers. The first integer |
| 5871 ** is 1 if SQLITE_BUSY was returned, or 0 otherwise. The following two integers | 6289 ** is 1 if SQLITE_BUSY was returned, or 0 otherwise. The following two integers |
| 5872 ** are the values returned via the output parameters by wal_checkpoint_v2() - | 6290 ** are the values returned via the output parameters by wal_checkpoint_v2() - |
| 5873 ** the number of frames in the log and the number of frames in the log | 6291 ** the number of frames in the log and the number of frames in the log |
| 5874 ** that have been checkpointed. | 6292 ** that have been checkpointed. |
| 5875 */ | 6293 */ |
| 5876 static int test_wal_checkpoint_v2( | 6294 static int SQLITE_TCLAPI test_wal_checkpoint_v2( |
| 5877 ClientData clientData, /* Unused */ | 6295 ClientData clientData, /* Unused */ |
| 5878 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 6296 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5879 int objc, /* Number of arguments */ | 6297 int objc, /* Number of arguments */ |
| 5880 Tcl_Obj *CONST objv[] /* Command arguments */ | 6298 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5881 ){ | 6299 ){ |
| 5882 char *zDb = 0; | 6300 char *zDb = 0; |
| 5883 sqlite3 *db; | 6301 sqlite3 *db; |
| 5884 int rc; | 6302 int rc; |
| 5885 | 6303 |
| 5886 int eMode; | 6304 int eMode; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5922 Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(nLog)); | 6340 Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(nLog)); |
| 5923 Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(nCkpt)); | 6341 Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(nCkpt)); |
| 5924 Tcl_SetObjResult(interp, pRet); | 6342 Tcl_SetObjResult(interp, pRet); |
| 5925 | 6343 |
| 5926 return TCL_OK; | 6344 return TCL_OK; |
| 5927 } | 6345 } |
| 5928 | 6346 |
| 5929 /* | 6347 /* |
| 5930 ** tclcmd: sqlite3_wal_autocheckpoint db VALUE | 6348 ** tclcmd: sqlite3_wal_autocheckpoint db VALUE |
| 5931 */ | 6349 */ |
| 5932 static int test_wal_autocheckpoint( | 6350 static int SQLITE_TCLAPI test_wal_autocheckpoint( |
| 5933 ClientData clientData, /* Unused */ | 6351 ClientData clientData, /* Unused */ |
| 5934 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 6352 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5935 int objc, /* Number of arguments */ | 6353 int objc, /* Number of arguments */ |
| 5936 Tcl_Obj *CONST objv[] /* Command arguments */ | 6354 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5937 ){ | 6355 ){ |
| 5938 sqlite3 *db; | 6356 sqlite3 *db; |
| 5939 int rc; | 6357 int rc; |
| 5940 int iVal; | 6358 int iVal; |
| 5941 | 6359 |
| 5942 | 6360 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 5973 static void xLogcallback(void *unused, int err, char *zMsg){ | 6391 static void xLogcallback(void *unused, int err, char *zMsg){ |
| 5974 Tcl_Obj *pNew = Tcl_DuplicateObj(logcallback.pObj); | 6392 Tcl_Obj *pNew = Tcl_DuplicateObj(logcallback.pObj); |
| 5975 Tcl_IncrRefCount(pNew); | 6393 Tcl_IncrRefCount(pNew); |
| 5976 Tcl_ListObjAppendElement( | 6394 Tcl_ListObjAppendElement( |
| 5977 0, pNew, Tcl_NewStringObj(sqlite3ErrName(err), -1) | 6395 0, pNew, Tcl_NewStringObj(sqlite3ErrName(err), -1) |
| 5978 ); | 6396 ); |
| 5979 Tcl_ListObjAppendElement(0, pNew, Tcl_NewStringObj(zMsg, -1)); | 6397 Tcl_ListObjAppendElement(0, pNew, Tcl_NewStringObj(zMsg, -1)); |
| 5980 Tcl_EvalObjEx(logcallback.pInterp, pNew, TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT); | 6398 Tcl_EvalObjEx(logcallback.pInterp, pNew, TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT); |
| 5981 Tcl_DecrRefCount(pNew); | 6399 Tcl_DecrRefCount(pNew); |
| 5982 } | 6400 } |
| 5983 static int test_sqlite3_log( | 6401 static int SQLITE_TCLAPI test_sqlite3_log( |
| 5984 ClientData clientData, | 6402 ClientData clientData, |
| 5985 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 6403 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 5986 int objc, /* Number of arguments */ | 6404 int objc, /* Number of arguments */ |
| 5987 Tcl_Obj *CONST objv[] /* Command arguments */ | 6405 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 5988 ){ | 6406 ){ |
| 5989 if( objc>2 ){ | 6407 if( objc>2 ){ |
| 5990 Tcl_WrongNumArgs(interp, 1, objv, "SCRIPT"); | 6408 Tcl_WrongNumArgs(interp, 1, objv, "SCRIPT"); |
| 5991 return TCL_ERROR; | 6409 return TCL_ERROR; |
| 5992 } | 6410 } |
| 5993 if( logcallback.pObj ){ | 6411 if( logcallback.pObj ){ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6004 } | 6422 } |
| 6005 return TCL_OK; | 6423 return TCL_OK; |
| 6006 } | 6424 } |
| 6007 | 6425 |
| 6008 /* | 6426 /* |
| 6009 ** tcl_objproc COMMANDNAME ARGS... | 6427 ** tcl_objproc COMMANDNAME ARGS... |
| 6010 ** | 6428 ** |
| 6011 ** Run a TCL command using its objProc interface. Throw an error if | 6429 ** Run a TCL command using its objProc interface. Throw an error if |
| 6012 ** the command has no objProc interface. | 6430 ** the command has no objProc interface. |
| 6013 */ | 6431 */ |
| 6014 static int runAsObjProc( | 6432 static int SQLITE_TCLAPI runAsObjProc( |
| 6015 void * clientData, | 6433 void * clientData, |
| 6016 Tcl_Interp *interp, | 6434 Tcl_Interp *interp, |
| 6017 int objc, | 6435 int objc, |
| 6018 Tcl_Obj *CONST objv[] | 6436 Tcl_Obj *CONST objv[] |
| 6019 ){ | 6437 ){ |
| 6020 Tcl_CmdInfo cmdInfo; | 6438 Tcl_CmdInfo cmdInfo; |
| 6021 if( objc<2 ){ | 6439 if( objc<2 ){ |
| 6022 Tcl_WrongNumArgs(interp, 1, objv, "COMMAND ..."); | 6440 Tcl_WrongNumArgs(interp, 1, objv, "COMMAND ..."); |
| 6023 return TCL_ERROR; | 6441 return TCL_ERROR; |
| 6024 } | 6442 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6067 int iOrder = sqlite3_column_int(pExplain, 1); | 6485 int iOrder = sqlite3_column_int(pExplain, 1); |
| 6068 int iFrom = sqlite3_column_int(pExplain, 2); | 6486 int iFrom = sqlite3_column_int(pExplain, 2); |
| 6069 const char *zDetail = (const char *)sqlite3_column_text(pExplain, 3); | 6487 const char *zDetail = (const char *)sqlite3_column_text(pExplain, 3); |
| 6070 | 6488 |
| 6071 printf("%d %d %d %s\n", iSelectid, iOrder, iFrom, zDetail); | 6489 printf("%d %d %d %s\n", iSelectid, iOrder, iFrom, zDetail); |
| 6072 } | 6490 } |
| 6073 | 6491 |
| 6074 return sqlite3_finalize(pExplain); | 6492 return sqlite3_finalize(pExplain); |
| 6075 } | 6493 } |
| 6076 | 6494 |
| 6077 static int test_print_eqp( | 6495 static int SQLITE_TCLAPI test_print_eqp( |
| 6078 void * clientData, | 6496 void * clientData, |
| 6079 Tcl_Interp *interp, | 6497 Tcl_Interp *interp, |
| 6080 int objc, | 6498 int objc, |
| 6081 Tcl_Obj *CONST objv[] | 6499 Tcl_Obj *CONST objv[] |
| 6082 ){ | 6500 ){ |
| 6083 int rc; | 6501 int rc; |
| 6084 sqlite3_stmt *pStmt; | 6502 sqlite3_stmt *pStmt; |
| 6085 | 6503 |
| 6086 if( objc!=2 ){ | 6504 if( objc!=2 ){ |
| 6087 Tcl_WrongNumArgs(interp, 1, objv, "STMT"); | 6505 Tcl_WrongNumArgs(interp, 1, objv, "STMT"); |
| 6088 return TCL_ERROR; | 6506 return TCL_ERROR; |
| 6089 } | 6507 } |
| 6090 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; | 6508 if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; |
| 6091 rc = printExplainQueryPlan(pStmt); | 6509 rc = printExplainQueryPlan(pStmt); |
| 6092 /* This is needed on Windows so that a test case using this | 6510 /* This is needed on Windows so that a test case using this |
| 6093 ** function can open a read pipe and get the output of | 6511 ** function can open a read pipe and get the output of |
| 6094 ** printExplainQueryPlan() immediately. | 6512 ** printExplainQueryPlan() immediately. |
| 6095 */ | 6513 */ |
| 6096 fflush(stdout); | 6514 fflush(stdout); |
| 6097 Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0); | 6515 Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0); |
| 6098 return TCL_OK; | 6516 return TCL_OK; |
| 6099 } | 6517 } |
| 6100 #endif /* SQLITE_OMIT_EXPLAIN */ | 6518 #endif /* SQLITE_OMIT_EXPLAIN */ |
| 6101 | 6519 |
| 6102 /* | 6520 /* |
| 6103 ** sqlite3_test_control VERB ARGS... | 6521 ** sqlite3_test_control VERB ARGS... |
| 6104 */ | 6522 */ |
| 6105 static int test_test_control( | 6523 static int SQLITE_TCLAPI test_test_control( |
| 6106 void * clientData, | 6524 void * clientData, |
| 6107 Tcl_Interp *interp, | 6525 Tcl_Interp *interp, |
| 6108 int objc, | 6526 int objc, |
| 6109 Tcl_Obj *CONST objv[] | 6527 Tcl_Obj *CONST objv[] |
| 6110 ){ | 6528 ){ |
| 6111 struct Verb { | 6529 struct Verb { |
| 6112 const char *zName; | 6530 const char *zName; |
| 6113 int i; | 6531 int i; |
| 6114 } aVerb[] = { | 6532 } aVerb[] = { |
| 6115 { "SQLITE_TESTCTRL_LOCALTIME_FAULT", SQLITE_TESTCTRL_LOCALTIME_FAULT }, | 6533 { "SQLITE_TESTCTRL_LOCALTIME_FAULT", SQLITE_TESTCTRL_LOCALTIME_FAULT }, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6174 } | 6592 } |
| 6175 | 6593 |
| 6176 Tcl_ResetResult(interp); | 6594 Tcl_ResetResult(interp); |
| 6177 return TCL_OK; | 6595 return TCL_OK; |
| 6178 } | 6596 } |
| 6179 | 6597 |
| 6180 #if SQLITE_OS_UNIX | 6598 #if SQLITE_OS_UNIX |
| 6181 #include <sys/time.h> | 6599 #include <sys/time.h> |
| 6182 #include <sys/resource.h> | 6600 #include <sys/resource.h> |
| 6183 | 6601 |
| 6184 static int test_getrusage( | 6602 static int SQLITE_TCLAPI test_getrusage( |
| 6185 void * clientData, | 6603 void * clientData, |
| 6186 Tcl_Interp *interp, | 6604 Tcl_Interp *interp, |
| 6187 int objc, | 6605 int objc, |
| 6188 Tcl_Obj *CONST objv[] | 6606 Tcl_Obj *CONST objv[] |
| 6189 ){ | 6607 ){ |
| 6190 char buf[1024]; | 6608 char buf[1024]; |
| 6191 struct rusage r; | 6609 struct rusage r; |
| 6192 memset(&r, 0, sizeof(r)); | 6610 memset(&r, 0, sizeof(r)); |
| 6193 getrusage(RUSAGE_SELF, &r); | 6611 getrusage(RUSAGE_SELF, &r); |
| 6194 | 6612 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 6217 int err; /* True if an error occurs */ | 6635 int err; /* True if an error occurs */ |
| 6218 }; | 6636 }; |
| 6219 #endif | 6637 #endif |
| 6220 | 6638 |
| 6221 | 6639 |
| 6222 #if SQLITE_OS_WIN | 6640 #if SQLITE_OS_WIN |
| 6223 #include <process.h> | 6641 #include <process.h> |
| 6224 /* | 6642 /* |
| 6225 ** The background thread that does file locking. | 6643 ** The background thread that does file locking. |
| 6226 */ | 6644 */ |
| 6227 static void win32_file_locker(void *pAppData){ | 6645 static void SQLITE_CDECL win32_file_locker(void *pAppData){ |
| 6228 struct win32FileLocker *p = (struct win32FileLocker*)pAppData; | 6646 struct win32FileLocker *p = (struct win32FileLocker*)pAppData; |
| 6229 if( p->evName ){ | 6647 if( p->evName ){ |
| 6230 HANDLE ev = OpenEvent(EVENT_MODIFY_STATE, FALSE, p->evName); | 6648 HANDLE ev = OpenEvent(EVENT_MODIFY_STATE, FALSE, p->evName); |
| 6231 if ( ev ){ | 6649 if ( ev ){ |
| 6232 SetEvent(ev); | 6650 SetEvent(ev); |
| 6233 CloseHandle(ev); | 6651 CloseHandle(ev); |
| 6234 } | 6652 } |
| 6235 } | 6653 } |
| 6236 if( p->delay1 ) Sleep(p->delay1); | 6654 if( p->delay1 ) Sleep(p->delay1); |
| 6237 if( LockFile(p->h, 0, 0, 100000000, 0) ){ | 6655 if( LockFile(p->h, 0, 0, 100000000, 0) ){ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6248 } | 6666 } |
| 6249 #endif | 6667 #endif |
| 6250 | 6668 |
| 6251 #if SQLITE_OS_WIN | 6669 #if SQLITE_OS_WIN |
| 6252 /* | 6670 /* |
| 6253 ** lock_win32_file FILENAME DELAY1 DELAY2 | 6671 ** lock_win32_file FILENAME DELAY1 DELAY2 |
| 6254 ** | 6672 ** |
| 6255 ** Get an exclusive manditory lock on file for DELAY2 milliseconds. | 6673 ** Get an exclusive manditory lock on file for DELAY2 milliseconds. |
| 6256 ** Wait DELAY1 milliseconds before acquiring the lock. | 6674 ** Wait DELAY1 milliseconds before acquiring the lock. |
| 6257 */ | 6675 */ |
| 6258 static int win32_file_lock( | 6676 static int SQLITE_TCLAPI win32_file_lock( |
| 6259 void * clientData, | 6677 void * clientData, |
| 6260 Tcl_Interp *interp, | 6678 Tcl_Interp *interp, |
| 6261 int objc, | 6679 int objc, |
| 6262 Tcl_Obj *CONST objv[] | 6680 Tcl_Obj *CONST objv[] |
| 6263 ){ | 6681 ){ |
| 6264 static struct win32FileLocker x = { "win32_file_lock", 0, 0, 0, 0, 0 }; | 6682 static struct win32FileLocker x = { "win32_file_lock", 0, 0, 0, 0, 0 }; |
| 6265 const char *zFilename; | 6683 const char *zFilename; |
| 6266 char zBuf[200]; | 6684 char zBuf[200]; |
| 6267 int retry = 0; | 6685 int retry = 0; |
| 6268 HANDLE ev; | 6686 HANDLE ev; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6312 CloseHandle(ev); | 6730 CloseHandle(ev); |
| 6313 return TCL_OK; | 6731 return TCL_OK; |
| 6314 } | 6732 } |
| 6315 | 6733 |
| 6316 /* | 6734 /* |
| 6317 ** exists_win32_path PATH | 6735 ** exists_win32_path PATH |
| 6318 ** | 6736 ** |
| 6319 ** Returns non-zero if the specified path exists, whose fully qualified name | 6737 ** Returns non-zero if the specified path exists, whose fully qualified name |
| 6320 ** may exceed 260 characters if it is prefixed with "\\?\". | 6738 ** may exceed 260 characters if it is prefixed with "\\?\". |
| 6321 */ | 6739 */ |
| 6322 static int win32_exists_path( | 6740 static int SQLITE_TCLAPI win32_exists_path( |
| 6323 void *clientData, | 6741 void *clientData, |
| 6324 Tcl_Interp *interp, | 6742 Tcl_Interp *interp, |
| 6325 int objc, | 6743 int objc, |
| 6326 Tcl_Obj *CONST objv[] | 6744 Tcl_Obj *CONST objv[] |
| 6327 ){ | 6745 ){ |
| 6328 if( objc!=2 ){ | 6746 if( objc!=2 ){ |
| 6329 Tcl_WrongNumArgs(interp, 1, objv, "PATH"); | 6747 Tcl_WrongNumArgs(interp, 1, objv, "PATH"); |
| 6330 return TCL_ERROR; | 6748 return TCL_ERROR; |
| 6331 } | 6749 } |
| 6332 Tcl_SetObjResult(interp, Tcl_NewBooleanObj( | 6750 Tcl_SetObjResult(interp, Tcl_NewBooleanObj( |
| 6333 GetFileAttributesW( Tcl_GetUnicode(objv[1]))!=INVALID_FILE_ATTRIBUTES )); | 6751 GetFileAttributesW( Tcl_GetUnicode(objv[1]))!=INVALID_FILE_ATTRIBUTES )); |
| 6334 return TCL_OK; | 6752 return TCL_OK; |
| 6335 } | 6753 } |
| 6336 | 6754 |
| 6337 /* | 6755 /* |
| 6338 ** find_win32_file PATTERN | 6756 ** find_win32_file PATTERN |
| 6339 ** | 6757 ** |
| 6340 ** Returns a list of entries in a directory that match the specified pattern, | 6758 ** Returns a list of entries in a directory that match the specified pattern, |
| 6341 ** whose fully qualified name may exceed 248 characters if it is prefixed with | 6759 ** whose fully qualified name may exceed 248 characters if it is prefixed with |
| 6342 ** "\\?\". | 6760 ** "\\?\". |
| 6343 */ | 6761 */ |
| 6344 static int win32_find_file( | 6762 static int SQLITE_TCLAPI win32_find_file( |
| 6345 void *clientData, | 6763 void *clientData, |
| 6346 Tcl_Interp *interp, | 6764 Tcl_Interp *interp, |
| 6347 int objc, | 6765 int objc, |
| 6348 Tcl_Obj *CONST objv[] | 6766 Tcl_Obj *CONST objv[] |
| 6349 ){ | 6767 ){ |
| 6350 HANDLE hFindFile = INVALID_HANDLE_VALUE; | 6768 HANDLE hFindFile = INVALID_HANDLE_VALUE; |
| 6351 WIN32_FIND_DATAW findData; | 6769 WIN32_FIND_DATAW findData; |
| 6352 Tcl_Obj *listObj; | 6770 Tcl_Obj *listObj; |
| 6353 DWORD lastErrno; | 6771 DWORD lastErrno; |
| 6354 if( objc!=2 ){ | 6772 if( objc!=2 ){ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 6379 Tcl_SetObjResult(interp, listObj); | 6797 Tcl_SetObjResult(interp, listObj); |
| 6380 return TCL_OK; | 6798 return TCL_OK; |
| 6381 } | 6799 } |
| 6382 | 6800 |
| 6383 /* | 6801 /* |
| 6384 ** delete_win32_file FILENAME | 6802 ** delete_win32_file FILENAME |
| 6385 ** | 6803 ** |
| 6386 ** Deletes the specified file, whose fully qualified name may exceed 260 | 6804 ** Deletes the specified file, whose fully qualified name may exceed 260 |
| 6387 ** characters if it is prefixed with "\\?\". | 6805 ** characters if it is prefixed with "\\?\". |
| 6388 */ | 6806 */ |
| 6389 static int win32_delete_file( | 6807 static int SQLITE_TCLAPI win32_delete_file( |
| 6390 void *clientData, | 6808 void *clientData, |
| 6391 Tcl_Interp *interp, | 6809 Tcl_Interp *interp, |
| 6392 int objc, | 6810 int objc, |
| 6393 Tcl_Obj *CONST objv[] | 6811 Tcl_Obj *CONST objv[] |
| 6394 ){ | 6812 ){ |
| 6395 if( objc!=2 ){ | 6813 if( objc!=2 ){ |
| 6396 Tcl_WrongNumArgs(interp, 1, objv, "FILENAME"); | 6814 Tcl_WrongNumArgs(interp, 1, objv, "FILENAME"); |
| 6397 return TCL_ERROR; | 6815 return TCL_ERROR; |
| 6398 } | 6816 } |
| 6399 if( !DeleteFileW(Tcl_GetUnicode(objv[1])) ){ | 6817 if( !DeleteFileW(Tcl_GetUnicode(objv[1])) ){ |
| 6400 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); | 6818 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); |
| 6401 return TCL_ERROR; | 6819 return TCL_ERROR; |
| 6402 } | 6820 } |
| 6403 Tcl_ResetResult(interp); | 6821 Tcl_ResetResult(interp); |
| 6404 return TCL_OK; | 6822 return TCL_OK; |
| 6405 } | 6823 } |
| 6406 | 6824 |
| 6407 /* | 6825 /* |
| 6408 ** make_win32_dir DIRECTORY | 6826 ** make_win32_dir DIRECTORY |
| 6409 ** | 6827 ** |
| 6410 ** Creates the specified directory, whose fully qualified name may exceed 248 | 6828 ** Creates the specified directory, whose fully qualified name may exceed 248 |
| 6411 ** characters if it is prefixed with "\\?\". | 6829 ** characters if it is prefixed with "\\?\". |
| 6412 */ | 6830 */ |
| 6413 static int win32_mkdir( | 6831 static int SQLITE_TCLAPI win32_mkdir( |
| 6414 void *clientData, | 6832 void *clientData, |
| 6415 Tcl_Interp *interp, | 6833 Tcl_Interp *interp, |
| 6416 int objc, | 6834 int objc, |
| 6417 Tcl_Obj *CONST objv[] | 6835 Tcl_Obj *CONST objv[] |
| 6418 ){ | 6836 ){ |
| 6419 if( objc!=2 ){ | 6837 if( objc!=2 ){ |
| 6420 Tcl_WrongNumArgs(interp, 1, objv, "DIRECTORY"); | 6838 Tcl_WrongNumArgs(interp, 1, objv, "DIRECTORY"); |
| 6421 return TCL_ERROR; | 6839 return TCL_ERROR; |
| 6422 } | 6840 } |
| 6423 if( !CreateDirectoryW(Tcl_GetUnicode(objv[1]), NULL) ){ | 6841 if( !CreateDirectoryW(Tcl_GetUnicode(objv[1]), NULL) ){ |
| 6424 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); | 6842 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); |
| 6425 return TCL_ERROR; | 6843 return TCL_ERROR; |
| 6426 } | 6844 } |
| 6427 Tcl_ResetResult(interp); | 6845 Tcl_ResetResult(interp); |
| 6428 return TCL_OK; | 6846 return TCL_OK; |
| 6429 } | 6847 } |
| 6430 | 6848 |
| 6431 /* | 6849 /* |
| 6432 ** remove_win32_dir DIRECTORY | 6850 ** remove_win32_dir DIRECTORY |
| 6433 ** | 6851 ** |
| 6434 ** Removes the specified directory, whose fully qualified name may exceed 248 | 6852 ** Removes the specified directory, whose fully qualified name may exceed 248 |
| 6435 ** characters if it is prefixed with "\\?\". | 6853 ** characters if it is prefixed with "\\?\". |
| 6436 */ | 6854 */ |
| 6437 static int win32_rmdir( | 6855 static int SQLITE_TCLAPI win32_rmdir( |
| 6438 void *clientData, | 6856 void *clientData, |
| 6439 Tcl_Interp *interp, | 6857 Tcl_Interp *interp, |
| 6440 int objc, | 6858 int objc, |
| 6441 Tcl_Obj *CONST objv[] | 6859 Tcl_Obj *CONST objv[] |
| 6442 ){ | 6860 ){ |
| 6443 if( objc!=2 ){ | 6861 if( objc!=2 ){ |
| 6444 Tcl_WrongNumArgs(interp, 1, objv, "DIRECTORY"); | 6862 Tcl_WrongNumArgs(interp, 1, objv, "DIRECTORY"); |
| 6445 return TCL_ERROR; | 6863 return TCL_ERROR; |
| 6446 } | 6864 } |
| 6447 if( !RemoveDirectoryW(Tcl_GetUnicode(objv[1])) ){ | 6865 if( !RemoveDirectoryW(Tcl_GetUnicode(objv[1])) ){ |
| 6448 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); | 6866 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError())); |
| 6449 return TCL_ERROR; | 6867 return TCL_ERROR; |
| 6450 } | 6868 } |
| 6451 Tcl_ResetResult(interp); | 6869 Tcl_ResetResult(interp); |
| 6452 return TCL_OK; | 6870 return TCL_OK; |
| 6453 } | 6871 } |
| 6454 #endif | 6872 #endif |
| 6455 | 6873 |
| 6456 | 6874 |
| 6457 /* | 6875 /* |
| 6458 ** optimization_control DB OPT BOOLEAN | 6876 ** optimization_control DB OPT BOOLEAN |
| 6459 ** | 6877 ** |
| 6460 ** Enable or disable query optimizations using the sqlite3_test_control() | 6878 ** Enable or disable query optimizations using the sqlite3_test_control() |
| 6461 ** interface. Disable if BOOLEAN is false and enable if BOOLEAN is true. | 6879 ** interface. Disable if BOOLEAN is false and enable if BOOLEAN is true. |
| 6462 ** OPT is the name of the optimization to be disabled. | 6880 ** OPT is the name of the optimization to be disabled. |
| 6463 */ | 6881 */ |
| 6464 static int optimization_control( | 6882 static int SQLITE_TCLAPI optimization_control( |
| 6465 void * clientData, | 6883 void * clientData, |
| 6466 Tcl_Interp *interp, | 6884 Tcl_Interp *interp, |
| 6467 int objc, | 6885 int objc, |
| 6468 Tcl_Obj *CONST objv[] | 6886 Tcl_Obj *CONST objv[] |
| 6469 ){ | 6887 ){ |
| 6470 int i; | 6888 int i; |
| 6471 sqlite3 *db; | 6889 sqlite3 *db; |
| 6472 const char *zOpt; | 6890 const char *zOpt; |
| 6473 int onoff; | 6891 int onoff; |
| 6474 int mask = 0; | 6892 int mask = 0; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6511 (char*)0); | 6929 (char*)0); |
| 6512 for(i=0; i<sizeof(aOpt)/sizeof(aOpt[0]); i++){ | 6930 for(i=0; i<sizeof(aOpt)/sizeof(aOpt[0]); i++){ |
| 6513 Tcl_AppendResult(interp, " ", aOpt[i].zOptName, (char*)0); | 6931 Tcl_AppendResult(interp, " ", aOpt[i].zOptName, (char*)0); |
| 6514 } | 6932 } |
| 6515 return TCL_ERROR; | 6933 return TCL_ERROR; |
| 6516 } | 6934 } |
| 6517 sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, db, mask); | 6935 sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, db, mask); |
| 6518 return TCL_OK; | 6936 return TCL_OK; |
| 6519 } | 6937 } |
| 6520 | 6938 |
| 6521 typedef struct sqlite3_api_routines sqlite3_api_routines; | |
| 6522 /* | 6939 /* |
| 6523 ** load_static_extension DB NAME ... | 6940 ** load_static_extension DB NAME ... |
| 6524 ** | 6941 ** |
| 6525 ** Load one or more statically linked extensions. | 6942 ** Load one or more statically linked extensions. |
| 6526 */ | 6943 */ |
| 6527 static int tclLoadStaticExtensionCmd( | 6944 static int SQLITE_TCLAPI tclLoadStaticExtensionCmd( |
| 6528 void * clientData, | 6945 void * clientData, |
| 6529 Tcl_Interp *interp, | 6946 Tcl_Interp *interp, |
| 6530 int objc, | 6947 int objc, |
| 6531 Tcl_Obj *CONST objv[] | 6948 Tcl_Obj *CONST objv[] |
| 6532 ){ | 6949 ){ |
| 6533 extern int sqlite3_amatch_init(sqlite3*,char**,const sqlite3_api_routines*); | 6950 extern int sqlite3_amatch_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6951 extern int sqlite3_carray_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6534 extern int sqlite3_closure_init(sqlite3*,char**,const sqlite3_api_routines*); | 6952 extern int sqlite3_closure_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6953 extern int sqlite3_csv_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6535 extern int sqlite3_eval_init(sqlite3*,char**,const sqlite3_api_routines*); | 6954 extern int sqlite3_eval_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6536 extern int sqlite3_fileio_init(sqlite3*,char**,const sqlite3_api_routines*); | 6955 extern int sqlite3_fileio_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6537 extern int sqlite3_fuzzer_init(sqlite3*,char**,const sqlite3_api_routines*); | 6956 extern int sqlite3_fuzzer_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6538 extern int sqlite3_ieee_init(sqlite3*,char**,const sqlite3_api_routines*); | 6957 extern int sqlite3_ieee_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6539 extern int sqlite3_nextchar_init(sqlite3*,char**,const sqlite3_api_routines*); | 6958 extern int sqlite3_nextchar_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6540 extern int sqlite3_percentile_init(sqlite3*,char**,const sqlite3_api_routines*
); | 6959 extern int sqlite3_percentile_init(sqlite3*,char**,const sqlite3_api_routines*
); |
| 6541 extern int sqlite3_regexp_init(sqlite3*,char**,const sqlite3_api_routines*); | 6960 extern int sqlite3_regexp_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6961 extern int sqlite3_remember_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6542 extern int sqlite3_series_init(sqlite3*,char**,const sqlite3_api_routines*); | 6962 extern int sqlite3_series_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6543 extern int sqlite3_spellfix_init(sqlite3*,char**,const sqlite3_api_routines*); | 6963 extern int sqlite3_spellfix_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6544 extern int sqlite3_totype_init(sqlite3*,char**,const sqlite3_api_routines*); | 6964 extern int sqlite3_totype_init(sqlite3*,char**,const sqlite3_api_routines*); |
| 6545 extern int sqlite3_wholenumber_init(sqlite3*,char**,const sqlite3_api_routines
*); | 6965 extern int sqlite3_wholenumber_init(sqlite3*,char**,const sqlite3_api_routines
*); |
| 6546 static const struct { | 6966 static const struct { |
| 6547 const char *zExtName; | 6967 const char *zExtName; |
| 6548 int (*pInit)(sqlite3*,char**,const sqlite3_api_routines*); | 6968 int (*pInit)(sqlite3*,char**,const sqlite3_api_routines*); |
| 6549 } aExtension[] = { | 6969 } aExtension[] = { |
| 6550 { "amatch", sqlite3_amatch_init }, | 6970 { "amatch", sqlite3_amatch_init }, |
| 6971 { "carray", sqlite3_carray_init }, |
| 6551 { "closure", sqlite3_closure_init }, | 6972 { "closure", sqlite3_closure_init }, |
| 6973 { "csv", sqlite3_csv_init }, |
| 6552 { "eval", sqlite3_eval_init }, | 6974 { "eval", sqlite3_eval_init }, |
| 6553 { "fileio", sqlite3_fileio_init }, | 6975 { "fileio", sqlite3_fileio_init }, |
| 6554 { "fuzzer", sqlite3_fuzzer_init }, | 6976 { "fuzzer", sqlite3_fuzzer_init }, |
| 6555 { "ieee754", sqlite3_ieee_init }, | 6977 { "ieee754", sqlite3_ieee_init }, |
| 6556 { "nextchar", sqlite3_nextchar_init }, | 6978 { "nextchar", sqlite3_nextchar_init }, |
| 6557 { "percentile", sqlite3_percentile_init }, | 6979 { "percentile", sqlite3_percentile_init }, |
| 6558 { "regexp", sqlite3_regexp_init }, | 6980 { "regexp", sqlite3_regexp_init }, |
| 6981 { "remember", sqlite3_remember_init }, |
| 6559 { "series", sqlite3_series_init }, | 6982 { "series", sqlite3_series_init }, |
| 6560 { "spellfix", sqlite3_spellfix_init }, | 6983 { "spellfix", sqlite3_spellfix_init }, |
| 6561 { "totype", sqlite3_totype_init }, | 6984 { "totype", sqlite3_totype_init }, |
| 6562 { "wholenumber", sqlite3_wholenumber_init }, | 6985 { "wholenumber", sqlite3_wholenumber_init }, |
| 6563 }; | 6986 }; |
| 6564 sqlite3 *db; | 6987 sqlite3 *db; |
| 6565 const char *zName; | 6988 const char *zName; |
| 6566 int i, j, rc; | 6989 int i, j, rc; |
| 6567 char *zErrMsg = 0; | 6990 char *zErrMsg = 0; |
| 6568 if( objc<3 ){ | 6991 if( objc<3 ){ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 6591 return TCL_ERROR; | 7014 return TCL_ERROR; |
| 6592 } | 7015 } |
| 6593 } | 7016 } |
| 6594 return TCL_OK; | 7017 return TCL_OK; |
| 6595 } | 7018 } |
| 6596 | 7019 |
| 6597 /* | 7020 /* |
| 6598 ** sorter_test_fakeheap BOOL | 7021 ** sorter_test_fakeheap BOOL |
| 6599 ** | 7022 ** |
| 6600 */ | 7023 */ |
| 6601 static int sorter_test_fakeheap( | 7024 static int SQLITE_TCLAPI sorter_test_fakeheap( |
| 6602 void * clientData, | 7025 void * clientData, |
| 6603 Tcl_Interp *interp, | 7026 Tcl_Interp *interp, |
| 6604 int objc, | 7027 int objc, |
| 6605 Tcl_Obj *CONST objv[] | 7028 Tcl_Obj *CONST objv[] |
| 6606 ){ | 7029 ){ |
| 6607 int bArg; | 7030 int bArg; |
| 6608 if( objc!=2 ){ | 7031 if( objc!=2 ){ |
| 6609 Tcl_WrongNumArgs(interp, 1, objv, "BOOL"); | 7032 Tcl_WrongNumArgs(interp, 1, objv, "BOOL"); |
| 6610 return TCL_ERROR; | 7033 return TCL_ERROR; |
| 6611 } | 7034 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 6631 /* | 7054 /* |
| 6632 ** sorter_test_sort4_helper DB SQL1 NSTEP SQL2 | 7055 ** sorter_test_sort4_helper DB SQL1 NSTEP SQL2 |
| 6633 ** | 7056 ** |
| 6634 ** Compile SQL statement $SQL1 and step it $NSTEP times. For each row, | 7057 ** Compile SQL statement $SQL1 and step it $NSTEP times. For each row, |
| 6635 ** check that the leftmost and rightmost columns returned are both integers, | 7058 ** check that the leftmost and rightmost columns returned are both integers, |
| 6636 ** and that both contain the same value. | 7059 ** and that both contain the same value. |
| 6637 ** | 7060 ** |
| 6638 ** Then execute statement $SQL2. Check that the statement returns the same | 7061 ** Then execute statement $SQL2. Check that the statement returns the same |
| 6639 ** set of integers in the same order as in the previous step (using $SQL1). | 7062 ** set of integers in the same order as in the previous step (using $SQL1). |
| 6640 */ | 7063 */ |
| 6641 static int sorter_test_sort4_helper( | 7064 static int SQLITE_TCLAPI sorter_test_sort4_helper( |
| 6642 void * clientData, | 7065 void * clientData, |
| 6643 Tcl_Interp *interp, | 7066 Tcl_Interp *interp, |
| 6644 int objc, | 7067 int objc, |
| 6645 Tcl_Obj *CONST objv[] | 7068 Tcl_Obj *CONST objv[] |
| 6646 ){ | 7069 ){ |
| 6647 const char *zSql1; | 7070 const char *zSql1; |
| 6648 const char *zSql2; | 7071 const char *zSql2; |
| 6649 int nStep; | 7072 int nStep; |
| 6650 int iStep; | 7073 int iStep; |
| 6651 int iCksum1 = 0; | 7074 unsigned int iCksum1 = 0; |
| 6652 int iCksum2 = 0; | 7075 unsigned int iCksum2 = 0; |
| 6653 int rc; | 7076 int rc; |
| 6654 int iB; | 7077 int iB; |
| 6655 sqlite3 *db; | 7078 sqlite3 *db; |
| 6656 sqlite3_stmt *pStmt; | 7079 sqlite3_stmt *pStmt; |
| 6657 | 7080 |
| 6658 if( objc!=5 ){ | 7081 if( objc!=5 ){ |
| 6659 Tcl_WrongNumArgs(interp, 1, objv, "DB SQL1 NSTEP SQL2"); | 7082 Tcl_WrongNumArgs(interp, 1, objv, "DB SQL1 NSTEP SQL2"); |
| 6660 return TCL_ERROR; | 7083 return TCL_ERROR; |
| 6661 } | 7084 } |
| 6662 | 7085 |
| 6663 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 7086 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 6664 zSql1 = Tcl_GetString(objv[2]); | 7087 zSql1 = Tcl_GetString(objv[2]); |
| 6665 if( Tcl_GetIntFromObj(interp, objv[3], &nStep) ) return TCL_ERROR; | 7088 if( Tcl_GetIntFromObj(interp, objv[3], &nStep) ) return TCL_ERROR; |
| 6666 zSql2 = Tcl_GetString(objv[4]); | 7089 zSql2 = Tcl_GetString(objv[4]); |
| 6667 | 7090 |
| 6668 rc = sqlite3_prepare_v2(db, zSql1, -1, &pStmt, 0); | 7091 rc = sqlite3_prepare_v2(db, zSql1, -1, &pStmt, 0); |
| 6669 if( rc!=SQLITE_OK ) goto sql_error; | 7092 if( rc!=SQLITE_OK ) goto sql_error; |
| 6670 | 7093 |
| 6671 iB = sqlite3_column_count(pStmt)-1; | 7094 iB = sqlite3_column_count(pStmt)-1; |
| 6672 for(iStep=0; iStep<nStep && SQLITE_ROW==sqlite3_step(pStmt); iStep++){ | 7095 for(iStep=0; iStep<nStep && SQLITE_ROW==sqlite3_step(pStmt); iStep++){ |
| 6673 int a = sqlite3_column_int(pStmt, 0); | 7096 int a = sqlite3_column_int(pStmt, 0); |
| 6674 if( a!=sqlite3_column_int(pStmt, iB) ){ | 7097 if( a!=sqlite3_column_int(pStmt, iB) ){ |
| 6675 Tcl_AppendResult(interp, "data error: (a!=b)", 0); | 7098 Tcl_AppendResult(interp, "data error: (a!=b)", 0); |
| 6676 return TCL_ERROR; | 7099 return TCL_ERROR; |
| 6677 } | 7100 } |
| 6678 | 7101 |
| 6679 iCksum1 += (iCksum1 << 3) + a; | 7102 iCksum1 += (iCksum1 << 3) + (unsigned int)a; |
| 6680 } | 7103 } |
| 6681 rc = sqlite3_finalize(pStmt); | 7104 rc = sqlite3_finalize(pStmt); |
| 6682 if( rc!=SQLITE_OK ) goto sql_error; | 7105 if( rc!=SQLITE_OK ) goto sql_error; |
| 6683 | 7106 |
| 6684 rc = sqlite3_prepare_v2(db, zSql2, -1, &pStmt, 0); | 7107 rc = sqlite3_prepare_v2(db, zSql2, -1, &pStmt, 0); |
| 6685 if( rc!=SQLITE_OK ) goto sql_error; | 7108 if( rc!=SQLITE_OK ) goto sql_error; |
| 6686 for(iStep=0; SQLITE_ROW==sqlite3_step(pStmt); iStep++){ | 7109 for(iStep=0; SQLITE_ROW==sqlite3_step(pStmt); iStep++){ |
| 6687 int a = sqlite3_column_int(pStmt, 0); | 7110 int a = sqlite3_column_int(pStmt, 0); |
| 6688 iCksum2 += (iCksum2 << 3) + a; | 7111 iCksum2 += (iCksum2 << 3) + (unsigned int)a; |
| 6689 } | 7112 } |
| 6690 rc = sqlite3_finalize(pStmt); | 7113 rc = sqlite3_finalize(pStmt); |
| 6691 if( rc!=SQLITE_OK ) goto sql_error; | 7114 if( rc!=SQLITE_OK ) goto sql_error; |
| 6692 | 7115 |
| 6693 if( iCksum1!=iCksum2 ){ | 7116 if( iCksum1!=iCksum2 ){ |
| 6694 Tcl_AppendResult(interp, "checksum mismatch", 0); | 7117 Tcl_AppendResult(interp, "checksum mismatch", 0); |
| 6695 return TCL_ERROR; | 7118 return TCL_ERROR; |
| 6696 } | 7119 } |
| 6697 | 7120 |
| 6698 return TCL_OK; | 7121 return TCL_OK; |
| 6699 sql_error: | 7122 sql_error: |
| 6700 Tcl_AppendResult(interp, "sql error: ", sqlite3_errmsg(db), 0); | 7123 Tcl_AppendResult(interp, "sql error: ", sqlite3_errmsg(db), 0); |
| 6701 return TCL_ERROR; | 7124 return TCL_ERROR; |
| 6702 } | 7125 } |
| 6703 | 7126 |
| 6704 | 7127 |
| 6705 #ifdef SQLITE_USER_AUTHENTICATION | 7128 #ifdef SQLITE_USER_AUTHENTICATION |
| 6706 #include "sqlite3userauth.h" | 7129 #include "sqlite3userauth.h" |
| 6707 /* | 7130 /* |
| 6708 ** tclcmd: sqlite3_user_authenticate DB USERNAME PASSWORD | 7131 ** tclcmd: sqlite3_user_authenticate DB USERNAME PASSWORD |
| 6709 */ | 7132 */ |
| 6710 static int test_user_authenticate( | 7133 static int SQLITE_TCLAPI test_user_authenticate( |
| 6711 ClientData clientData, /* Unused */ | 7134 ClientData clientData, /* Unused */ |
| 6712 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 7135 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 6713 int objc, /* Number of arguments */ | 7136 int objc, /* Number of arguments */ |
| 6714 Tcl_Obj *CONST objv[] /* Command arguments */ | 7137 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 6715 ){ | 7138 ){ |
| 6716 char *zUser = 0; | 7139 char *zUser = 0; |
| 6717 char *zPasswd = 0; | 7140 char *zPasswd = 0; |
| 6718 int nPasswd = 0; | 7141 int nPasswd = 0; |
| 6719 sqlite3 *db; | 7142 sqlite3 *db; |
| 6720 int rc; | 7143 int rc; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6731 rc = sqlite3_user_authenticate(db, zUser, zPasswd, nPasswd); | 7154 rc = sqlite3_user_authenticate(db, zUser, zPasswd, nPasswd); |
| 6732 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); | 7155 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); |
| 6733 return TCL_OK; | 7156 return TCL_OK; |
| 6734 } | 7157 } |
| 6735 #endif /* SQLITE_USER_AUTHENTICATION */ | 7158 #endif /* SQLITE_USER_AUTHENTICATION */ |
| 6736 | 7159 |
| 6737 #ifdef SQLITE_USER_AUTHENTICATION | 7160 #ifdef SQLITE_USER_AUTHENTICATION |
| 6738 /* | 7161 /* |
| 6739 ** tclcmd: sqlite3_user_add DB USERNAME PASSWORD ISADMIN | 7162 ** tclcmd: sqlite3_user_add DB USERNAME PASSWORD ISADMIN |
| 6740 */ | 7163 */ |
| 6741 static int test_user_add( | 7164 static int SQLITE_TCLAPI test_user_add( |
| 6742 ClientData clientData, /* Unused */ | 7165 ClientData clientData, /* Unused */ |
| 6743 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 7166 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 6744 int objc, /* Number of arguments */ | 7167 int objc, /* Number of arguments */ |
| 6745 Tcl_Obj *CONST objv[] /* Command arguments */ | 7168 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 6746 ){ | 7169 ){ |
| 6747 char *zUser = 0; | 7170 char *zUser = 0; |
| 6748 char *zPasswd = 0; | 7171 char *zPasswd = 0; |
| 6749 int nPasswd = 0; | 7172 int nPasswd = 0; |
| 6750 int isAdmin = 0; | 7173 int isAdmin = 0; |
| 6751 sqlite3 *db; | 7174 sqlite3 *db; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 6764 rc = sqlite3_user_add(db, zUser, zPasswd, nPasswd, isAdmin); | 7187 rc = sqlite3_user_add(db, zUser, zPasswd, nPasswd, isAdmin); |
| 6765 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); | 7188 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); |
| 6766 return TCL_OK; | 7189 return TCL_OK; |
| 6767 } | 7190 } |
| 6768 #endif /* SQLITE_USER_AUTHENTICATION */ | 7191 #endif /* SQLITE_USER_AUTHENTICATION */ |
| 6769 | 7192 |
| 6770 #ifdef SQLITE_USER_AUTHENTICATION | 7193 #ifdef SQLITE_USER_AUTHENTICATION |
| 6771 /* | 7194 /* |
| 6772 ** tclcmd: sqlite3_user_change DB USERNAME PASSWORD ISADMIN | 7195 ** tclcmd: sqlite3_user_change DB USERNAME PASSWORD ISADMIN |
| 6773 */ | 7196 */ |
| 6774 static int test_user_change( | 7197 static int SQLITE_TCLAPI test_user_change( |
| 6775 ClientData clientData, /* Unused */ | 7198 ClientData clientData, /* Unused */ |
| 6776 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 7199 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 6777 int objc, /* Number of arguments */ | 7200 int objc, /* Number of arguments */ |
| 6778 Tcl_Obj *CONST objv[] /* Command arguments */ | 7201 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 6779 ){ | 7202 ){ |
| 6780 char *zUser = 0; | 7203 char *zUser = 0; |
| 6781 char *zPasswd = 0; | 7204 char *zPasswd = 0; |
| 6782 int nPasswd = 0; | 7205 int nPasswd = 0; |
| 6783 int isAdmin = 0; | 7206 int isAdmin = 0; |
| 6784 sqlite3 *db; | 7207 sqlite3 *db; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 6797 rc = sqlite3_user_change(db, zUser, zPasswd, nPasswd, isAdmin); | 7220 rc = sqlite3_user_change(db, zUser, zPasswd, nPasswd, isAdmin); |
| 6798 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); | 7221 Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC); |
| 6799 return TCL_OK; | 7222 return TCL_OK; |
| 6800 } | 7223 } |
| 6801 #endif /* SQLITE_USER_AUTHENTICATION */ | 7224 #endif /* SQLITE_USER_AUTHENTICATION */ |
| 6802 | 7225 |
| 6803 #ifdef SQLITE_USER_AUTHENTICATION | 7226 #ifdef SQLITE_USER_AUTHENTICATION |
| 6804 /* | 7227 /* |
| 6805 ** tclcmd: sqlite3_user_delete DB USERNAME | 7228 ** tclcmd: sqlite3_user_delete DB USERNAME |
| 6806 */ | 7229 */ |
| 6807 static int test_user_delete( | 7230 static int SQLITE_TCLAPI test_user_delete( |
| 6808 ClientData clientData, /* Unused */ | 7231 ClientData clientData, /* Unused */ |
| 6809 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 7232 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 6810 int objc, /* Number of arguments */ | 7233 int objc, /* Number of arguments */ |
| 6811 Tcl_Obj *CONST objv[] /* Command arguments */ | 7234 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 6812 ){ | 7235 ){ |
| 6813 char *zUser = 0; | 7236 char *zUser = 0; |
| 6814 sqlite3 *db; | 7237 sqlite3 *db; |
| 6815 int rc; | 7238 int rc; |
| 6816 | 7239 |
| 6817 if( objc!=3 ){ | 7240 if( objc!=3 ){ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6834 ** Do some things that should trigger a valgrind or -fsanitize=undefined | 7257 ** Do some things that should trigger a valgrind or -fsanitize=undefined |
| 6835 ** warning. This is used to verify that errors and warnings output by those | 7258 ** warning. This is used to verify that errors and warnings output by those |
| 6836 ** tools are detected by the test scripts. | 7259 ** tools are detected by the test scripts. |
| 6837 ** | 7260 ** |
| 6838 ** TYPE BEHAVIOR | 7261 ** TYPE BEHAVIOR |
| 6839 ** 1 Overflow a signed integer | 7262 ** 1 Overflow a signed integer |
| 6840 ** 2 Jump based on an uninitialized variable | 7263 ** 2 Jump based on an uninitialized variable |
| 6841 ** 3 Read after free | 7264 ** 3 Read after free |
| 6842 ** 4 Panic | 7265 ** 4 Panic |
| 6843 */ | 7266 */ |
| 6844 static int test_bad_behavior( | 7267 static int SQLITE_TCLAPI test_bad_behavior( |
| 6845 ClientData clientData, /* Pointer to an integer containing zero */ | 7268 ClientData clientData, /* Pointer to an integer containing zero */ |
| 6846 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ | 7269 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ |
| 6847 int objc, /* Number of arguments */ | 7270 int objc, /* Number of arguments */ |
| 6848 Tcl_Obj *CONST objv[] /* Command arguments */ | 7271 Tcl_Obj *CONST objv[] /* Command arguments */ |
| 6849 ){ | 7272 ){ |
| 6850 int iType; | 7273 int iType; |
| 6851 int xyz; | 7274 int xyz; |
| 6852 int i = *(int*)clientData; | 7275 int i = *(int*)clientData; |
| 6853 int j; | 7276 int j; |
| 6854 int w[10]; | 7277 int w[10]; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 6884 } | 7307 } |
| 6885 } | 7308 } |
| 6886 return TCL_OK; | 7309 return TCL_OK; |
| 6887 } | 7310 } |
| 6888 | 7311 |
| 6889 /* | 7312 /* |
| 6890 ** tclcmd: register_dbstat_vtab DB | 7313 ** tclcmd: register_dbstat_vtab DB |
| 6891 ** | 7314 ** |
| 6892 ** Cause the dbstat virtual table to be available on the connection DB | 7315 ** Cause the dbstat virtual table to be available on the connection DB |
| 6893 */ | 7316 */ |
| 6894 static int test_register_dbstat_vtab( | 7317 static int SQLITE_TCLAPI test_register_dbstat_vtab( |
| 6895 void *clientData, | 7318 void *clientData, |
| 6896 Tcl_Interp *interp, | 7319 Tcl_Interp *interp, |
| 6897 int objc, | 7320 int objc, |
| 6898 Tcl_Obj *CONST objv[] | 7321 Tcl_Obj *CONST objv[] |
| 6899 ){ | 7322 ){ |
| 6900 #ifdef SQLITE_OMIT_VIRTUALTABLE | 7323 #ifdef SQLITE_OMIT_VIRTUALTABLE |
| 6901 Tcl_AppendResult(interp, "dbstat not available because of " | 7324 Tcl_AppendResult(interp, "dbstat not available because of " |
| 6902 "SQLITE_OMIT_VIRTUALTABLE", (void*)0); | 7325 "SQLITE_OMIT_VIRTUALTABLE", (void*)0); |
| 6903 return TCL_ERROR; | 7326 return TCL_ERROR; |
| 6904 #else | 7327 #else |
| 6905 struct SqliteDb { sqlite3 *db; }; | 7328 struct SqliteDb { sqlite3 *db; }; |
| 6906 char *zDb; | 7329 char *zDb; |
| 6907 Tcl_CmdInfo cmdInfo; | 7330 Tcl_CmdInfo cmdInfo; |
| 6908 | 7331 |
| 6909 if( objc!=2 ){ | 7332 if( objc!=2 ){ |
| 6910 Tcl_WrongNumArgs(interp, 1, objv, "DB"); | 7333 Tcl_WrongNumArgs(interp, 1, objv, "DB"); |
| 6911 return TCL_ERROR; | 7334 return TCL_ERROR; |
| 6912 } | 7335 } |
| 6913 | 7336 |
| 6914 zDb = Tcl_GetString(objv[1]); | 7337 zDb = Tcl_GetString(objv[1]); |
| 6915 if( Tcl_GetCommandInfo(interp, zDb, &cmdInfo) ){ | 7338 if( Tcl_GetCommandInfo(interp, zDb, &cmdInfo) ){ |
| 6916 sqlite3* db = ((struct SqliteDb*)cmdInfo.objClientData)->db; | 7339 sqlite3* db = ((struct SqliteDb*)cmdInfo.objClientData)->db; |
| 6917 sqlite3DbstatRegister(db); | 7340 sqlite3DbstatRegister(db); |
| 6918 } | 7341 } |
| 6919 return TCL_OK; | 7342 return TCL_OK; |
| 6920 #endif /* SQLITE_OMIT_VIRTUALTABLE */ | 7343 #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 6921 } | 7344 } |
| 6922 | 7345 |
| 6923 /* | 7346 /* |
| 7347 ** tclcmd: sqlite3_db_config DB SETTING VALUE |
| 7348 ** |
| 7349 ** Invoke sqlite3_db_config() for one of the setting values. |
| 7350 */ |
| 7351 static int SQLITE_TCLAPI test_sqlite3_db_config( |
| 7352 void *clientData, |
| 7353 Tcl_Interp *interp, |
| 7354 int objc, |
| 7355 Tcl_Obj *CONST objv[] |
| 7356 ){ |
| 7357 static const struct { |
| 7358 const char *zName; |
| 7359 int eVal; |
| 7360 } aSetting[] = { |
| 7361 { "FKEY", SQLITE_DBCONFIG_ENABLE_FKEY }, |
| 7362 { "TRIGGER", SQLITE_DBCONFIG_ENABLE_TRIGGER }, |
| 7363 { "FTS3_TOKENIZER", SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER }, |
| 7364 { "LOAD_EXTENSION", SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION }, |
| 7365 { "NO_CKPT_ON_CLOSE",SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE }, |
| 7366 }; |
| 7367 int i; |
| 7368 int v; |
| 7369 const char *zSetting; |
| 7370 sqlite3 *db; |
| 7371 |
| 7372 if( objc!=4 ){ |
| 7373 Tcl_WrongNumArgs(interp, 1, objv, "DB SETTING VALUE"); |
| 7374 return TCL_ERROR; |
| 7375 } |
| 7376 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 7377 zSetting = Tcl_GetString(objv[2]); |
| 7378 if( sqlite3_strglob("SQLITE_*", zSetting)==0 ) zSetting += 7; |
| 7379 if( sqlite3_strglob("DBCONFIG_*", zSetting)==0 ) zSetting += 9; |
| 7380 if( sqlite3_strglob("ENABLE_*", zSetting)==0 ) zSetting += 7; |
| 7381 for(i=0; i<ArraySize(aSetting); i++){ |
| 7382 if( strcmp(zSetting, aSetting[i].zName)==0 ) break; |
| 7383 } |
| 7384 if( i>=ArraySize(aSetting) ){ |
| 7385 Tcl_SetObjResult(interp, |
| 7386 Tcl_NewStringObj("unknown sqlite3_db_config setting", -1)); |
| 7387 return TCL_ERROR; |
| 7388 } |
| 7389 if( Tcl_GetIntFromObj(interp, objv[3], &v) ) return TCL_ERROR; |
| 7390 sqlite3_db_config(db, aSetting[i].eVal, v, &v); |
| 7391 Tcl_SetObjResult(interp, Tcl_NewIntObj(v)); |
| 7392 return TCL_OK; |
| 7393 } |
| 7394 |
| 7395 /* |
| 7396 ** Change the name of the main database schema from "main" to "icecube". |
| 7397 */ |
| 7398 static int SQLITE_TCLAPI test_dbconfig_maindbname_icecube( |
| 7399 void * clientData, |
| 7400 Tcl_Interp *interp, |
| 7401 int objc, |
| 7402 Tcl_Obj *CONST objv[] |
| 7403 ){ |
| 7404 int rc; |
| 7405 sqlite3 *db; |
| 7406 extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); |
| 7407 if( objc!=2 ){ |
| 7408 Tcl_WrongNumArgs(interp, 1, objv, "DB"); |
| 7409 return TCL_ERROR; |
| 7410 }else{ |
| 7411 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
| 7412 rc = sqlite3_db_config(db, SQLITE_DBCONFIG_MAINDBNAME, "icecube"); |
| 7413 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); |
| 7414 return TCL_OK; |
| 7415 } |
| 7416 } |
| 7417 |
| 7418 /* |
| 6924 ** Register commands with the TCL interpreter. | 7419 ** Register commands with the TCL interpreter. |
| 6925 */ | 7420 */ |
| 6926 int Sqlitetest1_Init(Tcl_Interp *interp){ | 7421 int Sqlitetest1_Init(Tcl_Interp *interp){ |
| 6927 extern int sqlite3_search_count; | 7422 extern int sqlite3_search_count; |
| 6928 extern int sqlite3_found_count; | 7423 extern int sqlite3_found_count; |
| 6929 extern int sqlite3_interrupt_count; | 7424 extern int sqlite3_interrupt_count; |
| 6930 extern int sqlite3_open_file_count; | 7425 extern int sqlite3_open_file_count; |
| 6931 extern int sqlite3_sort_count; | 7426 extern int sqlite3_sort_count; |
| 6932 extern int sqlite3_current_time; | 7427 extern int sqlite3_current_time; |
| 6933 #if SQLITE_OS_UNIX && defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE | 7428 #if SQLITE_OS_UNIX && defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE |
| 6934 extern int sqlite3_hostid_num; | 7429 extern int sqlite3_hostid_num; |
| 6935 #endif | 7430 #endif |
| 6936 extern int sqlite3_max_blobsize; | 7431 extern int sqlite3_max_blobsize; |
| 6937 extern int sqlite3BtreeSharedCacheReport(void*, | 7432 extern int SQLITE_TCLAPI sqlite3BtreeSharedCacheReport(void*, |
| 6938 Tcl_Interp*,int,Tcl_Obj*CONST*); | 7433 Tcl_Interp*,int,Tcl_Obj*CONST*); |
| 6939 static int iZero = 0; | 7434 static int iZero = 0; |
| 6940 static struct { | 7435 static struct { |
| 6941 char *zName; | 7436 char *zName; |
| 6942 Tcl_CmdProc *xProc; | 7437 Tcl_CmdProc *xProc; |
| 6943 } aCmd[] = { | 7438 } aCmd[] = { |
| 6944 { "db_enter", (Tcl_CmdProc*)db_enter }, | 7439 { "db_enter", (Tcl_CmdProc*)db_enter }, |
| 6945 { "db_leave", (Tcl_CmdProc*)db_leave }, | 7440 { "db_leave", (Tcl_CmdProc*)db_leave }, |
| 6946 { "sqlite3_mprintf_int", (Tcl_CmdProc*)sqlite3_mprintf_int }, | 7441 { "sqlite3_mprintf_int", (Tcl_CmdProc*)sqlite3_mprintf_int }, |
| 6947 { "sqlite3_mprintf_int64", (Tcl_CmdProc*)sqlite3_mprintf_int64 }, | 7442 { "sqlite3_mprintf_int64", (Tcl_CmdProc*)sqlite3_mprintf_int64 }, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6982 { "sqlite3_busy_timeout", (Tcl_CmdProc*)test_busy_timeout }, | 7477 { "sqlite3_busy_timeout", (Tcl_CmdProc*)test_busy_timeout }, |
| 6983 { "printf", (Tcl_CmdProc*)test_printf }, | 7478 { "printf", (Tcl_CmdProc*)test_printf }, |
| 6984 { "sqlite3IoTrace", (Tcl_CmdProc*)test_io_trace }, | 7479 { "sqlite3IoTrace", (Tcl_CmdProc*)test_io_trace }, |
| 6985 { "clang_sanitize_address", (Tcl_CmdProc*)clang_sanitize_address }, | 7480 { "clang_sanitize_address", (Tcl_CmdProc*)clang_sanitize_address }, |
| 6986 }; | 7481 }; |
| 6987 static struct { | 7482 static struct { |
| 6988 char *zName; | 7483 char *zName; |
| 6989 Tcl_ObjCmdProc *xProc; | 7484 Tcl_ObjCmdProc *xProc; |
| 6990 void *clientData; | 7485 void *clientData; |
| 6991 } aObjCmd[] = { | 7486 } aObjCmd[] = { |
| 7487 { "sqlite3_db_config", test_sqlite3_db_config, 0 }, |
| 6992 { "bad_behavior", test_bad_behavior, (void*)&iZero }, | 7488 { "bad_behavior", test_bad_behavior, (void*)&iZero }, |
| 6993 { "register_dbstat_vtab", test_register_dbstat_vtab }, | 7489 { "register_dbstat_vtab", test_register_dbstat_vtab }, |
| 6994 { "sqlite3_connection_pointer", get_sqlite_pointer, 0 }, | 7490 { "sqlite3_connection_pointer", get_sqlite_pointer, 0 }, |
| 7491 { "intarray_addr", test_intarray_addr, 0 }, |
| 7492 { "int64array_addr", test_int64array_addr, 0 }, |
| 7493 { "doublearray_addr", test_doublearray_addr, 0 }, |
| 7494 { "textarray_addr", test_textarray_addr, 0 }, |
| 6995 { "sqlite3_bind_int", test_bind_int, 0 }, | 7495 { "sqlite3_bind_int", test_bind_int, 0 }, |
| 6996 { "sqlite3_bind_zeroblob", test_bind_zeroblob, 0 }, | 7496 { "sqlite3_bind_zeroblob", test_bind_zeroblob, 0 }, |
| 6997 { "sqlite3_bind_zeroblob64", test_bind_zeroblob64, 0 }, | 7497 { "sqlite3_bind_zeroblob64", test_bind_zeroblob64, 0 }, |
| 6998 { "sqlite3_bind_int64", test_bind_int64, 0 }, | 7498 { "sqlite3_bind_int64", test_bind_int64, 0 }, |
| 6999 { "sqlite3_bind_double", test_bind_double, 0 }, | 7499 { "sqlite3_bind_double", test_bind_double, 0 }, |
| 7000 { "sqlite3_bind_null", test_bind_null ,0 }, | 7500 { "sqlite3_bind_null", test_bind_null ,0 }, |
| 7001 { "sqlite3_bind_text", test_bind_text ,0 }, | 7501 { "sqlite3_bind_text", test_bind_text ,0 }, |
| 7002 { "sqlite3_bind_text16", test_bind_text16 ,0 }, | 7502 { "sqlite3_bind_text16", test_bind_text16 ,0 }, |
| 7003 { "sqlite3_bind_blob", test_bind_blob ,0 }, | 7503 { "sqlite3_bind_blob", test_bind_blob ,0 }, |
| 7004 { "sqlite3_bind_parameter_count", test_bind_parameter_count, 0}, | 7504 { "sqlite3_bind_parameter_count", test_bind_parameter_count, 0}, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 7021 { "sqlite3_prepare_tkt3134", test_prepare_tkt3134, 0}, | 7521 { "sqlite3_prepare_tkt3134", test_prepare_tkt3134, 0}, |
| 7022 { "sqlite3_prepare16_v2", test_prepare16_v2 ,0 }, | 7522 { "sqlite3_prepare16_v2", test_prepare16_v2 ,0 }, |
| 7023 { "sqlite3_finalize", test_finalize ,0 }, | 7523 { "sqlite3_finalize", test_finalize ,0 }, |
| 7024 { "sqlite3_stmt_status", test_stmt_status ,0 }, | 7524 { "sqlite3_stmt_status", test_stmt_status ,0 }, |
| 7025 { "sqlite3_reset", test_reset ,0 }, | 7525 { "sqlite3_reset", test_reset ,0 }, |
| 7026 { "sqlite3_expired", test_expired ,0 }, | 7526 { "sqlite3_expired", test_expired ,0 }, |
| 7027 { "sqlite3_transfer_bindings", test_transfer_bind ,0 }, | 7527 { "sqlite3_transfer_bindings", test_transfer_bind ,0 }, |
| 7028 { "sqlite3_changes", test_changes ,0 }, | 7528 { "sqlite3_changes", test_changes ,0 }, |
| 7029 { "sqlite3_step", test_step ,0 }, | 7529 { "sqlite3_step", test_step ,0 }, |
| 7030 { "sqlite3_sql", test_sql ,0 }, | 7530 { "sqlite3_sql", test_sql ,0 }, |
| 7531 { "sqlite3_expanded_sql", test_ex_sql ,0 }, |
| 7031 { "sqlite3_next_stmt", test_next_stmt ,0 }, | 7532 { "sqlite3_next_stmt", test_next_stmt ,0 }, |
| 7032 { "sqlite3_stmt_readonly", test_stmt_readonly ,0 }, | 7533 { "sqlite3_stmt_readonly", test_stmt_readonly ,0 }, |
| 7033 { "sqlite3_stmt_busy", test_stmt_busy ,0 }, | 7534 { "sqlite3_stmt_busy", test_stmt_busy ,0 }, |
| 7034 { "uses_stmt_journal", uses_stmt_journal ,0 }, | 7535 { "uses_stmt_journal", uses_stmt_journal ,0 }, |
| 7035 | 7536 |
| 7036 { "sqlite3_release_memory", test_release_memory, 0}, | 7537 { "sqlite3_release_memory", test_release_memory, 0}, |
| 7037 { "sqlite3_db_release_memory", test_db_release_memory, 0}, | 7538 { "sqlite3_db_release_memory", test_db_release_memory, 0}, |
| 7038 { "sqlite3_db_cacheflush", test_db_cacheflush, 0}, | 7539 { "sqlite3_db_cacheflush", test_db_cacheflush, 0}, |
| 7540 { "sqlite3_system_errno", test_system_errno, 0}, |
| 7039 { "sqlite3_db_filename", test_db_filename, 0}, | 7541 { "sqlite3_db_filename", test_db_filename, 0}, |
| 7040 { "sqlite3_db_readonly", test_db_readonly, 0}, | 7542 { "sqlite3_db_readonly", test_db_readonly, 0}, |
| 7041 { "sqlite3_soft_heap_limit", test_soft_heap_limit, 0}, | 7543 { "sqlite3_soft_heap_limit", test_soft_heap_limit, 0}, |
| 7042 { "sqlite3_thread_cleanup", test_thread_cleanup, 0}, | 7544 { "sqlite3_thread_cleanup", test_thread_cleanup, 0}, |
| 7043 { "sqlite3_pager_refcounts", test_pager_refcounts, 0}, | 7545 { "sqlite3_pager_refcounts", test_pager_refcounts, 0}, |
| 7044 | 7546 |
| 7045 { "sqlite3_load_extension", test_load_extension, 0}, | 7547 { "sqlite3_load_extension", test_load_extension, 0}, |
| 7046 { "sqlite3_enable_load_extension", test_enable_load, 0}, | 7548 { "sqlite3_enable_load_extension", test_enable_load, 0}, |
| 7047 { "sqlite3_extended_result_codes", test_extended_result_codes, 0}, | 7549 { "sqlite3_extended_result_codes", test_extended_result_codes, 0}, |
| 7048 { "sqlite3_limit", test_limit, 0}, | 7550 { "sqlite3_limit", test_limit, 0}, |
| 7551 { "dbconfig_maindbname_icecube", test_dbconfig_maindbname_icecube }, |
| 7049 | 7552 |
| 7050 { "save_prng_state", save_prng_state, 0 }, | 7553 { "save_prng_state", save_prng_state, 0 }, |
| 7051 { "restore_prng_state", restore_prng_state, 0 }, | 7554 { "restore_prng_state", restore_prng_state, 0 }, |
| 7052 { "reset_prng_state", reset_prng_state, 0 }, | 7555 { "reset_prng_state", reset_prng_state, 0 }, |
| 7053 { "database_never_corrupt", database_never_corrupt, 0}, | 7556 { "database_never_corrupt", database_never_corrupt, 0}, |
| 7054 { "database_may_be_corrupt", database_may_be_corrupt, 0}, | 7557 { "database_may_be_corrupt", database_may_be_corrupt, 0}, |
| 7055 { "optimization_control", optimization_control,0}, | 7558 { "optimization_control", optimization_control,0}, |
| 7056 #if SQLITE_OS_WIN | 7559 #if SQLITE_OS_WIN |
| 7057 { "lock_win32_file", win32_file_lock, 0 }, | 7560 { "lock_win32_file", win32_file_lock, 0 }, |
| 7058 { "exists_win32_path", win32_exists_path, 0 }, | 7561 { "exists_win32_path", win32_exists_path, 0 }, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7105 { "vfs_initfail_test", vfs_initfail_test, 0 }, | 7608 { "vfs_initfail_test", vfs_initfail_test, 0 }, |
| 7106 { "vfs_unregister_all", vfs_unregister_all, 0 }, | 7609 { "vfs_unregister_all", vfs_unregister_all, 0 }, |
| 7107 { "vfs_reregister_all", vfs_reregister_all, 0 }, | 7610 { "vfs_reregister_all", vfs_reregister_all, 0 }, |
| 7108 { "file_control_test", file_control_test, 0 }, | 7611 { "file_control_test", file_control_test, 0 }, |
| 7109 { "file_control_lasterrno_test", file_control_lasterrno_test, 0 }, | 7612 { "file_control_lasterrno_test", file_control_lasterrno_test, 0 }, |
| 7110 { "file_control_lockproxy_test", file_control_lockproxy_test, 0 }, | 7613 { "file_control_lockproxy_test", file_control_lockproxy_test, 0 }, |
| 7111 { "file_control_chunksize_test", file_control_chunksize_test, 0 }, | 7614 { "file_control_chunksize_test", file_control_chunksize_test, 0 }, |
| 7112 { "file_control_sizehint_test", file_control_sizehint_test, 0 }, | 7615 { "file_control_sizehint_test", file_control_sizehint_test, 0 }, |
| 7113 #if SQLITE_OS_WIN | 7616 #if SQLITE_OS_WIN |
| 7114 { "file_control_win32_av_retry", file_control_win32_av_retry, 0 }, | 7617 { "file_control_win32_av_retry", file_control_win32_av_retry, 0 }, |
| 7618 { "file_control_win32_get_handle", file_control_win32_get_handle, 0 }, |
| 7115 { "file_control_win32_set_handle", file_control_win32_set_handle, 0 }, | 7619 { "file_control_win32_set_handle", file_control_win32_set_handle, 0 }, |
| 7116 #endif | 7620 #endif |
| 7117 { "file_control_persist_wal", file_control_persist_wal, 0 }, | 7621 { "file_control_persist_wal", file_control_persist_wal, 0 }, |
| 7118 { "file_control_powersafe_overwrite",file_control_powersafe_overwrite,0}, | 7622 { "file_control_powersafe_overwrite",file_control_powersafe_overwrite,0}, |
| 7119 { "file_control_vfsname", file_control_vfsname, 0 }, | 7623 { "file_control_vfsname", file_control_vfsname, 0 }, |
| 7120 { "file_control_tempfilename", file_control_tempfilename, 0 }, | 7624 { "file_control_tempfilename", file_control_tempfilename, 0 }, |
| 7121 { "sqlite3_vfs_list", vfs_list, 0 }, | 7625 { "sqlite3_vfs_list", vfs_list, 0 }, |
| 7122 { "sqlite3_create_function_v2", test_create_function_v2, 0 }, | 7626 { "sqlite3_create_function_v2", test_create_function_v2, 0 }, |
| 7123 | 7627 |
| 7124 /* Functions from os.h */ | 7628 /* Functions from os.h */ |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7168 { "sqlite3_stmt_scanstatus_reset", test_stmt_scanstatus_reset, 0 }, | 7672 { "sqlite3_stmt_scanstatus_reset", test_stmt_scanstatus_reset, 0 }, |
| 7169 #endif | 7673 #endif |
| 7170 #ifdef SQLITE_ENABLE_SQLLOG | 7674 #ifdef SQLITE_ENABLE_SQLLOG |
| 7171 { "sqlite3_config_sqllog", test_config_sqllog, 0 }, | 7675 { "sqlite3_config_sqllog", test_config_sqllog, 0 }, |
| 7172 #endif | 7676 #endif |
| 7173 { "vfs_current_time_int64", vfsCurrentTimeInt64, 0 }, | 7677 { "vfs_current_time_int64", vfsCurrentTimeInt64, 0 }, |
| 7174 #ifdef SQLITE_ENABLE_SNAPSHOT | 7678 #ifdef SQLITE_ENABLE_SNAPSHOT |
| 7175 { "sqlite3_snapshot_get", test_snapshot_get, 0 }, | 7679 { "sqlite3_snapshot_get", test_snapshot_get, 0 }, |
| 7176 { "sqlite3_snapshot_open", test_snapshot_open, 0 }, | 7680 { "sqlite3_snapshot_open", test_snapshot_open, 0 }, |
| 7177 { "sqlite3_snapshot_free", test_snapshot_free, 0 }, | 7681 { "sqlite3_snapshot_free", test_snapshot_free, 0 }, |
| 7682 { "sqlite3_snapshot_cmp", test_snapshot_cmp, 0 }, |
| 7683 { "sqlite3_snapshot_recover", test_snapshot_recover, 0 }, |
| 7684 { "sqlite3_snapshot_get_blob", test_snapshot_get_blob, 0 }, |
| 7685 { "sqlite3_snapshot_open_blob", test_snapshot_open_blob, 0 }, |
| 7686 { "sqlite3_snapshot_cmp_blob", test_snapshot_cmp_blob, 0 }, |
| 7178 #endif | 7687 #endif |
| 7688 { "sqlite3_delete_database", test_delete_database, 0 }, |
| 7179 }; | 7689 }; |
| 7180 static int bitmask_size = sizeof(Bitmask)*8; | 7690 static int bitmask_size = sizeof(Bitmask)*8; |
| 7181 static int longdouble_size = sizeof(LONGDOUBLE_TYPE); | 7691 static int longdouble_size = sizeof(LONGDOUBLE_TYPE); |
| 7182 int i; | 7692 int i; |
| 7183 extern int sqlite3_sync_count, sqlite3_fullsync_count; | 7693 extern int sqlite3_sync_count, sqlite3_fullsync_count; |
| 7184 extern int sqlite3_opentemp_count; | 7694 extern int sqlite3_opentemp_count; |
| 7185 extern int sqlite3_like_count; | 7695 extern int sqlite3_like_count; |
| 7186 extern int sqlite3_xferopt_count; | 7696 extern int sqlite3_xferopt_count; |
| 7187 extern int sqlite3_pager_readdb_count; | 7697 extern int sqlite3_pager_readdb_count; |
| 7188 extern int sqlite3_pager_writedb_count; | 7698 extern int sqlite3_pager_writedb_count; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7284 Tcl_LinkVar(interp, "sqlite_sync_count", | 7794 Tcl_LinkVar(interp, "sqlite_sync_count", |
| 7285 (char*)&sqlite3_sync_count, TCL_LINK_INT); | 7795 (char*)&sqlite3_sync_count, TCL_LINK_INT); |
| 7286 Tcl_LinkVar(interp, "sqlite_fullsync_count", | 7796 Tcl_LinkVar(interp, "sqlite_fullsync_count", |
| 7287 (char*)&sqlite3_fullsync_count, TCL_LINK_INT); | 7797 (char*)&sqlite3_fullsync_count, TCL_LINK_INT); |
| 7288 #if defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_TEST) | 7798 #if defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_TEST) |
| 7289 Tcl_LinkVar(interp, "sqlite_fts3_enable_parentheses", | 7799 Tcl_LinkVar(interp, "sqlite_fts3_enable_parentheses", |
| 7290 (char*)&sqlite3_fts3_enable_parentheses, TCL_LINK_INT); | 7800 (char*)&sqlite3_fts3_enable_parentheses, TCL_LINK_INT); |
| 7291 #endif | 7801 #endif |
| 7292 return TCL_OK; | 7802 return TCL_OK; |
| 7293 } | 7803 } |
| OLD | NEW |