/ Check-in [bbab9621]
Login

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

Overview
Comment:Simplify the affinity handling logic in codeAllEqualityTerms(). Logically the same, just a little easier to read and understand.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rowvalue
Files: files | file ages | folders
SHA1: bbab9621f512b04684163b98b6fc669c68038044
User & Date: drh 2016-09-07 13:30:40
Context
2016-09-07
19:37
Fix a problem handling expressions like "(a, b) IN (SELECT ... ORDER BY 1, 2)" when there is an index on "a" but not "b". Closed-Leaf check-in: 7f2c5c9e user: dan tags: rowvalue
13:30
Simplify the affinity handling logic in codeAllEqualityTerms(). Logically the same, just a little easier to read and understand. check-in: bbab9621 user: drh tags: rowvalue
13:12
Merge fixes from trunk. check-in: 193f036c user: drh tags: rowvalue
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/wherecode.c.

654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672

673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
      if( nReg==1 ){
        sqlite3ReleaseTempReg(pParse, regBase);
        regBase = r1;
      }else{
        sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j);
      }
    }
    testcase( pTerm->eOperator & WO_ISNULL );
    testcase( pTerm->eOperator & WO_IN );
    if( (pTerm->eOperator & WO_ISNULL)==0 ){
      if( pTerm->eOperator & WO_IN ){
        if( pTerm->pExpr->flags & EP_xIsSelect ){
          /* No affinity ever needs to be (or should be) applied to a value
          ** from the RHS of an "? IN (SELECT ...)" expression. The 
          ** sqlite3FindInIndex() routine has already ensured that the 
          ** affinity of the comparison has been applied to the value.  */
          if( zAff ) zAff[j] = SQLITE_AFF_BLOB;
        }
      }else{

        Expr *pRight = pTerm->pExpr->pRight;
        if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){
          sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
          VdbeCoverage(v);
        }
        if( zAff ){
          if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){
            zAff[j] = SQLITE_AFF_BLOB;
          }
          if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){
            zAff[j] = SQLITE_AFF_BLOB;
          }
        }
      }
    }
  }
  *pzAff = zAff;
  return regBase;
}







<
<
<
|
|
|
|
|
|
|
|
<
>
|
|
|
|
|
|
|
|
|
|
|
<







654
655
656
657
658
659
660



661
662
663
664
665
666
667
668

669
670
671
672
673
674
675
676
677
678
679
680

681
682
683
684
685
686
687
      if( nReg==1 ){
        sqlite3ReleaseTempReg(pParse, regBase);
        regBase = r1;
      }else{
        sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j);
      }
    }



    if( pTerm->eOperator & WO_IN ){
      if( pTerm->pExpr->flags & EP_xIsSelect ){
        /* No affinity ever needs to be (or should be) applied to a value
        ** from the RHS of an "? IN (SELECT ...)" expression. The 
        ** sqlite3FindInIndex() routine has already ensured that the 
        ** affinity of the comparison has been applied to the value.  */
        if( zAff ) zAff[j] = SQLITE_AFF_BLOB;
      }

    }else if( (pTerm->eOperator & WO_ISNULL)==0 ){
      Expr *pRight = pTerm->pExpr->pRight;
      if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){
        sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
        VdbeCoverage(v);
      }
      if( zAff ){
        if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){
          zAff[j] = SQLITE_AFF_BLOB;
        }
        if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){
          zAff[j] = SQLITE_AFF_BLOB;

        }
      }
    }
  }
  *pzAff = zAff;
  return regBase;
}