Index: ext/expert/expert1.test ================================================================== --- ext/expert/expert1.test +++ ext/expert/expert1.test @@ -289,10 +289,19 @@ } { CREATE INDEX t2_idx_00000064 ON t2(d); 0|0|0|SEARCH TABLE t2 USING INDEX t2_idx_00000064 (d=?) 0|1|1|SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?) } + +do_setup_rec_test $tn.16 { + CREATE TABLE t1(a, b); +} { + SELECT * FROM t1 WHERE b IS NOT NULL; +} { + (no new indexes) + 0|0|0|SCAN TABLE t1 +} } proc do_candidates_test {tn sql res} { set res [squish [string trim $res]] Index: src/where.c ================================================================== --- src/where.c +++ src/where.c @@ -3158,13 +3158,16 @@ */ const char *sqlite3_vtab_collation(sqlite3 *db, int iCons){ struct BestIndexCtx *p = (struct BestIndexCtx*)db->pBestIndexCtx; const char *zRet = 0; if( p && iCons>=0 && iConspIdxInfo->nConstraint ){ + CollSeq *pC = 0; int iTerm = p->pIdxInfo->aConstraint[iCons].iTermOffset; Expr *pX = p->pWC->a[iTerm].pExpr; - CollSeq *pC = sqlite3BinaryCompareCollSeq(p->pParse,pX->pLeft,pX->pRight); + if( pX->pLeft ){ + pC = sqlite3BinaryCompareCollSeq(p->pParse, pX->pLeft, pX->pRight); + } zRet = (pC ? pC->zName : "BINARY"); } return zRet; }