Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Change the API for binding strings and blobs so that the destructor now carries an extra argument which can be used as the sqlite4_env pointer, thus allowing functions like sqlite4_free() to be used as a string or blob destructor. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
56335097b187b038c4ee64a65a33ddbd |
User & Date: | drh 2013-02-13 12:28:13.287 |
Context
2013-02-14
| ||
15:32 | Fold in Peter Reid's fixes and enhancements to the sqlite4_num object. check-in: 8ede88c1df user: drh tags: trunk | |
2013-02-13
| ||
12:28 | Change the API for binding strings and blobs so that the destructor now carries an extra argument which can be used as the sqlite4_env pointer, thus allowing functions like sqlite4_free() to be used as a string or blob destructor. check-in: 56335097b1 user: drh tags: trunk | |
2013-02-11
| ||
18:33 | Fix the data decoder so that it correctly handles +Inf and -Inf. check-in: c04b47fd62 user: drh tags: trunk | |
Changes
Changes to src/alter.c.
︙ | |||
75 76 77 78 79 80 81 | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | - + | len = sqlite4GetToken(zCsr, &token); } while( token==TK_SPACE ); assert( len>0 ); } while( token!=TK_LP && token!=TK_USING ); zRet = sqlite4MPrintf(db, "%.*s\"%w\"%s", ((u8*)tname.z) - zSql, zSql, zTableName, tname.z+tname.n); |
︙ | |||
138 139 140 141 142 143 144 | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | - + | zInput = &z[n]; } sqlite4DbFree(db, zParent); } } zResult = sqlite4MPrintf(db, "%s%s", (zOutput?zOutput:""), zInput), |
︙ | |||
216 217 218 219 220 221 222 | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | - + | } while( dist!=2 || (token!=TK_WHEN && token!=TK_FOR && token!=TK_BEGIN) ); /* Variable tname now contains the token that is the old table-name ** in the CREATE TRIGGER statement. */ zRet = sqlite4MPrintf(db, "%.*s\"%w\"%s", ((u8*)tname.z) - zSql, zSql, zTableName, tname.z+tname.n); |
︙ |
Changes to src/callback.c.
︙ | |||
28 29 30 31 32 33 34 | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | - + | db->xCollNeeded(db->pCollNeededArg, db, enc, zExternal); sqlite4DbFree(db, zExternal); } #ifndef SQLITE4_OMIT_UTF16 if( db->xCollNeeded16 ){ char const *zExternal; sqlite4_value *pTmp = sqlite4ValueNew(db); |
︙ |
Changes to src/complete.c.
︙ | |||
265 266 267 268 269 270 271 | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | - + | int rc = SQLITE4_NOMEM; #ifndef SQLITE4_OMIT_AUTOINIT rc = sqlite4_initialize(0); if( rc ) return rc; #endif pVal = sqlite4ValueNew(0); |
︙ |
Changes to src/date.c.
︙ | |||
810 811 812 813 814 815 816 | 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 850 851 852 853 854 855 856 857 858 859 860 861 862 | - + - + - + | ){ DateTime x; if( isDate(context, argc, argv, &x)==0 ){ char zBuf[100]; computeYMD_HMS(&x); sqlite4_snprintf(zBuf,sizeof(zBuf), "%04d-%02d-%02d %02d:%02d:%02d", x.Y, x.M, x.D, x.h, x.m, (int)(x.s)); |
︙ | |||
996 997 998 999 1000 1001 1002 | 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 | - + | } default: z[j++] = '%'; break; } } } z[j] = 0; sqlite4_result_text(context, z, -1, |
︙ | |||
1083 1084 1085 1086 1087 1088 1089 | 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 | - + | sqlite4_mutex_enter(sqlite4MutexAlloc(SQLITE4_MUTEX_STATIC_MASTER)); pTm = gmtime(&t); if( pTm ) memcpy(&sNow, pTm, sizeof(sNow)); sqlite4_mutex_leave(sqlite4MutexAlloc(SQLITE4_MUTEX_STATIC_MASTER)); #endif if( pTm ){ strftime(zBuf, 20, zFormat, &sNow); |
︙ |
Changes to src/fts5.c.
︙ | |||
3392 3393 3394 3395 3396 3397 3398 | 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 | - + | if( zErr==0 ){ zErr = sqlite4MPrintf(db, "error parsing expression: %d", rc); } goto fts5_parse_expr_out; } fts5PrintExpr(db, azCol, pExpr, &zRet); |
︙ | |||
3419 3420 3421 3422 3423 3424 3425 | 3419 3420 3421 3422 3423 3424 3425 | - | int rc = sqlite4_create_function( db, "fts5_parse_expr", 3, SQLITE4_UTF8, 0, fts5_parse_expr, 0, 0 ); if( rc!=SQLITE4_OK ) return rc; #endif return sqlite4InitFts5Func(db); } |
Changes to src/fts5func.c.
︙ | |||
45 46 47 48 49 50 51 | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | - + | struct Fts5RankCtx { sqlite4 *db; double *aAvgdl; /* Average document size of each field */ int nPhrase; /* Number of phrases in query */ double *aIdf; /* IDF weights for each phrase in query */ }; |
︙ | |||
132 133 134 135 136 137 138 | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | - + | if( p==0 ){ int nPhrase; /* Number of phrases in query expression */ int nByte; /* Number of bytes of data to allocate */ sqlite4_mi_phrase_count(pCtx, &nPhrase); nByte = sizeof(Fts5RankCtx) + (nPhrase+nField) * sizeof(double); p = (Fts5RankCtx *)sqlite4DbMallocZero(db, nByte); |
︙ | |||
266 267 268 269 270 271 272 | 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | - + | } if( rc==SQLITE4_OK ){ if( bExplain ){ zExplain = sqlite4MAppendf( db, zExplain, "%s</table><b>overall rank=%.2f</b>", zExplain, rank ); |
︙ | |||
589 590 591 592 593 594 595 | 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | - + | if( rc==SQLITE4_OK ){ fts5SnippetImprove(pCtx, nTok, nSz, &aSnip[i]); rc = fts5SnippetText( pCtx, &aSnip[i], &text, nTok, zStart, zEnd, zEllipses ); } } |
︙ | |||
666 667 668 669 670 671 672 | 666 667 668 669 670 671 672 | - | void *p = SQLITE4_INT_TO_PTR(aRank[i].mask); const char *z = aRank[i].zName; rc = sqlite4_create_mi_function(db, z, -1, SQLITE4_UTF8, p, fts5Rank, 0); } return rc; } |
Changes to src/func.c.
︙ | |||
71 72 73 74 75 76 77 | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | - + | switch( sqlite4_value_type(argv[0]) ){ case SQLITE4_INTEGER: z = "integer"; break; case SQLITE4_TEXT: z = "text"; break; case SQLITE4_FLOAT: z = "real"; break; case SQLITE4_BLOB: z = "blob"; break; default: z = "null"; break; } |
︙ | |||
240 241 242 243 244 245 246 | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | - + - + | while( *z && p1 ){ SQLITE4_SKIP_UTF8(z); p1--; } for(z2=z; *z2 && p2; p2--){ SQLITE4_SKIP_UTF8(z2); } |
︙ | |||
332 333 334 335 336 337 338 | 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | - + - + | assert( z2==(char*)sqlite4_value_text(argv[0]) ); if( z2 ){ z1 = contextMalloc(context, ((i64)n)+1); if( z1 ){ for(i=0; i<n; i++){ z1[i] = (char)sqlite4Toupper(z2[i]); } |
︙ | |||
430 431 432 433 434 435 436 | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | - + | n = sqlite4_value_int(argv[0]); if( n<1 ){ n = 1; } p = contextMalloc(context, n); if( p ){ sqlite4_randomness(sqlite4_context_env(context), n, p); |
︙ | |||
750 751 752 753 754 755 756 | 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 | - + - + | sqlite4_context *context, int NotUsed, sqlite4_value **NotUsed2 ){ UNUSED_PARAMETER2(NotUsed, NotUsed2); /* IMP: R-48699-48617 This function is an SQL wrapper around the ** sqlite4_libversion() C-interface. */ |
︙ | |||
826 827 828 829 830 831 832 | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 | - + + | int n; assert( argc==1 ); UNUSED_PARAMETER(argc); /* IMP: R-04922-24076 The sqlite_compileoption_get() SQL function ** is a wrapper around the sqlite4_compileoption_get() C/C++ function. */ n = sqlite4_value_int(argv[0]); |
︙ | |||
873 874 875 876 877 878 879 | 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 | - + | zText[(i*2)+2] = hexdigits[(zBlob[i]>>4)&0x0F]; zText[(i*2)+3] = hexdigits[(zBlob[i])&0x0F]; } zText[(nBlob*2)+2] = '\''; zText[(nBlob*2)+3] = '\0'; zText[0] = 'x'; zText[1] = '\''; |
︙ | |||
897 898 899 900 901 902 903 | 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 | - + - + | z[j++] = zArg[i]; if( zArg[i]=='\'' ){ z[j++] = '\''; } } z[j++] = '\''; z[j] = 0; |
︙ | |||
934 935 936 937 938 939 940 | 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 | - + | if( zHex ){ for(i=0; i<n; i++, pBlob++){ unsigned char c = *pBlob; *(z++) = hexdigits[(c>>4)&0xf]; *(z++) = hexdigits[c&0xf]; } *z = 0; |
︙ | |||
1043 1044 1045 1046 1047 1048 1049 | 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 | - + | } } assert( j+nStr-i+1==nOut ); memcpy(&zOut[j], &zStr[i], nStr-i); j += nStr - i; assert( j<=nOut ); zOut[j] = 0; |
︙ | |||
1127 1128 1129 1130 1131 1132 1133 | 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 | - + | nIn -= len; } } if( zCharSet ){ sqlite4_free(sqlite4_context_env(context), azChar); } } |
︙ | |||
1182 1183 1184 1185 1186 1187 1188 | 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 | - + - + | prevcode = 0; } } while( j<4 ){ zResult[j++] = '0'; } zResult[j] = 0; |
︙ | |||
1414 1415 1416 1417 1418 1419 1420 | 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 | - + | if( pAccum ){ if( pAccum->tooBig ){ sqlite4_result_error_toobig(context); }else if( pAccum->mallocFailed ){ sqlite4_result_error_nomem(context); }else{ sqlite4_result_text(context, sqlite4StrAccumFinish(pAccum), -1, |
︙ |
Changes to src/main.c.
︙ | |||
25 26 27 28 29 30 31 | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | - + | #ifdef SQLITE4_ENABLE_ICU # include "sqliteicu.h" #endif /* ** Dummy function used as a unique symbol for SQLITE4_DYNAMIC */ |
︙ | |||
1263 1264 1265 1266 1267 1268 1269 | 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 | - + | sqlite4_mutex_enter(db->mutex); if( db->mallocFailed ){ z = (void *)outOfMem; }else{ z = sqlite4_value_text16(db->pErr); if( z==0 ){ sqlite4ValueSetStr(db->pErr, -1, sqlite4ErrStr(db->errCode), |
︙ |
Changes to src/shell.c.
︙ | |||
317 318 319 320 321 322 323 | 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | - + | int argc, sqlite4_value **argv ){ assert( 0==argc ); assert( zShellStatic ); UNUSED_PARAMETER(argc); UNUSED_PARAMETER(argv); |
︙ | |||
1803 1804 1805 1806 1807 1808 1809 | 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 | - + | int k; for(z=azCol[i], j=1, k=0; z[j]; j++){ if( z[j]=='"' ){ j++; if( z[j]==0 ) break; } z[k++] = z[j]; } z[k] = 0; } |
︙ | |||
2168 2169 2170 2171 2172 2173 2174 | 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 | - + - + | zSql = sqlite4_mprintf(0, "%z ORDER BY 1", zSql); rc = sqlite4_prepare(p->db, zSql, -1, &pStmt, 0); sqlite4_free(0, zSql); if( rc ) return rc; nRow = nAlloc = 0; azResult = 0; if( nArg>1 ){ |
︙ |
Changes to src/sqlite.h.in.
︙ | |||
1829 1830 1831 1832 1833 1834 1835 | 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 | - + + - - + + + + | ** [error code] if anything goes wrong. ** ^[SQLITE4_RANGE] is returned if the parameter ** index is out of range. ^[SQLITE4_NOMEM] is returned if malloc() fails. ** ** See also: [sqlite4_bind_parameter_count()], ** [sqlite4_bind_parameter_name()], and [sqlite4_bind_parameter_index()]. */ |
︙ | |||
2660 2661 2662 2663 2664 2665 2666 | 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 | - + + - - + + | ** expressions that are constant at compile time. This includes literal ** values and [parameters].)^ ** ** These routines must be called from the same thread in which ** the SQL function is running. */ void *sqlite4_get_auxdata(sqlite4_context*, int N); |
︙ | |||
2794 2795 2796 2797 2798 2799 2800 | 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 | - + + - - - - + + + + + + + + | ** [unprotected sqlite4_value] object is required, so either ** kind of [sqlite4_value] object can be used with this interface. ** ** If these routines are called from within the different thread ** than the one containing the application-defined function that received ** the [sqlite4_context] pointer, the results are undefined. */ |
︙ |
Changes to src/sqliteInt.h.
︙ | |||
2962 2963 2964 2965 2966 2967 2968 | 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 | - + | # define sqlite4FileSuffix3(X,Y) #endif u8 sqlite4GetBoolean(const char *z); const void *sqlite4ValueText(sqlite4_value*, u8); int sqlite4ValueBytes(sqlite4_value*, u8); void sqlite4ValueSetStr(sqlite4_value*, int, const void *,u8, |
︙ |
Changes to src/tclsqlite.c.
︙ | |||
502 503 504 505 506 507 508 | 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | - + - + | u8 *data; const char *zType = (pVar->typePtr ? pVar->typePtr->name : ""); char c = zType[0]; if( c=='b' && strcmp(zType,"bytearray")==0 && pVar->bytes==0 ){ /* Only return a BLOB type if the Tcl variable is a bytearray and ** has no string representation. */ data = Tcl_GetByteArrayFromObj(pVar, &n); |
︙ | |||
844 845 846 847 848 849 850 | 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | - + - + | char c = zType[0]; if( zVar[0]=='@' || (c=='b' && strcmp(zType,"bytearray")==0 && pVar->bytes==0) ){ /* Load a BLOB type if the Tcl variable is a bytearray and ** it has no string representation or the host ** parameter name begins with "@". */ data = Tcl_GetByteArrayFromObj(pVar, &n); |
︙ | |||
1666 1667 1668 1669 1670 1671 1672 | 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 | - + | for(i=0; i<nCol; i++){ /* check for null data, if so, bind as null */ if( (nNull>0 && strcmp(azCol[i], zNull)==0) || strlen30(azCol[i])==0 ){ sqlite4_bind_null(pStmt, i+1); }else{ |
︙ | |||
2799 2800 2801 2802 2803 2804 2805 | 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 | - + | static void md5finalize(sqlite4_context *context){ MD5Context *p; unsigned char digest[16]; char zBuf[33]; p = sqlite4_aggregate_context(context, sizeof(*p)); MD5Final(digest,p); MD5DigestToBase16(digest, zBuf); |
︙ |
Changes to src/utf.c.
︙ | |||
470 471 472 473 474 475 476 | 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | - + | ** ** NULL is returned if there is an allocation error. */ char *sqlite4Utf16to8(sqlite4 *db, const void *z, int nByte, u8 enc){ Mem m; memset(&m, 0, sizeof(m)); m.db = db; |
︙ | |||
498 499 500 501 502 503 504 | 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | - + | ** flag set. */ #ifdef SQLITE4_ENABLE_STAT3 char *sqlite4Utf8to16(sqlite4 *db, u8 enc, char *z, int n, int *pnOut){ Mem m; memset(&m, 0, sizeof(m)); m.db = db; |
︙ |
Changes to src/util.c.
︙ | |||
128 129 130 131 132 133 134 | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | - + - + | db->errCode = err_code; if( zFormat ){ char *z; va_list ap; va_start(ap, zFormat); z = sqlite4VMPrintf(db, zFormat, ap); va_end(ap); |
︙ |
Changes to src/vdbe.c.
︙ | |||
880 881 882 883 884 885 886 | 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 | - + + | case OP_String8: { /* same as TK_STRING, out2-prerelease */ assert( pOp->p4.z!=0 ); pOp->opcode = OP_String; pOp->p1 = sqlite4Strlen30(pOp->p4.z); #ifndef SQLITE4_OMIT_UTF16 if( encoding!=SQLITE4_UTF8 ){ |
︙ | |||
946 947 948 949 950 951 952 | 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 | - + | /* Opcode: Blob P1 P2 * P4 ** ** P4 points to a blob of data P1 bytes long. Store this ** blob in register P2. */ case OP_Blob: { /* out2-prerelease */ assert( pOp->p1 <= SQLITE4_MAX_LENGTH ); |
︙ | |||
2253 2254 2255 2256 2257 2258 2259 | 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 | - + + | if( rc ){ sqlite4DbFree(db, aRec); }else{ if( nSeq ){ memcpy(&aRec[nRec], &aSeq[sizeof(aSeq)-nSeq], nSeq); } |
︙ | |||
2343 2344 2345 2346 2347 2348 2349 | 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 | - + + - + | aRec = 0; rc = sqlite4VdbeEncodeKey(db, pData0, pC->pKeyInfo->nField, pC->iRoot, pC->pKeyInfo, &aRec, &nRec, 0 ); if( rc ){ sqlite4DbFree(db, aRec); }else{ |
︙ | |||
3517 3518 3519 3520 3521 3522 3523 | 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 | - + | pIn3 = &aMem[pOp->p3]; if( (pIn3->flags & MEM_Blob) && pIn3->n==nKey && 0==memcmp(pIn3->z, aKey, nKey) ){ pc = pOp->p2-1; }else{ |
︙ | |||
3584 3585 3586 3587 3588 3589 3590 | 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 | - + | rc = sqlite4KVCursorKey(pCrsr, &pData, &nData); }else{ rc = sqlite4KVCursorData(pCrsr, 0, -1, &pData, &nData); } if( rc==SQLITE4_OK && nData>db->aLimit[SQLITE4_LIMIT_LENGTH] ){ goto too_big; } |
︙ | |||
4105 4106 4107 4108 4109 4110 4111 | 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 | - + + | CHECK_FOR_INTERRUPT; pIn1 = &aMem[pOp->p1]; pOut = &aMem[pOp->p3]; if( (pIn1->flags & MEM_RowSet) && (aKey = sqlite4RowSetRead(pIn1->u.pRowSet, &nKey)) ){ |
︙ |
Changes to src/vdbe.h.
︙ | |||
200 201 202 203 204 205 206 | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | - + | int sqlite4VdbeAssertMayAbort(Vdbe *, int); void sqlite4VdbeTrace(Vdbe*,FILE*); #endif void sqlite4VdbeResetStepResult(Vdbe*); void sqlite4VdbeRewind(Vdbe*); int sqlite4VdbeReset(Vdbe*); void sqlite4VdbeSetNumCols(Vdbe*,int); |
︙ |
Changes to src/vdbeInt.h.
︙ | |||
145 146 147 148 149 150 151 | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | - + + | u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ u8 type; /* One of SQLITE4_NULL, SQLITE4_TEXT, SQLITE4_INTEGER, etc */ u8 enc; /* SQLITE4_UTF8, SQLITE4_UTF16BE, SQLITE4_UTF16LE */ #ifdef SQLITE4_DEBUG Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */ void *pFiller; /* So that sizeof(Mem) is a multiple of 8 */ #endif |
︙ | |||
213 214 215 216 217 218 219 | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | - + + | ** invocations. */ struct VdbeFunc { FuncDef *pFunc; /* The definition of the function */ int nAux; /* Number of entries allocated for apAux[] */ struct AuxData { void *pAux; /* Aux data for the i-th argument */ |
︙ | |||
394 395 396 397 398 399 400 | 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | - + + | int sqlite4VdbeHalt(Vdbe*); int sqlite4VdbeChangeEncoding(Mem *, int); int sqlite4VdbeMemTooBig(Mem*); int sqlite4VdbeMemCopy(Mem*, const Mem*); void sqlite4VdbeMemShallowCopy(Mem*, const Mem*, int); void sqlite4VdbeMemMove(Mem*, Mem*); int sqlite4VdbeMemNulTerminate(Mem*); |
︙ |
Changes to src/vdbeapi.c.
︙ | |||
185 186 187 188 189 190 191 | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | - - - - - + + + + + + - + - + + - + - + - + - + + - + - + + - + - + + - + - + + - + - + - + | ** the function result. ** ** The setStrOrError() funtion calls sqlite4VdbeMemSetStr() to store the ** result as a string or blob but if the string or blob is too large, it ** then sets the error code to SQLITE4_TOOBIG */ static void setResultStrOrError( |
︙ | |||
587 588 589 590 591 592 593 | 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | - + + | ** argument to the user-function defined by pCtx. Any previous value is ** deleted by calling the delete function specified when it was set. */ void sqlite4_set_auxdata( sqlite4_context *pCtx, int iArg, void *pAux, |
︙ | |||
610 611 612 613 614 615 616 | 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | - + + - + | memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux)); pVdbeFunc->nAux = iArg+1; pVdbeFunc->pFunc = pCtx->pFunc; } pAuxData = &pVdbeFunc->apAux[iArg]; if( pAuxData->pAux && pAuxData->xDelete ){ |
︙ | |||
1004 1005 1006 1007 1008 1009 1010 | 1012 1013 1014 1015 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 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 | - - - - - - + + + + + + + - + - + - + + - + | return SQLITE4_OK; } /* ** Bind a text or BLOB value. */ static int bindText( |
︙ | |||
1083 1084 1085 1086 1087 1088 1089 | 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 | - + + - + - + + - + - + + - + | return rc; } int sqlite4_bind_text( sqlite4_stmt *pStmt, int i, const char *zData, int nData, |
︙ |
Changes to src/vdbeaux.c.
︙ | |||
1191 1192 1193 1194 1195 1196 1197 | 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 | - + | if( sqlite4VdbeMemGrow(pMem, 32, 0) ){ /* P4 */ assert( p->db->mallocFailed ); return SQLITE4_ERROR; } pMem->flags = MEM_Dyn|MEM_Str|MEM_Term; z = displayP4(pOp, pMem->z, 32); if( z!=pMem->z ){ |
︙ | |||
1634 1635 1636 1637 1638 1639 1640 | 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 | - + + + - + | ** to by zName will be freed by sqlite4DbFree() when the vdbe is destroyed. */ int sqlite4VdbeSetColName( Vdbe *p, /* Vdbe being configured */ int idx, /* Index of column zName applies to */ int var, /* One of the COLNAME_* constants */ const char *zName, /* Pointer to buffer containing name */ |
︙ | |||
1972 1973 1974 1975 1976 1977 1978 | 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 | - + + | */ int sqlite4VdbeTransferError(Vdbe *p){ sqlite4 *db = p->db; int rc = p->rc; if( p->zErrMsg ){ u8 mallocFailed = db->mallocFailed; sqlite4BeginBenignMalloc(db->pEnv); |
︙ | |||
2019 2020 2021 2022 2023 2024 2025 | 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 | - + + | if( p->runOnlyOnce ) p->expired = 1; }else if( p->rc && p->expired ){ /* The expired flag was set on the VDBE before the first call ** to sqlite4_step(). For consistency (since sqlite4_step() was ** called), set the database error in this case as well. */ sqlite4Error(db, p->rc, 0); |
︙ | |||
2081 2082 2083 2084 2085 2086 2087 | 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 | - + | */ void sqlite4VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){ int i; for(i=0; i<pVdbeFunc->nAux; i++){ struct AuxData *pAux = &pVdbeFunc->apAux[i]; if( (i>31 || !(mask&(((u32)1)<<i))) && pAux->pAux ){ if( pAux->xDelete ){ |
︙ |
Changes to src/vdbecodec.c.
︙ | |||
141 142 143 144 145 146 147 | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | - + - + - + - + + | e = e>>2; while( e>=10 ){ r *= 1.0e10; e -= 10; } while( e>0 ){ r *= 10.0; e--; } } sqlite4VdbeMemSetDouble(pOut, r); }else if( cclass==0 ){ if( size==0 ){ |
︙ |
Changes to src/vdbemem.c.
︙ | |||
89 90 91 92 93 94 95 | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | - + | } if( pMem->z && preserve && pMem->zMalloc && pMem->z!=pMem->zMalloc ){ memcpy(pMem->zMalloc, pMem->z, pMem->n); } if( pMem->flags&MEM_Dyn && pMem->xDel ){ assert( pMem->xDel!=SQLITE4_DYNAMIC ); |
︙ | |||
240 241 242 243 244 245 246 | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | - + | if( p->flags&MEM_Agg ){ sqlite4VdbeMemFinalize(p, p->u.pDef); assert( (p->flags & MEM_Agg)==0 ); sqlite4VdbeMemRelease(p); }else if( p->flags&MEM_Dyn && p->xDel ){ assert( (p->flags&MEM_RowSet)==0 ); assert( p->xDel!=SQLITE4_DYNAMIC ); |
︙ | |||
632 633 634 635 636 637 638 | 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | - - - - - + + + + + + | ** If the string is too large (if it exceeds the SQLITE4_LIMIT_LENGTH ** size limit) then no memory allocation occurs. If the string can be ** stored without allocating memory, then it is. If a memory allocation ** is required to store the string, then value of pMem is unchanged. In ** either case, SQLITE4_TOOBIG is returned. */ int sqlite4VdbeMemSetStr( |
︙ | |||
691 692 693 694 695 696 697 698 699 700 701 702 703 704 | 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 | + | sqlite4VdbeMemRelease(pMem); pMem->zMalloc = pMem->z = (char *)z; pMem->xDel = 0; }else{ sqlite4VdbeMemRelease(pMem); pMem->z = (char *)z; pMem->xDel = xDel; pMem->pDelArg = pDelArg; flags |= ((xDel==SQLITE4_STATIC)?MEM_Static:MEM_Dyn); } pMem->n = nByte; pMem->flags = flags; pMem->enc = (enc==0 ? SQLITE4_UTF8 : enc); pMem->type = (enc==0 ? SQLITE4_BLOB : SQLITE4_TEXT); |
︙ | |||
947 948 949 950 951 952 953 | 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 | - + | pVal = sqlite4ValueNew(db); if( pVal==0 ) goto no_mem; if( ExprHasProperty(pExpr, EP_IntValue) ){ sqlite4VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt); }else{ zVal = sqlite4MPrintf(db, "%s%s", zNeg, pExpr->u.zToken); if( zVal==0 ) goto no_mem; |
︙ | |||
988 989 990 991 992 993 994 | 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 | - + | assert( pExpr->u.zToken[1]=='\'' ); pVal = sqlite4ValueNew(db); if( !pVal ) goto no_mem; zVal = &pExpr->u.zToken[2]; nVal = sqlite4Strlen30(zVal)-1; assert( zVal[nVal]=='\'' ); sqlite4VdbeMemSetStr(pVal, sqlite4HexToBlob(db, zVal, nVal), nVal/2, |
︙ | |||
1010 1011 1012 1013 1014 1015 1016 | 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 | - - - - - + + + + + + - + | return SQLITE4_NOMEM; } /* ** Change the string value of an sqlite4_value object */ void sqlite4ValueSetStr( |
︙ |
Changes to src/vdbetrace.c.
︙ | |||
126 127 128 129 130 131 132 | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | - + | }else if( pVar->flags & MEM_Str ){ #ifndef SQLITE4_OMIT_UTF16 u8 enc = ENC(db); if( enc!=SQLITE4_UTF8 ){ Mem utf8; memset(&utf8, 0, sizeof(utf8)); utf8.db = db; |
︙ |
Changes to test/test_func.c.
︙ | |||
65 66 67 68 69 70 71 | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | - + - + | } assert( n<sizeof(zBuf) ); sqlite4_randomness(pEnv, n, zBuf); for(i=0; i<n; i++){ zBuf[i] = zSrc[zBuf[i]%(sizeof(zSrc)-1)]; } zBuf[n] = 0; |
︙ | |||
107 108 109 110 111 112 113 | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | - + | if( !zVal ){ return; } zVal[len+1] = 0; zVal[len+2] = 0; zVal++; memcpy(zVal, sqlite4_value_text(argv[0]), len); |
︙ | |||
130 131 132 133 134 135 136 | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | - + | if( !zVal ){ return; } zVal[len+1] = 0; zVal[len+2] = 0; zVal++; memcpy(zVal, sqlite4_value_text16(argv[0]), len); |
︙ | |||
163 164 165 166 167 168 169 | 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 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | - + - + + + + - + + - + + | #ifndef SQLITE4_OMIT_UTF16 const void *z; sqlite4 * db = sqlite4_context_db_handle(ctx); sqlite4_aggregate_context(ctx, 2048); sqlite4BeginBenignMalloc(); z = sqlite4_errmsg16(db); sqlite4EndBenignMalloc(); |
︙ | |||
230 231 232 233 234 235 236 | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | - + | sqlite4_result_error_code(pCtx, sqlite4_value_int(argv[1])); } } /* A counter object with its destructor. Used by counterFunc() below. */ struct counterObject { int cnt; sqlite4_env *pEnv; }; |
︙ | |||
256 257 258 259 260 261 262 | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | - + | pCounter = sqlite4_malloc(sqlite4_context_env(pCtx), sizeof(*pCounter) ); if( pCounter==0 ){ sqlite4_result_error_nomem(pCtx); return; } pCounter->cnt = sqlite4_value_int(argv[0]); pCounter->pEnv = sqlite4_context_env(pCtx); |
︙ | |||
319 320 321 322 323 324 325 | 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | - + | } if( rc ){ char *zErr; sqlite4_env *pEnv = sqlite4_context_env(pCtx); assert( pStmt==0 ); zErr = sqlite4_mprintf(pEnv, "sqlite4_prepare() error: %s", sqlite4_errmsg(db)); |
︙ | |||
372 373 374 375 376 377 378 | 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | - + | n = sqlite4_value_bytes(argv[0]); zIn = (const char*)sqlite4_value_text(argv[0]); zOut = sqlite4_malloc(sqlite4_context_env(pCtx), n/2 ); if( zOut==0 ){ sqlite4_result_error_nomem(pCtx); }else{ testHexToBin(zIn, zOut); |
︙ | |||
399 400 401 402 403 404 405 | 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | - + | n = sqlite4_value_bytes(argv[0]); zIn = (const char*)sqlite4_value_text(argv[0]); zOut = sqlite4_malloc(sqlite4_context_env(pCtx), n/2 ); if( zOut==0 ){ sqlite4_result_error_nomem(pCtx); }else{ testHexToBin(zIn, zOut); |
︙ | |||
426 427 428 429 430 431 432 | 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | - + | n = sqlite4_value_bytes(argv[0]); zIn = (const char*)sqlite4_value_text(argv[0]); zOut = sqlite4_malloc(sqlite4_context_env(pCtx), n/2 ); if( zOut==0 ){ sqlite4_result_error_nomem(pCtx); }else{ testHexToBin(zIn, zOut); |
︙ |
Changes to test/test_main.c.
︙ | |||
682 683 684 685 686 687 688 | 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 | - + - + - + | sqlite4_value **argv ){ int i; for(i=0; i<argc; i++){ if( SQLITE4_NULL!=sqlite4_value_type(argv[i]) ){ int n = sqlite4_value_bytes(argv[i]); sqlite4_result_text(context, (char*)sqlite4_value_text(argv[i]), |
︙ | |||
787 788 789 790 791 792 793 | 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 | - + | sqlite4_value **argv ){ struct dstr x; memset(&x, 0, sizeof(x)); (void)sqlite4_exec((sqlite4*)sqlite4_user_data(context), (char*)sqlite4_value_text(argv[0]), execFuncCallback, &x, 0); |
︙ | |||
827 828 829 830 831 832 833 | 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 | - + | zText3 = sqlite4_value_text(argv[0]); if( zText1!=zText2 || zText2!=zText3 ){ sqlite4_result_error(context, "tkt2213 is not fixed", -1); }else{ char *zCopy = (char *)sqlite4_malloc(sqlite4_context_env(context),nText); memcpy(zCopy, zText1, nText); |
︙ | |||
965 966 967 968 969 970 971 | 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | - + + | /* Use the sqlite4_create_function16() API here. Mainly for fun, but also ** because it is not tested anywhere else. */ if( rc==SQLITE4_OK ){ const void *zUtf16; sqlite4_value *pVal; sqlite4_mutex_enter(db->mutex); pVal = sqlite4ValueNew(db); |
︙ | |||
1710 1711 1712 1713 1714 1715 1716 | 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 | - + | if( zArg0 ){ if( 0==sqlite4_stricmp(zArg0, "int") ){ sqlite4_result_int(context, sqlite4_value_int(argv[1])); }else if( sqlite4_stricmp(zArg0,"int64")==0 ){ sqlite4_result_int64(context, sqlite4_value_int64(argv[1])); }else if( sqlite4_stricmp(zArg0,"string")==0 ){ sqlite4_result_text(context, (char*)sqlite4_value_text(argv[1]), -1, |
︙ | |||
2096 2097 2098 2099 2100 2101 2102 | 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 | - + - + - + - + | return TCL_ERROR; } if( getStmtPointer(interp, argv[1], &pStmt) ) return TCL_ERROR; if( Tcl_GetInt(interp, argv[2], &idx) ) return TCL_ERROR; if( strcmp(argv[4],"null")==0 ){ rc = sqlite4_bind_null(pStmt, idx); }else if( strcmp(argv[4],"static")==0 ){ |
︙ | |||
2183 2184 2185 2186 2187 2188 2189 | 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 | - + - + | default: assert(0); } sqlite4BeginBenignMalloc(pEnv); pVal = sqlite4ValueNew(0); if( pVal ){ |
︙ | |||
2385 2386 2387 2388 2389 2390 2391 | 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 | - + + - + - + - - + + + - + - + - + - + | pX = Tcl_NewStringObj("test_function", -1); Tcl_IncrRefCount(pX); Tcl_ListObjAppendElement(interp, pX, Tcl_NewStringObj("UTF-8", -1)); Tcl_ListObjAppendElement(interp, pX, Tcl_NewStringObj((char*)sqlite4_value_text(argv[0]), -1)); Tcl_EvalObjEx(interp, pX, 0); Tcl_DecrRefCount(pX); |
︙ | |||
2784 2785 2786 2787 2788 2789 2790 | 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 | - + | } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; value = (char*)Tcl_GetByteArrayFromObj(objv[3], &bytes); if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR; |
︙ | |||
2832 2833 2834 2835 2836 2837 2838 | 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 | - + | } if( getStmtPointer(interp, Tcl_GetString(oStmt), &pStmt) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, oN, &idx) ) return TCL_ERROR; value = (char*)Tcl_GetByteArrayFromObj(oString, 0); if( Tcl_GetIntFromObj(interp, oBytes, &bytes) ) return TCL_ERROR; |
︙ | |||
2879 2880 2881 2882 2883 2884 2885 | 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 | - + | } if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR; value = Tcl_GetString(objv[3]); if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR; |
︙ |
Changes to test/test_utf.c.
︙ | |||
112 113 114 115 116 117 118 | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | - + + + - + | } if( pEnc->enc==SQLITE4_UTF16 ){ return SQLITE4_UTF16NATIVE; } return pEnc->enc; } |
︙ | |||
155 156 157 158 159 160 161 | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | - + - + | pVal = sqlite4ValueNew(0); if( enc_from==SQLITE4_UTF8 ){ z = Tcl_GetString(objv[1]); if( objc==5 ){ z = sqlite4_mprintf(0, "%s", z); } |
︙ |