OLD | NEW |
1 /* | 1 /* |
2 ** 2007 August 15 | 2 ** 2007 August 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 ** | 12 ** |
13 ** This file contains code used to implement test interfaces to the | 13 ** This file contains code used to implement test interfaces to the |
14 ** memory allocation subsystem. | 14 ** memory allocation subsystem. |
15 */ | 15 */ |
16 #include "sqliteInt.h" | 16 #include "sqliteInt.h" |
17 #include "tcl.h" | 17 #if defined(INCLUDE_SQLITE_TCL_H) |
| 18 # include "sqlite_tcl.h" |
| 19 #else |
| 20 # include "tcl.h" |
| 21 #endif |
18 #include <stdlib.h> | 22 #include <stdlib.h> |
19 #include <string.h> | 23 #include <string.h> |
20 #include <assert.h> | 24 #include <assert.h> |
21 | 25 |
22 /* | 26 /* |
23 ** This structure is used to encapsulate the global state variables used | 27 ** This structure is used to encapsulate the global state variables used |
24 ** by malloc() fault simulation. | 28 ** by malloc() fault simulation. |
25 */ | 29 */ |
26 static struct MemFault { | 30 static struct MemFault { |
27 int iCountdown; /* Number of pending successes before a failure */ | 31 int iCountdown; /* Number of pending successes before a failure */ |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 assert( 0 ); | 303 assert( 0 ); |
300 } | 304 } |
301 return TCL_OK; | 305 return TCL_OK; |
302 } | 306 } |
303 | 307 |
304 /* | 308 /* |
305 ** Usage: sqlite3_malloc NBYTES | 309 ** Usage: sqlite3_malloc NBYTES |
306 ** | 310 ** |
307 ** Raw test interface for sqlite3_malloc(). | 311 ** Raw test interface for sqlite3_malloc(). |
308 */ | 312 */ |
309 static int test_malloc( | 313 static int SQLITE_TCLAPI test_malloc( |
310 void * clientData, | 314 void * clientData, |
311 Tcl_Interp *interp, | 315 Tcl_Interp *interp, |
312 int objc, | 316 int objc, |
313 Tcl_Obj *CONST objv[] | 317 Tcl_Obj *CONST objv[] |
314 ){ | 318 ){ |
315 int nByte; | 319 int nByte; |
316 void *p; | 320 void *p; |
317 char zOut[100]; | 321 char zOut[100]; |
318 if( objc!=2 ){ | 322 if( objc!=2 ){ |
319 Tcl_WrongNumArgs(interp, 1, objv, "NBYTES"); | 323 Tcl_WrongNumArgs(interp, 1, objv, "NBYTES"); |
320 return TCL_ERROR; | 324 return TCL_ERROR; |
321 } | 325 } |
322 if( Tcl_GetIntFromObj(interp, objv[1], &nByte) ) return TCL_ERROR; | 326 if( Tcl_GetIntFromObj(interp, objv[1], &nByte) ) return TCL_ERROR; |
323 p = sqlite3_malloc((unsigned)nByte); | 327 p = sqlite3_malloc((unsigned)nByte); |
324 pointerToText(p, zOut); | 328 pointerToText(p, zOut); |
325 Tcl_AppendResult(interp, zOut, NULL); | 329 Tcl_AppendResult(interp, zOut, NULL); |
326 return TCL_OK; | 330 return TCL_OK; |
327 } | 331 } |
328 | 332 |
329 /* | 333 /* |
330 ** Usage: sqlite3_realloc PRIOR NBYTES | 334 ** Usage: sqlite3_realloc PRIOR NBYTES |
331 ** | 335 ** |
332 ** Raw test interface for sqlite3_realloc(). | 336 ** Raw test interface for sqlite3_realloc(). |
333 */ | 337 */ |
334 static int test_realloc( | 338 static int SQLITE_TCLAPI test_realloc( |
335 void * clientData, | 339 void * clientData, |
336 Tcl_Interp *interp, | 340 Tcl_Interp *interp, |
337 int objc, | 341 int objc, |
338 Tcl_Obj *CONST objv[] | 342 Tcl_Obj *CONST objv[] |
339 ){ | 343 ){ |
340 int nByte; | 344 int nByte; |
341 void *pPrior, *p; | 345 void *pPrior, *p; |
342 char zOut[100]; | 346 char zOut[100]; |
343 if( objc!=3 ){ | 347 if( objc!=3 ){ |
344 Tcl_WrongNumArgs(interp, 1, objv, "PRIOR NBYTES"); | 348 Tcl_WrongNumArgs(interp, 1, objv, "PRIOR NBYTES"); |
345 return TCL_ERROR; | 349 return TCL_ERROR; |
346 } | 350 } |
347 if( Tcl_GetIntFromObj(interp, objv[2], &nByte) ) return TCL_ERROR; | 351 if( Tcl_GetIntFromObj(interp, objv[2], &nByte) ) return TCL_ERROR; |
348 if( textToPointer(Tcl_GetString(objv[1]), &pPrior) ){ | 352 if( textToPointer(Tcl_GetString(objv[1]), &pPrior) ){ |
349 Tcl_AppendResult(interp, "bad pointer: ", Tcl_GetString(objv[1]), (char*)0); | 353 Tcl_AppendResult(interp, "bad pointer: ", Tcl_GetString(objv[1]), (char*)0); |
350 return TCL_ERROR; | 354 return TCL_ERROR; |
351 } | 355 } |
352 p = sqlite3_realloc(pPrior, (unsigned)nByte); | 356 p = sqlite3_realloc(pPrior, (unsigned)nByte); |
353 pointerToText(p, zOut); | 357 pointerToText(p, zOut); |
354 Tcl_AppendResult(interp, zOut, NULL); | 358 Tcl_AppendResult(interp, zOut, NULL); |
355 return TCL_OK; | 359 return TCL_OK; |
356 } | 360 } |
357 | 361 |
358 /* | 362 /* |
359 ** Usage: sqlite3_free PRIOR | 363 ** Usage: sqlite3_free PRIOR |
360 ** | 364 ** |
361 ** Raw test interface for sqlite3_free(). | 365 ** Raw test interface for sqlite3_free(). |
362 */ | 366 */ |
363 static int test_free( | 367 static int SQLITE_TCLAPI test_free( |
364 void * clientData, | 368 void * clientData, |
365 Tcl_Interp *interp, | 369 Tcl_Interp *interp, |
366 int objc, | 370 int objc, |
367 Tcl_Obj *CONST objv[] | 371 Tcl_Obj *CONST objv[] |
368 ){ | 372 ){ |
369 void *pPrior; | 373 void *pPrior; |
370 if( objc!=2 ){ | 374 if( objc!=2 ){ |
371 Tcl_WrongNumArgs(interp, 1, objv, "PRIOR"); | 375 Tcl_WrongNumArgs(interp, 1, objv, "PRIOR"); |
372 return TCL_ERROR; | 376 return TCL_ERROR; |
373 } | 377 } |
(...skipping 10 matching lines...) Expand all Loading... |
384 */ | 388 */ |
385 int sqlite3TestHexToBin(const char *, int, char *); | 389 int sqlite3TestHexToBin(const char *, int, char *); |
386 int sqlite3TestBinToHex(char*,int); | 390 int sqlite3TestBinToHex(char*,int); |
387 | 391 |
388 /* | 392 /* |
389 ** Usage: memset ADDRESS SIZE HEX | 393 ** Usage: memset ADDRESS SIZE HEX |
390 ** | 394 ** |
391 ** Set a chunk of memory (obtained from malloc, probably) to a | 395 ** Set a chunk of memory (obtained from malloc, probably) to a |
392 ** specified hex pattern. | 396 ** specified hex pattern. |
393 */ | 397 */ |
394 static int test_memset( | 398 static int SQLITE_TCLAPI test_memset( |
395 void * clientData, | 399 void * clientData, |
396 Tcl_Interp *interp, | 400 Tcl_Interp *interp, |
397 int objc, | 401 int objc, |
398 Tcl_Obj *CONST objv[] | 402 Tcl_Obj *CONST objv[] |
399 ){ | 403 ){ |
400 void *p; | 404 void *p; |
401 int size, n, i; | 405 int size, n, i; |
402 char *zHex; | 406 char *zHex; |
403 char *zOut; | 407 char *zOut; |
404 char zBin[100]; | 408 char zBin[100]; |
(...skipping 25 matching lines...) Expand all Loading... |
430 zOut[i] = zBin[i%n]; | 434 zOut[i] = zBin[i%n]; |
431 } | 435 } |
432 return TCL_OK; | 436 return TCL_OK; |
433 } | 437 } |
434 | 438 |
435 /* | 439 /* |
436 ** Usage: memget ADDRESS SIZE | 440 ** Usage: memget ADDRESS SIZE |
437 ** | 441 ** |
438 ** Return memory as hexadecimal text. | 442 ** Return memory as hexadecimal text. |
439 */ | 443 */ |
440 static int test_memget( | 444 static int SQLITE_TCLAPI test_memget( |
441 void * clientData, | 445 void * clientData, |
442 Tcl_Interp *interp, | 446 Tcl_Interp *interp, |
443 int objc, | 447 int objc, |
444 Tcl_Obj *CONST objv[] | 448 Tcl_Obj *CONST objv[] |
445 ){ | 449 ){ |
446 void *p; | 450 void *p; |
447 int size, n; | 451 int size, n; |
448 char *zBin; | 452 char *zBin; |
449 char zHex[100]; | 453 char zHex[100]; |
450 | 454 |
(...skipping 26 matching lines...) Expand all Loading... |
477 Tcl_AppendResult(interp, zHex, (char*)0); | 481 Tcl_AppendResult(interp, zHex, (char*)0); |
478 } | 482 } |
479 return TCL_OK; | 483 return TCL_OK; |
480 } | 484 } |
481 | 485 |
482 /* | 486 /* |
483 ** Usage: sqlite3_memory_used | 487 ** Usage: sqlite3_memory_used |
484 ** | 488 ** |
485 ** Raw test interface for sqlite3_memory_used(). | 489 ** Raw test interface for sqlite3_memory_used(). |
486 */ | 490 */ |
487 static int test_memory_used( | 491 static int SQLITE_TCLAPI test_memory_used( |
488 void * clientData, | 492 void * clientData, |
489 Tcl_Interp *interp, | 493 Tcl_Interp *interp, |
490 int objc, | 494 int objc, |
491 Tcl_Obj *CONST objv[] | 495 Tcl_Obj *CONST objv[] |
492 ){ | 496 ){ |
493 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(sqlite3_memory_used())); | 497 Tcl_SetObjResult(interp, Tcl_NewWideIntObj(sqlite3_memory_used())); |
494 return TCL_OK; | 498 return TCL_OK; |
495 } | 499 } |
496 | 500 |
497 /* | 501 /* |
498 ** Usage: sqlite3_memory_highwater ?RESETFLAG? | 502 ** Usage: sqlite3_memory_highwater ?RESETFLAG? |
499 ** | 503 ** |
500 ** Raw test interface for sqlite3_memory_highwater(). | 504 ** Raw test interface for sqlite3_memory_highwater(). |
501 */ | 505 */ |
502 static int test_memory_highwater( | 506 static int SQLITE_TCLAPI test_memory_highwater( |
503 void * clientData, | 507 void * clientData, |
504 Tcl_Interp *interp, | 508 Tcl_Interp *interp, |
505 int objc, | 509 int objc, |
506 Tcl_Obj *CONST objv[] | 510 Tcl_Obj *CONST objv[] |
507 ){ | 511 ){ |
508 int resetFlag = 0; | 512 int resetFlag = 0; |
509 if( objc!=1 && objc!=2 ){ | 513 if( objc!=1 && objc!=2 ){ |
510 Tcl_WrongNumArgs(interp, 1, objv, "?RESET?"); | 514 Tcl_WrongNumArgs(interp, 1, objv, "?RESET?"); |
511 return TCL_ERROR; | 515 return TCL_ERROR; |
512 } | 516 } |
513 if( objc==2 ){ | 517 if( objc==2 ){ |
514 if( Tcl_GetBooleanFromObj(interp, objv[1], &resetFlag) ) return TCL_ERROR; | 518 if( Tcl_GetBooleanFromObj(interp, objv[1], &resetFlag) ) return TCL_ERROR; |
515 } | 519 } |
516 Tcl_SetObjResult(interp, | 520 Tcl_SetObjResult(interp, |
517 Tcl_NewWideIntObj(sqlite3_memory_highwater(resetFlag))); | 521 Tcl_NewWideIntObj(sqlite3_memory_highwater(resetFlag))); |
518 return TCL_OK; | 522 return TCL_OK; |
519 } | 523 } |
520 | 524 |
521 /* | 525 /* |
522 ** Usage: sqlite3_memdebug_backtrace DEPTH | 526 ** Usage: sqlite3_memdebug_backtrace DEPTH |
523 ** | 527 ** |
524 ** Set the depth of backtracing. If SQLITE_MEMDEBUG is not defined | 528 ** Set the depth of backtracing. If SQLITE_MEMDEBUG is not defined |
525 ** then this routine is a no-op. | 529 ** then this routine is a no-op. |
526 */ | 530 */ |
527 static int test_memdebug_backtrace( | 531 static int SQLITE_TCLAPI test_memdebug_backtrace( |
528 void * clientData, | 532 void * clientData, |
529 Tcl_Interp *interp, | 533 Tcl_Interp *interp, |
530 int objc, | 534 int objc, |
531 Tcl_Obj *CONST objv[] | 535 Tcl_Obj *CONST objv[] |
532 ){ | 536 ){ |
533 int depth; | 537 int depth; |
534 if( objc!=2 ){ | 538 if( objc!=2 ){ |
535 Tcl_WrongNumArgs(interp, 1, objv, "DEPT"); | 539 Tcl_WrongNumArgs(interp, 1, objv, "DEPT"); |
536 return TCL_ERROR; | 540 return TCL_ERROR; |
537 } | 541 } |
538 if( Tcl_GetIntFromObj(interp, objv[1], &depth) ) return TCL_ERROR; | 542 if( Tcl_GetIntFromObj(interp, objv[1], &depth) ) return TCL_ERROR; |
539 #ifdef SQLITE_MEMDEBUG | 543 #ifdef SQLITE_MEMDEBUG |
540 { | 544 { |
541 extern void sqlite3MemdebugBacktrace(int); | 545 extern void sqlite3MemdebugBacktrace(int); |
542 sqlite3MemdebugBacktrace(depth); | 546 sqlite3MemdebugBacktrace(depth); |
543 } | 547 } |
544 #endif | 548 #endif |
545 return TCL_OK; | 549 return TCL_OK; |
546 } | 550 } |
547 | 551 |
548 /* | 552 /* |
549 ** Usage: sqlite3_memdebug_dump FILENAME | 553 ** Usage: sqlite3_memdebug_dump FILENAME |
550 ** | 554 ** |
551 ** Write a summary of unfreed memory to FILENAME. | 555 ** Write a summary of unfreed memory to FILENAME. |
552 */ | 556 */ |
553 static int test_memdebug_dump( | 557 static int SQLITE_TCLAPI test_memdebug_dump( |
554 void * clientData, | 558 void * clientData, |
555 Tcl_Interp *interp, | 559 Tcl_Interp *interp, |
556 int objc, | 560 int objc, |
557 Tcl_Obj *CONST objv[] | 561 Tcl_Obj *CONST objv[] |
558 ){ | 562 ){ |
559 if( objc!=2 ){ | 563 if( objc!=2 ){ |
560 Tcl_WrongNumArgs(interp, 1, objv, "FILENAME"); | 564 Tcl_WrongNumArgs(interp, 1, objv, "FILENAME"); |
561 return TCL_ERROR; | 565 return TCL_ERROR; |
562 } | 566 } |
563 #if defined(SQLITE_MEMDEBUG) || defined(SQLITE_MEMORY_SIZE) \ | 567 #if defined(SQLITE_MEMDEBUG) || defined(SQLITE_MEMORY_SIZE) \ |
564 || defined(SQLITE_POW2_MEMORY_SIZE) | 568 || defined(SQLITE_POW2_MEMORY_SIZE) |
565 { | 569 { |
566 extern void sqlite3MemdebugDump(const char*); | 570 extern void sqlite3MemdebugDump(const char*); |
567 sqlite3MemdebugDump(Tcl_GetString(objv[1])); | 571 sqlite3MemdebugDump(Tcl_GetString(objv[1])); |
568 } | 572 } |
569 #endif | 573 #endif |
570 return TCL_OK; | 574 return TCL_OK; |
571 } | 575 } |
572 | 576 |
573 /* | 577 /* |
574 ** Usage: sqlite3_memdebug_malloc_count | 578 ** Usage: sqlite3_memdebug_malloc_count |
575 ** | 579 ** |
576 ** Return the total number of times malloc() has been called. | 580 ** Return the total number of times malloc() has been called. |
577 */ | 581 */ |
578 static int test_memdebug_malloc_count( | 582 static int SQLITE_TCLAPI test_memdebug_malloc_count( |
579 void * clientData, | 583 void * clientData, |
580 Tcl_Interp *interp, | 584 Tcl_Interp *interp, |
581 int objc, | 585 int objc, |
582 Tcl_Obj *CONST objv[] | 586 Tcl_Obj *CONST objv[] |
583 ){ | 587 ){ |
584 int nMalloc = -1; | 588 int nMalloc = -1; |
585 if( objc!=1 ){ | 589 if( objc!=1 ){ |
586 Tcl_WrongNumArgs(interp, 1, objv, ""); | 590 Tcl_WrongNumArgs(interp, 1, objv, ""); |
587 return TCL_ERROR; | 591 return TCL_ERROR; |
588 } | 592 } |
(...skipping 19 matching lines...) Expand all Loading... |
608 ** Arrange for a simulated malloc() failure after COUNTER successes. | 612 ** Arrange for a simulated malloc() failure after COUNTER successes. |
609 ** If a repeat count is specified, the fault is repeated that many | 613 ** If a repeat count is specified, the fault is repeated that many |
610 ** times. | 614 ** times. |
611 ** | 615 ** |
612 ** Each call to this routine overrides the prior counter value. | 616 ** Each call to this routine overrides the prior counter value. |
613 ** This routine returns the number of simulated failures that have | 617 ** This routine returns the number of simulated failures that have |
614 ** happened since the previous call to this routine. | 618 ** happened since the previous call to this routine. |
615 ** | 619 ** |
616 ** To disable simulated failures, use a COUNTER of -1. | 620 ** To disable simulated failures, use a COUNTER of -1. |
617 */ | 621 */ |
618 static int test_memdebug_fail( | 622 static int SQLITE_TCLAPI test_memdebug_fail( |
619 void * clientData, | 623 void * clientData, |
620 Tcl_Interp *interp, | 624 Tcl_Interp *interp, |
621 int objc, | 625 int objc, |
622 Tcl_Obj *CONST objv[] | 626 Tcl_Obj *CONST objv[] |
623 ){ | 627 ){ |
624 int ii; | 628 int ii; |
625 int iFail; | 629 int iFail; |
626 int nRepeat = 1; | 630 int nRepeat = 1; |
627 Tcl_Obj *pBenignCnt = 0; | 631 Tcl_Obj *pBenignCnt = 0; |
628 int nBenign; | 632 int nBenign; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 return TCL_OK; | 678 return TCL_OK; |
675 } | 679 } |
676 | 680 |
677 /* | 681 /* |
678 ** Usage: sqlite3_memdebug_pending | 682 ** Usage: sqlite3_memdebug_pending |
679 ** | 683 ** |
680 ** Return the number of malloc() calls that will succeed before a | 684 ** Return the number of malloc() calls that will succeed before a |
681 ** simulated failure occurs. A negative return value indicates that | 685 ** simulated failure occurs. A negative return value indicates that |
682 ** no malloc() failure is scheduled. | 686 ** no malloc() failure is scheduled. |
683 */ | 687 */ |
684 static int test_memdebug_pending( | 688 static int SQLITE_TCLAPI test_memdebug_pending( |
685 void * clientData, | 689 void * clientData, |
686 Tcl_Interp *interp, | 690 Tcl_Interp *interp, |
687 int objc, | 691 int objc, |
688 Tcl_Obj *CONST objv[] | 692 Tcl_Obj *CONST objv[] |
689 ){ | 693 ){ |
690 int nPending; | 694 int nPending; |
691 if( objc!=1 ){ | 695 if( objc!=1 ){ |
692 Tcl_WrongNumArgs(interp, 1, objv, ""); | 696 Tcl_WrongNumArgs(interp, 1, objv, ""); |
693 return TCL_ERROR; | 697 return TCL_ERROR; |
694 } | 698 } |
(...skipping 12 matching lines...) Expand all Loading... |
707 /* | 711 /* |
708 ** Usage: sqlite3_memdebug_settitle TITLE | 712 ** Usage: sqlite3_memdebug_settitle TITLE |
709 ** | 713 ** |
710 ** Set a title string stored with each allocation. The TITLE is | 714 ** Set a title string stored with each allocation. The TITLE is |
711 ** typically the name of the test that was running when the | 715 ** typically the name of the test that was running when the |
712 ** allocation occurred. The TITLE is stored with the allocation | 716 ** allocation occurred. The TITLE is stored with the allocation |
713 ** and can be used to figure out which tests are leaking memory. | 717 ** and can be used to figure out which tests are leaking memory. |
714 ** | 718 ** |
715 ** Each title overwrite the previous. | 719 ** Each title overwrite the previous. |
716 */ | 720 */ |
717 static int test_memdebug_settitle( | 721 static int SQLITE_TCLAPI test_memdebug_settitle( |
718 void * clientData, | 722 void * clientData, |
719 Tcl_Interp *interp, | 723 Tcl_Interp *interp, |
720 int objc, | 724 int objc, |
721 Tcl_Obj *CONST objv[] | 725 Tcl_Obj *CONST objv[] |
722 ){ | 726 ){ |
723 sqlite3_memdebug_title_count++; | 727 sqlite3_memdebug_title_count++; |
724 if( objc!=2 ){ | 728 if( objc!=2 ){ |
725 Tcl_WrongNumArgs(interp, 1, objv, "TITLE"); | 729 Tcl_WrongNumArgs(interp, 1, objv, "TITLE"); |
726 return TCL_ERROR; | 730 return TCL_ERROR; |
727 } | 731 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 pEntry; | 792 pEntry; |
789 pEntry=Tcl_NextHashEntry(&search) | 793 pEntry=Tcl_NextHashEntry(&search) |
790 ){ | 794 ){ |
791 MallocLog *pLog = (MallocLog *)Tcl_GetHashValue(pEntry); | 795 MallocLog *pLog = (MallocLog *)Tcl_GetHashValue(pEntry); |
792 Tcl_Free((char *)pLog); | 796 Tcl_Free((char *)pLog); |
793 } | 797 } |
794 Tcl_DeleteHashTable(&aMallocLog); | 798 Tcl_DeleteHashTable(&aMallocLog); |
795 Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_KEYINTS); | 799 Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_KEYINTS); |
796 } | 800 } |
797 | 801 |
798 static int test_memdebug_log( | 802 static int SQLITE_TCLAPI test_memdebug_log( |
799 void * clientData, | 803 void * clientData, |
800 Tcl_Interp *interp, | 804 Tcl_Interp *interp, |
801 int objc, | 805 int objc, |
802 Tcl_Obj *CONST objv[] | 806 Tcl_Obj *CONST objv[] |
803 ){ | 807 ){ |
804 static int isInit = 0; | 808 static int isInit = 0; |
805 int iSub; | 809 int iSub; |
806 | 810 |
807 static const char *MB_strs[] = { "start", "stop", "dump", "clear", "sync" }; | 811 static const char *MB_strs[] = { "start", "stop", "dump", "clear", "sync" }; |
808 enum MB_enum { | 812 enum MB_enum { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 /* | 890 /* |
887 ** Usage: sqlite3_config_scratch SIZE N | 891 ** Usage: sqlite3_config_scratch SIZE N |
888 ** | 892 ** |
889 ** Set the scratch memory buffer using SQLITE_CONFIG_SCRATCH. | 893 ** Set the scratch memory buffer using SQLITE_CONFIG_SCRATCH. |
890 ** The buffer is static and is of limited size. N might be | 894 ** The buffer is static and is of limited size. N might be |
891 ** adjusted downward as needed to accommodate the requested size. | 895 ** adjusted downward as needed to accommodate the requested size. |
892 ** The revised value of N is returned. | 896 ** The revised value of N is returned. |
893 ** | 897 ** |
894 ** A negative SIZE causes the buffer pointer to be NULL. | 898 ** A negative SIZE causes the buffer pointer to be NULL. |
895 */ | 899 */ |
896 static int test_config_scratch( | 900 static int SQLITE_TCLAPI test_config_scratch( |
897 void * clientData, | 901 void * clientData, |
898 Tcl_Interp *interp, | 902 Tcl_Interp *interp, |
899 int objc, | 903 int objc, |
900 Tcl_Obj *CONST objv[] | 904 Tcl_Obj *CONST objv[] |
901 ){ | 905 ){ |
902 int sz, N, rc; | 906 int sz, N, rc; |
903 Tcl_Obj *pResult; | 907 Tcl_Obj *pResult; |
904 static char *buf = 0; | 908 static char *buf = 0; |
905 if( objc!=3 ){ | 909 if( objc!=3 ){ |
906 Tcl_WrongNumArgs(interp, 1, objv, "SIZE N"); | 910 Tcl_WrongNumArgs(interp, 1, objv, "SIZE N"); |
(...skipping 19 matching lines...) Expand all Loading... |
926 /* | 930 /* |
927 ** Usage: sqlite3_config_pagecache SIZE N | 931 ** Usage: sqlite3_config_pagecache SIZE N |
928 ** | 932 ** |
929 ** Set the page-cache memory buffer using SQLITE_CONFIG_PAGECACHE. | 933 ** Set the page-cache memory buffer using SQLITE_CONFIG_PAGECACHE. |
930 ** The buffer is static and is of limited size. N might be | 934 ** The buffer is static and is of limited size. N might be |
931 ** adjusted downward as needed to accommodate the requested size. | 935 ** adjusted downward as needed to accommodate the requested size. |
932 ** The revised value of N is returned. | 936 ** The revised value of N is returned. |
933 ** | 937 ** |
934 ** A negative SIZE causes the buffer pointer to be NULL. | 938 ** A negative SIZE causes the buffer pointer to be NULL. |
935 */ | 939 */ |
936 static int test_config_pagecache( | 940 static int SQLITE_TCLAPI test_config_pagecache( |
937 void * clientData, | 941 void * clientData, |
938 Tcl_Interp *interp, | 942 Tcl_Interp *interp, |
939 int objc, | 943 int objc, |
940 Tcl_Obj *CONST objv[] | 944 Tcl_Obj *CONST objv[] |
941 ){ | 945 ){ |
942 int sz, N; | 946 int sz, N; |
943 Tcl_Obj *pRes; | 947 Tcl_Obj *pRes; |
944 static char *buf = 0; | 948 static char *buf = 0; |
945 if( objc!=3 ){ | 949 if( objc!=3 ){ |
946 Tcl_WrongNumArgs(interp, 1, objv, "SIZE N"); | 950 Tcl_WrongNumArgs(interp, 1, objv, "SIZE N"); |
(...skipping 22 matching lines...) Expand all Loading... |
969 /* | 973 /* |
970 ** Usage: sqlite3_config_alt_pcache INSTALL_FLAG DISCARD_CHANCE PRNG_SEED | 974 ** Usage: sqlite3_config_alt_pcache INSTALL_FLAG DISCARD_CHANCE PRNG_SEED |
971 ** | 975 ** |
972 ** Set up the alternative test page cache. Install if INSTALL_FLAG is | 976 ** Set up the alternative test page cache. Install if INSTALL_FLAG is |
973 ** true and uninstall (reverting to the default page cache) if INSTALL_FLAG | 977 ** true and uninstall (reverting to the default page cache) if INSTALL_FLAG |
974 ** is false. DISCARD_CHANGE is an integer between 0 and 100 inclusive | 978 ** is false. DISCARD_CHANGE is an integer between 0 and 100 inclusive |
975 ** which determines the chance of discarding a page when unpinned. 100 | 979 ** which determines the chance of discarding a page when unpinned. 100 |
976 ** is certainty. 0 is never. PRNG_SEED is the pseudo-random number generator | 980 ** is certainty. 0 is never. PRNG_SEED is the pseudo-random number generator |
977 ** seed. | 981 ** seed. |
978 */ | 982 */ |
979 static int test_alt_pcache( | 983 static int SQLITE_TCLAPI test_alt_pcache( |
980 void * clientData, | 984 void * clientData, |
981 Tcl_Interp *interp, | 985 Tcl_Interp *interp, |
982 int objc, | 986 int objc, |
983 Tcl_Obj *CONST objv[] | 987 Tcl_Obj *CONST objv[] |
984 ){ | 988 ){ |
985 int installFlag; | 989 int installFlag; |
986 int discardChance = 0; | 990 int discardChance = 0; |
987 int prngSeed = 0; | 991 int prngSeed = 0; |
988 int highStress = 0; | 992 int highStress = 0; |
989 extern void installTestPCache(int,unsigned,unsigned,unsigned); | 993 extern void installTestPCache(int,unsigned,unsigned,unsigned); |
(...skipping 20 matching lines...) Expand all Loading... |
1010 installTestPCache(installFlag, (unsigned)discardChance, (unsigned)prngSeed, | 1014 installTestPCache(installFlag, (unsigned)discardChance, (unsigned)prngSeed, |
1011 (unsigned)highStress); | 1015 (unsigned)highStress); |
1012 return TCL_OK; | 1016 return TCL_OK; |
1013 } | 1017 } |
1014 | 1018 |
1015 /* | 1019 /* |
1016 ** Usage: sqlite3_config_memstatus BOOLEAN | 1020 ** Usage: sqlite3_config_memstatus BOOLEAN |
1017 ** | 1021 ** |
1018 ** Enable or disable memory status reporting using SQLITE_CONFIG_MEMSTATUS. | 1022 ** Enable or disable memory status reporting using SQLITE_CONFIG_MEMSTATUS. |
1019 */ | 1023 */ |
1020 static int test_config_memstatus( | 1024 static int SQLITE_TCLAPI test_config_memstatus( |
1021 void * clientData, | 1025 void * clientData, |
1022 Tcl_Interp *interp, | 1026 Tcl_Interp *interp, |
1023 int objc, | 1027 int objc, |
1024 Tcl_Obj *CONST objv[] | 1028 Tcl_Obj *CONST objv[] |
1025 ){ | 1029 ){ |
1026 int enable, rc; | 1030 int enable, rc; |
1027 if( objc!=2 ){ | 1031 if( objc!=2 ){ |
1028 Tcl_WrongNumArgs(interp, 1, objv, "BOOLEAN"); | 1032 Tcl_WrongNumArgs(interp, 1, objv, "BOOLEAN"); |
1029 return TCL_ERROR; | 1033 return TCL_ERROR; |
1030 } | 1034 } |
1031 if( Tcl_GetBooleanFromObj(interp, objv[1], &enable) ) return TCL_ERROR; | 1035 if( Tcl_GetBooleanFromObj(interp, objv[1], &enable) ) return TCL_ERROR; |
1032 rc = sqlite3_config(SQLITE_CONFIG_MEMSTATUS, enable); | 1036 rc = sqlite3_config(SQLITE_CONFIG_MEMSTATUS, enable); |
1033 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); | 1037 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); |
1034 return TCL_OK; | 1038 return TCL_OK; |
1035 } | 1039 } |
1036 | 1040 |
1037 /* | 1041 /* |
1038 ** Usage: sqlite3_config_lookaside SIZE COUNT | 1042 ** Usage: sqlite3_config_lookaside SIZE COUNT |
1039 ** | 1043 ** |
1040 */ | 1044 */ |
1041 static int test_config_lookaside( | 1045 static int SQLITE_TCLAPI test_config_lookaside( |
1042 void * clientData, | 1046 void * clientData, |
1043 Tcl_Interp *interp, | 1047 Tcl_Interp *interp, |
1044 int objc, | 1048 int objc, |
1045 Tcl_Obj *CONST objv[] | 1049 Tcl_Obj *CONST objv[] |
1046 ){ | 1050 ){ |
1047 int sz, cnt; | 1051 int sz, cnt; |
1048 Tcl_Obj *pRet; | 1052 Tcl_Obj *pRet; |
1049 if( objc!=3 ){ | 1053 if( objc!=3 ){ |
1050 Tcl_WrongNumArgs(interp, 1, objv, "SIZE COUNT"); | 1054 Tcl_WrongNumArgs(interp, 1, objv, "SIZE COUNT"); |
1051 return TCL_ERROR; | 1055 return TCL_ERROR; |
(...skipping 13 matching lines...) Expand all Loading... |
1065 } | 1069 } |
1066 | 1070 |
1067 | 1071 |
1068 /* | 1072 /* |
1069 ** Usage: sqlite3_db_config_lookaside CONNECTION BUFID SIZE COUNT | 1073 ** Usage: sqlite3_db_config_lookaside CONNECTION BUFID SIZE COUNT |
1070 ** | 1074 ** |
1071 ** There are two static buffers with BUFID 1 and 2. Each static buffer | 1075 ** There are two static buffers with BUFID 1 and 2. Each static buffer |
1072 ** is 10KB in size. A BUFID of 0 indicates that the buffer should be NULL | 1076 ** is 10KB in size. A BUFID of 0 indicates that the buffer should be NULL |
1073 ** which will cause sqlite3_db_config() to allocate space on its own. | 1077 ** which will cause sqlite3_db_config() to allocate space on its own. |
1074 */ | 1078 */ |
1075 static int test_db_config_lookaside( | 1079 static int SQLITE_TCLAPI test_db_config_lookaside( |
1076 void * clientData, | 1080 void * clientData, |
1077 Tcl_Interp *interp, | 1081 Tcl_Interp *interp, |
1078 int objc, | 1082 int objc, |
1079 Tcl_Obj *CONST objv[] | 1083 Tcl_Obj *CONST objv[] |
1080 ){ | 1084 ){ |
1081 int rc; | 1085 int rc; |
1082 int sz, cnt; | 1086 int sz, cnt; |
1083 sqlite3 *db; | 1087 sqlite3 *db; |
1084 int bufid; | 1088 int bufid; |
1085 static char azBuf[2][10000]; | 1089 static char azBuf[2][10000]; |
1086 extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); | 1090 extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); |
1087 if( objc!=5 ){ | 1091 if( objc!=5 ){ |
1088 Tcl_WrongNumArgs(interp, 1, objv, "BUFID SIZE COUNT"); | 1092 Tcl_WrongNumArgs(interp, 1, objv, "BUFID SIZE COUNT"); |
1089 return TCL_ERROR; | 1093 return TCL_ERROR; |
1090 } | 1094 } |
1091 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 1095 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
1092 if( Tcl_GetIntFromObj(interp, objv[2], &bufid) ) return TCL_ERROR; | 1096 if( Tcl_GetIntFromObj(interp, objv[2], &bufid) ) return TCL_ERROR; |
1093 if( Tcl_GetIntFromObj(interp, objv[3], &sz) ) return TCL_ERROR; | 1097 if( Tcl_GetIntFromObj(interp, objv[3], &sz) ) return TCL_ERROR; |
1094 if( Tcl_GetIntFromObj(interp, objv[4], &cnt) ) return TCL_ERROR; | 1098 if( Tcl_GetIntFromObj(interp, objv[4], &cnt) ) return TCL_ERROR; |
1095 if( bufid==0 ){ | 1099 if( bufid==0 ){ |
1096 rc = sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE, 0, sz, cnt); | 1100 rc = sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE, (void*)0, sz, cnt); |
1097 }else if( bufid>=1 && bufid<=2 && sz*cnt<=sizeof(azBuf[0]) ){ | 1101 }else if( bufid>=1 && bufid<=2 && sz*cnt<=sizeof(azBuf[0]) ){ |
1098 rc = sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE, azBuf[bufid], sz,cnt); | 1102 rc = sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE, azBuf[bufid], sz,cnt); |
1099 }else{ | 1103 }else{ |
1100 Tcl_AppendResult(interp, "illegal arguments - see documentation", (char*)0); | 1104 Tcl_AppendResult(interp, "illegal arguments - see documentation", (char*)0); |
1101 return TCL_ERROR; | 1105 return TCL_ERROR; |
1102 } | 1106 } |
1103 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); | 1107 Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); |
1104 return TCL_OK; | 1108 return TCL_OK; |
1105 } | 1109 } |
1106 | 1110 |
1107 /* | 1111 /* |
1108 ** Usage: sqlite3_config_heap NBYTE NMINALLOC | 1112 ** Usage: sqlite3_config_heap NBYTE NMINALLOC |
1109 */ | 1113 */ |
1110 static int test_config_heap( | 1114 static int SQLITE_TCLAPI test_config_heap( |
1111 void * clientData, | 1115 void * clientData, |
1112 Tcl_Interp *interp, | 1116 Tcl_Interp *interp, |
1113 int objc, | 1117 int objc, |
1114 Tcl_Obj *CONST objv[] | 1118 Tcl_Obj *CONST objv[] |
1115 ){ | 1119 ){ |
1116 static char *zBuf; /* Use this memory */ | 1120 static char *zBuf; /* Use this memory */ |
1117 int nByte; /* Size of buffer to pass to sqlite3_config() */ | 1121 int nByte; /* Size of buffer to pass to sqlite3_config() */ |
1118 int nMinAlloc; /* Size of minimum allocation */ | 1122 int nMinAlloc; /* Size of minimum allocation */ |
1119 int rc; /* Return code of sqlite3_config() */ | 1123 int rc; /* Return code of sqlite3_config() */ |
1120 | 1124 |
(...skipping 16 matching lines...) Expand all Loading... |
1137 rc = sqlite3_config(SQLITE_CONFIG_HEAP, zBuf, nByte, nMinAlloc); | 1141 rc = sqlite3_config(SQLITE_CONFIG_HEAP, zBuf, nByte, nMinAlloc); |
1138 } | 1142 } |
1139 | 1143 |
1140 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); | 1144 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
1141 return TCL_OK; | 1145 return TCL_OK; |
1142 } | 1146 } |
1143 | 1147 |
1144 /* | 1148 /* |
1145 ** Usage: sqlite3_config_heap_size NBYTE | 1149 ** Usage: sqlite3_config_heap_size NBYTE |
1146 */ | 1150 */ |
1147 static int test_config_heap_size( | 1151 static int SQLITE_TCLAPI test_config_heap_size( |
1148 void * clientData, | 1152 void * clientData, |
1149 Tcl_Interp *interp, | 1153 Tcl_Interp *interp, |
1150 int objc, | 1154 int objc, |
1151 Tcl_Obj *CONST objv[] | 1155 Tcl_Obj *CONST objv[] |
1152 ){ | 1156 ){ |
1153 int nByte; /* Size to pass to sqlite3_config() */ | 1157 int nByte; /* Size to pass to sqlite3_config() */ |
1154 int rc; /* Return code of sqlite3_config() */ | 1158 int rc; /* Return code of sqlite3_config() */ |
1155 | 1159 |
1156 Tcl_Obj * CONST *aArg = &objv[1]; | 1160 Tcl_Obj * CONST *aArg = &objv[1]; |
1157 int nArg = objc-1; | 1161 int nArg = objc-1; |
1158 | 1162 |
1159 if( nArg!=1 ){ | 1163 if( nArg!=1 ){ |
1160 Tcl_WrongNumArgs(interp, 1, objv, "NBYTE"); | 1164 Tcl_WrongNumArgs(interp, 1, objv, "NBYTE"); |
1161 return TCL_ERROR; | 1165 return TCL_ERROR; |
1162 } | 1166 } |
1163 if( Tcl_GetIntFromObj(interp, aArg[0], &nByte) ) return TCL_ERROR; | 1167 if( Tcl_GetIntFromObj(interp, aArg[0], &nByte) ) return TCL_ERROR; |
1164 | 1168 |
1165 rc = sqlite3_config(SQLITE_CONFIG_WIN32_HEAPSIZE, nByte); | 1169 rc = sqlite3_config(SQLITE_CONFIG_WIN32_HEAPSIZE, nByte); |
1166 | 1170 |
1167 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); | 1171 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
1168 return TCL_OK; | 1172 return TCL_OK; |
1169 } | 1173 } |
1170 | 1174 |
1171 /* | 1175 /* |
1172 ** Usage: sqlite3_config_error [DB] | 1176 ** Usage: sqlite3_config_error [DB] |
1173 ** | 1177 ** |
1174 ** Invoke sqlite3_config() or sqlite3_db_config() with invalid | 1178 ** Invoke sqlite3_config() or sqlite3_db_config() with invalid |
1175 ** opcodes and verify that they return errors. | 1179 ** opcodes and verify that they return errors. |
1176 */ | 1180 */ |
1177 static int test_config_error( | 1181 static int SQLITE_TCLAPI test_config_error( |
1178 void * clientData, | 1182 void * clientData, |
1179 Tcl_Interp *interp, | 1183 Tcl_Interp *interp, |
1180 int objc, | 1184 int objc, |
1181 Tcl_Obj *CONST objv[] | 1185 Tcl_Obj *CONST objv[] |
1182 ){ | 1186 ){ |
1183 sqlite3 *db; | 1187 sqlite3 *db; |
1184 extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); | 1188 extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); |
1185 | 1189 |
1186 if( objc!=2 && objc!=1 ){ | 1190 if( objc!=2 && objc!=1 ){ |
1187 Tcl_WrongNumArgs(interp, 1, objv, "[DB]"); | 1191 Tcl_WrongNumArgs(interp, 1, objv, "[DB]"); |
(...skipping 17 matching lines...) Expand all Loading... |
1205 } | 1209 } |
1206 return TCL_OK; | 1210 return TCL_OK; |
1207 } | 1211 } |
1208 | 1212 |
1209 /* | 1213 /* |
1210 ** Usage: sqlite3_config_uri BOOLEAN | 1214 ** Usage: sqlite3_config_uri BOOLEAN |
1211 ** | 1215 ** |
1212 ** Enables or disables interpretation of URI parameters by default using | 1216 ** Enables or disables interpretation of URI parameters by default using |
1213 ** SQLITE_CONFIG_URI. | 1217 ** SQLITE_CONFIG_URI. |
1214 */ | 1218 */ |
1215 static int test_config_uri( | 1219 static int SQLITE_TCLAPI test_config_uri( |
1216 void * clientData, | 1220 void * clientData, |
1217 Tcl_Interp *interp, | 1221 Tcl_Interp *interp, |
1218 int objc, | 1222 int objc, |
1219 Tcl_Obj *CONST objv[] | 1223 Tcl_Obj *CONST objv[] |
1220 ){ | 1224 ){ |
1221 int rc; | 1225 int rc; |
1222 int bOpenUri; | 1226 int bOpenUri; |
1223 | 1227 |
1224 if( objc!=2 ){ | 1228 if( objc!=2 ){ |
1225 Tcl_WrongNumArgs(interp, 1, objv, "BOOL"); | 1229 Tcl_WrongNumArgs(interp, 1, objv, "BOOL"); |
1226 return TCL_ERROR; | 1230 return TCL_ERROR; |
1227 } | 1231 } |
1228 if( Tcl_GetBooleanFromObj(interp, objv[1], &bOpenUri) ){ | 1232 if( Tcl_GetBooleanFromObj(interp, objv[1], &bOpenUri) ){ |
1229 return TCL_ERROR; | 1233 return TCL_ERROR; |
1230 } | 1234 } |
1231 | 1235 |
1232 rc = sqlite3_config(SQLITE_CONFIG_URI, bOpenUri); | 1236 rc = sqlite3_config(SQLITE_CONFIG_URI, bOpenUri); |
1233 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); | 1237 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
1234 | 1238 |
1235 return TCL_OK; | 1239 return TCL_OK; |
1236 } | 1240 } |
1237 | 1241 |
1238 /* | 1242 /* |
1239 ** Usage: sqlite3_config_cis BOOLEAN | 1243 ** Usage: sqlite3_config_cis BOOLEAN |
1240 ** | 1244 ** |
1241 ** Enables or disables the use of the covering-index scan optimization. | 1245 ** Enables or disables the use of the covering-index scan optimization. |
1242 ** SQLITE_CONFIG_COVERING_INDEX_SCAN. | 1246 ** SQLITE_CONFIG_COVERING_INDEX_SCAN. |
1243 */ | 1247 */ |
1244 static int test_config_cis( | 1248 static int SQLITE_TCLAPI test_config_cis( |
1245 void * clientData, | 1249 void * clientData, |
1246 Tcl_Interp *interp, | 1250 Tcl_Interp *interp, |
1247 int objc, | 1251 int objc, |
1248 Tcl_Obj *CONST objv[] | 1252 Tcl_Obj *CONST objv[] |
1249 ){ | 1253 ){ |
1250 int rc; | 1254 int rc; |
1251 int bUseCis; | 1255 int bUseCis; |
1252 | 1256 |
1253 if( objc!=2 ){ | 1257 if( objc!=2 ){ |
1254 Tcl_WrongNumArgs(interp, 1, objv, "BOOL"); | 1258 Tcl_WrongNumArgs(interp, 1, objv, "BOOL"); |
1255 return TCL_ERROR; | 1259 return TCL_ERROR; |
1256 } | 1260 } |
1257 if( Tcl_GetBooleanFromObj(interp, objv[1], &bUseCis) ){ | 1261 if( Tcl_GetBooleanFromObj(interp, objv[1], &bUseCis) ){ |
1258 return TCL_ERROR; | 1262 return TCL_ERROR; |
1259 } | 1263 } |
1260 | 1264 |
1261 rc = sqlite3_config(SQLITE_CONFIG_COVERING_INDEX_SCAN, bUseCis); | 1265 rc = sqlite3_config(SQLITE_CONFIG_COVERING_INDEX_SCAN, bUseCis); |
1262 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); | 1266 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
1263 | 1267 |
1264 return TCL_OK; | 1268 return TCL_OK; |
1265 } | 1269 } |
1266 | 1270 |
1267 /* | 1271 /* |
1268 ** Usage: sqlite3_config_pmasz INTEGER | 1272 ** Usage: sqlite3_config_pmasz INTEGER |
1269 ** | 1273 ** |
1270 ** Set the minimum PMA size. | 1274 ** Set the minimum PMA size. |
1271 */ | 1275 */ |
1272 static int test_config_pmasz( | 1276 static int SQLITE_TCLAPI test_config_pmasz( |
1273 void * clientData, | 1277 void * clientData, |
1274 Tcl_Interp *interp, | 1278 Tcl_Interp *interp, |
1275 int objc, | 1279 int objc, |
1276 Tcl_Obj *CONST objv[] | 1280 Tcl_Obj *CONST objv[] |
1277 ){ | 1281 ){ |
1278 int rc; | 1282 int rc; |
1279 int iPmaSz; | 1283 int iPmaSz; |
1280 | 1284 |
1281 if( objc!=2 ){ | 1285 if( objc!=2 ){ |
1282 Tcl_WrongNumArgs(interp, 1, objv, "BOOL"); | 1286 Tcl_WrongNumArgs(interp, 1, objv, "BOOL"); |
1283 return TCL_ERROR; | 1287 return TCL_ERROR; |
1284 } | 1288 } |
1285 if( Tcl_GetIntFromObj(interp, objv[1], &iPmaSz) ){ | 1289 if( Tcl_GetIntFromObj(interp, objv[1], &iPmaSz) ){ |
1286 return TCL_ERROR; | 1290 return TCL_ERROR; |
1287 } | 1291 } |
1288 | 1292 |
1289 rc = sqlite3_config(SQLITE_CONFIG_PMASZ, iPmaSz); | 1293 rc = sqlite3_config(SQLITE_CONFIG_PMASZ, iPmaSz); |
1290 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); | 1294 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
1291 | 1295 |
1292 return TCL_OK; | 1296 return TCL_OK; |
1293 } | 1297 } |
1294 | 1298 |
1295 | 1299 |
1296 /* | 1300 /* |
1297 ** Usage: sqlite3_dump_memsys3 FILENAME | 1301 ** Usage: sqlite3_dump_memsys3 FILENAME |
1298 ** sqlite3_dump_memsys5 FILENAME | 1302 ** sqlite3_dump_memsys5 FILENAME |
1299 ** | 1303 ** |
1300 ** Write a summary of unfreed memsys3 allocations to FILENAME. | 1304 ** Write a summary of unfreed memsys3 allocations to FILENAME. |
1301 */ | 1305 */ |
1302 static int test_dump_memsys3( | 1306 static int SQLITE_TCLAPI test_dump_memsys3( |
1303 void * clientData, | 1307 void * clientData, |
1304 Tcl_Interp *interp, | 1308 Tcl_Interp *interp, |
1305 int objc, | 1309 int objc, |
1306 Tcl_Obj *CONST objv[] | 1310 Tcl_Obj *CONST objv[] |
1307 ){ | 1311 ){ |
1308 if( objc!=2 ){ | 1312 if( objc!=2 ){ |
1309 Tcl_WrongNumArgs(interp, 1, objv, "FILENAME"); | 1313 Tcl_WrongNumArgs(interp, 1, objv, "FILENAME"); |
1310 return TCL_ERROR; | 1314 return TCL_ERROR; |
1311 } | 1315 } |
1312 | 1316 |
(...skipping 15 matching lines...) Expand all Loading... |
1328 } | 1332 } |
1329 return TCL_OK; | 1333 return TCL_OK; |
1330 } | 1334 } |
1331 | 1335 |
1332 /* | 1336 /* |
1333 ** Usage: sqlite3_status OPCODE RESETFLAG | 1337 ** Usage: sqlite3_status OPCODE RESETFLAG |
1334 ** | 1338 ** |
1335 ** Return a list of three elements which are the sqlite3_status() return | 1339 ** Return a list of three elements which are the sqlite3_status() return |
1336 ** code, the current value, and the high-water mark value. | 1340 ** code, the current value, and the high-water mark value. |
1337 */ | 1341 */ |
1338 static int test_status( | 1342 static int SQLITE_TCLAPI test_status( |
1339 void * clientData, | 1343 void * clientData, |
1340 Tcl_Interp *interp, | 1344 Tcl_Interp *interp, |
1341 int objc, | 1345 int objc, |
1342 Tcl_Obj *CONST objv[] | 1346 Tcl_Obj *CONST objv[] |
1343 ){ | 1347 ){ |
1344 int rc, iValue, mxValue; | 1348 int rc, iValue, mxValue; |
1345 int i, op = 0, resetFlag; | 1349 int i, op = 0, resetFlag; |
1346 const char *zOpName; | 1350 const char *zOpName; |
1347 static const struct { | 1351 static const struct { |
1348 const char *zName; | 1352 const char *zName; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 Tcl_SetObjResult(interp, pResult); | 1389 Tcl_SetObjResult(interp, pResult); |
1386 return TCL_OK; | 1390 return TCL_OK; |
1387 } | 1391 } |
1388 | 1392 |
1389 /* | 1393 /* |
1390 ** Usage: sqlite3_db_status DATABASE OPCODE RESETFLAG | 1394 ** Usage: sqlite3_db_status DATABASE OPCODE RESETFLAG |
1391 ** | 1395 ** |
1392 ** Return a list of three elements which are the sqlite3_db_status() return | 1396 ** Return a list of three elements which are the sqlite3_db_status() return |
1393 ** code, the current value, and the high-water mark value. | 1397 ** code, the current value, and the high-water mark value. |
1394 */ | 1398 */ |
1395 static int test_db_status( | 1399 static int SQLITE_TCLAPI test_db_status( |
1396 void * clientData, | 1400 void * clientData, |
1397 Tcl_Interp *interp, | 1401 Tcl_Interp *interp, |
1398 int objc, | 1402 int objc, |
1399 Tcl_Obj *CONST objv[] | 1403 Tcl_Obj *CONST objv[] |
1400 ){ | 1404 ){ |
1401 int rc, iValue, mxValue; | 1405 int rc, iValue, mxValue; |
1402 int i, op = 0, resetFlag; | 1406 int i, op = 0, resetFlag; |
1403 const char *zOpName; | 1407 const char *zOpName; |
1404 sqlite3 *db; | 1408 sqlite3 *db; |
1405 extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); | 1409 extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); |
1406 static const struct { | 1410 static const struct { |
1407 const char *zName; | 1411 const char *zName; |
1408 int op; | 1412 int op; |
1409 } aOp[] = { | 1413 } aOp[] = { |
1410 { "LOOKASIDE_USED", SQLITE_DBSTATUS_LOOKASIDE_USED }, | 1414 { "LOOKASIDE_USED", SQLITE_DBSTATUS_LOOKASIDE_USED }, |
1411 { "CACHE_USED", SQLITE_DBSTATUS_CACHE_USED }, | 1415 { "CACHE_USED", SQLITE_DBSTATUS_CACHE_USED }, |
1412 { "SCHEMA_USED", SQLITE_DBSTATUS_SCHEMA_USED }, | 1416 { "SCHEMA_USED", SQLITE_DBSTATUS_SCHEMA_USED }, |
1413 { "STMT_USED", SQLITE_DBSTATUS_STMT_USED }, | 1417 { "STMT_USED", SQLITE_DBSTATUS_STMT_USED }, |
1414 { "LOOKASIDE_HIT", SQLITE_DBSTATUS_LOOKASIDE_HIT }, | 1418 { "LOOKASIDE_HIT", SQLITE_DBSTATUS_LOOKASIDE_HIT }, |
1415 { "LOOKASIDE_MISS_SIZE", SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE }, | 1419 { "LOOKASIDE_MISS_SIZE", SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE }, |
1416 { "LOOKASIDE_MISS_FULL", SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL }, | 1420 { "LOOKASIDE_MISS_FULL", SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL }, |
1417 { "CACHE_HIT", SQLITE_DBSTATUS_CACHE_HIT }, | 1421 { "CACHE_HIT", SQLITE_DBSTATUS_CACHE_HIT }, |
1418 { "CACHE_MISS", SQLITE_DBSTATUS_CACHE_MISS }, | 1422 { "CACHE_MISS", SQLITE_DBSTATUS_CACHE_MISS }, |
1419 { "CACHE_WRITE", SQLITE_DBSTATUS_CACHE_WRITE }, | 1423 { "CACHE_WRITE", SQLITE_DBSTATUS_CACHE_WRITE }, |
1420 { "DEFERRED_FKS", SQLITE_DBSTATUS_DEFERRED_FKS } | 1424 { "DEFERRED_FKS", SQLITE_DBSTATUS_DEFERRED_FKS }, |
| 1425 { "CACHE_USED_SHARED", SQLITE_DBSTATUS_CACHE_USED_SHARED }, |
1421 }; | 1426 }; |
1422 Tcl_Obj *pResult; | 1427 Tcl_Obj *pResult; |
1423 if( objc!=4 ){ | 1428 if( objc!=4 ){ |
1424 Tcl_WrongNumArgs(interp, 1, objv, "DB PARAMETER RESETFLAG"); | 1429 Tcl_WrongNumArgs(interp, 1, objv, "DB PARAMETER RESETFLAG"); |
1425 return TCL_ERROR; | 1430 return TCL_ERROR; |
1426 } | 1431 } |
1427 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 1432 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
1428 zOpName = Tcl_GetString(objv[2]); | 1433 zOpName = Tcl_GetString(objv[2]); |
1429 if( memcmp(zOpName, "SQLITE_", 7)==0 ) zOpName += 7; | 1434 if( memcmp(zOpName, "SQLITE_", 7)==0 ) zOpName += 7; |
1430 if( memcmp(zOpName, "DBSTATUS_", 9)==0 ) zOpName += 9; | 1435 if( memcmp(zOpName, "DBSTATUS_", 9)==0 ) zOpName += 9; |
(...skipping 14 matching lines...) Expand all Loading... |
1445 Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(rc)); | 1450 Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(rc)); |
1446 Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(iValue)); | 1451 Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(iValue)); |
1447 Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(mxValue)); | 1452 Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(mxValue)); |
1448 Tcl_SetObjResult(interp, pResult); | 1453 Tcl_SetObjResult(interp, pResult); |
1449 return TCL_OK; | 1454 return TCL_OK; |
1450 } | 1455 } |
1451 | 1456 |
1452 /* | 1457 /* |
1453 ** install_malloc_faultsim BOOLEAN | 1458 ** install_malloc_faultsim BOOLEAN |
1454 */ | 1459 */ |
1455 static int test_install_malloc_faultsim( | 1460 static int SQLITE_TCLAPI test_install_malloc_faultsim( |
1456 void * clientData, | 1461 void * clientData, |
1457 Tcl_Interp *interp, | 1462 Tcl_Interp *interp, |
1458 int objc, | 1463 int objc, |
1459 Tcl_Obj *CONST objv[] | 1464 Tcl_Obj *CONST objv[] |
1460 ){ | 1465 ){ |
1461 int rc; | 1466 int rc; |
1462 int isInstall; | 1467 int isInstall; |
1463 | 1468 |
1464 if( objc!=2 ){ | 1469 if( objc!=2 ){ |
1465 Tcl_WrongNumArgs(interp, 1, objv, "BOOLEAN"); | 1470 Tcl_WrongNumArgs(interp, 1, objv, "BOOLEAN"); |
1466 return TCL_ERROR; | 1471 return TCL_ERROR; |
1467 } | 1472 } |
1468 if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[1], &isInstall) ){ | 1473 if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[1], &isInstall) ){ |
1469 return TCL_ERROR; | 1474 return TCL_ERROR; |
1470 } | 1475 } |
1471 rc = faultsimInstall(isInstall); | 1476 rc = faultsimInstall(isInstall); |
1472 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); | 1477 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
1473 return TCL_OK; | 1478 return TCL_OK; |
1474 } | 1479 } |
1475 | 1480 |
1476 /* | 1481 /* |
1477 ** sqlite3_install_memsys3 | 1482 ** sqlite3_install_memsys3 |
1478 */ | 1483 */ |
1479 static int test_install_memsys3( | 1484 static int SQLITE_TCLAPI test_install_memsys3( |
1480 void * clientData, | 1485 void * clientData, |
1481 Tcl_Interp *interp, | 1486 Tcl_Interp *interp, |
1482 int objc, | 1487 int objc, |
1483 Tcl_Obj *CONST objv[] | 1488 Tcl_Obj *CONST objv[] |
1484 ){ | 1489 ){ |
1485 int rc = SQLITE_MISUSE; | 1490 int rc = SQLITE_MISUSE; |
1486 #ifdef SQLITE_ENABLE_MEMSYS3 | 1491 #ifdef SQLITE_ENABLE_MEMSYS3 |
1487 const sqlite3_mem_methods *sqlite3MemGetMemsys3(void); | 1492 const sqlite3_mem_methods *sqlite3MemGetMemsys3(void); |
1488 rc = sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetMemsys3()); | 1493 rc = sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetMemsys3()); |
1489 #endif | 1494 #endif |
1490 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); | 1495 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE); |
1491 return TCL_OK; | 1496 return TCL_OK; |
1492 } | 1497 } |
1493 | 1498 |
1494 static int test_vfs_oom_test( | 1499 static int SQLITE_TCLAPI test_vfs_oom_test( |
1495 void * clientData, | 1500 void * clientData, |
1496 Tcl_Interp *interp, | 1501 Tcl_Interp *interp, |
1497 int objc, | 1502 int objc, |
1498 Tcl_Obj *CONST objv[] | 1503 Tcl_Obj *CONST objv[] |
1499 ){ | 1504 ){ |
1500 extern int sqlite3_memdebug_vfs_oom_test; | 1505 extern int sqlite3_memdebug_vfs_oom_test; |
1501 if( objc>2 ){ | 1506 if( objc>2 ){ |
1502 Tcl_WrongNumArgs(interp, 1, objv, "?INTEGER?"); | 1507 Tcl_WrongNumArgs(interp, 1, objv, "?INTEGER?"); |
1503 return TCL_ERROR; | 1508 return TCL_ERROR; |
1504 }else if( objc==2 ){ | 1509 }else if( objc==2 ){ |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 { "sqlite3_memdebug_vfs_oom_test", test_vfs_oom_test ,0 }, | 1559 { "sqlite3_memdebug_vfs_oom_test", test_vfs_oom_test ,0 }, |
1555 }; | 1560 }; |
1556 int i; | 1561 int i; |
1557 for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ | 1562 for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ |
1558 ClientData c = (ClientData)SQLITE_INT_TO_PTR(aObjCmd[i].clientData); | 1563 ClientData c = (ClientData)SQLITE_INT_TO_PTR(aObjCmd[i].clientData); |
1559 Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, c, 0); | 1564 Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, c, 0); |
1560 } | 1565 } |
1561 return TCL_OK; | 1566 return TCL_OK; |
1562 } | 1567 } |
1563 #endif | 1568 #endif |
OLD | NEW |