Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: third_party/sqlite/sqlite-src-3100200/src/test_func.c

Issue 1610543003: [sql] Import reference version of SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 ** 2008 March 19 2 ** 2008 March 19
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 **
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 }else{ 455 }else{
456 zOut[14-i*2] = "0123456789abcdef"[v.x[i]>>4]; 456 zOut[14-i*2] = "0123456789abcdef"[v.x[i]>>4];
457 zOut[14-i*2+1] = "0123456789abcdef"[v.x[i]&0xf]; 457 zOut[14-i*2+1] = "0123456789abcdef"[v.x[i]&0xf];
458 } 458 }
459 } 459 }
460 zOut[16] = 0; 460 zOut[16] = 0;
461 sqlite3_result_text(context, zOut, -1, SQLITE_TRANSIENT); 461 sqlite3_result_text(context, zOut, -1, SQLITE_TRANSIENT);
462 } 462 }
463 463
464 /* 464 /*
465 ** tclcmd: test_extract(record, field) 465 ** test_extract(record, field)
466 ** 466 **
467 ** This function implements an SQL user-function that accepts a blob 467 ** This function implements an SQL user-function that accepts a blob
468 ** containing a formatted database record as the first argument. The 468 ** containing a formatted database record as the first argument. The
469 ** second argument is the index of the field within that record to 469 ** second argument is the index of the field within that record to
470 ** extract and return. 470 ** extract and return.
471 */ 471 */
472 static void test_extract( 472 static void test_extract(
473 sqlite3_context *context, 473 sqlite3_context *context,
474 int argc, 474 int argc,
475 sqlite3_value **argv 475 sqlite3_value **argv
(...skipping 26 matching lines...) Expand all
502 502
503 if( iCurrent==iIdx ){ 503 if( iCurrent==iIdx ){
504 sqlite3_result_value(context, &mem); 504 sqlite3_result_value(context, &mem);
505 } 505 }
506 506
507 if( mem.szMalloc ) sqlite3DbFree(db, mem.zMalloc); 507 if( mem.szMalloc ) sqlite3DbFree(db, mem.zMalloc);
508 } 508 }
509 } 509 }
510 510
511 /* 511 /*
512 ** tclcmd: test_decode(record) 512 ** test_decode(record)
513 ** 513 **
514 ** This function implements an SQL user-function that accepts a blob 514 ** This function implements an SQL user-function that accepts a blob
515 ** containing a formatted database record as its only argument. It returns 515 ** containing a formatted database record as its only argument. It returns
516 ** a tcl list (type SQLITE_TEXT) containing each of the values stored 516 ** a tcl list (type SQLITE_TEXT) containing each of the values stored
517 ** in the record. 517 ** in the record.
518 */ 518 */
519 static void test_decode( 519 static void test_decode(
520 sqlite3_context *context, 520 sqlite3_context *context,
521 int argc, 521 int argc,
522 sqlite3_value **argv 522 sqlite3_value **argv
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 593
594 if( mem.szMalloc ){ 594 if( mem.szMalloc ){
595 sqlite3DbFree(db, mem.zMalloc); 595 sqlite3DbFree(db, mem.zMalloc);
596 } 596 }
597 } 597 }
598 598
599 sqlite3_result_text(context, Tcl_GetString(pRet), -1, SQLITE_TRANSIENT); 599 sqlite3_result_text(context, Tcl_GetString(pRet), -1, SQLITE_TRANSIENT);
600 Tcl_DecrRefCount(pRet); 600 Tcl_DecrRefCount(pRet);
601 } 601 }
602 602
603 /*
604 ** test_zeroblob(N)
605 **
606 ** The implementation of scalar SQL function "test_zeroblob()". This is
607 ** similar to the built-in zeroblob() function, except that it does not
608 ** check that the integer parameter is within range before passing it
609 ** to sqlite3_result_zeroblob().
610 */
611 static void test_zeroblob(
612 sqlite3_context *context,
613 int argc,
614 sqlite3_value **argv
615 ){
616 int nZero = sqlite3_value_int(argv[0]);
617 sqlite3_result_zeroblob(context, nZero);
618 }
619
620 /* test_getsubtype(V)
621 **
622 ** Return the subtype for value V.
623 */
624 static void test_getsubtype(
625 sqlite3_context *context,
626 int argc,
627 sqlite3_value **argv
628 ){
629 sqlite3_result_int(context, (int)sqlite3_value_subtype(argv[0]));
630 }
631
632 /* test_setsubtype(V, T)
633 **
634 ** Return the value V with its subtype changed to T
635 */
636 static void test_setsubtype(
637 sqlite3_context *context,
638 int argc,
639 sqlite3_value **argv
640 ){
641 sqlite3_result_value(context, argv[0]);
642 sqlite3_result_subtype(context, (unsigned int)sqlite3_value_int(argv[1]));
643 }
603 644
604 static int registerTestFunctions(sqlite3 *db){ 645 static int registerTestFunctions(sqlite3 *db){
605 static const struct { 646 static const struct {
606 char *zName; 647 char *zName;
607 signed char nArg; 648 signed char nArg;
608 unsigned char eTextRep; /* 1: UTF-16. 0: UTF-8 */ 649 unsigned int eTextRep; /* 1: UTF-16. 0: UTF-8 */
609 void (*xFunc)(sqlite3_context*,int,sqlite3_value **); 650 void (*xFunc)(sqlite3_context*,int,sqlite3_value **);
610 } aFuncs[] = { 651 } aFuncs[] = {
611 { "randstr", 2, SQLITE_UTF8, randStr }, 652 { "randstr", 2, SQLITE_UTF8, randStr },
612 { "test_destructor", 1, SQLITE_UTF8, test_destructor}, 653 { "test_destructor", 1, SQLITE_UTF8, test_destructor},
613 #ifndef SQLITE_OMIT_UTF16 654 #ifndef SQLITE_OMIT_UTF16
614 { "test_destructor16", 1, SQLITE_UTF8, test_destructor16}, 655 { "test_destructor16", 1, SQLITE_UTF8, test_destructor16},
615 { "hex_to_utf16be", 1, SQLITE_UTF8, testHexToUtf16be}, 656 { "hex_to_utf16be", 1, SQLITE_UTF8, testHexToUtf16be},
616 { "hex_to_utf16le", 1, SQLITE_UTF8, testHexToUtf16le}, 657 { "hex_to_utf16le", 1, SQLITE_UTF8, testHexToUtf16le},
617 #endif 658 #endif
618 { "hex_to_utf8", 1, SQLITE_UTF8, testHexToUtf8}, 659 { "hex_to_utf8", 1, SQLITE_UTF8, testHexToUtf8},
619 { "test_destructor_count", 0, SQLITE_UTF8, test_destructor_count}, 660 { "test_destructor_count", 0, SQLITE_UTF8, test_destructor_count},
620 { "test_auxdata", -1, SQLITE_UTF8, test_auxdata}, 661 { "test_auxdata", -1, SQLITE_UTF8, test_auxdata},
621 { "test_error", 1, SQLITE_UTF8, test_error}, 662 { "test_error", 1, SQLITE_UTF8, test_error},
622 { "test_error", 2, SQLITE_UTF8, test_error}, 663 { "test_error", 2, SQLITE_UTF8, test_error},
623 { "test_eval", 1, SQLITE_UTF8, test_eval}, 664 { "test_eval", 1, SQLITE_UTF8, test_eval},
624 { "test_isolation", 2, SQLITE_UTF8, test_isolation}, 665 { "test_isolation", 2, SQLITE_UTF8, test_isolation},
625 { "test_counter", 1, SQLITE_UTF8, counterFunc}, 666 { "test_counter", 1, SQLITE_UTF8, counterFunc},
626 { "real2hex", 1, SQLITE_UTF8, real2hex}, 667 { "real2hex", 1, SQLITE_UTF8, real2hex},
627 { "test_decode", 1, SQLITE_UTF8, test_decode}, 668 { "test_decode", 1, SQLITE_UTF8, test_decode},
628 { "test_extract", 2, SQLITE_UTF8, test_extract}, 669 { "test_extract", 2, SQLITE_UTF8, test_extract},
670 { "test_zeroblob", 1, SQLITE_UTF8|SQLITE_DETERMINISTIC, test_zeroblob},
671 { "test_getsubtype", 1, SQLITE_UTF8, test_getsubtype},
672 { "test_setsubtype", 2, SQLITE_UTF8, test_setsubtype},
629 }; 673 };
630 int i; 674 int i;
631 675
632 for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){ 676 for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){
633 sqlite3_create_function(db, aFuncs[i].zName, aFuncs[i].nArg, 677 sqlite3_create_function(db, aFuncs[i].zName, aFuncs[i].nArg,
634 aFuncs[i].eTextRep, 0, aFuncs[i].xFunc, 0, 0); 678 aFuncs[i].eTextRep, 0, aFuncs[i].xFunc, 0, 0);
635 } 679 }
636 680
637 sqlite3_create_function(db, "test_agg_errmsg16", 0, SQLITE_ANY, 0, 0, 681 sqlite3_create_function(db, "test_agg_errmsg16", 0, SQLITE_ANY, 0, 0,
638 test_agg_errmsg16_step, test_agg_errmsg16_final); 682 test_agg_errmsg16_step, test_agg_errmsg16_final);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 extern int Md5_Register(sqlite3*); 800 extern int Md5_Register(sqlite3*);
757 801
758 for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ 802 for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){
759 Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0); 803 Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0);
760 } 804 }
761 sqlite3_initialize(); 805 sqlite3_initialize();
762 sqlite3_auto_extension((void*)registerTestFunctions); 806 sqlite3_auto_extension((void*)registerTestFunctions);
763 sqlite3_auto_extension((void*)Md5_Register); 807 sqlite3_auto_extension((void*)Md5_Register);
764 return TCL_OK; 808 return TCL_OK;
765 } 809 }
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3100200/src/test_fs.c ('k') | third_party/sqlite/sqlite-src-3100200/src/test_hexio.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698