Comment improvements. Put ALWAYS and NEVER macros on three unreachable
branches.
FossilOrigin-Name: 397617009e07004596476d6f5644fdf84c376f54
diff --git a/src/expr.c b/src/expr.c
index 982605d..f067079 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -2443,9 +2443,9 @@
ExprList *pEList = pSelect->pEList;
assert( !isRowid );
- if( pEList->nExpr!=nVal ){
- sqlite3SubselectError(pParse, pEList->nExpr, nVal);
- }else{
+ /* If the LHS and RHS of the IN operator do not match, that
+ ** error will have been caught long before we reach this point. */
+ if( ALWAYS(pEList->nExpr==nVal) ){
SelectDest dest;
int i;
sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
diff --git a/src/where.c b/src/where.c
index 30854ee..74da408 100644
--- a/src/where.c
+++ b/src/where.c
@@ -2224,7 +2224,11 @@
** this case is 3.
*/
int whereRangeVectorLen(
- Parse *pParse, int iCur, Index *pIdx, int nEq, WhereTerm *pTerm
+ Parse *pParse, /* Parsing context */
+ int iCur, /* Cursor open on pIdx */
+ Index *pIdx, /* The index to be used for a inequality constraint */
+ int nEq, /* Number of prior equality constraints on same index */
+ WhereTerm *pTerm /* The vector inequality constraint */
){
int nCmp = sqlite3ExprVectorSize(pTerm->pExpr->pLeft);
int i;
@@ -2261,7 +2265,8 @@
if( aff!=idxaff ) break;
pColl = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);
- if( pColl==0 || sqlite3StrICmp(pColl->zName, pIdx->azColl[i+nEq]) ) break;
+ if( NEVER(pColl==0) ) break;
+ if( sqlite3StrICmp(pColl->zName, pIdx->azColl[i+nEq]) ) break;
}
return i;
}
@@ -3573,7 +3578,11 @@
isOrderDistinct = 0;
}
continue;
- }else if( eOp & WO_IN ){
+ }else if( ALWAYS(eOp & WO_IN) ){
+ /* ALWAYS() justification: eOp is an equality operator due to the
+ ** j<pLoop->u.btree.nEq constraint above. Any equality other
+ ** than WO_IN is captured by the previous "if". So this one
+ ** always has to be WO_IN. */
Expr *pX = pLoop->aLTerm[j]->pExpr;
for(i=j+1; i<pLoop->u.btree.nEq; i++){
if( pLoop->aLTerm[i]->pExpr==pX ){
diff --git a/src/whereexpr.c b/src/whereexpr.c
index 823a2df..0032898 100644
--- a/src/whereexpr.c
+++ b/src/whereexpr.c
@@ -846,7 +846,9 @@
** inequality constraint (>, <, >= or <=), perform the processing
** on the first element of the vector. */
assert( TK_GT+1==TK_LE && TK_GT+2==TK_LT && TK_GT+3==TK_GE );
- if( pExpr->op==TK_VECTOR && (op>=TK_GT && op<=TK_GE) ){
+ assert( TK_IS<TK_GE && TK_ISNULL<TK_GE && TK_IN<TK_GE );
+ assert( op<=TK_GE );
+ if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){
pExpr = pExpr->x.pList->a[0].pExpr;
}