| | @@ -325,11 +325,11 @@ |
| 325 | 325 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 326 | 326 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 327 | 327 | */ |
| 328 | 328 | #define SQLITE_VERSION "3.8.12" |
| 329 | 329 | #define SQLITE_VERSION_NUMBER 3008012 |
| 330 | | -#define SQLITE_SOURCE_ID "2015-09-24 18:47:59 668fc1ebaf426f9eed3ed7865e41f1023dafebfb" |
| 330 | +#define SQLITE_SOURCE_ID "2015-09-28 14:40:20 9d057f52217e7ef9c3f3eb84117abe3365503f44" |
| 331 | 331 | |
| 332 | 332 | /* |
| 333 | 333 | ** CAPI3REF: Run-Time Library Version Numbers |
| 334 | 334 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 335 | 335 | ** |
| | @@ -4572,11 +4572,11 @@ |
| 4572 | 4572 | SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*); |
| 4573 | 4573 | SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*); |
| 4574 | 4574 | SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*); |
| 4575 | 4575 | |
| 4576 | 4576 | /* |
| 4577 | | -** CAPI3REF: Obtaining SQL Values |
| 4577 | +** CAPI3REF: Finding The Subtype Of SQL Values |
| 4578 | 4578 | ** METHOD: sqlite3_value |
| 4579 | 4579 | ** |
| 4580 | 4580 | ** The sqlite3_value_subtype(V) function returns the subtype for |
| 4581 | 4581 | ** an [application-defined SQL function] argument V. The subtype |
| 4582 | 4582 | ** information can be used to pass a limited amount of context from |
| | @@ -19781,11 +19781,13 @@ |
| 19781 | 19781 | return p->nRef==0 || pthread_equal(p->owner, pthread_self())==0; |
| 19782 | 19782 | } |
| 19783 | 19783 | #endif |
| 19784 | 19784 | |
| 19785 | 19785 | /* |
| 19786 | | -** Try to provide a memory barrier operation, needed for initialization only. |
| 19786 | +** Try to provide a memory barrier operation, needed for initialization |
| 19787 | +** and also for the implementation of xShmBarrier in the VFS in cases |
| 19788 | +** where SQLite is compiled without mutexes. |
| 19787 | 19789 | */ |
| 19788 | 19790 | SQLITE_PRIVATE void sqlite3MemoryBarrier(void){ |
| 19789 | 19791 | #if defined(SQLITE_MEMORY_BARRIER) |
| 19790 | 19792 | SQLITE_MEMORY_BARRIER; |
| 19791 | 19793 | #elif defined(__GNUC__) && GCC_VERSION>=4001000 |
| | @@ -20454,11 +20456,13 @@ |
| 20454 | 20456 | return winMutexNotheld2(p, tid); |
| 20455 | 20457 | } |
| 20456 | 20458 | #endif |
| 20457 | 20459 | |
| 20458 | 20460 | /* |
| 20459 | | -** Try to provide a memory barrier operation, needed for initialization only. |
| 20461 | +** Try to provide a memory barrier operation, needed for initialization |
| 20462 | +** and also for the xShmBarrier method of the VFS in cases when SQLite is |
| 20463 | +** compiled without mutexes (SQLITE_THREADSAFE=0). |
| 20460 | 20464 | */ |
| 20461 | 20465 | SQLITE_PRIVATE void sqlite3MemoryBarrier(void){ |
| 20462 | 20466 | #if defined(SQLITE_MEMORY_BARRIER) |
| 20463 | 20467 | SQLITE_MEMORY_BARRIER; |
| 20464 | 20468 | #elif defined(__GNUC__) |
| | @@ -23266,10 +23270,14 @@ |
| 23266 | 23270 | p = sqlite3Malloc(sizeof(*p)); |
| 23267 | 23271 | if( p==0 ) return SQLITE_NOMEM; |
| 23268 | 23272 | memset(p, 0, sizeof(*p)); |
| 23269 | 23273 | p->xTask = xTask; |
| 23270 | 23274 | p->pIn = pIn; |
| 23275 | + /* If the SQLITE_TESTCTRL_FAULT_INSTALL callback is registered to a |
| 23276 | + ** function that returns SQLITE_ERROR when passed the argument 200, that |
| 23277 | + ** forces worker threads to run sequentially and deterministically |
| 23278 | + ** for testing purposes. */ |
| 23271 | 23279 | if( sqlite3FaultSim(200) ){ |
| 23272 | 23280 | rc = 1; |
| 23273 | 23281 | }else{ |
| 23274 | 23282 | rc = pthread_create(&p->tid, 0, xTask, pIn); |
| 23275 | 23283 | } |
| | @@ -23350,11 +23358,16 @@ |
| 23350 | 23358 | assert( ppThread!=0 ); |
| 23351 | 23359 | assert( xTask!=0 ); |
| 23352 | 23360 | *ppThread = 0; |
| 23353 | 23361 | p = sqlite3Malloc(sizeof(*p)); |
| 23354 | 23362 | if( p==0 ) return SQLITE_NOMEM; |
| 23355 | | - if( sqlite3GlobalConfig.bCoreMutex==0 ){ |
| 23363 | + /* If the SQLITE_TESTCTRL_FAULT_INSTALL callback is registered to a |
| 23364 | + ** function that returns SQLITE_ERROR when passed the argument 200, that |
| 23365 | + ** forces worker threads to run sequentially and deterministically |
| 23366 | + ** (via the sqlite3FaultSim() term of the conditional) for testing |
| 23367 | + ** purposes. */ |
| 23368 | + if( sqlite3GlobalConfig.bCoreMutex==0 || sqlite3FaultSim(200) ){ |
| 23356 | 23369 | memset(p, 0, sizeof(*p)); |
| 23357 | 23370 | }else{ |
| 23358 | 23371 | p->xTask = xTask; |
| 23359 | 23372 | p->pIn = pIn; |
| 23360 | 23373 | p->tid = (void*)_beginthreadex(0, 0, sqlite3ThreadProc, p, 0, &p->id); |
| | @@ -23378,11 +23391,11 @@ |
| 23378 | 23391 | BOOL bRc; |
| 23379 | 23392 | |
| 23380 | 23393 | assert( ppOut!=0 ); |
| 23381 | 23394 | if( NEVER(p==0) ) return SQLITE_NOMEM; |
| 23382 | 23395 | if( p->xTask==0 ){ |
| 23383 | | - assert( p->id==GetCurrentThreadId() ); |
| 23396 | + /* assert( p->id==GetCurrentThreadId() ); */ |
| 23384 | 23397 | rc = WAIT_OBJECT_0; |
| 23385 | 23398 | assert( p->tid==0 ); |
| 23386 | 23399 | }else{ |
| 23387 | 23400 | assert( p->id!=0 && p->id!=GetCurrentThreadId() ); |
| 23388 | 23401 | rc = sqlite3Win32Wait((HANDLE)p->tid); |
| | @@ -94256,12 +94269,11 @@ |
| 94256 | 94269 | int iDb; |
| 94257 | 94270 | sqlite3 *db = pParse->db; |
| 94258 | 94271 | |
| 94259 | 94272 | if( pParse->nVar>0 ){ |
| 94260 | 94273 | sqlite3ErrorMsg(pParse, "parameters are not allowed in views"); |
| 94261 | | - sqlite3SelectDelete(db, pSelect); |
| 94262 | | - return; |
| 94274 | + goto create_view_fail; |
| 94263 | 94275 | } |
| 94264 | 94276 | sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr); |
| 94265 | 94277 | p = pParse->pNewTable; |
| 94266 | 94278 | if( p==0 || pParse->nErr ) goto create_view_fail; |
| 94267 | 94279 | sqlite3TwoPartName(pParse, pName1, pName2, &pName); |
| | @@ -106729,12 +106741,12 @@ |
| 106729 | 106741 | int uniqOk = sqlite3VdbeMakeLabel(v); |
| 106730 | 106742 | int jmp6; |
| 106731 | 106743 | int kk; |
| 106732 | 106744 | for(kk=0; kk<pIdx->nKeyCol; kk++){ |
| 106733 | 106745 | int iCol = pIdx->aiColumn[kk]; |
| 106734 | | - assert( iCol>=0 && iCol<pTab->nCol ); |
| 106735 | | - if( pTab->aCol[iCol].notNull ) continue; |
| 106746 | + assert( iCol!=(-1) && iCol<pTab->nCol ); |
| 106747 | + if( iCol>=0 && pTab->aCol[iCol].notNull ) continue; |
| 106736 | 106748 | sqlite3VdbeAddOp2(v, OP_IsNull, r1+kk, uniqOk); |
| 106737 | 106749 | VdbeCoverage(v); |
| 106738 | 106750 | } |
| 106739 | 106751 | jmp6 = sqlite3VdbeAddOp1(v, OP_Next, iIdxCur+j); VdbeCoverage(v); |
| 106740 | 106752 | sqlite3VdbeGoto(v, uniqOk); |
| | @@ -112889,11 +112901,21 @@ |
| 112889 | 112901 | #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) |
| 112890 | 112902 | for(i=0; !p->pPrior && i<pTabList->nSrc; i++){ |
| 112891 | 112903 | struct SrcList_item *pItem = &pTabList->a[i]; |
| 112892 | 112904 | Select *pSub = pItem->pSelect; |
| 112893 | 112905 | int isAggSub; |
| 112906 | + Table *pTab = pItem->pTab; |
| 112894 | 112907 | if( pSub==0 ) continue; |
| 112908 | + |
| 112909 | + /* Catch mismatch in the declared columns of a view and the number of |
| 112910 | + ** columns in the SELECT on the RHS */ |
| 112911 | + if( pTab->nCol!=pSub->pEList->nExpr ){ |
| 112912 | + sqlite3ErrorMsg(pParse, "expected %d columns for '%s' but got %d", |
| 112913 | + pTab->nCol, pTab->zName, pSub->pEList->nExpr); |
| 112914 | + goto select_end; |
| 112915 | + } |
| 112916 | + |
| 112895 | 112917 | isAggSub = (pSub->selFlags & SF_Aggregate)!=0; |
| 112896 | 112918 | if( flattenSubquery(pParse, p, i, isAgg, isAggSub) ){ |
| 112897 | 112919 | /* This subquery can be absorbed into its parent. */ |
| 112898 | 112920 | if( isAggSub ){ |
| 112899 | 112921 | isAgg = 1; |
| | @@ -121896,10 +121918,11 @@ |
| 121896 | 121918 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 121897 | 121919 | /* |
| 121898 | 121920 | ** Return the affinity for a single column of an index. |
| 121899 | 121921 | */ |
| 121900 | 121922 | static char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){ |
| 121923 | + assert( iCol>=0 && iCol<pIdx->nColumn ); |
| 121901 | 121924 | if( !pIdx->zColAff ){ |
| 121902 | 121925 | if( sqlite3IndexAffinityStr(db, pIdx)==0 ) return SQLITE_AFF_BLOB; |
| 121903 | 121926 | } |
| 121904 | 121927 | return pIdx->zColAff[iCol]; |
| 121905 | 121928 | } |
| | @@ -121953,12 +121976,11 @@ |
| 121953 | 121976 | int nEq = pLoop->u.btree.nEq; |
| 121954 | 121977 | sqlite3 *db = pParse->db; |
| 121955 | 121978 | int nLower = -1; |
| 121956 | 121979 | int nUpper = p->nSample+1; |
| 121957 | 121980 | int rc = SQLITE_OK; |
| 121958 | | - int iCol = p->aiColumn[nEq]; |
| 121959 | | - u8 aff = sqlite3IndexColumnAffinity(db, p, iCol); |
| 121981 | + u8 aff = sqlite3IndexColumnAffinity(db, p, nEq); |
| 121960 | 121982 | CollSeq *pColl; |
| 121961 | 121983 | |
| 121962 | 121984 | sqlite3_value *p1 = 0; /* Value extracted from pLower */ |
| 121963 | 121985 | sqlite3_value *p2 = 0; /* Value extracted from pUpper */ |
| 121964 | 121986 | sqlite3_value *pVal = 0; /* Value extracted from record */ |
| | @@ -125266,11 +125288,14 @@ |
| 125266 | 125288 | if( pLoop->wsFlags & (WHERE_INDEXED|WHERE_IDX_ONLY) ){ |
| 125267 | 125289 | pIdx = pLoop->u.btree.pIndex; |
| 125268 | 125290 | }else if( pLoop->wsFlags & WHERE_MULTI_OR ){ |
| 125269 | 125291 | pIdx = pLevel->u.pCovidx; |
| 125270 | 125292 | } |
| 125271 | | - if( pIdx && !db->mallocFailed ){ |
| 125293 | + if( pIdx |
| 125294 | + && (pWInfo->eOnePass==ONEPASS_OFF || !HasRowid(pIdx->pTable)) |
| 125295 | + && !db->mallocFailed |
| 125296 | + ){ |
| 125272 | 125297 | last = sqlite3VdbeCurrentAddr(v); |
| 125273 | 125298 | k = pLevel->addrBody; |
| 125274 | 125299 | pOp = sqlite3VdbeGetOp(v, k); |
| 125275 | 125300 | for(; k<last; k++, pOp++){ |
| 125276 | 125301 | if( pOp->p1!=pLevel->iTabCur ) continue; |
| | @@ -133020,10 +133045,17 @@ |
| 133020 | 133045 | #ifdef SQLITE_ENABLE_DBSTAT_VTAB |
| 133021 | 133046 | if( !db->mallocFailed && rc==SQLITE_OK){ |
| 133022 | 133047 | rc = sqlite3DbstatRegister(db); |
| 133023 | 133048 | } |
| 133024 | 133049 | #endif |
| 133050 | + |
| 133051 | +#ifdef SQLITE_ENABLE_JSON1 |
| 133052 | + if( !db->mallocFailed && rc==SQLITE_OK){ |
| 133053 | + extern int sqlite3Json1Init(sqlite3*); |
| 133054 | + rc = sqlite3Json1Init(db); |
| 133055 | + } |
| 133056 | +#endif |
| 133025 | 133057 | |
| 133026 | 133058 | /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking |
| 133027 | 133059 | ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking |
| 133028 | 133060 | ** mode. Doing nothing at all also makes NORMAL the default. |
| 133029 | 133061 | */ |
| 133030 | 133062 | |