| | @@ -222,11 +222,11 @@ |
| 222 | 222 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 223 | 223 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 224 | 224 | */ |
| 225 | 225 | #define SQLITE_VERSION "3.8.6" |
| 226 | 226 | #define SQLITE_VERSION_NUMBER 3008006 |
| 227 | | -#define SQLITE_SOURCE_ID "2014-08-11 13:53:30 de27c742c0dcda20b51339598bf6094a8dcf5fb9" |
| 227 | +#define SQLITE_SOURCE_ID "2014-08-12 16:13:37 6715991296886c2a02b9a285a1e61189ad1f79c0" |
| 228 | 228 | |
| 229 | 229 | /* |
| 230 | 230 | ** CAPI3REF: Run-Time Library Version Numbers |
| 231 | 231 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 232 | 232 | ** |
| | @@ -390,11 +390,11 @@ |
| 390 | 390 | ** |
| 391 | 391 | ** ^If the database connection is associated with unfinalized prepared |
| 392 | 392 | ** statements or unfinished sqlite3_backup objects then sqlite3_close() |
| 393 | 393 | ** will leave the database connection open and return [SQLITE_BUSY]. |
| 394 | 394 | ** ^If sqlite3_close_v2() is called with unfinalized prepared statements |
| 395 | | -** and unfinished sqlite3_backups, then the database connection becomes |
| 395 | +** and/or unfinished sqlite3_backups, then the database connection becomes |
| 396 | 396 | ** an unusable "zombie" which will automatically be deallocated when the |
| 397 | 397 | ** last prepared statement is finalized or the last sqlite3_backup is |
| 398 | 398 | ** finished. The sqlite3_close_v2() interface is intended for use with |
| 399 | 399 | ** host languages that are garbage collected, and where the order in which |
| 400 | 400 | ** destructors are called is arbitrary. |
| | @@ -403,11 +403,11 @@ |
| 403 | 403 | ** [sqlite3_blob_close | close] all [BLOB handles], and |
| 404 | 404 | ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated |
| 405 | 405 | ** with the [sqlite3] object prior to attempting to close the object. ^If |
| 406 | 406 | ** sqlite3_close_v2() is called on a [database connection] that still has |
| 407 | 407 | ** outstanding [prepared statements], [BLOB handles], and/or |
| 408 | | -** [sqlite3_backup] objects then it returns [SQLITE_OK] but the deallocation |
| 408 | +** [sqlite3_backup] objects then it returns [SQLITE_OK] and the deallocation |
| 409 | 409 | ** of resources is deferred until all [prepared statements], [BLOB handles], |
| 410 | 410 | ** and [sqlite3_backup] objects are also destroyed. |
| 411 | 411 | ** |
| 412 | 412 | ** ^If an [sqlite3] object is destroyed while a transaction is open, |
| 413 | 413 | ** the transaction is automatically rolled back. |
| | @@ -25565,16 +25565,16 @@ |
| 25565 | 25565 | |
| 25566 | 25566 | /* |
| 25567 | 25567 | ** Return TRUE if pFile has been renamed or unlinked since it was first opened. |
| 25568 | 25568 | */ |
| 25569 | 25569 | static int fileHasMoved(unixFile *pFile){ |
| 25570 | +#if OS_VXWORKS |
| 25571 | + return pFile->pInode!=0 && pFile->pId!=pFile->pInode->fileId.pId; |
| 25572 | +#else |
| 25570 | 25573 | struct stat buf; |
| 25571 | 25574 | return pFile->pInode!=0 && |
| 25572 | | -#if OS_VXWORKS |
| 25573 | | - pFile->pId!=pFile->pInode->fileId.Pid; |
| 25574 | | -#else |
| 25575 | | - (osStat(pFile->zPath, &buf)!=0 || buf.st_ino!=pFile->pInode->fileId.ino); |
| 25575 | + (osStat(pFile->zPath, &buf)!=0 || buf.st_ino!=pFile->pInode->fileId.ino); |
| 25576 | 25576 | #endif |
| 25577 | 25577 | } |
| 25578 | 25578 | |
| 25579 | 25579 | |
| 25580 | 25580 | /* |
| | @@ -32049,22 +32049,18 @@ |
| 32049 | 32049 | #ifndef NTDDI_WINBLUE |
| 32050 | 32050 | # define NTDDI_WINBLUE 0x06030000 |
| 32051 | 32051 | #endif |
| 32052 | 32052 | |
| 32053 | 32053 | /* |
| 32054 | | -** Check if the GetVersionEx[AW] functions should be considered deprecated |
| 32055 | | -** and avoid using them in that case. It should be noted here that if the |
| 32056 | | -** value of the SQLITE_WIN32_GETVERSIONEX pre-processor macro is zero |
| 32057 | | -** (whether via this block or via being manually specified), that implies |
| 32058 | | -** the underlying operating system will always be based on the Windows NT |
| 32059 | | -** Kernel. |
| 32054 | +** Check to see if the GetVersionEx[AW] functions are deprecated on the |
| 32055 | +** target system. GetVersionEx was first deprecated in Win8.1. |
| 32060 | 32056 | */ |
| 32061 | 32057 | #ifndef SQLITE_WIN32_GETVERSIONEX |
| 32062 | 32058 | # if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WINBLUE |
| 32063 | | -# define SQLITE_WIN32_GETVERSIONEX 0 |
| 32059 | +# define SQLITE_WIN32_GETVERSIONEX 0 /* GetVersionEx() is deprecated */ |
| 32064 | 32060 | # else |
| 32065 | | -# define SQLITE_WIN32_GETVERSIONEX 1 |
| 32061 | +# define SQLITE_WIN32_GETVERSIONEX 1 /* GetVersionEx() is current */ |
| 32066 | 32062 | # endif |
| 32067 | 32063 | #endif |
| 32068 | 32064 | |
| 32069 | 32065 | /* |
| 32070 | 32066 | ** This constant should already be defined (in the "WinDef.h" SDK file). |
| | @@ -32132,11 +32128,11 @@ |
| 32132 | 32128 | /* |
| 32133 | 32129 | ** This macro is used when a local variable is set to a value that is |
| 32134 | 32130 | ** [sometimes] not used by the code (e.g. via conditional compilation). |
| 32135 | 32131 | */ |
| 32136 | 32132 | #ifndef UNUSED_VARIABLE_VALUE |
| 32137 | | -# define UNUSED_VARIABLE_VALUE(x) (void)(x) |
| 32133 | +# define UNUSED_VARIABLE_VALUE(x) (void)(x) |
| 32138 | 32134 | #endif |
| 32139 | 32135 | |
| 32140 | 32136 | /* |
| 32141 | 32137 | ** Returns the character that should be used as the directory separator. |
| 32142 | 32138 | */ |
| | @@ -33029,11 +33025,20 @@ |
| 33029 | 33025 | /* |
| 33030 | 33026 | ** NOTE: On some sub-platforms, the InterlockedCompareExchange "function" |
| 33031 | 33027 | ** is really just a macro that uses a compiler intrinsic (e.g. x64). |
| 33032 | 33028 | ** So do not try to make this is into a redefinable interface. |
| 33033 | 33029 | */ |
| 33030 | +#if defined(InterlockedCompareExchange) |
| 33031 | + { "InterlockedCompareExchange", (SYSCALL)0, 0 }, |
| 33032 | + |
| 33034 | 33033 | #define osInterlockedCompareExchange InterlockedCompareExchange |
| 33034 | +#else |
| 33035 | + { "InterlockedCompareExchange", (SYSCALL)InterlockedCompareExchange, 0 }, |
| 33036 | + |
| 33037 | +#define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG volatile*, \ |
| 33038 | + LONG,LONG))aSyscall[76].pCurrent) |
| 33039 | +#endif /* defined(InterlockedCompareExchange) */ |
| 33035 | 33040 | |
| 33036 | 33041 | }; /* End of the overrideable system calls */ |
| 33037 | 33042 | |
| 33038 | 33043 | /* |
| 33039 | 33044 | ** This is the xSetSystemCall() method of sqlite3_vfs for all of the |
| | @@ -33289,24 +33294,33 @@ |
| 33289 | 33294 | /* |
| 33290 | 33295 | ** This function determines if the machine is running a version of Windows |
| 33291 | 33296 | ** based on the NT kernel. |
| 33292 | 33297 | */ |
| 33293 | 33298 | SQLITE_API int sqlite3_win32_is_nt(void){ |
| 33299 | +#if defined(SQLITE_WIN32_GETVERSIONEX) && SQLITE_WIN32_GETVERSIONEX |
| 33294 | 33300 | if( osInterlockedCompareExchange(&sqlite3_os_type, 0, 0)==0 ){ |
| 33295 | | -#if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WIN8 |
| 33301 | +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \ |
| 33302 | + defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WIN8 |
| 33296 | 33303 | OSVERSIONINFOW sInfo; |
| 33297 | 33304 | sInfo.dwOSVersionInfoSize = sizeof(sInfo); |
| 33298 | 33305 | osGetVersionExW(&sInfo); |
| 33299 | | -#else |
| 33306 | + osInterlockedCompareExchange(&sqlite3_os_type, |
| 33307 | + (sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 2 : 1, 0); |
| 33308 | +#elif defined(SQLITE_WIN32_HAS_ANSI) |
| 33300 | 33309 | OSVERSIONINFOA sInfo; |
| 33301 | 33310 | sInfo.dwOSVersionInfoSize = sizeof(sInfo); |
| 33302 | 33311 | osGetVersionExA(&sInfo); |
| 33303 | | -#endif |
| 33304 | 33312 | osInterlockedCompareExchange(&sqlite3_os_type, |
| 33305 | 33313 | (sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 2 : 1, 0); |
| 33314 | +#endif |
| 33306 | 33315 | } |
| 33316 | + return osInterlockedCompareExchange(&sqlite3_os_type, 2, 2)==2; |
| 33317 | +#elif SQLITE_TEST |
| 33307 | 33318 | return osInterlockedCompareExchange(&sqlite3_os_type, 2, 2)==2; |
| 33319 | +#else |
| 33320 | + return 1; |
| 33321 | +#endif |
| 33308 | 33322 | } |
| 33309 | 33323 | |
| 33310 | 33324 | #ifdef SQLITE_WIN32_MALLOC |
| 33311 | 33325 | /* |
| 33312 | 33326 | ** Allocate nBytes of memory. |
| | @@ -37459,11 +37473,11 @@ |
| 37459 | 37473 | }; |
| 37460 | 37474 | #endif |
| 37461 | 37475 | |
| 37462 | 37476 | /* Double-check that the aSyscall[] array has been constructed |
| 37463 | 37477 | ** correctly. See ticket [bb3a86e890c8e96ab] */ |
| 37464 | | - assert( ArraySize(aSyscall)==76 ); |
| 37478 | + assert( ArraySize(aSyscall)==77 ); |
| 37465 | 37479 | |
| 37466 | 37480 | /* get memory map allocation granularity */ |
| 37467 | 37481 | memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); |
| 37468 | 37482 | #if SQLITE_OS_WINRT |
| 37469 | 37483 | osGetNativeSystemInfo(&winSysInfo); |
| | @@ -62277,22 +62291,39 @@ |
| 62277 | 62291 | pB->zSql = zTmp; |
| 62278 | 62292 | pB->isPrepareV2 = pA->isPrepareV2; |
| 62279 | 62293 | } |
| 62280 | 62294 | |
| 62281 | 62295 | /* |
| 62282 | | -** Resize the Vdbe.aOp array so that it is at least one op larger than |
| 62283 | | -** it was. |
| 62296 | +** Resize the Vdbe.aOp array so that it is at least nOp elements larger |
| 62297 | +** than its current size. nOp is guaranteed to be less than or equal |
| 62298 | +** to 1024/sizeof(Op). |
| 62284 | 62299 | ** |
| 62285 | 62300 | ** If an out-of-memory error occurs while resizing the array, return |
| 62286 | | -** SQLITE_NOMEM. In this case Vdbe.aOp and Vdbe.nOpAlloc remain |
| 62301 | +** SQLITE_NOMEM. In this case Vdbe.aOp and Parse.nOpAlloc remain |
| 62287 | 62302 | ** unchanged (this is so that any opcodes already allocated can be |
| 62288 | 62303 | ** correctly deallocated along with the rest of the Vdbe). |
| 62289 | 62304 | */ |
| 62290 | | -static int growOpArray(Vdbe *v){ |
| 62305 | +static int growOpArray(Vdbe *v, int nOp){ |
| 62291 | 62306 | VdbeOp *pNew; |
| 62292 | 62307 | Parse *p = v->pParse; |
| 62308 | + |
| 62309 | + /* The SQLITE_TEST_REALLOC_STRESS compile-time option is designed to force |
| 62310 | + ** more frequent reallocs and hence provide more opportunities for |
| 62311 | + ** simulated OOM faults. SQLITE_TEST_REALLOC_STRESS is generally used |
| 62312 | + ** during testing only. With SQLITE_TEST_REALLOC_STRESS grow the op array |
| 62313 | + ** by the minimum* amount required until the size reaches 512. Normal |
| 62314 | + ** operation (without SQLITE_TEST_REALLOC_STRESS) is to double the current |
| 62315 | + ** size of the op array or add 1KB of space, whichever is smaller. */ |
| 62316 | +#ifdef SQLITE_TEST_REALLOC_STRESS |
| 62317 | + int nNew = (p->nOpAlloc>=512 ? p->nOpAlloc*2 : p->nOpAlloc+nOp); |
| 62318 | +#else |
| 62293 | 62319 | int nNew = (p->nOpAlloc ? p->nOpAlloc*2 : (int)(1024/sizeof(Op))); |
| 62320 | + UNUSED_PARAMETER(nOp); |
| 62321 | +#endif |
| 62322 | + |
| 62323 | + assert( nOp<=(1024/sizeof(Op)) ); |
| 62324 | + assert( nNew>=(p->nOpAlloc+nOp) ); |
| 62294 | 62325 | pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op)); |
| 62295 | 62326 | if( pNew ){ |
| 62296 | 62327 | p->nOpAlloc = sqlite3DbMallocSize(p->db, pNew)/sizeof(Op); |
| 62297 | 62328 | v->aOp = pNew; |
| 62298 | 62329 | } |
| | @@ -62332,11 +62363,11 @@ |
| 62332 | 62363 | |
| 62333 | 62364 | i = p->nOp; |
| 62334 | 62365 | assert( p->magic==VDBE_MAGIC_INIT ); |
| 62335 | 62366 | assert( op>0 && op<0xff ); |
| 62336 | 62367 | if( p->pParse->nOpAlloc<=i ){ |
| 62337 | | - if( growOpArray(p) ){ |
| 62368 | + if( growOpArray(p, 1) ){ |
| 62338 | 62369 | return 1; |
| 62339 | 62370 | } |
| 62340 | 62371 | } |
| 62341 | 62372 | p->nOp++; |
| 62342 | 62373 | pOp = &p->aOp[i]; |
| | @@ -62734,11 +62765,11 @@ |
| 62734 | 62765 | ** address of the first operation added. |
| 62735 | 62766 | */ |
| 62736 | 62767 | SQLITE_PRIVATE int sqlite3VdbeAddOpList(Vdbe *p, int nOp, VdbeOpList const *aOp, int iLineno){ |
| 62737 | 62768 | int addr; |
| 62738 | 62769 | assert( p->magic==VDBE_MAGIC_INIT ); |
| 62739 | | - if( p->nOp + nOp > p->pParse->nOpAlloc && growOpArray(p) ){ |
| 62770 | + if( p->nOp + nOp > p->pParse->nOpAlloc && growOpArray(p, nOp) ){ |
| 62740 | 62771 | return 0; |
| 62741 | 62772 | } |
| 62742 | 62773 | addr = p->nOp; |
| 62743 | 62774 | if( ALWAYS(nOp>0) ){ |
| 62744 | 62775 | int i; |
| | @@ -62919,11 +62950,11 @@ |
| 62919 | 62950 | |
| 62920 | 62951 | /* |
| 62921 | 62952 | ** Change the opcode at addr into OP_Noop |
| 62922 | 62953 | */ |
| 62923 | 62954 | SQLITE_PRIVATE void sqlite3VdbeChangeToNoop(Vdbe *p, int addr){ |
| 62924 | | - if( p->aOp ){ |
| 62955 | + if( addr<p->nOp ){ |
| 62925 | 62956 | VdbeOp *pOp = &p->aOp[addr]; |
| 62926 | 62957 | sqlite3 *db = p->db; |
| 62927 | 62958 | freeP4(db, pOp->p4type, pOp->p4.p); |
| 62928 | 62959 | memset(pOp, 0, sizeof(pOp[0])); |
| 62929 | 62960 | pOp->opcode = OP_Noop; |
| | @@ -77439,11 +77470,15 @@ |
| 77439 | 77470 | } |
| 77440 | 77471 | }else{ |
| 77441 | 77472 | /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is equivalent to |
| 77442 | 77473 | ** likelihood(X, 0.0625). |
| 77443 | 77474 | ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is short-hand for |
| 77444 | | - ** likelihood(X,0.0625). */ |
| 77475 | + ** likelihood(X,0.0625). |
| 77476 | + ** EVIDENCE-OF: R-36850-34127 The likely(X) function is short-hand for |
| 77477 | + ** likelihood(X,0.9375). |
| 77478 | + ** EVIDENCE-OF: R-53436-40973 The likely(X) function is equivalent to |
| 77479 | + ** likelihood(X,0.9375). */ |
| 77445 | 77480 | /* TUNING: unlikely() probability is 0.0625. likely() is 0.9375 */ |
| 77446 | 77481 | pExpr->iTable = pDef->zName[0]=='u' ? 62 : 938; |
| 77447 | 77482 | } |
| 77448 | 77483 | } |
| 77449 | 77484 | } |
| | @@ -96859,10 +96894,13 @@ |
| 96859 | 96894 | goto exec_out; |
| 96860 | 96895 | } |
| 96861 | 96896 | } |
| 96862 | 96897 | } |
| 96863 | 96898 | if( xCallback(pArg, nCol, azVals, azCols) ){ |
| 96899 | + /* EVIDENCE-OF: R-38229-40159 If the callback function to |
| 96900 | + ** sqlite3_exec() returns non-zero, then sqlite3_exec() will |
| 96901 | + ** return SQLITE_ABORT. */ |
| 96864 | 96902 | rc = SQLITE_ABORT; |
| 96865 | 96903 | sqlite3VdbeFinalize((Vdbe *)pStmt); |
| 96866 | 96904 | pStmt = 0; |
| 96867 | 96905 | sqlite3Error(db, SQLITE_ABORT, 0); |
| 96868 | 96906 | goto exec_out; |
| | @@ -102110,11 +102148,11 @@ |
| 102110 | 102148 | VdbeCoverage(v); |
| 102111 | 102149 | } |
| 102112 | 102150 | sqlite3VdbeChangeP4(v, -1, (const char *)pColl, P4_COLLSEQ); |
| 102113 | 102151 | sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); |
| 102114 | 102152 | } |
| 102115 | | - assert( sqlite3VdbeCurrentAddr(v)==iJump ); |
| 102153 | + assert( sqlite3VdbeCurrentAddr(v)==iJump || pParse->db->mallocFailed ); |
| 102116 | 102154 | sqlite3VdbeAddOp3(v, OP_Copy, regResult, regPrev, nResultCol-1); |
| 102117 | 102155 | break; |
| 102118 | 102156 | } |
| 102119 | 102157 | |
| 102120 | 102158 | case WHERE_DISTINCT_UNIQUE: { |
| | @@ -122944,10 +122982,12 @@ |
| 122944 | 122982 | /* |
| 122945 | 122983 | ** Close an existing SQLite database |
| 122946 | 122984 | */ |
| 122947 | 122985 | static int sqlite3Close(sqlite3 *db, int forceZombie){ |
| 122948 | 122986 | if( !db ){ |
| 122987 | + /* EVIDENCE-OF: R-63257-11740 Calling sqlite3_close() or |
| 122988 | + ** sqlite3_close_v2() with a NULL pointer argument is a harmless no-op. */ |
| 122949 | 122989 | return SQLITE_OK; |
| 122950 | 122990 | } |
| 122951 | 122991 | if( !sqlite3SafetyCheckSickOrOk(db) ){ |
| 122952 | 122992 | return SQLITE_MISUSE_BKPT; |
| 122953 | 122993 | } |
| | @@ -124192,11 +124232,11 @@ |
| 124192 | 124232 | SQLITE_MAX_COMPOUND_SELECT, |
| 124193 | 124233 | SQLITE_MAX_VDBE_OP, |
| 124194 | 124234 | SQLITE_MAX_FUNCTION_ARG, |
| 124195 | 124235 | SQLITE_MAX_ATTACHED, |
| 124196 | 124236 | SQLITE_MAX_LIKE_PATTERN_LENGTH, |
| 124197 | | - SQLITE_MAX_VARIABLE_NUMBER, |
| 124237 | + SQLITE_MAX_VARIABLE_NUMBER, /* IMP: R-38091-32352 */ |
| 124198 | 124238 | SQLITE_MAX_TRIGGER_DEPTH, |
| 124199 | 124239 | }; |
| 124200 | 124240 | |
| 124201 | 124241 | /* |
| 124202 | 124242 | ** Make sure the hard limits are set to reasonable values |
| | @@ -144154,11 +144194,11 @@ |
| 144154 | 144194 | int *piEnd, /* OUT: Ending offset of token */ |
| 144155 | 144195 | int *piPos /* OUT: Position integer of token */ |
| 144156 | 144196 | ){ |
| 144157 | 144197 | unicode_cursor *pCsr = (unicode_cursor *)pC; |
| 144158 | 144198 | unicode_tokenizer *p = ((unicode_tokenizer *)pCsr->base.pTokenizer); |
| 144159 | | - int iCode; |
| 144199 | + int iCode = 0; |
| 144160 | 144200 | char *zOut; |
| 144161 | 144201 | const unsigned char *z = &pCsr->aInput[pCsr->iOff]; |
| 144162 | 144202 | const unsigned char *zStart = z; |
| 144163 | 144203 | const unsigned char *zEnd; |
| 144164 | 144204 | const unsigned char *zTerm = &pCsr->aInput[pCsr->nInput]; |
| 144165 | 144205 | |