aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2014-08-04 18:50:54 +0000
committerdrh <drh@noemail.net>2014-08-04 18:50:54 +0000
commit7248a8b2b95a99d7fb7af7e5a3481f9cfcb95e3e (patch)
tree54ff754388b959bc21c8dd8cd53ffb245297cfaf /src/expr.c
parenta976979b6e1c01dbdfaeaddee5b3c80fc924ef94 (diff)
downloadsqlite-7248a8b2b95a99d7fb7af7e5a3481f9cfcb95e3e.tar.gz
sqlite-7248a8b2b95a99d7fb7af7e5a3481f9cfcb95e3e.zip
Further enhancements to IN-operator processing.
FossilOrigin-Name: 7fdf26da1d2f40b80f9e44ff6f5af22ace8f95f3
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/expr.c b/src/expr.c
index 86787a9c3..6816d560d 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -1368,6 +1368,9 @@ int sqlite3ExprCanBeNull(const Expr *p){
case TK_FLOAT:
case TK_BLOB:
return 0;
+ case TK_COLUMN:
+ assert( p->pTab!=0 );
+ return p->iColumn>=0 && p->pTab->aCol[p->iColumn].notNull==0;
default:
return 1;
}
@@ -2038,16 +2041,18 @@ static void sqlite3ExprCodeIN(
/* If the LHS is NULL, then the result is either false or NULL depending
** on whether the RHS is empty or not, respectively.
*/
- if( destIfNull==destIfFalse ){
- /* Shortcut for the common case where the false and NULL outcomes are
- ** the same. */
- sqlite3VdbeAddOp2(v, OP_IsNull, r1, destIfNull); VdbeCoverage(v);
- }else{
- int addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, r1); VdbeCoverage(v);
- sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);
- VdbeCoverage(v);
- sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfNull);
- sqlite3VdbeJumpHere(v, addr1);
+ if( sqlite3ExprCanBeNull(pExpr->pLeft) ){
+ if( destIfNull==destIfFalse ){
+ /* Shortcut for the common case where the false and NULL outcomes are
+ ** the same. */
+ sqlite3VdbeAddOp2(v, OP_IsNull, r1, destIfNull); VdbeCoverage(v);
+ }else{
+ int addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, r1); VdbeCoverage(v);
+ sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);
+ VdbeCoverage(v);
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfNull);
+ sqlite3VdbeJumpHere(v, addr1);
+ }
}
if( eType==IN_INDEX_ROWID ){