Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Use the faster LIKE function from sqlite v2. Add special user functions to test builds to test the auxdata APIs. (CVS 1610) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
b9493c5facea4d24a6cbc4f6fa2f75dc |
User & Date: | danielk1977 2004-06-17 05:36:44.000 |
Context
2004-06-17
| ||
06:13 | Handle conflicting ON CONFLICT clauses in table definitions. (CVS 1611) (check-in: 12e77e759e user: danielk1977 tags: trunk) | |
05:36 | Use the faster LIKE function from sqlite v2. Add special user functions to test builds to test the auxdata APIs. (CVS 1610) (check-in: b9493c5fac user: danielk1977 tags: trunk) | |
00:01 | Remove the second definition of SQLITE_N_BTREE_META from test3.c. (CVS 1609) (check-in: b1e66ae464 user: danielk1977 tags: trunk) | |
Changes
Changes to src/func.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | ** This file contains the C functions that implement various SQL ** functions of SQLite. ** ** There is only one exported symbol in this file - the function ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** This file contains the C functions that implement various SQL ** functions of SQLite. ** ** There is only one exported symbol in this file - the function ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** ** $Id: func.c,v 1.71 2004/06/17 05:36:44 danielk1977 Exp $ */ #include <ctype.h> #include <math.h> #include <stdlib.h> #include <assert.h> #include "sqliteInt.h" #include "vdbeInt.h" |
︙ | ︙ | |||
313 314 315 316 317 318 319 320 | typedef struct LikePattern LikePattern; void deleteLike(void *pLike){ sqliteFree(pLike); } /* #define TRACE_LIKE */ | > < | 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | typedef struct LikePattern LikePattern; void deleteLike(void *pLike){ sqliteFree(pLike); } #if 0 /* #define TRACE_LIKE */ #if defined(TRACE_LIKE) && !defined(NDEBUG) char *dumpLike(LikePattern *pLike){ int i; int k = 0; char *zBuf = (char *)sqliteMalloc(pLike->nState*40); k += sprintf(&zBuf[k], "%d states - ", pLike->nState); |
︙ | ︙ | |||
538 539 540 541 542 543 544 545 546 547 548 549 550 551 | }while( c && pState>=aState ); if( (pState-aState)==pLike->nState || (pState-aState)<-1 ){ sqlite3_result_int(context, 1); }else{ sqlite3_result_int(context, 0); } } /* ** Implementation of the glob() SQL function. This function implements ** the build-in GLOB operator. The first argument to the function is the ** string and the second argument is the pattern. So, the SQL statements: ** | > > > > > > > > > > > > > > > > > > > > > > > > > | 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | }while( c && pState>=aState ); if( (pState-aState)==pLike->nState || (pState-aState)<-1 ){ sqlite3_result_int(context, 1); }else{ sqlite3_result_int(context, 0); } } #endif /* ** Implementation of the like() SQL function. This function implements ** the build-in LIKE operator. The first argument to the function is the ** pattern and the second argument is the string. So, the SQL statements: ** ** A LIKE B ** ** is implemented as like(B,A). ** ** If the pointer retrieved by via a call to sqlite3_user_data() is ** not NULL, then this function uses UTF-16. Otherwise UTF-8. */ static void likeFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ const unsigned char *zA = sqlite3_value_text(argv[0]); const unsigned char *zB = sqlite3_value_text(argv[1]); if( zA && zB ){ sqlite3_result_int(context, sqlite3utf8LikeCompare(zA, zB)); } } /* ** Implementation of the glob() SQL function. This function implements ** the build-in GLOB operator. The first argument to the function is the ** string and the second argument is the pattern. So, the SQL statements: ** |
︙ | ︙ | |||
781 782 783 784 785 786 787 788 789 790 791 792 793 794 | static void test_destructor_count( sqlite3_context *pCtx, int nArg, sqlite3_value **argv ){ sqlite3_result_int(pCtx, test_destructor_count_var); } #endif /* ** An instance of the following structure holds the context of a ** sum() or avg() aggregate computation. */ typedef struct SumCtx SumCtx; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 | static void test_destructor_count( sqlite3_context *pCtx, int nArg, sqlite3_value **argv ){ sqlite3_result_int(pCtx, test_destructor_count_var); } static void free_test_auxdata(void *p) {sqliteFree(p);} static void test_auxdata( sqlite3_context *pCtx, int nArg, sqlite3_value **argv ){ int i; char *zRet = sqliteMalloc(nArg*2); if( !zRet ) return; for(i=0; i<nArg; i++){ char const *z = sqlite3_value_text(argv[i]); if( z ){ char *zAux = sqlite3_get_auxdata(pCtx, i); if( zAux ){ zRet[i*2] = '1'; if( strcmp(zAux, z) ){ sqlite3_result_error(pCtx, "Auxilary data corruption", -1); return; } }else{ zRet[i*2] = '0'; zAux = sqliteStrDup(z); sqlite3_set_auxdata(pCtx, i, zAux, free_test_auxdata); } zRet[i*2+1] = ' '; } } sqlite3_result_text(pCtx, zRet, 2*nArg-1, free_test_auxdata); } #endif /* ** An instance of the following structure holds the context of a ** sum() or avg() aggregate computation. */ typedef struct SumCtx SumCtx; |
︙ | ︙ | |||
961 962 963 964 965 966 967 | { "lower", 1, 0, SQLITE_UTF8, 0, lowerFunc }, { "coalesce", -1, 0, SQLITE_UTF8, 0, ifnullFunc }, { "coalesce", 0, 0, SQLITE_UTF8, 0, 0 }, { "coalesce", 1, 0, SQLITE_UTF8, 0, 0 }, { "ifnull", 2, 0, SQLITE_UTF8, 1, ifnullFunc }, { "random", -1, 0, SQLITE_UTF8, 0, randomFunc }, { "like", 2, 0, SQLITE_UTF8, 0, likeFunc }, | | > | 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 | { "lower", 1, 0, SQLITE_UTF8, 0, lowerFunc }, { "coalesce", -1, 0, SQLITE_UTF8, 0, ifnullFunc }, { "coalesce", 0, 0, SQLITE_UTF8, 0, 0 }, { "coalesce", 1, 0, SQLITE_UTF8, 0, 0 }, { "ifnull", 2, 0, SQLITE_UTF8, 1, ifnullFunc }, { "random", -1, 0, SQLITE_UTF8, 0, randomFunc }, { "like", 2, 0, SQLITE_UTF8, 0, likeFunc }, /* { "like", 2, 2, SQLITE_UTF16,0, likeFunc }, */ { "glob", 2, 0, SQLITE_UTF8, 0, globFunc }, { "nullif", 2, 0, SQLITE_UTF8, 0, nullifFunc }, { "sqlite_version", 0, 0, SQLITE_UTF8, 0, versionFunc}, { "quote", 1, 0, SQLITE_UTF8, 0, quoteFunc }, { "last_insert_rowid", 0, 1, SQLITE_UTF8, 0, last_insert_rowid }, { "change_count", 0, 1, SQLITE_UTF8, 0, change_count }, { "last_statement_change_count", 0, 1, SQLITE_UTF8, 0, last_statement_change_count }, #ifdef SQLITE_SOUNDEX { "soundex", 1, 0, SQLITE_UTF8, 0, soundexFunc}, #endif #ifdef SQLITE_TEST { "randstr", 2, 0, SQLITE_UTF8, 0, randStr }, { "test_destructor", 1, 0, SQLITE_UTF8, 0, test_destructor}, { "test_destructor_count", 0, 0, SQLITE_UTF8, 0, test_destructor_count}, { "test_auxdata", -1, 0, SQLITE_UTF8, 0, test_auxdata}, #endif }; static struct { char *zName; signed char nArg; u8 argType; u8 needCollSeq; |
︙ | ︙ |
Changes to src/sqliteInt.h.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** ** @(#) $Id: sqliteInt.h,v 1.286 2004/06/17 05:36:44 danielk1977 Exp $ */ #include "config.h" #include "sqlite3.h" #include "hash.h" #include "parse.h" #include <stdio.h> #include <stdlib.h> |
︙ | ︙ | |||
1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 | unsigned char *sqlite3utf16to8(const void *pData, int N, int big_endian); void *sqlite3utf8to16be(const unsigned char *pIn, int N); void *sqlite3utf8to16le(const unsigned char *pIn, int N); void sqlite3utf16to16le(void *pData, int N); void sqlite3utf16to16be(void *pData, int N); int sqlite3utf16ByteLen(const void *pData, int nChar); int sqlite3utf8CharLen(const char *pData, int nByte); int sqlite3PutVarint(unsigned char *, u64); int sqlite3GetVarint(const unsigned char *, u64 *); int sqlite3GetVarint32(const unsigned char *, u32 *); int sqlite3VarintLen(u64 v); char sqlite3AffinityType(const char *, int); void sqlite3IndexAffinityStr(Vdbe *, Index *); void sqlite3TableAffinityStr(Vdbe *, Table *); | > | 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 | unsigned char *sqlite3utf16to8(const void *pData, int N, int big_endian); void *sqlite3utf8to16be(const unsigned char *pIn, int N); void *sqlite3utf8to16le(const unsigned char *pIn, int N); void sqlite3utf16to16le(void *pData, int N); void sqlite3utf16to16be(void *pData, int N); int sqlite3utf16ByteLen(const void *pData, int nChar); int sqlite3utf8CharLen(const char *pData, int nByte); int sqlite3utf8LikeCompare(const unsigned char*, const unsigned char*); int sqlite3PutVarint(unsigned char *, u64); int sqlite3GetVarint(const unsigned char *, u64 *); int sqlite3GetVarint32(const unsigned char *, u32 *); int sqlite3VarintLen(u64 v); char sqlite3AffinityType(const char *, int); void sqlite3IndexAffinityStr(Vdbe *, Index *); void sqlite3TableAffinityStr(Vdbe *, Table *); |
︙ | ︙ | |||
1410 1411 1412 1413 1414 1415 1416 | int sqlite3CheckObjectName(Parse *, const char *); const void *sqlite3ValueText(sqlite3_value*, u8); int sqlite3ValueBytes(sqlite3_value*, u8); void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8); void sqlite3ValueFree(sqlite3_value*); sqlite3_value *sqlite3ValueNew(); | < | 1411 1412 1413 1414 1415 1416 1417 | int sqlite3CheckObjectName(Parse *, const char *); const void *sqlite3ValueText(sqlite3_value*, u8); int sqlite3ValueBytes(sqlite3_value*, u8); void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8); void sqlite3ValueFree(sqlite3_value*); sqlite3_value *sqlite3ValueNew(); |
Changes to src/utf.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used to translate between UTF-8, ** UTF-16, UTF-16BE, and UTF-16LE. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used to translate between UTF-8, ** UTF-16, UTF-16BE, and UTF-16LE. ** ** $Id: utf.c,v 1.20 2004/06/17 05:36:44 danielk1977 Exp $ ** ** Notes on UTF-8: ** ** Byte-0 Byte-1 Byte-2 Byte-3 Value ** 0xxxxxxx 00000000 00000000 0xxxxxxx ** 110yyyyy 10xxxxxx 00000000 00000yyy yyxxxxxx ** 1110zzzz 10yyyyyy 10xxxxxx 00000000 zzzzyyyy yyxxxxxx |
︙ | ︙ | |||
81 82 83 84 85 86 87 | ** case relationship between the 26 characters used in the English ** language only. ** ** This means that characters with umlauts etc. will not be folded ** correctly (unless they are encoded as composite characters, which would ** doubtless cause much trouble). */ | | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | ** case relationship between the 26 characters used in the English ** language only. ** ** This means that characters with umlauts etc. will not be folded ** correctly (unless they are encoded as composite characters, which would ** doubtless cause much trouble). */ #define LOWERCASE(x) (x<91?(int)(UpperToLower[x]):x) static unsigned char UpperToLower[91] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 97, 98, 99,100,101,102,103, 104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121, 122, |
︙ | ︙ | |||
705 706 707 708 709 710 711 | }else{ *zOut = sqlite3utf16to8(zData, nData, enc1==SQLITE_UTF16BE); if( !(*zOut) ) return SQLITE_NOMEM; *nOut = strlen(*zOut); } return SQLITE_OK; } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 | }else{ *zOut = sqlite3utf16to8(zData, nData, enc1==SQLITE_UTF16BE); if( !(*zOut) ) return SQLITE_NOMEM; *nOut = strlen(*zOut); } return SQLITE_OK; } #define sqliteNextChar(X) while( (0xc0&*++(X))==0x80 ){} /* ** Compare two UTF-8 strings for equality using the "LIKE" operator of ** SQL. The '%' character matches any sequence of 0 or more ** characters and '_' matches any single character. Case is ** not significant. */ int sqlite3utf8LikeCompare( const unsigned char *zPattern, const unsigned char *zString ){ register int c; int c2; while( (c = LOWERCASE(*zPattern))!=0 ){ switch( c ){ case '%': { while( (c=zPattern[1]) == '%' || c == '_' ){ if( c=='_' ){ if( *zString==0 ) return 0; sqliteNextChar(zString); } zPattern++; } if( c==0 ) return 1; c = LOWERCASE(c); while( (c2=LOWERCASE(*zString))!=0 ){ while( c2 != 0 && c2 != c ){ zString++; c2 = LOWERCASE(*zString); } if( c2==0 ) return 0; if( sqlite3utf8LikeCompare(&zPattern[1],zString) ) return 1; sqliteNextChar(zString); } return 0; } case '_': { if( *zString==0 ) return 0; sqliteNextChar(zString); zPattern++; break; } default: { if( c != LOWERCASE(*zString) ) return 0; zPattern++; zString++; break; } } } return *zString==0; } |
Changes to src/vdbemem.c.
︙ | ︙ | |||
143 144 145 146 147 148 149 | /* ** Make sure the given Mem is \u0000 terminated. */ int sqlite3VdbeMemNulTerminate(Mem *pMem){ if( (pMem->flags & MEM_Term)!=0 || (pMem->flags & (MEM_Str|MEM_Blob))==0 ){ return SQLITE_OK; /* Nothing to do */ } | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | /* ** Make sure the given Mem is \u0000 terminated. */ int sqlite3VdbeMemNulTerminate(Mem *pMem){ if( (pMem->flags & MEM_Term)!=0 || (pMem->flags & (MEM_Str|MEM_Blob))==0 ){ return SQLITE_OK; /* Nothing to do */ } if( pMem->flags & (MEM_Static|MEM_Ephem) ){ return sqlite3VdbeMemMakeWriteable(pMem); }else{ if( pMem->flags & MEM_Dyn ){ if( pMem->xDel ){ char *z = sqliteMalloc(pMem->n+2); if( !z ) return SQLITE_NOMEM; memcpy(z, pMem->z, pMem->n); pMem->xDel(pMem->z); pMem->xDel = 0; pMem->z = z; }else{ pMem->z = sqliteRealloc(pMem->z, pMem->n+2); if( !pMem->z ) return SQLITE_NOMEM; } }else{ assert( pMem->flags & MEM_Short ); if( pMem->n+2>NBFS ){ char *z = sqliteMalloc(pMem->n+2); if( !z ) return SQLITE_NOMEM; memcpy(z, pMem->z, pMem->n); pMem->flags &= !(MEM_Short); pMem->flags |= MEM_Dyn; pMem->xDel = 0; pMem->z = z; } } pMem->z[pMem->n++] = 0; pMem->z[pMem->n++] = 0; } return SQLITE_OK; } /* ** Add MEM_Str to the set of representations for the given Mem. ** A NULL is converted into an empty string. Numbers are converted ** using sqlite3_snprintf(). Converting a BLOB to a string is a ** no-op. |
︙ | ︙ |
Changes to test/expr.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing expressions. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing expressions. # # $Id: expr.test,v 1.34 2004/06/17 05:36:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a table to work with. # execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)} |
︙ | ︙ | |||
228 229 230 231 232 233 234 235 236 237 238 239 240 241 | test_expr expr-4.20 {r1='0.0', r2='abc'} {r1>r2} 0 test_expr expr-5.1 {t1='abc', t2='xyz'} {t1 LIKE t2} 0 test_expr expr-5.2 {t1='abc', t2='ABC'} {t1 LIKE t2} 1 test_expr expr-5.3 {t1='abc', t2='A_C'} {t1 LIKE t2} 1 test_expr expr-5.4 {t1='abc', t2='abc_'} {t1 LIKE t2} 0 test_expr expr-5.5 {t1='abc', t2='A%C'} {t1 LIKE t2} 1 test_expr expr-5.5b {t1='ac', t2='A%C'} {t1 LIKE t2} 1 test_expr expr-5.6 {t1='abxyzzyc', t2='A%C'} {t1 LIKE t2} 1 test_expr expr-5.7 {t1='abxyzzy', t2='A%C'} {t1 LIKE t2} 0 test_expr expr-5.8 {t1='abxyzzycx', t2='A%C'} {t1 LIKE t2} 0 test_expr expr-5.8b {t1='abxyzzycy', t2='A%CX'} {t1 LIKE t2} 0 test_expr expr-5.9 {t1='abc', t2='A%_C'} {t1 LIKE t2} 1 test_expr expr-5.9b {t1='ac', t2='A%_C'} {t1 LIKE t2} 0 | > | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | test_expr expr-4.20 {r1='0.0', r2='abc'} {r1>r2} 0 test_expr expr-5.1 {t1='abc', t2='xyz'} {t1 LIKE t2} 0 test_expr expr-5.2 {t1='abc', t2='ABC'} {t1 LIKE t2} 1 test_expr expr-5.3 {t1='abc', t2='A_C'} {t1 LIKE t2} 1 test_expr expr-5.4 {t1='abc', t2='abc_'} {t1 LIKE t2} 0 test_expr expr-5.5 {t1='abc', t2='A%C'} {t1 LIKE t2} 1 test_expr expr-5.5a {t1='abdc', t2='a%c'} {t1 LIKE t2} 1 test_expr expr-5.5b {t1='ac', t2='A%C'} {t1 LIKE t2} 1 test_expr expr-5.6 {t1='abxyzzyc', t2='A%C'} {t1 LIKE t2} 1 test_expr expr-5.7 {t1='abxyzzy', t2='A%C'} {t1 LIKE t2} 0 test_expr expr-5.8 {t1='abxyzzycx', t2='A%C'} {t1 LIKE t2} 0 test_expr expr-5.8b {t1='abxyzzycy', t2='A%CX'} {t1 LIKE t2} 0 test_expr expr-5.9 {t1='abc', t2='A%_C'} {t1 LIKE t2} 1 test_expr expr-5.9b {t1='ac', t2='A%_C'} {t1 LIKE t2} 0 |
︙ | ︙ |
Changes to test/func.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing built-in functions. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing built-in functions. # # $Id: func.test,v 1.22 2004/06/17 05:36:45 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a table to work with. # do_test func-0.0 { |
︙ | ︙ | |||
333 334 335 336 337 338 339 | do_test func-11.1 { execsql { SELECT sqlite_version(*); } } [sqlite -version] # Test that destructors passed to sqlite by calls to sqlite3_result_text() | | > > > > > > > | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | do_test func-11.1 { execsql { SELECT sqlite_version(*); } } [sqlite -version] # Test that destructors passed to sqlite by calls to sqlite3_result_text() # etc. are called. These tests use two special user-defined functions # (implemented in func.c) only available in test builds. # # Function test_destructor() takes one argument and returns a copy of the # text form of that argument. A destructor is associated with the return # value. Function test_destructor_count() returns the number of outstanding # destructor calls for values returned by test_destructor(). # do_test func-12.1 { execsql { SELECT test_destructor('hello world'), test_destructor_count(); } } {{hello world} 1} do_test func-12.2 { execsql { |
︙ | ︙ | |||
367 368 369 370 371 372 373 | } } {hello world} do_test func-12.6 { execsql { SELECT test_destructor_count(); } } {0} | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | } } {hello world} do_test func-12.6 { execsql { SELECT test_destructor_count(); } } {0} do_test func-12.7 { execsql { DROP TABLE t4; } } {} # Test that the auxdata API for scalar functions works. This test uses # a special user-defined function only available in test builds, # test_auxdata(). Function test_auxdata() takes any number of arguments. do_test func-13.1 { execsql { SELECT test_auxdata('hello world'); } } {0} do_test func-13.2 { execsql { CREATE TABLE t4(a, b); INSERT INTO t4 VALUES('abc', 'def'); INSERT INTO t4 VALUES('ghi', 'jkl'); } } {} do_test func-13.3 { execsql { SELECT test_auxdata('hello world') FROM t4; } } {0 1} do_test func-13.4 { execsql { SELECT test_auxdata('hello world', 123) FROM t4; } } {{0 0} {1 1}} do_test func-13.5 { execsql { SELECT test_auxdata('hello world', a) FROM t4; } } {{0 0} {1 0}} do_test func-13.6 { execsql { SELECT test_auxdata('hello'||'world', a) FROM t4; } } {{0 0} {1 0}} # Test that auxilary data is preserved between calls for SQL variables. do_test func-13.7 { db close set DB [sqlite db test.db] set sql "SELECT test_auxdata( ? , a ) FROM t4;" set STMT [sqlite3_prepare $DB $sql -1 TAIL] sqlite3_bind_text $STMT 1 hello -1 set res [list] while { "SQLITE_ROW"==[sqlite3_step $STMT] } { lappend res [sqlite3_column_text $STMT 0] } lappend res [sqlite3_finalize $STMT] } {{0 0} {1 0} SQLITE_OK} finish_test |