Fossil SCM
Update the built-in SQLite 3.15.0 beta.
Commit
3d8a41f12c8cc8ac562e072d07fdd0ca54772ebe
Parent
912a0d500884dff…
2 files changed
+109
-128
+1
-1
+109
-128
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -381,11 +381,11 @@ | ||
| 381 | 381 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 382 | 382 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 383 | 383 | */ |
| 384 | 384 | #define SQLITE_VERSION "3.15.0" |
| 385 | 385 | #define SQLITE_VERSION_NUMBER 3015000 |
| 386 | -#define SQLITE_SOURCE_ID "2016-10-01 23:55:23 fe07609efc31c4639c40fbda501c55f443756ad2" | |
| 386 | +#define SQLITE_SOURCE_ID "2016-10-04 12:20:12 3a9d802fda10585654332b314d317250dc5d894e" | |
| 387 | 387 | |
| 388 | 388 | /* |
| 389 | 389 | ** CAPI3REF: Run-Time Library Version Numbers |
| 390 | 390 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 391 | 391 | ** |
| @@ -16180,11 +16180,11 @@ | ||
| 16180 | 16180 | SQLITE_PRIVATE void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*); |
| 16181 | 16181 | SQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token*); |
| 16182 | 16182 | SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*); |
| 16183 | 16183 | SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*); |
| 16184 | 16184 | SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*); |
| 16185 | -SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*); | |
| 16185 | +SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); | |
| 16186 | 16186 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); |
| 16187 | 16187 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); |
| 16188 | 16188 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*); |
| 16189 | 16189 | SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int); |
| 16190 | 16190 | SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int); |
| @@ -58987,11 +58987,11 @@ | ||
| 58987 | 58987 | int bias, /* Bias search to the high end */ |
| 58988 | 58988 | int *pRes /* Write search results here */ |
| 58989 | 58989 | ){ |
| 58990 | 58990 | int rc; /* Status code */ |
| 58991 | 58991 | UnpackedRecord *pIdxKey; /* Unpacked index key */ |
| 58992 | - char aSpace[200]; /* Temp space for pIdxKey - to avoid a malloc */ | |
| 58992 | + char aSpace[384]; /* Temp space for pIdxKey - to avoid a malloc */ | |
| 58993 | 58993 | char *pFree = 0; |
| 58994 | 58994 | |
| 58995 | 58995 | if( pKey ){ |
| 58996 | 58996 | assert( nKey==(i64)(int)nKey ); |
| 58997 | 58997 | pIdxKey = sqlite3VdbeAllocUnpackedRecord( |
| @@ -64324,12 +64324,10 @@ | ||
| 64324 | 64324 | nSrc = pX->nData; |
| 64325 | 64325 | assert( pPage->intKeyLeaf ); /* fillInCell() only called for leaves */ |
| 64326 | 64326 | nHeader += putVarint32(&pCell[nHeader], nPayload); |
| 64327 | 64327 | nHeader += putVarint(&pCell[nHeader], *(u64*)&pX->nKey); |
| 64328 | 64328 | }else{ |
| 64329 | - assert( pX->nData==0 ); | |
| 64330 | - assert( pX->nZero==0 ); | |
| 64331 | 64329 | assert( pX->nKey<=0x7fffffff && pX->pKey!=0 ); |
| 64332 | 64330 | nSrc = nPayload = (int)pX->nKey; |
| 64333 | 64331 | pSrc = pX->pKey; |
| 64334 | 64332 | nHeader += putVarint32(&pCell[nHeader], nPayload); |
| 64335 | 64333 | } |
| @@ -68025,26 +68023,20 @@ | ||
| 68025 | 68023 | */ |
| 68026 | 68024 | static Btree *findBtree(sqlite3 *pErrorDb, sqlite3 *pDb, const char *zDb){ |
| 68027 | 68025 | int i = sqlite3FindDbName(pDb, zDb); |
| 68028 | 68026 | |
| 68029 | 68027 | if( i==1 ){ |
| 68030 | - Parse *pParse; | |
| 68028 | + Parse sParse; | |
| 68031 | 68029 | int rc = 0; |
| 68032 | - pParse = sqlite3StackAllocZero(pErrorDb, sizeof(*pParse)); | |
| 68033 | - if( pParse==0 ){ | |
| 68034 | - sqlite3ErrorWithMsg(pErrorDb, SQLITE_NOMEM, "out of memory"); | |
| 68035 | - rc = SQLITE_NOMEM_BKPT; | |
| 68036 | - }else{ | |
| 68037 | - pParse->db = pDb; | |
| 68038 | - if( sqlite3OpenTempDatabase(pParse) ){ | |
| 68039 | - sqlite3ErrorWithMsg(pErrorDb, pParse->rc, "%s", pParse->zErrMsg); | |
| 68040 | - rc = SQLITE_ERROR; | |
| 68041 | - } | |
| 68042 | - sqlite3DbFree(pErrorDb, pParse->zErrMsg); | |
| 68043 | - sqlite3ParserReset(pParse); | |
| 68044 | - sqlite3StackFree(pErrorDb, pParse); | |
| 68045 | - } | |
| 68030 | + memset(&sParse, 0, sizeof(sParse)); | |
| 68031 | + sParse.db = pDb; | |
| 68032 | + if( sqlite3OpenTempDatabase(&sParse) ){ | |
| 68033 | + sqlite3ErrorWithMsg(pErrorDb, sParse.rc, "%s", sParse.zErrMsg); | |
| 68034 | + rc = SQLITE_ERROR; | |
| 68035 | + } | |
| 68036 | + sqlite3DbFree(pErrorDb, sParse.zErrMsg); | |
| 68037 | + sqlite3ParserReset(&sParse); | |
| 68046 | 68038 | if( rc ){ |
| 68047 | 68039 | return 0; |
| 68048 | 68040 | } |
| 68049 | 68041 | } |
| 68050 | 68042 | |
| @@ -82350,13 +82342,10 @@ | ||
| 82350 | 82342 | if( pOp->opcode==OP_SorterInsert ){ |
| 82351 | 82343 | rc = sqlite3VdbeSorterWrite(pC, pIn2); |
| 82352 | 82344 | }else{ |
| 82353 | 82345 | x.nKey = pIn2->n; |
| 82354 | 82346 | x.pKey = pIn2->z; |
| 82355 | - x.nData = 0; | |
| 82356 | - x.nZero = 0; | |
| 82357 | - x.pData = 0; | |
| 82358 | 82347 | rc = sqlite3BtreeInsert(pC->uc.pCursor, &x, pOp->p3, |
| 82359 | 82348 | ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0) |
| 82360 | 82349 | ); |
| 82361 | 82350 | assert( pC->deferredMoveto==0 ); |
| 82362 | 82351 | pC->cacheStatus = CACHE_STALE; |
| @@ -88795,11 +88784,10 @@ | ||
| 88795 | 88784 | const char *zDb; |
| 88796 | 88785 | Expr *pRight; |
| 88797 | 88786 | |
| 88798 | 88787 | /* if( pSrcList==0 ) break; */ |
| 88799 | 88788 | notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr); |
| 88800 | - /*notValid(pParse, pNC, "the \".\" operator", NC_PartIdx|NC_IsCheck, 1);*/ | |
| 88801 | 88789 | pRight = pExpr->pRight; |
| 88802 | 88790 | if( pRight->op==TK_ID ){ |
| 88803 | 88791 | zDb = 0; |
| 88804 | 88792 | zTable = pExpr->pLeft->u.zToken; |
| 88805 | 88793 | zColumn = pRight->u.zToken; |
| @@ -88824,11 +88812,11 @@ | ||
| 88824 | 88812 | const char *zId; /* The function name. */ |
| 88825 | 88813 | FuncDef *pDef; /* Information about the function */ |
| 88826 | 88814 | u8 enc = ENC(pParse->db); /* The database encoding */ |
| 88827 | 88815 | |
| 88828 | 88816 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 88829 | - notValid(pParse, pNC, "functions", NC_PartIdx); | |
| 88817 | +// notValid(pParse, pNC, "functions", NC_PartIdx); | |
| 88830 | 88818 | zId = pExpr->u.zToken; |
| 88831 | 88819 | nId = sqlite3Strlen30(zId); |
| 88832 | 88820 | pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0); |
| 88833 | 88821 | if( pDef==0 ){ |
| 88834 | 88822 | pDef = sqlite3FindFunction(pParse->db, zId, -2, enc, 0); |
| @@ -88884,11 +88872,12 @@ | ||
| 88884 | 88872 | } |
| 88885 | 88873 | if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){ |
| 88886 | 88874 | /* Date/time functions that use 'now', and other functions like |
| 88887 | 88875 | ** sqlite_version() that might change over time cannot be used |
| 88888 | 88876 | ** in an index. */ |
| 88889 | - notValid(pParse, pNC, "non-deterministic functions", NC_IdxExpr); | |
| 88877 | + notValid(pParse, pNC, "non-deterministic functions", | |
| 88878 | + NC_IdxExpr|NC_PartIdx); | |
| 88890 | 88879 | } |
| 88891 | 88880 | } |
| 88892 | 88881 | if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){ |
| 88893 | 88882 | sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId); |
| 88894 | 88883 | pNC->nErr++; |
| @@ -90424,11 +90413,11 @@ | ||
| 90424 | 90413 | ** stored in u.zToken. Instead, the integer values is written |
| 90425 | 90414 | ** into u.iValue and the EP_IntValue flag is set. No extra storage |
| 90426 | 90415 | ** is allocated to hold the integer text and the dequote flag is ignored. |
| 90427 | 90416 | */ |
| 90428 | 90417 | SQLITE_PRIVATE Expr *sqlite3ExprAlloc( |
| 90429 | - sqlite3 *db, /* Handle for sqlite3DbMallocZero() (may be null) */ | |
| 90418 | + sqlite3 *db, /* Handle for sqlite3DbMallocRawNN() */ | |
| 90430 | 90419 | int op, /* Expression opcode */ |
| 90431 | 90420 | const Token *pToken, /* Token argument. Might be NULL */ |
| 90432 | 90421 | int dequote /* True to dequote */ |
| 90433 | 90422 | ){ |
| 90434 | 90423 | Expr *pNew; |
| @@ -90642,40 +90631,40 @@ | ||
| 90642 | 90631 | ** Wildcards of the form ":aaa", "@aaa", or "$aaa" are assigned the same number |
| 90643 | 90632 | ** as the previous instance of the same wildcard. Or if this is the first |
| 90644 | 90633 | ** instance of the wildcard, the next sequential variable number is |
| 90645 | 90634 | ** assigned. |
| 90646 | 90635 | */ |
| 90647 | -SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){ | |
| 90636 | +SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n){ | |
| 90648 | 90637 | sqlite3 *db = pParse->db; |
| 90649 | 90638 | const char *z; |
| 90650 | 90639 | |
| 90651 | 90640 | if( pExpr==0 ) return; |
| 90652 | 90641 | assert( !ExprHasProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) ); |
| 90653 | 90642 | z = pExpr->u.zToken; |
| 90654 | 90643 | assert( z!=0 ); |
| 90655 | 90644 | assert( z[0]!=0 ); |
| 90645 | + assert( n==sqlite3Strlen30(z) ); | |
| 90656 | 90646 | if( z[1]==0 ){ |
| 90657 | 90647 | /* Wildcard of the form "?". Assign the next variable number */ |
| 90658 | 90648 | assert( z[0]=='?' ); |
| 90659 | 90649 | pExpr->iColumn = (ynVar)(++pParse->nVar); |
| 90660 | 90650 | }else{ |
| 90661 | - ynVar x = 0; | |
| 90662 | - u32 n = sqlite3Strlen30(z); | |
| 90651 | + ynVar x; | |
| 90663 | 90652 | if( z[0]=='?' ){ |
| 90664 | 90653 | /* Wildcard of the form "?nnn". Convert "nnn" to an integer and |
| 90665 | 90654 | ** use it as the variable number */ |
| 90666 | 90655 | i64 i; |
| 90667 | 90656 | int bOk = 0==sqlite3Atoi64(&z[1], &i, n-1, SQLITE_UTF8); |
| 90668 | - pExpr->iColumn = x = (ynVar)i; | |
| 90657 | + x = (ynVar)i; | |
| 90669 | 90658 | testcase( i==0 ); |
| 90670 | 90659 | testcase( i==1 ); |
| 90671 | 90660 | testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 ); |
| 90672 | 90661 | testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ); |
| 90673 | 90662 | if( bOk==0 || i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){ |
| 90674 | 90663 | sqlite3ErrorMsg(pParse, "variable number must be between ?1 and ?%d", |
| 90675 | 90664 | db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]); |
| 90676 | - x = 0; | |
| 90665 | + return; | |
| 90677 | 90666 | } |
| 90678 | 90667 | if( i>pParse->nVar ){ |
| 90679 | 90668 | pParse->nVar = (int)i; |
| 90680 | 90669 | } |
| 90681 | 90670 | }else{ |
| @@ -90682,37 +90671,35 @@ | ||
| 90682 | 90671 | /* Wildcards like ":aaa", "$aaa" or "@aaa". Reuse the same variable |
| 90683 | 90672 | ** number as the prior appearance of the same name, or if the name |
| 90684 | 90673 | ** has never appeared before, reuse the same variable number |
| 90685 | 90674 | */ |
| 90686 | 90675 | ynVar i; |
| 90687 | - for(i=0; i<pParse->nzVar; i++){ | |
| 90676 | + for(i=x=0; i<pParse->nzVar; i++){ | |
| 90688 | 90677 | if( pParse->azVar[i] && strcmp(pParse->azVar[i],z)==0 ){ |
| 90689 | - pExpr->iColumn = x = (ynVar)i+1; | |
| 90690 | - break; | |
| 90691 | - } | |
| 90692 | - } | |
| 90693 | - if( x==0 ) x = pExpr->iColumn = (ynVar)(++pParse->nVar); | |
| 90694 | - } | |
| 90695 | - if( x>0 ){ | |
| 90696 | - if( x>pParse->nzVar ){ | |
| 90697 | - char **a; | |
| 90698 | - a = sqlite3DbRealloc(db, pParse->azVar, x*sizeof(a[0])); | |
| 90699 | - if( a==0 ){ | |
| 90700 | - assert( db->mallocFailed ); /* Error reported through mallocFailed */ | |
| 90701 | - return; | |
| 90702 | - } | |
| 90703 | - pParse->azVar = a; | |
| 90704 | - memset(&a[pParse->nzVar], 0, (x-pParse->nzVar)*sizeof(a[0])); | |
| 90705 | - pParse->nzVar = x; | |
| 90706 | - } | |
| 90707 | - if( z[0]!='?' || pParse->azVar[x-1]==0 ){ | |
| 90708 | - sqlite3DbFree(db, pParse->azVar[x-1]); | |
| 90709 | - pParse->azVar[x-1] = sqlite3DbStrNDup(db, z, n); | |
| 90710 | - } | |
| 90711 | - } | |
| 90712 | - } | |
| 90713 | - if( !pParse->nErr && pParse->nVar>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){ | |
| 90678 | + x = (ynVar)i+1; | |
| 90679 | + break; | |
| 90680 | + } | |
| 90681 | + } | |
| 90682 | + if( x==0 ) x = (ynVar)(++pParse->nVar); | |
| 90683 | + } | |
| 90684 | + pExpr->iColumn = x; | |
| 90685 | + if( x>pParse->nzVar ){ | |
| 90686 | + char **a; | |
| 90687 | + a = sqlite3DbRealloc(db, pParse->azVar, x*sizeof(a[0])); | |
| 90688 | + if( a==0 ){ | |
| 90689 | + assert( db->mallocFailed ); /* Error reported through mallocFailed */ | |
| 90690 | + return; | |
| 90691 | + } | |
| 90692 | + pParse->azVar = a; | |
| 90693 | + memset(&a[pParse->nzVar], 0, (x-pParse->nzVar)*sizeof(a[0])); | |
| 90694 | + pParse->nzVar = x; | |
| 90695 | + } | |
| 90696 | + if( pParse->azVar[x-1]==0 ){ | |
| 90697 | + pParse->azVar[x-1] = sqlite3DbStrNDup(db, z, n); | |
| 90698 | + } | |
| 90699 | + } | |
| 90700 | + if( pParse->nVar>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){ | |
| 90714 | 90701 | sqlite3ErrorMsg(pParse, "too many SQL variables"); |
| 90715 | 90702 | } |
| 90716 | 90703 | } |
| 90717 | 90704 | |
| 90718 | 90705 | /* |
| @@ -109529,10 +109516,11 @@ | ||
| 109529 | 109516 | } |
| 109530 | 109517 | if( emptySrcTest ) sqlite3VdbeJumpHere(v, emptySrcTest); |
| 109531 | 109518 | sqlite3ReleaseTempReg(pParse, regRowid); |
| 109532 | 109519 | sqlite3ReleaseTempReg(pParse, regData); |
| 109533 | 109520 | if( emptyDestTest ){ |
| 109521 | + sqlite3AutoincrementEnd(pParse); | |
| 109534 | 109522 | sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_OK, 0); |
| 109535 | 109523 | sqlite3VdbeJumpHere(v, emptyDestTest); |
| 109536 | 109524 | sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); |
| 109537 | 109525 | return 0; |
| 109538 | 109526 | }else{ |
| @@ -114025,24 +114013,18 @@ | ||
| 114025 | 114013 | int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ |
| 114026 | 114014 | Vdbe *pReprepare, /* VM being reprepared */ |
| 114027 | 114015 | sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ |
| 114028 | 114016 | const char **pzTail /* OUT: End of parsed string */ |
| 114029 | 114017 | ){ |
| 114030 | - Parse *pParse; /* Parsing context */ | |
| 114031 | 114018 | char *zErrMsg = 0; /* Error message */ |
| 114032 | 114019 | int rc = SQLITE_OK; /* Result code */ |
| 114033 | 114020 | int i; /* Loop counter */ |
| 114034 | - | |
| 114035 | - /* Allocate the parsing context */ | |
| 114036 | - pParse = sqlite3StackAllocRaw(db, sizeof(*pParse)); | |
| 114037 | - if( pParse==0 ){ | |
| 114038 | - rc = SQLITE_NOMEM_BKPT; | |
| 114039 | - goto end_prepare; | |
| 114040 | - } | |
| 114041 | - memset(pParse, 0, PARSE_HDR_SZ); | |
| 114042 | - memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ); | |
| 114043 | - pParse->pReprepare = pReprepare; | |
| 114021 | + Parse sParse; /* Parsing context */ | |
| 114022 | + | |
| 114023 | + memset(&sParse, 0, PARSE_HDR_SZ); | |
| 114024 | + memset(PARSE_TAIL(&sParse), 0, PARSE_TAIL_SZ); | |
| 114025 | + sParse.pReprepare = pReprepare; | |
| 114044 | 114026 | assert( ppStmt && *ppStmt==0 ); |
| 114045 | 114027 | /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */ |
| 114046 | 114028 | assert( sqlite3_mutex_held(db->mutex) ); |
| 114047 | 114029 | |
| 114048 | 114030 | /* Check to verify that it is possible to get a read lock on all |
| @@ -114082,12 +114064,11 @@ | ||
| 114082 | 114064 | } |
| 114083 | 114065 | } |
| 114084 | 114066 | |
| 114085 | 114067 | sqlite3VtabUnlockList(db); |
| 114086 | 114068 | |
| 114087 | - pParse->db = db; | |
| 114088 | - pParse->nQueryLoop = 0; /* Logarithmic, so 0 really means 1 */ | |
| 114069 | + sParse.db = db; | |
| 114089 | 114070 | if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){ |
| 114090 | 114071 | char *zSqlCopy; |
| 114091 | 114072 | int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH]; |
| 114092 | 114073 | testcase( nBytes==mxLen ); |
| 114093 | 114074 | testcase( nBytes==mxLen+1 ); |
| @@ -114096,65 +114077,65 @@ | ||
| 114096 | 114077 | rc = sqlite3ApiExit(db, SQLITE_TOOBIG); |
| 114097 | 114078 | goto end_prepare; |
| 114098 | 114079 | } |
| 114099 | 114080 | zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes); |
| 114100 | 114081 | if( zSqlCopy ){ |
| 114101 | - sqlite3RunParser(pParse, zSqlCopy, &zErrMsg); | |
| 114102 | - pParse->zTail = &zSql[pParse->zTail-zSqlCopy]; | |
| 114082 | + sqlite3RunParser(&sParse, zSqlCopy, &zErrMsg); | |
| 114083 | + sParse.zTail = &zSql[sParse.zTail-zSqlCopy]; | |
| 114103 | 114084 | sqlite3DbFree(db, zSqlCopy); |
| 114104 | 114085 | }else{ |
| 114105 | - pParse->zTail = &zSql[nBytes]; | |
| 114086 | + sParse.zTail = &zSql[nBytes]; | |
| 114106 | 114087 | } |
| 114107 | 114088 | }else{ |
| 114108 | - sqlite3RunParser(pParse, zSql, &zErrMsg); | |
| 114089 | + sqlite3RunParser(&sParse, zSql, &zErrMsg); | |
| 114109 | 114090 | } |
| 114110 | - assert( 0==pParse->nQueryLoop ); | |
| 114091 | + assert( 0==sParse.nQueryLoop ); | |
| 114111 | 114092 | |
| 114112 | - if( pParse->rc==SQLITE_DONE ) pParse->rc = SQLITE_OK; | |
| 114113 | - if( pParse->checkSchema ){ | |
| 114114 | - schemaIsValid(pParse); | |
| 114093 | + if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK; | |
| 114094 | + if( sParse.checkSchema ){ | |
| 114095 | + schemaIsValid(&sParse); | |
| 114115 | 114096 | } |
| 114116 | 114097 | if( db->mallocFailed ){ |
| 114117 | - pParse->rc = SQLITE_NOMEM_BKPT; | |
| 114098 | + sParse.rc = SQLITE_NOMEM_BKPT; | |
| 114118 | 114099 | } |
| 114119 | 114100 | if( pzTail ){ |
| 114120 | - *pzTail = pParse->zTail; | |
| 114101 | + *pzTail = sParse.zTail; | |
| 114121 | 114102 | } |
| 114122 | - rc = pParse->rc; | |
| 114103 | + rc = sParse.rc; | |
| 114123 | 114104 | |
| 114124 | 114105 | #ifndef SQLITE_OMIT_EXPLAIN |
| 114125 | - if( rc==SQLITE_OK && pParse->pVdbe && pParse->explain ){ | |
| 114106 | + if( rc==SQLITE_OK && sParse.pVdbe && sParse.explain ){ | |
| 114126 | 114107 | static const char * const azColName[] = { |
| 114127 | 114108 | "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment", |
| 114128 | 114109 | "selectid", "order", "from", "detail" |
| 114129 | 114110 | }; |
| 114130 | 114111 | int iFirst, mx; |
| 114131 | - if( pParse->explain==2 ){ | |
| 114132 | - sqlite3VdbeSetNumCols(pParse->pVdbe, 4); | |
| 114112 | + if( sParse.explain==2 ){ | |
| 114113 | + sqlite3VdbeSetNumCols(sParse.pVdbe, 4); | |
| 114133 | 114114 | iFirst = 8; |
| 114134 | 114115 | mx = 12; |
| 114135 | 114116 | }else{ |
| 114136 | - sqlite3VdbeSetNumCols(pParse->pVdbe, 8); | |
| 114117 | + sqlite3VdbeSetNumCols(sParse.pVdbe, 8); | |
| 114137 | 114118 | iFirst = 0; |
| 114138 | 114119 | mx = 8; |
| 114139 | 114120 | } |
| 114140 | 114121 | for(i=iFirst; i<mx; i++){ |
| 114141 | - sqlite3VdbeSetColName(pParse->pVdbe, i-iFirst, COLNAME_NAME, | |
| 114122 | + sqlite3VdbeSetColName(sParse.pVdbe, i-iFirst, COLNAME_NAME, | |
| 114142 | 114123 | azColName[i], SQLITE_STATIC); |
| 114143 | 114124 | } |
| 114144 | 114125 | } |
| 114145 | 114126 | #endif |
| 114146 | 114127 | |
| 114147 | 114128 | if( db->init.busy==0 ){ |
| 114148 | - Vdbe *pVdbe = pParse->pVdbe; | |
| 114149 | - sqlite3VdbeSetSql(pVdbe, zSql, (int)(pParse->zTail-zSql), saveSqlFlag); | |
| 114129 | + Vdbe *pVdbe = sParse.pVdbe; | |
| 114130 | + sqlite3VdbeSetSql(pVdbe, zSql, (int)(sParse.zTail-zSql), saveSqlFlag); | |
| 114150 | 114131 | } |
| 114151 | - if( pParse->pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){ | |
| 114152 | - sqlite3VdbeFinalize(pParse->pVdbe); | |
| 114132 | + if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){ | |
| 114133 | + sqlite3VdbeFinalize(sParse.pVdbe); | |
| 114153 | 114134 | assert(!(*ppStmt)); |
| 114154 | 114135 | }else{ |
| 114155 | - *ppStmt = (sqlite3_stmt*)pParse->pVdbe; | |
| 114136 | + *ppStmt = (sqlite3_stmt*)sParse.pVdbe; | |
| 114156 | 114137 | } |
| 114157 | 114138 | |
| 114158 | 114139 | if( zErrMsg ){ |
| 114159 | 114140 | sqlite3ErrorWithMsg(db, rc, "%s", zErrMsg); |
| 114160 | 114141 | sqlite3DbFree(db, zErrMsg); |
| @@ -114161,20 +114142,19 @@ | ||
| 114161 | 114142 | }else{ |
| 114162 | 114143 | sqlite3Error(db, rc); |
| 114163 | 114144 | } |
| 114164 | 114145 | |
| 114165 | 114146 | /* Delete any TriggerPrg structures allocated while parsing this statement. */ |
| 114166 | - while( pParse->pTriggerPrg ){ | |
| 114167 | - TriggerPrg *pT = pParse->pTriggerPrg; | |
| 114168 | - pParse->pTriggerPrg = pT->pNext; | |
| 114147 | + while( sParse.pTriggerPrg ){ | |
| 114148 | + TriggerPrg *pT = sParse.pTriggerPrg; | |
| 114149 | + sParse.pTriggerPrg = pT->pNext; | |
| 114169 | 114150 | sqlite3DbFree(db, pT); |
| 114170 | 114151 | } |
| 114171 | 114152 | |
| 114172 | 114153 | end_prepare: |
| 114173 | 114154 | |
| 114174 | - sqlite3ParserReset(pParse); | |
| 114175 | - sqlite3StackFree(db, pParse); | |
| 114155 | + sqlite3ParserReset(&sParse); | |
| 114176 | 114156 | rc = sqlite3ApiExit(db, rc); |
| 114177 | 114157 | assert( (rc&db->errMask)==rc ); |
| 114178 | 114158 | return rc; |
| 114179 | 114159 | } |
| 114180 | 114160 | static int sqlite3LockAndPrepare( |
| @@ -124035,24 +124015,24 @@ | ||
| 124035 | 124015 | ** in prereqRight and prereqAll. The default is 64 bits, hence SQLite |
| 124036 | 124016 | ** is only able to process joins with 64 or fewer tables. |
| 124037 | 124017 | */ |
| 124038 | 124018 | struct WhereTerm { |
| 124039 | 124019 | Expr *pExpr; /* Pointer to the subexpression that is this term */ |
| 124020 | + WhereClause *pWC; /* The clause this term is part of */ | |
| 124021 | + LogEst truthProb; /* Probability of truth for this expression */ | |
| 124022 | + u16 wtFlags; /* TERM_xxx bit flags. See below */ | |
| 124023 | + u16 eOperator; /* A WO_xx value describing <op> */ | |
| 124024 | + u8 nChild; /* Number of children that must disable us */ | |
| 124025 | + u8 eMatchOp; /* Op for vtab MATCH/LIKE/GLOB/REGEXP terms */ | |
| 124040 | 124026 | int iParent; /* Disable pWC->a[iParent] when this term disabled */ |
| 124041 | 124027 | int leftCursor; /* Cursor number of X in "X <op> <expr>" */ |
| 124042 | 124028 | int iField; /* Field in (?,?,?) IN (SELECT...) vector */ |
| 124043 | 124029 | union { |
| 124044 | 124030 | int leftColumn; /* Column number of X in "X <op> <expr>" */ |
| 124045 | 124031 | WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */ |
| 124046 | 124032 | WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */ |
| 124047 | 124033 | } u; |
| 124048 | - LogEst truthProb; /* Probability of truth for this expression */ | |
| 124049 | - u16 eOperator; /* A WO_xx value describing <op> */ | |
| 124050 | - u16 wtFlags; /* TERM_xxx bit flags. See below */ | |
| 124051 | - u8 nChild; /* Number of children that must disable us */ | |
| 124052 | - u8 eMatchOp; /* Op for vtab MATCH/LIKE/GLOB/REGEXP terms */ | |
| 124053 | - WhereClause *pWC; /* The clause this term is part of */ | |
| 124054 | 124034 | Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */ |
| 124055 | 124035 | Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */ |
| 124056 | 124036 | }; |
| 124057 | 124037 | |
| 124058 | 124038 | /* |
| @@ -124201,29 +124181,29 @@ | ||
| 124201 | 124181 | struct WhereInfo { |
| 124202 | 124182 | Parse *pParse; /* Parsing and code generating context */ |
| 124203 | 124183 | SrcList *pTabList; /* List of tables in the join */ |
| 124204 | 124184 | ExprList *pOrderBy; /* The ORDER BY clause or NULL */ |
| 124205 | 124185 | ExprList *pDistinctSet; /* DISTINCT over all these values */ |
| 124206 | - WhereLoop *pLoops; /* List of all WhereLoop objects */ | |
| 124207 | - Bitmask revMask; /* Mask of ORDER BY terms that need reversing */ | |
| 124208 | - LogEst nRowOut; /* Estimated number of output rows */ | |
| 124209 | 124186 | LogEst iLimit; /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */ |
| 124187 | + int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */ | |
| 124188 | + int iContinue; /* Jump here to continue with next record */ | |
| 124189 | + int iBreak; /* Jump here to break out of the loop */ | |
| 124190 | + int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ | |
| 124210 | 124191 | u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */ |
| 124192 | + u8 nLevel; /* Number of nested loop */ | |
| 124211 | 124193 | i8 nOBSat; /* Number of ORDER BY terms satisfied by indices */ |
| 124212 | 124194 | u8 sorted; /* True if really sorted (not just grouped) */ |
| 124213 | 124195 | u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */ |
| 124214 | 124196 | u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */ |
| 124215 | 124197 | u8 eDistinct; /* One of the WHERE_DISTINCT_* values */ |
| 124216 | - u8 nLevel; /* Number of nested loop */ | |
| 124217 | 124198 | u8 bOrderedInnerLoop; /* True if only the inner-most loop is ordered */ |
| 124218 | 124199 | int iTop; /* The very beginning of the WHERE loop */ |
| 124219 | - int iContinue; /* Jump here to continue with next record */ | |
| 124220 | - int iBreak; /* Jump here to break out of the loop */ | |
| 124221 | - int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ | |
| 124222 | - int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */ | |
| 124223 | - WhereMaskSet sMaskSet; /* Map cursor numbers to bitmasks */ | |
| 124200 | + WhereLoop *pLoops; /* List of all WhereLoop objects */ | |
| 124201 | + Bitmask revMask; /* Mask of ORDER BY terms that need reversing */ | |
| 124202 | + LogEst nRowOut; /* Estimated number of output rows */ | |
| 124224 | 124203 | WhereClause sWC; /* Decomposition of the WHERE clause */ |
| 124204 | + WhereMaskSet sMaskSet; /* Map cursor numbers to bitmasks */ | |
| 124225 | 124205 | WhereLevel a[1]; /* Information about each nest loop in WHERE */ |
| 124226 | 124206 | }; |
| 124227 | 124207 | |
| 124228 | 124208 | /* |
| 124229 | 124209 | ** Private interfaces - callable only by other where.c routines. |
| @@ -126309,11 +126289,11 @@ | ||
| 126309 | 126289 | ** and we are coding the t1 loop and the t2 loop has not yet coded, |
| 126310 | 126290 | ** then we cannot use the "t1.a=t2.b" constraint, but we can code |
| 126311 | 126291 | ** the implied "t1.a=123" constraint. |
| 126312 | 126292 | */ |
| 126313 | 126293 | for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){ |
| 126314 | - Expr *pE, *pEAlt; | |
| 126294 | + Expr *pE, sEAlt; | |
| 126315 | 126295 | WhereTerm *pAlt; |
| 126316 | 126296 | if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 126317 | 126297 | if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) continue; |
| 126318 | 126298 | if( (pTerm->eOperator & WO_EQUIV)==0 ) continue; |
| 126319 | 126299 | if( pTerm->leftCursor!=iCur ) continue; |
| @@ -126327,17 +126307,13 @@ | ||
| 126327 | 126307 | if( pAlt->wtFlags & (TERM_CODED) ) continue; |
| 126328 | 126308 | testcase( pAlt->eOperator & WO_EQ ); |
| 126329 | 126309 | testcase( pAlt->eOperator & WO_IS ); |
| 126330 | 126310 | testcase( pAlt->eOperator & WO_IN ); |
| 126331 | 126311 | VdbeModuleComment((v, "begin transitive constraint")); |
| 126332 | - pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt)); | |
| 126333 | - if( pEAlt ){ | |
| 126334 | - *pEAlt = *pAlt->pExpr; | |
| 126335 | - pEAlt->pLeft = pE->pLeft; | |
| 126336 | - sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL); | |
| 126337 | - sqlite3StackFree(db, pEAlt); | |
| 126338 | - } | |
| 126312 | + sEAlt = *pAlt->pExpr; | |
| 126313 | + sEAlt.pLeft = pE->pLeft; | |
| 126314 | + sqlite3ExprIfFalse(pParse, &sEAlt, addrCont, SQLITE_JUMPIFNULL); | |
| 126339 | 126315 | } |
| 126340 | 126316 | |
| 126341 | 126317 | /* For a LEFT OUTER JOIN, generate code that will record the fact that |
| 126342 | 126318 | ** at least one row of the right table has matched the left table. |
| 126343 | 126319 | */ |
| @@ -126442,11 +126418,10 @@ | ||
| 126442 | 126418 | memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm); |
| 126443 | 126419 | if( pOld!=pWC->aStatic ){ |
| 126444 | 126420 | sqlite3DbFree(db, pOld); |
| 126445 | 126421 | } |
| 126446 | 126422 | pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]); |
| 126447 | - memset(&pWC->a[pWC->nTerm], 0, sizeof(pWC->a[0])*(pWC->nSlot-pWC->nTerm)); | |
| 126448 | 126423 | } |
| 126449 | 126424 | pTerm = &pWC->a[idx = pWC->nTerm++]; |
| 126450 | 126425 | if( p && ExprHasProperty(p, EP_Unlikely) ){ |
| 126451 | 126426 | pTerm->truthProb = sqlite3LogEst(p->iTable) - 270; |
| 126452 | 126427 | }else{ |
| @@ -126454,10 +126429,12 @@ | ||
| 126454 | 126429 | } |
| 126455 | 126430 | pTerm->pExpr = sqlite3ExprSkipCollate(p); |
| 126456 | 126431 | pTerm->wtFlags = wtFlags; |
| 126457 | 126432 | pTerm->pWC = pWC; |
| 126458 | 126433 | pTerm->iParent = -1; |
| 126434 | + memset(&pTerm->eOperator, 0, | |
| 126435 | + sizeof(WhereTerm) - offsetof(WhereTerm,eOperator)); | |
| 126459 | 126436 | return idx; |
| 126460 | 126437 | } |
| 126461 | 126438 | |
| 126462 | 126439 | /* |
| 126463 | 126440 | ** Return TRUE if the given operator is one of the operators that is |
| @@ -132212,26 +132189,29 @@ | ||
| 132212 | 132189 | ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte |
| 132213 | 132190 | ** field (type Bitmask) it must be aligned on an 8-byte boundary on |
| 132214 | 132191 | ** some architectures. Hence the ROUND8() below. |
| 132215 | 132192 | */ |
| 132216 | 132193 | nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel)); |
| 132217 | - pWInfo = sqlite3DbMallocZero(db, nByteWInfo + sizeof(WhereLoop)); | |
| 132194 | + pWInfo = sqlite3DbMallocRawNN(db, nByteWInfo + sizeof(WhereLoop)); | |
| 132218 | 132195 | if( db->mallocFailed ){ |
| 132219 | 132196 | sqlite3DbFree(db, pWInfo); |
| 132220 | 132197 | pWInfo = 0; |
| 132221 | 132198 | goto whereBeginError; |
| 132222 | 132199 | } |
| 132223 | - pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1; | |
| 132224 | - pWInfo->nLevel = nTabList; | |
| 132225 | 132200 | pWInfo->pParse = pParse; |
| 132226 | 132201 | pWInfo->pTabList = pTabList; |
| 132227 | 132202 | pWInfo->pOrderBy = pOrderBy; |
| 132228 | 132203 | pWInfo->pDistinctSet = pDistinctSet; |
| 132204 | + pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1; | |
| 132205 | + pWInfo->nLevel = nTabList; | |
| 132229 | 132206 | pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v); |
| 132230 | 132207 | pWInfo->wctrlFlags = wctrlFlags; |
| 132231 | 132208 | pWInfo->iLimit = iAuxArg; |
| 132232 | 132209 | pWInfo->savedNQueryLoop = pParse->nQueryLoop; |
| 132210 | + memset(&pWInfo->nOBSat, 0, | |
| 132211 | + offsetof(WhereInfo,sWC) - offsetof(WhereInfo,nOBSat)); | |
| 132212 | + memset(&pWInfo->a[0], 0, sizeof(WhereLoop)+nTabList*sizeof(WhereLevel)); | |
| 132233 | 132213 | assert( pWInfo->eOnePass==ONEPASS_OFF ); /* ONEPASS defaults to OFF */ |
| 132234 | 132214 | pMaskSet = &pWInfo->sMaskSet; |
| 132235 | 132215 | sWLB.pWInfo = pWInfo; |
| 132236 | 132216 | sWLB.pWC = &pWInfo->sWC; |
| 132237 | 132217 | sWLB.pNew = (WhereLoop*)(((char*)pWInfo)+nByteWInfo); |
| @@ -135684,12 +135664,13 @@ | ||
| 135684 | 135664 | yymsp[0].minor.yy190 = yylhsminor.yy190; |
| 135685 | 135665 | break; |
| 135686 | 135666 | case 159: /* expr ::= VARIABLE */ |
| 135687 | 135667 | { |
| 135688 | 135668 | if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){ |
| 135669 | + u32 n = yymsp[0].minor.yy0.n; | |
| 135689 | 135670 | spanExpr(&yymsp[0].minor.yy190, pParse, TK_VARIABLE, yymsp[0].minor.yy0); |
| 135690 | - sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr); | |
| 135671 | + sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr, n); | |
| 135691 | 135672 | }else{ |
| 135692 | 135673 | /* When doing a nested parse, one can include terms in an expression |
| 135693 | 135674 | ** that look like this: #1 #2 ... These terms refer to registers |
| 135694 | 135675 | ** in the virtual machine. #N is the N-th register. */ |
| 135695 | 135676 | Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/ |
| @@ -136458,11 +136439,11 @@ | ||
| 136458 | 136439 | } |
| 136459 | 136440 | #endif |
| 136460 | 136441 | yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); |
| 136461 | 136442 | yymajor = YYNOCODE; |
| 136462 | 136443 | }else{ |
| 136463 | - while( yypParser->yytos >= &yypParser->yystack | |
| 136444 | + while( yypParser->yytos >= yypParser->yystack | |
| 136464 | 136445 | && yymx != YYERRORSYMBOL |
| 136465 | 136446 | && (yyact = yy_find_reduce_action( |
| 136466 | 136447 | yypParser->yytos->stateno, |
| 136467 | 136448 | YYERRORSYMBOL)) >= YY_MIN_REDUCE |
| 136468 | 136449 | ){ |
| @@ -181149,11 +181130,11 @@ | ||
| 181149 | 181130 | } |
| 181150 | 181131 | #endif |
| 181151 | 181132 | fts5yy_destructor(fts5yypParser, (fts5YYCODETYPE)fts5yymajor, &fts5yyminorunion); |
| 181152 | 181133 | fts5yymajor = fts5YYNOCODE; |
| 181153 | 181134 | }else{ |
| 181154 | - while( fts5yypParser->fts5yytos >= &fts5yypParser->fts5yystack | |
| 181135 | + while( fts5yypParser->fts5yytos >= fts5yypParser->fts5yystack | |
| 181155 | 181136 | && fts5yymx != fts5YYERRORSYMBOL |
| 181156 | 181137 | && (fts5yyact = fts5yy_find_reduce_action( |
| 181157 | 181138 | fts5yypParser->fts5yytos->stateno, |
| 181158 | 181139 | fts5YYERRORSYMBOL)) >= fts5YY_MIN_REDUCE |
| 181159 | 181140 | ){ |
| @@ -195606,11 +195587,11 @@ | ||
| 195606 | 195587 | int nArg, /* Number of args */ |
| 195607 | 195588 | sqlite3_value **apUnused /* Function arguments */ |
| 195608 | 195589 | ){ |
| 195609 | 195590 | assert( nArg==0 ); |
| 195610 | 195591 | UNUSED_PARAM2(nArg, apUnused); |
| 195611 | - sqlite3_result_text(pCtx, "fts5: 2016-09-16 17:50:57 e3d9efa2770cd789ece3f4db4941b901c8b805ad", -1, SQLITE_TRANSIENT); | |
| 195592 | + sqlite3_result_text(pCtx, "fts5: 2016-10-04 00:47:26 b10d0f939c82c4de3faa90b86de9ec4a89992856", -1, SQLITE_TRANSIENT); | |
| 195612 | 195593 | } |
| 195613 | 195594 | |
| 195614 | 195595 | static int fts5Init(sqlite3 *db){ |
| 195615 | 195596 | static const sqlite3_module fts5Mod = { |
| 195616 | 195597 | /* iVersion */ 2, |
| 195617 | 195598 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -381,11 +381,11 @@ | |
| 381 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 382 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 383 | */ |
| 384 | #define SQLITE_VERSION "3.15.0" |
| 385 | #define SQLITE_VERSION_NUMBER 3015000 |
| 386 | #define SQLITE_SOURCE_ID "2016-10-01 23:55:23 fe07609efc31c4639c40fbda501c55f443756ad2" |
| 387 | |
| 388 | /* |
| 389 | ** CAPI3REF: Run-Time Library Version Numbers |
| 390 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 391 | ** |
| @@ -16180,11 +16180,11 @@ | |
| 16180 | SQLITE_PRIVATE void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*); |
| 16181 | SQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token*); |
| 16182 | SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*); |
| 16183 | SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*); |
| 16184 | SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*); |
| 16185 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*); |
| 16186 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); |
| 16187 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); |
| 16188 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*); |
| 16189 | SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int); |
| 16190 | SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int); |
| @@ -58987,11 +58987,11 @@ | |
| 58987 | int bias, /* Bias search to the high end */ |
| 58988 | int *pRes /* Write search results here */ |
| 58989 | ){ |
| 58990 | int rc; /* Status code */ |
| 58991 | UnpackedRecord *pIdxKey; /* Unpacked index key */ |
| 58992 | char aSpace[200]; /* Temp space for pIdxKey - to avoid a malloc */ |
| 58993 | char *pFree = 0; |
| 58994 | |
| 58995 | if( pKey ){ |
| 58996 | assert( nKey==(i64)(int)nKey ); |
| 58997 | pIdxKey = sqlite3VdbeAllocUnpackedRecord( |
| @@ -64324,12 +64324,10 @@ | |
| 64324 | nSrc = pX->nData; |
| 64325 | assert( pPage->intKeyLeaf ); /* fillInCell() only called for leaves */ |
| 64326 | nHeader += putVarint32(&pCell[nHeader], nPayload); |
| 64327 | nHeader += putVarint(&pCell[nHeader], *(u64*)&pX->nKey); |
| 64328 | }else{ |
| 64329 | assert( pX->nData==0 ); |
| 64330 | assert( pX->nZero==0 ); |
| 64331 | assert( pX->nKey<=0x7fffffff && pX->pKey!=0 ); |
| 64332 | nSrc = nPayload = (int)pX->nKey; |
| 64333 | pSrc = pX->pKey; |
| 64334 | nHeader += putVarint32(&pCell[nHeader], nPayload); |
| 64335 | } |
| @@ -68025,26 +68023,20 @@ | |
| 68025 | */ |
| 68026 | static Btree *findBtree(sqlite3 *pErrorDb, sqlite3 *pDb, const char *zDb){ |
| 68027 | int i = sqlite3FindDbName(pDb, zDb); |
| 68028 | |
| 68029 | if( i==1 ){ |
| 68030 | Parse *pParse; |
| 68031 | int rc = 0; |
| 68032 | pParse = sqlite3StackAllocZero(pErrorDb, sizeof(*pParse)); |
| 68033 | if( pParse==0 ){ |
| 68034 | sqlite3ErrorWithMsg(pErrorDb, SQLITE_NOMEM, "out of memory"); |
| 68035 | rc = SQLITE_NOMEM_BKPT; |
| 68036 | }else{ |
| 68037 | pParse->db = pDb; |
| 68038 | if( sqlite3OpenTempDatabase(pParse) ){ |
| 68039 | sqlite3ErrorWithMsg(pErrorDb, pParse->rc, "%s", pParse->zErrMsg); |
| 68040 | rc = SQLITE_ERROR; |
| 68041 | } |
| 68042 | sqlite3DbFree(pErrorDb, pParse->zErrMsg); |
| 68043 | sqlite3ParserReset(pParse); |
| 68044 | sqlite3StackFree(pErrorDb, pParse); |
| 68045 | } |
| 68046 | if( rc ){ |
| 68047 | return 0; |
| 68048 | } |
| 68049 | } |
| 68050 | |
| @@ -82350,13 +82342,10 @@ | |
| 82350 | if( pOp->opcode==OP_SorterInsert ){ |
| 82351 | rc = sqlite3VdbeSorterWrite(pC, pIn2); |
| 82352 | }else{ |
| 82353 | x.nKey = pIn2->n; |
| 82354 | x.pKey = pIn2->z; |
| 82355 | x.nData = 0; |
| 82356 | x.nZero = 0; |
| 82357 | x.pData = 0; |
| 82358 | rc = sqlite3BtreeInsert(pC->uc.pCursor, &x, pOp->p3, |
| 82359 | ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0) |
| 82360 | ); |
| 82361 | assert( pC->deferredMoveto==0 ); |
| 82362 | pC->cacheStatus = CACHE_STALE; |
| @@ -88795,11 +88784,10 @@ | |
| 88795 | const char *zDb; |
| 88796 | Expr *pRight; |
| 88797 | |
| 88798 | /* if( pSrcList==0 ) break; */ |
| 88799 | notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr); |
| 88800 | /*notValid(pParse, pNC, "the \".\" operator", NC_PartIdx|NC_IsCheck, 1);*/ |
| 88801 | pRight = pExpr->pRight; |
| 88802 | if( pRight->op==TK_ID ){ |
| 88803 | zDb = 0; |
| 88804 | zTable = pExpr->pLeft->u.zToken; |
| 88805 | zColumn = pRight->u.zToken; |
| @@ -88824,11 +88812,11 @@ | |
| 88824 | const char *zId; /* The function name. */ |
| 88825 | FuncDef *pDef; /* Information about the function */ |
| 88826 | u8 enc = ENC(pParse->db); /* The database encoding */ |
| 88827 | |
| 88828 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 88829 | notValid(pParse, pNC, "functions", NC_PartIdx); |
| 88830 | zId = pExpr->u.zToken; |
| 88831 | nId = sqlite3Strlen30(zId); |
| 88832 | pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0); |
| 88833 | if( pDef==0 ){ |
| 88834 | pDef = sqlite3FindFunction(pParse->db, zId, -2, enc, 0); |
| @@ -88884,11 +88872,12 @@ | |
| 88884 | } |
| 88885 | if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){ |
| 88886 | /* Date/time functions that use 'now', and other functions like |
| 88887 | ** sqlite_version() that might change over time cannot be used |
| 88888 | ** in an index. */ |
| 88889 | notValid(pParse, pNC, "non-deterministic functions", NC_IdxExpr); |
| 88890 | } |
| 88891 | } |
| 88892 | if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){ |
| 88893 | sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId); |
| 88894 | pNC->nErr++; |
| @@ -90424,11 +90413,11 @@ | |
| 90424 | ** stored in u.zToken. Instead, the integer values is written |
| 90425 | ** into u.iValue and the EP_IntValue flag is set. No extra storage |
| 90426 | ** is allocated to hold the integer text and the dequote flag is ignored. |
| 90427 | */ |
| 90428 | SQLITE_PRIVATE Expr *sqlite3ExprAlloc( |
| 90429 | sqlite3 *db, /* Handle for sqlite3DbMallocZero() (may be null) */ |
| 90430 | int op, /* Expression opcode */ |
| 90431 | const Token *pToken, /* Token argument. Might be NULL */ |
| 90432 | int dequote /* True to dequote */ |
| 90433 | ){ |
| 90434 | Expr *pNew; |
| @@ -90642,40 +90631,40 @@ | |
| 90642 | ** Wildcards of the form ":aaa", "@aaa", or "$aaa" are assigned the same number |
| 90643 | ** as the previous instance of the same wildcard. Or if this is the first |
| 90644 | ** instance of the wildcard, the next sequential variable number is |
| 90645 | ** assigned. |
| 90646 | */ |
| 90647 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){ |
| 90648 | sqlite3 *db = pParse->db; |
| 90649 | const char *z; |
| 90650 | |
| 90651 | if( pExpr==0 ) return; |
| 90652 | assert( !ExprHasProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) ); |
| 90653 | z = pExpr->u.zToken; |
| 90654 | assert( z!=0 ); |
| 90655 | assert( z[0]!=0 ); |
| 90656 | if( z[1]==0 ){ |
| 90657 | /* Wildcard of the form "?". Assign the next variable number */ |
| 90658 | assert( z[0]=='?' ); |
| 90659 | pExpr->iColumn = (ynVar)(++pParse->nVar); |
| 90660 | }else{ |
| 90661 | ynVar x = 0; |
| 90662 | u32 n = sqlite3Strlen30(z); |
| 90663 | if( z[0]=='?' ){ |
| 90664 | /* Wildcard of the form "?nnn". Convert "nnn" to an integer and |
| 90665 | ** use it as the variable number */ |
| 90666 | i64 i; |
| 90667 | int bOk = 0==sqlite3Atoi64(&z[1], &i, n-1, SQLITE_UTF8); |
| 90668 | pExpr->iColumn = x = (ynVar)i; |
| 90669 | testcase( i==0 ); |
| 90670 | testcase( i==1 ); |
| 90671 | testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 ); |
| 90672 | testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ); |
| 90673 | if( bOk==0 || i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){ |
| 90674 | sqlite3ErrorMsg(pParse, "variable number must be between ?1 and ?%d", |
| 90675 | db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]); |
| 90676 | x = 0; |
| 90677 | } |
| 90678 | if( i>pParse->nVar ){ |
| 90679 | pParse->nVar = (int)i; |
| 90680 | } |
| 90681 | }else{ |
| @@ -90682,37 +90671,35 @@ | |
| 90682 | /* Wildcards like ":aaa", "$aaa" or "@aaa". Reuse the same variable |
| 90683 | ** number as the prior appearance of the same name, or if the name |
| 90684 | ** has never appeared before, reuse the same variable number |
| 90685 | */ |
| 90686 | ynVar i; |
| 90687 | for(i=0; i<pParse->nzVar; i++){ |
| 90688 | if( pParse->azVar[i] && strcmp(pParse->azVar[i],z)==0 ){ |
| 90689 | pExpr->iColumn = x = (ynVar)i+1; |
| 90690 | break; |
| 90691 | } |
| 90692 | } |
| 90693 | if( x==0 ) x = pExpr->iColumn = (ynVar)(++pParse->nVar); |
| 90694 | } |
| 90695 | if( x>0 ){ |
| 90696 | if( x>pParse->nzVar ){ |
| 90697 | char **a; |
| 90698 | a = sqlite3DbRealloc(db, pParse->azVar, x*sizeof(a[0])); |
| 90699 | if( a==0 ){ |
| 90700 | assert( db->mallocFailed ); /* Error reported through mallocFailed */ |
| 90701 | return; |
| 90702 | } |
| 90703 | pParse->azVar = a; |
| 90704 | memset(&a[pParse->nzVar], 0, (x-pParse->nzVar)*sizeof(a[0])); |
| 90705 | pParse->nzVar = x; |
| 90706 | } |
| 90707 | if( z[0]!='?' || pParse->azVar[x-1]==0 ){ |
| 90708 | sqlite3DbFree(db, pParse->azVar[x-1]); |
| 90709 | pParse->azVar[x-1] = sqlite3DbStrNDup(db, z, n); |
| 90710 | } |
| 90711 | } |
| 90712 | } |
| 90713 | if( !pParse->nErr && pParse->nVar>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){ |
| 90714 | sqlite3ErrorMsg(pParse, "too many SQL variables"); |
| 90715 | } |
| 90716 | } |
| 90717 | |
| 90718 | /* |
| @@ -109529,10 +109516,11 @@ | |
| 109529 | } |
| 109530 | if( emptySrcTest ) sqlite3VdbeJumpHere(v, emptySrcTest); |
| 109531 | sqlite3ReleaseTempReg(pParse, regRowid); |
| 109532 | sqlite3ReleaseTempReg(pParse, regData); |
| 109533 | if( emptyDestTest ){ |
| 109534 | sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_OK, 0); |
| 109535 | sqlite3VdbeJumpHere(v, emptyDestTest); |
| 109536 | sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); |
| 109537 | return 0; |
| 109538 | }else{ |
| @@ -114025,24 +114013,18 @@ | |
| 114025 | int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ |
| 114026 | Vdbe *pReprepare, /* VM being reprepared */ |
| 114027 | sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ |
| 114028 | const char **pzTail /* OUT: End of parsed string */ |
| 114029 | ){ |
| 114030 | Parse *pParse; /* Parsing context */ |
| 114031 | char *zErrMsg = 0; /* Error message */ |
| 114032 | int rc = SQLITE_OK; /* Result code */ |
| 114033 | int i; /* Loop counter */ |
| 114034 | |
| 114035 | /* Allocate the parsing context */ |
| 114036 | pParse = sqlite3StackAllocRaw(db, sizeof(*pParse)); |
| 114037 | if( pParse==0 ){ |
| 114038 | rc = SQLITE_NOMEM_BKPT; |
| 114039 | goto end_prepare; |
| 114040 | } |
| 114041 | memset(pParse, 0, PARSE_HDR_SZ); |
| 114042 | memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ); |
| 114043 | pParse->pReprepare = pReprepare; |
| 114044 | assert( ppStmt && *ppStmt==0 ); |
| 114045 | /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */ |
| 114046 | assert( sqlite3_mutex_held(db->mutex) ); |
| 114047 | |
| 114048 | /* Check to verify that it is possible to get a read lock on all |
| @@ -114082,12 +114064,11 @@ | |
| 114082 | } |
| 114083 | } |
| 114084 | |
| 114085 | sqlite3VtabUnlockList(db); |
| 114086 | |
| 114087 | pParse->db = db; |
| 114088 | pParse->nQueryLoop = 0; /* Logarithmic, so 0 really means 1 */ |
| 114089 | if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){ |
| 114090 | char *zSqlCopy; |
| 114091 | int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH]; |
| 114092 | testcase( nBytes==mxLen ); |
| 114093 | testcase( nBytes==mxLen+1 ); |
| @@ -114096,65 +114077,65 @@ | |
| 114096 | rc = sqlite3ApiExit(db, SQLITE_TOOBIG); |
| 114097 | goto end_prepare; |
| 114098 | } |
| 114099 | zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes); |
| 114100 | if( zSqlCopy ){ |
| 114101 | sqlite3RunParser(pParse, zSqlCopy, &zErrMsg); |
| 114102 | pParse->zTail = &zSql[pParse->zTail-zSqlCopy]; |
| 114103 | sqlite3DbFree(db, zSqlCopy); |
| 114104 | }else{ |
| 114105 | pParse->zTail = &zSql[nBytes]; |
| 114106 | } |
| 114107 | }else{ |
| 114108 | sqlite3RunParser(pParse, zSql, &zErrMsg); |
| 114109 | } |
| 114110 | assert( 0==pParse->nQueryLoop ); |
| 114111 | |
| 114112 | if( pParse->rc==SQLITE_DONE ) pParse->rc = SQLITE_OK; |
| 114113 | if( pParse->checkSchema ){ |
| 114114 | schemaIsValid(pParse); |
| 114115 | } |
| 114116 | if( db->mallocFailed ){ |
| 114117 | pParse->rc = SQLITE_NOMEM_BKPT; |
| 114118 | } |
| 114119 | if( pzTail ){ |
| 114120 | *pzTail = pParse->zTail; |
| 114121 | } |
| 114122 | rc = pParse->rc; |
| 114123 | |
| 114124 | #ifndef SQLITE_OMIT_EXPLAIN |
| 114125 | if( rc==SQLITE_OK && pParse->pVdbe && pParse->explain ){ |
| 114126 | static const char * const azColName[] = { |
| 114127 | "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment", |
| 114128 | "selectid", "order", "from", "detail" |
| 114129 | }; |
| 114130 | int iFirst, mx; |
| 114131 | if( pParse->explain==2 ){ |
| 114132 | sqlite3VdbeSetNumCols(pParse->pVdbe, 4); |
| 114133 | iFirst = 8; |
| 114134 | mx = 12; |
| 114135 | }else{ |
| 114136 | sqlite3VdbeSetNumCols(pParse->pVdbe, 8); |
| 114137 | iFirst = 0; |
| 114138 | mx = 8; |
| 114139 | } |
| 114140 | for(i=iFirst; i<mx; i++){ |
| 114141 | sqlite3VdbeSetColName(pParse->pVdbe, i-iFirst, COLNAME_NAME, |
| 114142 | azColName[i], SQLITE_STATIC); |
| 114143 | } |
| 114144 | } |
| 114145 | #endif |
| 114146 | |
| 114147 | if( db->init.busy==0 ){ |
| 114148 | Vdbe *pVdbe = pParse->pVdbe; |
| 114149 | sqlite3VdbeSetSql(pVdbe, zSql, (int)(pParse->zTail-zSql), saveSqlFlag); |
| 114150 | } |
| 114151 | if( pParse->pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){ |
| 114152 | sqlite3VdbeFinalize(pParse->pVdbe); |
| 114153 | assert(!(*ppStmt)); |
| 114154 | }else{ |
| 114155 | *ppStmt = (sqlite3_stmt*)pParse->pVdbe; |
| 114156 | } |
| 114157 | |
| 114158 | if( zErrMsg ){ |
| 114159 | sqlite3ErrorWithMsg(db, rc, "%s", zErrMsg); |
| 114160 | sqlite3DbFree(db, zErrMsg); |
| @@ -114161,20 +114142,19 @@ | |
| 114161 | }else{ |
| 114162 | sqlite3Error(db, rc); |
| 114163 | } |
| 114164 | |
| 114165 | /* Delete any TriggerPrg structures allocated while parsing this statement. */ |
| 114166 | while( pParse->pTriggerPrg ){ |
| 114167 | TriggerPrg *pT = pParse->pTriggerPrg; |
| 114168 | pParse->pTriggerPrg = pT->pNext; |
| 114169 | sqlite3DbFree(db, pT); |
| 114170 | } |
| 114171 | |
| 114172 | end_prepare: |
| 114173 | |
| 114174 | sqlite3ParserReset(pParse); |
| 114175 | sqlite3StackFree(db, pParse); |
| 114176 | rc = sqlite3ApiExit(db, rc); |
| 114177 | assert( (rc&db->errMask)==rc ); |
| 114178 | return rc; |
| 114179 | } |
| 114180 | static int sqlite3LockAndPrepare( |
| @@ -124035,24 +124015,24 @@ | |
| 124035 | ** in prereqRight and prereqAll. The default is 64 bits, hence SQLite |
| 124036 | ** is only able to process joins with 64 or fewer tables. |
| 124037 | */ |
| 124038 | struct WhereTerm { |
| 124039 | Expr *pExpr; /* Pointer to the subexpression that is this term */ |
| 124040 | int iParent; /* Disable pWC->a[iParent] when this term disabled */ |
| 124041 | int leftCursor; /* Cursor number of X in "X <op> <expr>" */ |
| 124042 | int iField; /* Field in (?,?,?) IN (SELECT...) vector */ |
| 124043 | union { |
| 124044 | int leftColumn; /* Column number of X in "X <op> <expr>" */ |
| 124045 | WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */ |
| 124046 | WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */ |
| 124047 | } u; |
| 124048 | LogEst truthProb; /* Probability of truth for this expression */ |
| 124049 | u16 eOperator; /* A WO_xx value describing <op> */ |
| 124050 | u16 wtFlags; /* TERM_xxx bit flags. See below */ |
| 124051 | u8 nChild; /* Number of children that must disable us */ |
| 124052 | u8 eMatchOp; /* Op for vtab MATCH/LIKE/GLOB/REGEXP terms */ |
| 124053 | WhereClause *pWC; /* The clause this term is part of */ |
| 124054 | Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */ |
| 124055 | Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */ |
| 124056 | }; |
| 124057 | |
| 124058 | /* |
| @@ -124201,29 +124181,29 @@ | |
| 124201 | struct WhereInfo { |
| 124202 | Parse *pParse; /* Parsing and code generating context */ |
| 124203 | SrcList *pTabList; /* List of tables in the join */ |
| 124204 | ExprList *pOrderBy; /* The ORDER BY clause or NULL */ |
| 124205 | ExprList *pDistinctSet; /* DISTINCT over all these values */ |
| 124206 | WhereLoop *pLoops; /* List of all WhereLoop objects */ |
| 124207 | Bitmask revMask; /* Mask of ORDER BY terms that need reversing */ |
| 124208 | LogEst nRowOut; /* Estimated number of output rows */ |
| 124209 | LogEst iLimit; /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */ |
| 124210 | u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */ |
| 124211 | i8 nOBSat; /* Number of ORDER BY terms satisfied by indices */ |
| 124212 | u8 sorted; /* True if really sorted (not just grouped) */ |
| 124213 | u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */ |
| 124214 | u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */ |
| 124215 | u8 eDistinct; /* One of the WHERE_DISTINCT_* values */ |
| 124216 | u8 nLevel; /* Number of nested loop */ |
| 124217 | u8 bOrderedInnerLoop; /* True if only the inner-most loop is ordered */ |
| 124218 | int iTop; /* The very beginning of the WHERE loop */ |
| 124219 | int iContinue; /* Jump here to continue with next record */ |
| 124220 | int iBreak; /* Jump here to break out of the loop */ |
| 124221 | int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ |
| 124222 | int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */ |
| 124223 | WhereMaskSet sMaskSet; /* Map cursor numbers to bitmasks */ |
| 124224 | WhereClause sWC; /* Decomposition of the WHERE clause */ |
| 124225 | WhereLevel a[1]; /* Information about each nest loop in WHERE */ |
| 124226 | }; |
| 124227 | |
| 124228 | /* |
| 124229 | ** Private interfaces - callable only by other where.c routines. |
| @@ -126309,11 +126289,11 @@ | |
| 126309 | ** and we are coding the t1 loop and the t2 loop has not yet coded, |
| 126310 | ** then we cannot use the "t1.a=t2.b" constraint, but we can code |
| 126311 | ** the implied "t1.a=123" constraint. |
| 126312 | */ |
| 126313 | for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){ |
| 126314 | Expr *pE, *pEAlt; |
| 126315 | WhereTerm *pAlt; |
| 126316 | if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 126317 | if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) continue; |
| 126318 | if( (pTerm->eOperator & WO_EQUIV)==0 ) continue; |
| 126319 | if( pTerm->leftCursor!=iCur ) continue; |
| @@ -126327,17 +126307,13 @@ | |
| 126327 | if( pAlt->wtFlags & (TERM_CODED) ) continue; |
| 126328 | testcase( pAlt->eOperator & WO_EQ ); |
| 126329 | testcase( pAlt->eOperator & WO_IS ); |
| 126330 | testcase( pAlt->eOperator & WO_IN ); |
| 126331 | VdbeModuleComment((v, "begin transitive constraint")); |
| 126332 | pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt)); |
| 126333 | if( pEAlt ){ |
| 126334 | *pEAlt = *pAlt->pExpr; |
| 126335 | pEAlt->pLeft = pE->pLeft; |
| 126336 | sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL); |
| 126337 | sqlite3StackFree(db, pEAlt); |
| 126338 | } |
| 126339 | } |
| 126340 | |
| 126341 | /* For a LEFT OUTER JOIN, generate code that will record the fact that |
| 126342 | ** at least one row of the right table has matched the left table. |
| 126343 | */ |
| @@ -126442,11 +126418,10 @@ | |
| 126442 | memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm); |
| 126443 | if( pOld!=pWC->aStatic ){ |
| 126444 | sqlite3DbFree(db, pOld); |
| 126445 | } |
| 126446 | pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]); |
| 126447 | memset(&pWC->a[pWC->nTerm], 0, sizeof(pWC->a[0])*(pWC->nSlot-pWC->nTerm)); |
| 126448 | } |
| 126449 | pTerm = &pWC->a[idx = pWC->nTerm++]; |
| 126450 | if( p && ExprHasProperty(p, EP_Unlikely) ){ |
| 126451 | pTerm->truthProb = sqlite3LogEst(p->iTable) - 270; |
| 126452 | }else{ |
| @@ -126454,10 +126429,12 @@ | |
| 126454 | } |
| 126455 | pTerm->pExpr = sqlite3ExprSkipCollate(p); |
| 126456 | pTerm->wtFlags = wtFlags; |
| 126457 | pTerm->pWC = pWC; |
| 126458 | pTerm->iParent = -1; |
| 126459 | return idx; |
| 126460 | } |
| 126461 | |
| 126462 | /* |
| 126463 | ** Return TRUE if the given operator is one of the operators that is |
| @@ -132212,26 +132189,29 @@ | |
| 132212 | ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte |
| 132213 | ** field (type Bitmask) it must be aligned on an 8-byte boundary on |
| 132214 | ** some architectures. Hence the ROUND8() below. |
| 132215 | */ |
| 132216 | nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel)); |
| 132217 | pWInfo = sqlite3DbMallocZero(db, nByteWInfo + sizeof(WhereLoop)); |
| 132218 | if( db->mallocFailed ){ |
| 132219 | sqlite3DbFree(db, pWInfo); |
| 132220 | pWInfo = 0; |
| 132221 | goto whereBeginError; |
| 132222 | } |
| 132223 | pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1; |
| 132224 | pWInfo->nLevel = nTabList; |
| 132225 | pWInfo->pParse = pParse; |
| 132226 | pWInfo->pTabList = pTabList; |
| 132227 | pWInfo->pOrderBy = pOrderBy; |
| 132228 | pWInfo->pDistinctSet = pDistinctSet; |
| 132229 | pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v); |
| 132230 | pWInfo->wctrlFlags = wctrlFlags; |
| 132231 | pWInfo->iLimit = iAuxArg; |
| 132232 | pWInfo->savedNQueryLoop = pParse->nQueryLoop; |
| 132233 | assert( pWInfo->eOnePass==ONEPASS_OFF ); /* ONEPASS defaults to OFF */ |
| 132234 | pMaskSet = &pWInfo->sMaskSet; |
| 132235 | sWLB.pWInfo = pWInfo; |
| 132236 | sWLB.pWC = &pWInfo->sWC; |
| 132237 | sWLB.pNew = (WhereLoop*)(((char*)pWInfo)+nByteWInfo); |
| @@ -135684,12 +135664,13 @@ | |
| 135684 | yymsp[0].minor.yy190 = yylhsminor.yy190; |
| 135685 | break; |
| 135686 | case 159: /* expr ::= VARIABLE */ |
| 135687 | { |
| 135688 | if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){ |
| 135689 | spanExpr(&yymsp[0].minor.yy190, pParse, TK_VARIABLE, yymsp[0].minor.yy0); |
| 135690 | sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr); |
| 135691 | }else{ |
| 135692 | /* When doing a nested parse, one can include terms in an expression |
| 135693 | ** that look like this: #1 #2 ... These terms refer to registers |
| 135694 | ** in the virtual machine. #N is the N-th register. */ |
| 135695 | Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/ |
| @@ -136458,11 +136439,11 @@ | |
| 136458 | } |
| 136459 | #endif |
| 136460 | yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); |
| 136461 | yymajor = YYNOCODE; |
| 136462 | }else{ |
| 136463 | while( yypParser->yytos >= &yypParser->yystack |
| 136464 | && yymx != YYERRORSYMBOL |
| 136465 | && (yyact = yy_find_reduce_action( |
| 136466 | yypParser->yytos->stateno, |
| 136467 | YYERRORSYMBOL)) >= YY_MIN_REDUCE |
| 136468 | ){ |
| @@ -181149,11 +181130,11 @@ | |
| 181149 | } |
| 181150 | #endif |
| 181151 | fts5yy_destructor(fts5yypParser, (fts5YYCODETYPE)fts5yymajor, &fts5yyminorunion); |
| 181152 | fts5yymajor = fts5YYNOCODE; |
| 181153 | }else{ |
| 181154 | while( fts5yypParser->fts5yytos >= &fts5yypParser->fts5yystack |
| 181155 | && fts5yymx != fts5YYERRORSYMBOL |
| 181156 | && (fts5yyact = fts5yy_find_reduce_action( |
| 181157 | fts5yypParser->fts5yytos->stateno, |
| 181158 | fts5YYERRORSYMBOL)) >= fts5YY_MIN_REDUCE |
| 181159 | ){ |
| @@ -195606,11 +195587,11 @@ | |
| 195606 | int nArg, /* Number of args */ |
| 195607 | sqlite3_value **apUnused /* Function arguments */ |
| 195608 | ){ |
| 195609 | assert( nArg==0 ); |
| 195610 | UNUSED_PARAM2(nArg, apUnused); |
| 195611 | sqlite3_result_text(pCtx, "fts5: 2016-09-16 17:50:57 e3d9efa2770cd789ece3f4db4941b901c8b805ad", -1, SQLITE_TRANSIENT); |
| 195612 | } |
| 195613 | |
| 195614 | static int fts5Init(sqlite3 *db){ |
| 195615 | static const sqlite3_module fts5Mod = { |
| 195616 | /* iVersion */ 2, |
| 195617 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -381,11 +381,11 @@ | |
| 381 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 382 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 383 | */ |
| 384 | #define SQLITE_VERSION "3.15.0" |
| 385 | #define SQLITE_VERSION_NUMBER 3015000 |
| 386 | #define SQLITE_SOURCE_ID "2016-10-04 12:20:12 3a9d802fda10585654332b314d317250dc5d894e" |
| 387 | |
| 388 | /* |
| 389 | ** CAPI3REF: Run-Time Library Version Numbers |
| 390 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 391 | ** |
| @@ -16180,11 +16180,11 @@ | |
| 16180 | SQLITE_PRIVATE void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*); |
| 16181 | SQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token*); |
| 16182 | SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*); |
| 16183 | SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*); |
| 16184 | SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*); |
| 16185 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); |
| 16186 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); |
| 16187 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); |
| 16188 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*); |
| 16189 | SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int); |
| 16190 | SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int); |
| @@ -58987,11 +58987,11 @@ | |
| 58987 | int bias, /* Bias search to the high end */ |
| 58988 | int *pRes /* Write search results here */ |
| 58989 | ){ |
| 58990 | int rc; /* Status code */ |
| 58991 | UnpackedRecord *pIdxKey; /* Unpacked index key */ |
| 58992 | char aSpace[384]; /* Temp space for pIdxKey - to avoid a malloc */ |
| 58993 | char *pFree = 0; |
| 58994 | |
| 58995 | if( pKey ){ |
| 58996 | assert( nKey==(i64)(int)nKey ); |
| 58997 | pIdxKey = sqlite3VdbeAllocUnpackedRecord( |
| @@ -64324,12 +64324,10 @@ | |
| 64324 | nSrc = pX->nData; |
| 64325 | assert( pPage->intKeyLeaf ); /* fillInCell() only called for leaves */ |
| 64326 | nHeader += putVarint32(&pCell[nHeader], nPayload); |
| 64327 | nHeader += putVarint(&pCell[nHeader], *(u64*)&pX->nKey); |
| 64328 | }else{ |
| 64329 | assert( pX->nKey<=0x7fffffff && pX->pKey!=0 ); |
| 64330 | nSrc = nPayload = (int)pX->nKey; |
| 64331 | pSrc = pX->pKey; |
| 64332 | nHeader += putVarint32(&pCell[nHeader], nPayload); |
| 64333 | } |
| @@ -68025,26 +68023,20 @@ | |
| 68023 | */ |
| 68024 | static Btree *findBtree(sqlite3 *pErrorDb, sqlite3 *pDb, const char *zDb){ |
| 68025 | int i = sqlite3FindDbName(pDb, zDb); |
| 68026 | |
| 68027 | if( i==1 ){ |
| 68028 | Parse sParse; |
| 68029 | int rc = 0; |
| 68030 | memset(&sParse, 0, sizeof(sParse)); |
| 68031 | sParse.db = pDb; |
| 68032 | if( sqlite3OpenTempDatabase(&sParse) ){ |
| 68033 | sqlite3ErrorWithMsg(pErrorDb, sParse.rc, "%s", sParse.zErrMsg); |
| 68034 | rc = SQLITE_ERROR; |
| 68035 | } |
| 68036 | sqlite3DbFree(pErrorDb, sParse.zErrMsg); |
| 68037 | sqlite3ParserReset(&sParse); |
| 68038 | if( rc ){ |
| 68039 | return 0; |
| 68040 | } |
| 68041 | } |
| 68042 | |
| @@ -82350,13 +82342,10 @@ | |
| 82342 | if( pOp->opcode==OP_SorterInsert ){ |
| 82343 | rc = sqlite3VdbeSorterWrite(pC, pIn2); |
| 82344 | }else{ |
| 82345 | x.nKey = pIn2->n; |
| 82346 | x.pKey = pIn2->z; |
| 82347 | rc = sqlite3BtreeInsert(pC->uc.pCursor, &x, pOp->p3, |
| 82348 | ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0) |
| 82349 | ); |
| 82350 | assert( pC->deferredMoveto==0 ); |
| 82351 | pC->cacheStatus = CACHE_STALE; |
| @@ -88795,11 +88784,10 @@ | |
| 88784 | const char *zDb; |
| 88785 | Expr *pRight; |
| 88786 | |
| 88787 | /* if( pSrcList==0 ) break; */ |
| 88788 | notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr); |
| 88789 | pRight = pExpr->pRight; |
| 88790 | if( pRight->op==TK_ID ){ |
| 88791 | zDb = 0; |
| 88792 | zTable = pExpr->pLeft->u.zToken; |
| 88793 | zColumn = pRight->u.zToken; |
| @@ -88824,11 +88812,11 @@ | |
| 88812 | const char *zId; /* The function name. */ |
| 88813 | FuncDef *pDef; /* Information about the function */ |
| 88814 | u8 enc = ENC(pParse->db); /* The database encoding */ |
| 88815 | |
| 88816 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 88817 | // notValid(pParse, pNC, "functions", NC_PartIdx); |
| 88818 | zId = pExpr->u.zToken; |
| 88819 | nId = sqlite3Strlen30(zId); |
| 88820 | pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0); |
| 88821 | if( pDef==0 ){ |
| 88822 | pDef = sqlite3FindFunction(pParse->db, zId, -2, enc, 0); |
| @@ -88884,11 +88872,12 @@ | |
| 88872 | } |
| 88873 | if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){ |
| 88874 | /* Date/time functions that use 'now', and other functions like |
| 88875 | ** sqlite_version() that might change over time cannot be used |
| 88876 | ** in an index. */ |
| 88877 | notValid(pParse, pNC, "non-deterministic functions", |
| 88878 | NC_IdxExpr|NC_PartIdx); |
| 88879 | } |
| 88880 | } |
| 88881 | if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){ |
| 88882 | sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId); |
| 88883 | pNC->nErr++; |
| @@ -90424,11 +90413,11 @@ | |
| 90413 | ** stored in u.zToken. Instead, the integer values is written |
| 90414 | ** into u.iValue and the EP_IntValue flag is set. No extra storage |
| 90415 | ** is allocated to hold the integer text and the dequote flag is ignored. |
| 90416 | */ |
| 90417 | SQLITE_PRIVATE Expr *sqlite3ExprAlloc( |
| 90418 | sqlite3 *db, /* Handle for sqlite3DbMallocRawNN() */ |
| 90419 | int op, /* Expression opcode */ |
| 90420 | const Token *pToken, /* Token argument. Might be NULL */ |
| 90421 | int dequote /* True to dequote */ |
| 90422 | ){ |
| 90423 | Expr *pNew; |
| @@ -90642,40 +90631,40 @@ | |
| 90631 | ** Wildcards of the form ":aaa", "@aaa", or "$aaa" are assigned the same number |
| 90632 | ** as the previous instance of the same wildcard. Or if this is the first |
| 90633 | ** instance of the wildcard, the next sequential variable number is |
| 90634 | ** assigned. |
| 90635 | */ |
| 90636 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n){ |
| 90637 | sqlite3 *db = pParse->db; |
| 90638 | const char *z; |
| 90639 | |
| 90640 | if( pExpr==0 ) return; |
| 90641 | assert( !ExprHasProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) ); |
| 90642 | z = pExpr->u.zToken; |
| 90643 | assert( z!=0 ); |
| 90644 | assert( z[0]!=0 ); |
| 90645 | assert( n==sqlite3Strlen30(z) ); |
| 90646 | if( z[1]==0 ){ |
| 90647 | /* Wildcard of the form "?". Assign the next variable number */ |
| 90648 | assert( z[0]=='?' ); |
| 90649 | pExpr->iColumn = (ynVar)(++pParse->nVar); |
| 90650 | }else{ |
| 90651 | ynVar x; |
| 90652 | if( z[0]=='?' ){ |
| 90653 | /* Wildcard of the form "?nnn". Convert "nnn" to an integer and |
| 90654 | ** use it as the variable number */ |
| 90655 | i64 i; |
| 90656 | int bOk = 0==sqlite3Atoi64(&z[1], &i, n-1, SQLITE_UTF8); |
| 90657 | x = (ynVar)i; |
| 90658 | testcase( i==0 ); |
| 90659 | testcase( i==1 ); |
| 90660 | testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 ); |
| 90661 | testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ); |
| 90662 | if( bOk==0 || i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){ |
| 90663 | sqlite3ErrorMsg(pParse, "variable number must be between ?1 and ?%d", |
| 90664 | db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]); |
| 90665 | return; |
| 90666 | } |
| 90667 | if( i>pParse->nVar ){ |
| 90668 | pParse->nVar = (int)i; |
| 90669 | } |
| 90670 | }else{ |
| @@ -90682,37 +90671,35 @@ | |
| 90671 | /* Wildcards like ":aaa", "$aaa" or "@aaa". Reuse the same variable |
| 90672 | ** number as the prior appearance of the same name, or if the name |
| 90673 | ** has never appeared before, reuse the same variable number |
| 90674 | */ |
| 90675 | ynVar i; |
| 90676 | for(i=x=0; i<pParse->nzVar; i++){ |
| 90677 | if( pParse->azVar[i] && strcmp(pParse->azVar[i],z)==0 ){ |
| 90678 | x = (ynVar)i+1; |
| 90679 | break; |
| 90680 | } |
| 90681 | } |
| 90682 | if( x==0 ) x = (ynVar)(++pParse->nVar); |
| 90683 | } |
| 90684 | pExpr->iColumn = x; |
| 90685 | if( x>pParse->nzVar ){ |
| 90686 | char **a; |
| 90687 | a = sqlite3DbRealloc(db, pParse->azVar, x*sizeof(a[0])); |
| 90688 | if( a==0 ){ |
| 90689 | assert( db->mallocFailed ); /* Error reported through mallocFailed */ |
| 90690 | return; |
| 90691 | } |
| 90692 | pParse->azVar = a; |
| 90693 | memset(&a[pParse->nzVar], 0, (x-pParse->nzVar)*sizeof(a[0])); |
| 90694 | pParse->nzVar = x; |
| 90695 | } |
| 90696 | if( pParse->azVar[x-1]==0 ){ |
| 90697 | pParse->azVar[x-1] = sqlite3DbStrNDup(db, z, n); |
| 90698 | } |
| 90699 | } |
| 90700 | if( pParse->nVar>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){ |
| 90701 | sqlite3ErrorMsg(pParse, "too many SQL variables"); |
| 90702 | } |
| 90703 | } |
| 90704 | |
| 90705 | /* |
| @@ -109529,10 +109516,11 @@ | |
| 109516 | } |
| 109517 | if( emptySrcTest ) sqlite3VdbeJumpHere(v, emptySrcTest); |
| 109518 | sqlite3ReleaseTempReg(pParse, regRowid); |
| 109519 | sqlite3ReleaseTempReg(pParse, regData); |
| 109520 | if( emptyDestTest ){ |
| 109521 | sqlite3AutoincrementEnd(pParse); |
| 109522 | sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_OK, 0); |
| 109523 | sqlite3VdbeJumpHere(v, emptyDestTest); |
| 109524 | sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); |
| 109525 | return 0; |
| 109526 | }else{ |
| @@ -114025,24 +114013,18 @@ | |
| 114013 | int saveSqlFlag, /* True to copy SQL text into the sqlite3_stmt */ |
| 114014 | Vdbe *pReprepare, /* VM being reprepared */ |
| 114015 | sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ |
| 114016 | const char **pzTail /* OUT: End of parsed string */ |
| 114017 | ){ |
| 114018 | char *zErrMsg = 0; /* Error message */ |
| 114019 | int rc = SQLITE_OK; /* Result code */ |
| 114020 | int i; /* Loop counter */ |
| 114021 | Parse sParse; /* Parsing context */ |
| 114022 | |
| 114023 | memset(&sParse, 0, PARSE_HDR_SZ); |
| 114024 | memset(PARSE_TAIL(&sParse), 0, PARSE_TAIL_SZ); |
| 114025 | sParse.pReprepare = pReprepare; |
| 114026 | assert( ppStmt && *ppStmt==0 ); |
| 114027 | /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */ |
| 114028 | assert( sqlite3_mutex_held(db->mutex) ); |
| 114029 | |
| 114030 | /* Check to verify that it is possible to get a read lock on all |
| @@ -114082,12 +114064,11 @@ | |
| 114064 | } |
| 114065 | } |
| 114066 | |
| 114067 | sqlite3VtabUnlockList(db); |
| 114068 | |
| 114069 | sParse.db = db; |
| 114070 | if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){ |
| 114071 | char *zSqlCopy; |
| 114072 | int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH]; |
| 114073 | testcase( nBytes==mxLen ); |
| 114074 | testcase( nBytes==mxLen+1 ); |
| @@ -114096,65 +114077,65 @@ | |
| 114077 | rc = sqlite3ApiExit(db, SQLITE_TOOBIG); |
| 114078 | goto end_prepare; |
| 114079 | } |
| 114080 | zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes); |
| 114081 | if( zSqlCopy ){ |
| 114082 | sqlite3RunParser(&sParse, zSqlCopy, &zErrMsg); |
| 114083 | sParse.zTail = &zSql[sParse.zTail-zSqlCopy]; |
| 114084 | sqlite3DbFree(db, zSqlCopy); |
| 114085 | }else{ |
| 114086 | sParse.zTail = &zSql[nBytes]; |
| 114087 | } |
| 114088 | }else{ |
| 114089 | sqlite3RunParser(&sParse, zSql, &zErrMsg); |
| 114090 | } |
| 114091 | assert( 0==sParse.nQueryLoop ); |
| 114092 | |
| 114093 | if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK; |
| 114094 | if( sParse.checkSchema ){ |
| 114095 | schemaIsValid(&sParse); |
| 114096 | } |
| 114097 | if( db->mallocFailed ){ |
| 114098 | sParse.rc = SQLITE_NOMEM_BKPT; |
| 114099 | } |
| 114100 | if( pzTail ){ |
| 114101 | *pzTail = sParse.zTail; |
| 114102 | } |
| 114103 | rc = sParse.rc; |
| 114104 | |
| 114105 | #ifndef SQLITE_OMIT_EXPLAIN |
| 114106 | if( rc==SQLITE_OK && sParse.pVdbe && sParse.explain ){ |
| 114107 | static const char * const azColName[] = { |
| 114108 | "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment", |
| 114109 | "selectid", "order", "from", "detail" |
| 114110 | }; |
| 114111 | int iFirst, mx; |
| 114112 | if( sParse.explain==2 ){ |
| 114113 | sqlite3VdbeSetNumCols(sParse.pVdbe, 4); |
| 114114 | iFirst = 8; |
| 114115 | mx = 12; |
| 114116 | }else{ |
| 114117 | sqlite3VdbeSetNumCols(sParse.pVdbe, 8); |
| 114118 | iFirst = 0; |
| 114119 | mx = 8; |
| 114120 | } |
| 114121 | for(i=iFirst; i<mx; i++){ |
| 114122 | sqlite3VdbeSetColName(sParse.pVdbe, i-iFirst, COLNAME_NAME, |
| 114123 | azColName[i], SQLITE_STATIC); |
| 114124 | } |
| 114125 | } |
| 114126 | #endif |
| 114127 | |
| 114128 | if( db->init.busy==0 ){ |
| 114129 | Vdbe *pVdbe = sParse.pVdbe; |
| 114130 | sqlite3VdbeSetSql(pVdbe, zSql, (int)(sParse.zTail-zSql), saveSqlFlag); |
| 114131 | } |
| 114132 | if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){ |
| 114133 | sqlite3VdbeFinalize(sParse.pVdbe); |
| 114134 | assert(!(*ppStmt)); |
| 114135 | }else{ |
| 114136 | *ppStmt = (sqlite3_stmt*)sParse.pVdbe; |
| 114137 | } |
| 114138 | |
| 114139 | if( zErrMsg ){ |
| 114140 | sqlite3ErrorWithMsg(db, rc, "%s", zErrMsg); |
| 114141 | sqlite3DbFree(db, zErrMsg); |
| @@ -114161,20 +114142,19 @@ | |
| 114142 | }else{ |
| 114143 | sqlite3Error(db, rc); |
| 114144 | } |
| 114145 | |
| 114146 | /* Delete any TriggerPrg structures allocated while parsing this statement. */ |
| 114147 | while( sParse.pTriggerPrg ){ |
| 114148 | TriggerPrg *pT = sParse.pTriggerPrg; |
| 114149 | sParse.pTriggerPrg = pT->pNext; |
| 114150 | sqlite3DbFree(db, pT); |
| 114151 | } |
| 114152 | |
| 114153 | end_prepare: |
| 114154 | |
| 114155 | sqlite3ParserReset(&sParse); |
| 114156 | rc = sqlite3ApiExit(db, rc); |
| 114157 | assert( (rc&db->errMask)==rc ); |
| 114158 | return rc; |
| 114159 | } |
| 114160 | static int sqlite3LockAndPrepare( |
| @@ -124035,24 +124015,24 @@ | |
| 124015 | ** in prereqRight and prereqAll. The default is 64 bits, hence SQLite |
| 124016 | ** is only able to process joins with 64 or fewer tables. |
| 124017 | */ |
| 124018 | struct WhereTerm { |
| 124019 | Expr *pExpr; /* Pointer to the subexpression that is this term */ |
| 124020 | WhereClause *pWC; /* The clause this term is part of */ |
| 124021 | LogEst truthProb; /* Probability of truth for this expression */ |
| 124022 | u16 wtFlags; /* TERM_xxx bit flags. See below */ |
| 124023 | u16 eOperator; /* A WO_xx value describing <op> */ |
| 124024 | u8 nChild; /* Number of children that must disable us */ |
| 124025 | u8 eMatchOp; /* Op for vtab MATCH/LIKE/GLOB/REGEXP terms */ |
| 124026 | int iParent; /* Disable pWC->a[iParent] when this term disabled */ |
| 124027 | int leftCursor; /* Cursor number of X in "X <op> <expr>" */ |
| 124028 | int iField; /* Field in (?,?,?) IN (SELECT...) vector */ |
| 124029 | union { |
| 124030 | int leftColumn; /* Column number of X in "X <op> <expr>" */ |
| 124031 | WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */ |
| 124032 | WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */ |
| 124033 | } u; |
| 124034 | Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */ |
| 124035 | Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */ |
| 124036 | }; |
| 124037 | |
| 124038 | /* |
| @@ -124201,29 +124181,29 @@ | |
| 124181 | struct WhereInfo { |
| 124182 | Parse *pParse; /* Parsing and code generating context */ |
| 124183 | SrcList *pTabList; /* List of tables in the join */ |
| 124184 | ExprList *pOrderBy; /* The ORDER BY clause or NULL */ |
| 124185 | ExprList *pDistinctSet; /* DISTINCT over all these values */ |
| 124186 | LogEst iLimit; /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */ |
| 124187 | int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */ |
| 124188 | int iContinue; /* Jump here to continue with next record */ |
| 124189 | int iBreak; /* Jump here to break out of the loop */ |
| 124190 | int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ |
| 124191 | u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */ |
| 124192 | u8 nLevel; /* Number of nested loop */ |
| 124193 | i8 nOBSat; /* Number of ORDER BY terms satisfied by indices */ |
| 124194 | u8 sorted; /* True if really sorted (not just grouped) */ |
| 124195 | u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */ |
| 124196 | u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */ |
| 124197 | u8 eDistinct; /* One of the WHERE_DISTINCT_* values */ |
| 124198 | u8 bOrderedInnerLoop; /* True if only the inner-most loop is ordered */ |
| 124199 | int iTop; /* The very beginning of the WHERE loop */ |
| 124200 | WhereLoop *pLoops; /* List of all WhereLoop objects */ |
| 124201 | Bitmask revMask; /* Mask of ORDER BY terms that need reversing */ |
| 124202 | LogEst nRowOut; /* Estimated number of output rows */ |
| 124203 | WhereClause sWC; /* Decomposition of the WHERE clause */ |
| 124204 | WhereMaskSet sMaskSet; /* Map cursor numbers to bitmasks */ |
| 124205 | WhereLevel a[1]; /* Information about each nest loop in WHERE */ |
| 124206 | }; |
| 124207 | |
| 124208 | /* |
| 124209 | ** Private interfaces - callable only by other where.c routines. |
| @@ -126309,11 +126289,11 @@ | |
| 126289 | ** and we are coding the t1 loop and the t2 loop has not yet coded, |
| 126290 | ** then we cannot use the "t1.a=t2.b" constraint, but we can code |
| 126291 | ** the implied "t1.a=123" constraint. |
| 126292 | */ |
| 126293 | for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){ |
| 126294 | Expr *pE, sEAlt; |
| 126295 | WhereTerm *pAlt; |
| 126296 | if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 126297 | if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) continue; |
| 126298 | if( (pTerm->eOperator & WO_EQUIV)==0 ) continue; |
| 126299 | if( pTerm->leftCursor!=iCur ) continue; |
| @@ -126327,17 +126307,13 @@ | |
| 126307 | if( pAlt->wtFlags & (TERM_CODED) ) continue; |
| 126308 | testcase( pAlt->eOperator & WO_EQ ); |
| 126309 | testcase( pAlt->eOperator & WO_IS ); |
| 126310 | testcase( pAlt->eOperator & WO_IN ); |
| 126311 | VdbeModuleComment((v, "begin transitive constraint")); |
| 126312 | sEAlt = *pAlt->pExpr; |
| 126313 | sEAlt.pLeft = pE->pLeft; |
| 126314 | sqlite3ExprIfFalse(pParse, &sEAlt, addrCont, SQLITE_JUMPIFNULL); |
| 126315 | } |
| 126316 | |
| 126317 | /* For a LEFT OUTER JOIN, generate code that will record the fact that |
| 126318 | ** at least one row of the right table has matched the left table. |
| 126319 | */ |
| @@ -126442,11 +126418,10 @@ | |
| 126418 | memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm); |
| 126419 | if( pOld!=pWC->aStatic ){ |
| 126420 | sqlite3DbFree(db, pOld); |
| 126421 | } |
| 126422 | pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]); |
| 126423 | } |
| 126424 | pTerm = &pWC->a[idx = pWC->nTerm++]; |
| 126425 | if( p && ExprHasProperty(p, EP_Unlikely) ){ |
| 126426 | pTerm->truthProb = sqlite3LogEst(p->iTable) - 270; |
| 126427 | }else{ |
| @@ -126454,10 +126429,12 @@ | |
| 126429 | } |
| 126430 | pTerm->pExpr = sqlite3ExprSkipCollate(p); |
| 126431 | pTerm->wtFlags = wtFlags; |
| 126432 | pTerm->pWC = pWC; |
| 126433 | pTerm->iParent = -1; |
| 126434 | memset(&pTerm->eOperator, 0, |
| 126435 | sizeof(WhereTerm) - offsetof(WhereTerm,eOperator)); |
| 126436 | return idx; |
| 126437 | } |
| 126438 | |
| 126439 | /* |
| 126440 | ** Return TRUE if the given operator is one of the operators that is |
| @@ -132212,26 +132189,29 @@ | |
| 132189 | ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte |
| 132190 | ** field (type Bitmask) it must be aligned on an 8-byte boundary on |
| 132191 | ** some architectures. Hence the ROUND8() below. |
| 132192 | */ |
| 132193 | nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel)); |
| 132194 | pWInfo = sqlite3DbMallocRawNN(db, nByteWInfo + sizeof(WhereLoop)); |
| 132195 | if( db->mallocFailed ){ |
| 132196 | sqlite3DbFree(db, pWInfo); |
| 132197 | pWInfo = 0; |
| 132198 | goto whereBeginError; |
| 132199 | } |
| 132200 | pWInfo->pParse = pParse; |
| 132201 | pWInfo->pTabList = pTabList; |
| 132202 | pWInfo->pOrderBy = pOrderBy; |
| 132203 | pWInfo->pDistinctSet = pDistinctSet; |
| 132204 | pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1; |
| 132205 | pWInfo->nLevel = nTabList; |
| 132206 | pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v); |
| 132207 | pWInfo->wctrlFlags = wctrlFlags; |
| 132208 | pWInfo->iLimit = iAuxArg; |
| 132209 | pWInfo->savedNQueryLoop = pParse->nQueryLoop; |
| 132210 | memset(&pWInfo->nOBSat, 0, |
| 132211 | offsetof(WhereInfo,sWC) - offsetof(WhereInfo,nOBSat)); |
| 132212 | memset(&pWInfo->a[0], 0, sizeof(WhereLoop)+nTabList*sizeof(WhereLevel)); |
| 132213 | assert( pWInfo->eOnePass==ONEPASS_OFF ); /* ONEPASS defaults to OFF */ |
| 132214 | pMaskSet = &pWInfo->sMaskSet; |
| 132215 | sWLB.pWInfo = pWInfo; |
| 132216 | sWLB.pWC = &pWInfo->sWC; |
| 132217 | sWLB.pNew = (WhereLoop*)(((char*)pWInfo)+nByteWInfo); |
| @@ -135684,12 +135664,13 @@ | |
| 135664 | yymsp[0].minor.yy190 = yylhsminor.yy190; |
| 135665 | break; |
| 135666 | case 159: /* expr ::= VARIABLE */ |
| 135667 | { |
| 135668 | if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){ |
| 135669 | u32 n = yymsp[0].minor.yy0.n; |
| 135670 | spanExpr(&yymsp[0].minor.yy190, pParse, TK_VARIABLE, yymsp[0].minor.yy0); |
| 135671 | sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr, n); |
| 135672 | }else{ |
| 135673 | /* When doing a nested parse, one can include terms in an expression |
| 135674 | ** that look like this: #1 #2 ... These terms refer to registers |
| 135675 | ** in the virtual machine. #N is the N-th register. */ |
| 135676 | Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/ |
| @@ -136458,11 +136439,11 @@ | |
| 136439 | } |
| 136440 | #endif |
| 136441 | yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); |
| 136442 | yymajor = YYNOCODE; |
| 136443 | }else{ |
| 136444 | while( yypParser->yytos >= yypParser->yystack |
| 136445 | && yymx != YYERRORSYMBOL |
| 136446 | && (yyact = yy_find_reduce_action( |
| 136447 | yypParser->yytos->stateno, |
| 136448 | YYERRORSYMBOL)) >= YY_MIN_REDUCE |
| 136449 | ){ |
| @@ -181149,11 +181130,11 @@ | |
| 181130 | } |
| 181131 | #endif |
| 181132 | fts5yy_destructor(fts5yypParser, (fts5YYCODETYPE)fts5yymajor, &fts5yyminorunion); |
| 181133 | fts5yymajor = fts5YYNOCODE; |
| 181134 | }else{ |
| 181135 | while( fts5yypParser->fts5yytos >= fts5yypParser->fts5yystack |
| 181136 | && fts5yymx != fts5YYERRORSYMBOL |
| 181137 | && (fts5yyact = fts5yy_find_reduce_action( |
| 181138 | fts5yypParser->fts5yytos->stateno, |
| 181139 | fts5YYERRORSYMBOL)) >= fts5YY_MIN_REDUCE |
| 181140 | ){ |
| @@ -195606,11 +195587,11 @@ | |
| 195587 | int nArg, /* Number of args */ |
| 195588 | sqlite3_value **apUnused /* Function arguments */ |
| 195589 | ){ |
| 195590 | assert( nArg==0 ); |
| 195591 | UNUSED_PARAM2(nArg, apUnused); |
| 195592 | sqlite3_result_text(pCtx, "fts5: 2016-10-04 00:47:26 b10d0f939c82c4de3faa90b86de9ec4a89992856", -1, SQLITE_TRANSIENT); |
| 195593 | } |
| 195594 | |
| 195595 | static int fts5Init(sqlite3 *db){ |
| 195596 | static const sqlite3_module fts5Mod = { |
| 195597 | /* iVersion */ 2, |
| 195598 |
+1
-1
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -121,11 +121,11 @@ | ||
| 121 | 121 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 122 | 122 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 123 | 123 | */ |
| 124 | 124 | #define SQLITE_VERSION "3.15.0" |
| 125 | 125 | #define SQLITE_VERSION_NUMBER 3015000 |
| 126 | -#define SQLITE_SOURCE_ID "2016-10-01 23:55:23 fe07609efc31c4639c40fbda501c55f443756ad2" | |
| 126 | +#define SQLITE_SOURCE_ID "2016-10-04 12:20:12 3a9d802fda10585654332b314d317250dc5d894e" | |
| 127 | 127 | |
| 128 | 128 | /* |
| 129 | 129 | ** CAPI3REF: Run-Time Library Version Numbers |
| 130 | 130 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 131 | 131 | ** |
| 132 | 132 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -121,11 +121,11 @@ | |
| 121 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 122 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 123 | */ |
| 124 | #define SQLITE_VERSION "3.15.0" |
| 125 | #define SQLITE_VERSION_NUMBER 3015000 |
| 126 | #define SQLITE_SOURCE_ID "2016-10-01 23:55:23 fe07609efc31c4639c40fbda501c55f443756ad2" |
| 127 | |
| 128 | /* |
| 129 | ** CAPI3REF: Run-Time Library Version Numbers |
| 130 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 131 | ** |
| 132 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -121,11 +121,11 @@ | |
| 121 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 122 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 123 | */ |
| 124 | #define SQLITE_VERSION "3.15.0" |
| 125 | #define SQLITE_VERSION_NUMBER 3015000 |
| 126 | #define SQLITE_SOURCE_ID "2016-10-04 12:20:12 3a9d802fda10585654332b314d317250dc5d894e" |
| 127 | |
| 128 | /* |
| 129 | ** CAPI3REF: Run-Time Library Version Numbers |
| 130 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 131 | ** |
| 132 |