/ Check-in [92ba2821]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Refinements to the enhanced IN-operator logic.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | IN-operator-improvements
Files: files | file ages | folders
SHA1: 92ba2821468ecbfac2469161d81c873de67b2243
User & Date: drh 2014-08-04 16:39:39
Context
2014-08-04
18:50
Further enhancements to IN-operator processing. check-in: 7fdf26da user: drh tags: IN-operator-improvements
16:39
Refinements to the enhanced IN-operator logic. check-in: 92ba2821 user: drh tags: IN-operator-improvements
2014-08-02
21:03
Enhancements to the code generator for the IN operator that result in much faster queries in some cases, for example when the RHS of the IN operator changes for each row of a large table scan. check-in: 436e8842 user: drh tags: IN-operator-improvements
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

  2002   2002       ExprList *pList = pExpr->x.pList;
  2003   2003       CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
  2004   2004       int labelOk = sqlite3VdbeMakeLabel(v);
  2005   2005       int r2, regToFree;
  2006   2006       int regCkNull = 0;
  2007   2007       int ii;
  2008   2008       assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
  2009         -    sqlite3VdbeAddOp2(v, OP_IsNull, r1, destIfNull); VdbeCoverage(v);
  2010   2009       if( destIfNull!=destIfFalse ){
  2011   2010         regCkNull = sqlite3GetTempReg(pParse);
  2012         -      sqlite3VdbeAddOp2(v, OP_Integer, 0, regCkNull);
         2011  +      sqlite3VdbeAddOp3(v, OP_BitAnd, r1, r1, regCkNull);
  2013   2012       }
  2014   2013       for(ii=0; ii<pList->nExpr; ii++){
  2015   2014         r2 = sqlite3ExprCodeTemp(pParse, pList->a[ii].pExpr, &regToFree);
  2016         -      if( regCkNull ){
         2015  +      if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){
  2017   2016           sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull);
  2018   2017         }
  2019   2018         if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){
  2020   2019           sqlite3VdbeAddOp4(v, OP_Eq, r1, labelOk, r2,
  2021   2020                             (void*)pColl, P4_COLLSEQ); VdbeCoverage(v);
  2022   2021           sqlite3VdbeChangeP5(v, affinity);
  2023   2022         }else{
................................................................................
  2718   2717         assert( TK_NOTNULL==OP_NotNull ); testcase( op==TK_NOTNULL );
  2719   2718         sqlite3VdbeAddOp2(v, OP_Integer, 1, target);
  2720   2719         r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
  2721   2720         testcase( regFree1==0 );
  2722   2721         addr = sqlite3VdbeAddOp1(v, op, r1);
  2723   2722         VdbeCoverageIf(v, op==TK_ISNULL);
  2724   2723         VdbeCoverageIf(v, op==TK_NOTNULL);
  2725         -      sqlite3VdbeAddOp2(v, OP_AddImm, target, -1);
         2724  +      sqlite3VdbeAddOp2(v, OP_Integer, 0, target);
  2726   2725         sqlite3VdbeJumpHere(v, addr);
  2727   2726         break;
  2728   2727       }
  2729   2728       case TK_AGG_FUNCTION: {
  2730   2729         AggInfo *pInfo = pExpr->pAggInfo;
  2731   2730         if( pInfo==0 ){
  2732   2731           assert( !ExprHasProperty(pExpr, EP_IntValue) );