Protect the WhereTerm.u union using nearby assert()s and/or branches.
FossilOrigin-Name: 8a56de5b9c6f4522000f8d991373490b67b9e9d97f03c1ca2cf32816d84789ef
This commit is contained in:
parent
285f2ef4ad
commit
220f0d6f8e
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C Protect\sthe\sJsonNode.u\sunion\susing\snearby\sassert()s\sand\sbranches.
|
||||
D 2021-10-15T16:15:04.901
|
||||
C Protect\sthe\sWhereTerm.u\sunion\susing\snearby\sassert()s\sand/or\sbranches.
|
||||
D 2021-10-15T17:06:16.174
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -636,10 +636,10 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
|
||||
F src/wal.c 2be08331d798237ad5d7ae0b252700ffb2b63189cb18d993496d009a93e2f81c
|
||||
F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
|
||||
F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b
|
||||
F src/where.c 782d333e2102eaf965d42d7835672bd851b933c8b7b1e2d1e53213a746acaa3d
|
||||
F src/where.c ecabef93b0f14442a73eca205fc960428984d75fbdc7d60226b7fc9cac127187
|
||||
F src/whereInt.h 83877a75a1bce056ea44aff02f1dfa958ad1d6038c213ddadb8652003b45151d
|
||||
F src/wherecode.c 5a7d3c80d32a81c6d8a26e0d8554d3b61fcb4d94ae5b0809766080f95b1592a5
|
||||
F src/whereexpr.c 4514a162d878b6523a698fac1d760991b5728be0d7e2b2b0687aa175144dcf15
|
||||
F src/wherecode.c a1d79cc5a11f44b079bf2352e542ddb265f84cfa6c835d40a9f195dbe5fff83e
|
||||
F src/whereexpr.c 17bdbf4f5b490e70a18635498f0b910a558f953a9bf80af7f19cbde6e60e6825
|
||||
F src/window.c 0dff6fedf61493490d21ced5d7a7b4321d4c0db6c8123f0179c46080a860850a
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627
|
||||
@ -1929,7 +1929,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 69a3ff0cc159cdf84a5367eaf708882ddeda4fa65c96a5b546ae4a0114f02cb7
|
||||
R ede285ffb2c5c992e5f7bd66e443ce38
|
||||
P 7b8ea2298927fd34f27b3345add3ce751ed728387fe3d9207b601ba6449d5af9
|
||||
R f8f24b4e90ad954c123bdee77c1d3c2d
|
||||
U drh
|
||||
Z 01fdfdb7db3b89a4154d6f89726d1593
|
||||
Z 0a05442607cc8af1d2c0566962c413f4
|
||||
|
@ -1 +1 @@
|
||||
7b8ea2298927fd34f27b3345add3ce751ed728387fe3d9207b601ba6449d5af9
|
||||
8a56de5b9c6f4522000f8d991373490b67b9e9d97f03c1ca2cf32816d84789ef
|
22
src/where.c
22
src/where.c
@ -286,8 +286,10 @@ static WhereTerm *whereScanNext(WhereScan *pScan){
|
||||
iColumn = pScan->aiColumn[pScan->iEquiv-1];
|
||||
iCur = pScan->aiCur[pScan->iEquiv-1];
|
||||
assert( pWC!=0 );
|
||||
assert( iCur>=0 );
|
||||
do{
|
||||
for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
|
||||
assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 || pTerm->leftCursor<0 );
|
||||
if( pTerm->leftCursor==iCur
|
||||
&& pTerm->u.x.leftColumn==iColumn
|
||||
&& (iColumn!=XN_EXPR
|
||||
@ -727,6 +729,7 @@ static int termCanDriveIndex(
|
||||
return 0;
|
||||
}
|
||||
if( (pTerm->prereqRight & notReady)!=0 ) return 0;
|
||||
assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
|
||||
if( pTerm->u.x.leftColumn<0 ) return 0;
|
||||
aff = pSrc->pTab->aCol[pTerm->u.x.leftColumn].affinity;
|
||||
if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0;
|
||||
@ -799,8 +802,11 @@ static void constructAutomaticIndex(
|
||||
sqlite3ExprDup(pParse->db, pExpr, 0));
|
||||
}
|
||||
if( termCanDriveIndex(pTerm, pSrc, notReady) ){
|
||||
int iCol = pTerm->u.x.leftColumn;
|
||||
Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);
|
||||
int iCol;
|
||||
Bitmask cMask;
|
||||
assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
|
||||
iCol = pTerm->u.x.leftColumn;
|
||||
cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);
|
||||
testcase( iCol==BMS );
|
||||
testcase( iCol==BMS-1 );
|
||||
if( !sentWarning ){
|
||||
@ -852,8 +858,11 @@ static void constructAutomaticIndex(
|
||||
idxCols = 0;
|
||||
for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
|
||||
if( termCanDriveIndex(pTerm, pSrc, notReady) ){
|
||||
int iCol = pTerm->u.x.leftColumn;
|
||||
Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);
|
||||
int iCol;
|
||||
Bitmask cMask;
|
||||
assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
|
||||
iCol = pTerm->u.x.leftColumn;
|
||||
cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);
|
||||
testcase( iCol==BMS-1 );
|
||||
testcase( iCol==BMS );
|
||||
if( (idxCols & cMask)==0 ){
|
||||
@ -980,6 +989,7 @@ static sqlite3_index_info *allocateIndexInfo(
|
||||
testcase( pTerm->eOperator & WO_ALL );
|
||||
if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
|
||||
if( pTerm->wtFlags & TERM_VNULL ) continue;
|
||||
assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
|
||||
assert( pTerm->u.x.leftColumn>=(-1) );
|
||||
nTerm++;
|
||||
}
|
||||
@ -1040,6 +1050,7 @@ static sqlite3_index_info *allocateIndexInfo(
|
||||
){
|
||||
continue;
|
||||
}
|
||||
assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
|
||||
assert( pTerm->u.x.leftColumn>=(-1) );
|
||||
pIdxCons[j].iColumn = pTerm->u.x.leftColumn;
|
||||
pIdxCons[j].iTermOffset = i;
|
||||
@ -1803,6 +1814,7 @@ void sqlite3WhereTermPrint(WhereTerm *pTerm, int iTerm){
|
||||
if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L';
|
||||
if( pTerm->wtFlags & TERM_CODED ) zType[3] = 'C';
|
||||
if( pTerm->eOperator & WO_SINGLE ){
|
||||
assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
|
||||
sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}",
|
||||
pTerm->leftCursor, pTerm->u.x.leftColumn);
|
||||
}else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){
|
||||
@ -1820,7 +1832,7 @@ void sqlite3WhereTermPrint(WhereTerm *pTerm, int iTerm){
|
||||
sqlite3DebugPrintf(" prob=%-3d prereq=%llx,%llx",
|
||||
pTerm->truthProb, (u64)pTerm->prereqAll, (u64)pTerm->prereqRight);
|
||||
}
|
||||
if( pTerm->u.x.iField ){
|
||||
if( (pTerm->eOperator & (WO_OR|WO_AND))==0 && pTerm->u.x.iField ){
|
||||
sqlite3DebugPrintf(" iField=%d", pTerm->u.x.iField);
|
||||
}
|
||||
if( pTerm->iParent>=0 ){
|
||||
|
@ -430,7 +430,9 @@ static Expr *removeUnindexableInClauseTerms(
|
||||
pOrigLhs = pNew->pLeft->x.pList;
|
||||
for(i=iEq; i<pLoop->nLTerm; i++){
|
||||
if( pLoop->aLTerm[i]->pExpr==pX ){
|
||||
int iField = pLoop->aLTerm[i]->u.x.iField - 1;
|
||||
int iField;
|
||||
assert( (pLoop->aLTerm[i]->eOperator & (WO_OR|WO_AND))==0 );
|
||||
iField = pLoop->aLTerm[i]->u.x.iField - 1;
|
||||
if( pOrigRhs->a[iField].pExpr==0 ) continue; /* Duplicate PK column */
|
||||
pRhs = sqlite3ExprListAppend(pParse, pRhs, pOrigRhs->a[iField].pExpr);
|
||||
pOrigRhs->a[iField].pExpr = 0;
|
||||
@ -2471,6 +2473,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
|
||||
#endif
|
||||
assert( !ExprHasProperty(pE, EP_FromJoin) );
|
||||
assert( (pTerm->prereqRight & pLevel->notReady)!=0 );
|
||||
assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
|
||||
pAlt = sqlite3WhereFindTerm(pWC, iCur, pTerm->u.x.leftColumn, notReady,
|
||||
WO_EQ|WO_IN|WO_IS, 0);
|
||||
if( pAlt==0 ) continue;
|
||||
|
@ -694,6 +694,7 @@ static void exprAnalyzeOrTerm(
|
||||
pOrTerm->u.pAndInfo = pAndInfo;
|
||||
pOrTerm->wtFlags |= TERM_ANDINFO;
|
||||
pOrTerm->eOperator = WO_AND;
|
||||
pOrTerm->leftCursor = -1;
|
||||
pAndWC = &pAndInfo->wc;
|
||||
memset(pAndWC->aStatic, 0, sizeof(pAndWC->aStatic));
|
||||
sqlite3WhereClauseInit(pAndWC, pWC->pWInfo);
|
||||
@ -736,11 +737,10 @@ static void exprAnalyzeOrTerm(
|
||||
** empty.
|
||||
*/
|
||||
pOrInfo->indexable = indexable;
|
||||
pTerm->eOperator = WO_OR;
|
||||
pTerm->leftCursor = -1;
|
||||
if( indexable ){
|
||||
pTerm->eOperator = WO_OR;
|
||||
pWC->hasOr = 1;
|
||||
}else{
|
||||
pTerm->eOperator = WO_OR;
|
||||
}
|
||||
|
||||
/* For a two-way OR, attempt to implementation case 2.
|
||||
@ -813,6 +813,7 @@ static void exprAnalyzeOrTerm(
|
||||
assert( pOrTerm->wtFlags & (TERM_COPIED|TERM_VIRTUAL) );
|
||||
continue;
|
||||
}
|
||||
assert( (pOrTerm->eOperator & (WO_OR|WO_AND))==0 );
|
||||
iColumn = pOrTerm->u.x.leftColumn;
|
||||
iCursor = pOrTerm->leftCursor;
|
||||
pLeft = pOrTerm->pExpr->pLeft;
|
||||
@ -833,6 +834,7 @@ static void exprAnalyzeOrTerm(
|
||||
okToChngToIN = 1;
|
||||
for(; i>=0 && okToChngToIN; i--, pOrTerm++){
|
||||
assert( pOrTerm->eOperator & WO_EQ );
|
||||
assert( (pOrTerm->eOperator & (WO_OR|WO_AND))==0 );
|
||||
if( pOrTerm->leftCursor!=iCursor ){
|
||||
pOrTerm->wtFlags &= ~TERM_OR_OK;
|
||||
}else if( pOrTerm->u.x.leftColumn!=iColumn || (iColumn==XN_EXPR
|
||||
@ -869,6 +871,7 @@ static void exprAnalyzeOrTerm(
|
||||
for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0; i--, pOrTerm++){
|
||||
if( (pOrTerm->wtFlags & TERM_OR_OK)==0 ) continue;
|
||||
assert( pOrTerm->eOperator & WO_EQ );
|
||||
assert( (pOrTerm->eOperator & (WO_OR|WO_AND))==0 );
|
||||
assert( pOrTerm->leftCursor==iCursor );
|
||||
assert( pOrTerm->u.x.leftColumn==iColumn );
|
||||
pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0);
|
||||
@ -1118,6 +1121,7 @@ static void exprAnalyze(
|
||||
|
||||
if( exprMightBeIndexed(pSrc, prereqLeft, aiCurCol, pLeft, op) ){
|
||||
pTerm->leftCursor = aiCurCol[0];
|
||||
assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
|
||||
pTerm->u.x.leftColumn = aiCurCol[1];
|
||||
pTerm->eOperator = operatorMask(op) & opMask;
|
||||
}
|
||||
@ -1155,6 +1159,7 @@ static void exprAnalyze(
|
||||
}
|
||||
pNew->wtFlags |= exprCommute(pParse, pDup);
|
||||
pNew->leftCursor = aiCurCol[0];
|
||||
assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
|
||||
pNew->u.x.leftColumn = aiCurCol[1];
|
||||
testcase( (prereqLeft | extraRight) != prereqLeft );
|
||||
pNew->prereqRight = prereqLeft | extraRight;
|
||||
|
Loading…
Reference in New Issue
Block a user