diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/expr.c | 10 | ||||
-rw-r--r-- | src/vdbe.c | 18 |
2 files changed, 26 insertions, 2 deletions
diff --git a/src/expr.c b/src/expr.c index e3d28f4d4..403ecc8c2 100644 --- a/src/expr.c +++ b/src/expr.c @@ -4054,9 +4054,15 @@ expr_code_doover: }else{ r1 = sqlite3ExprCodeTemp(pParse, pLeft, ®Free1); r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); - codeCompare(pParse, pLeft, pExpr->pRight, op, - r1, r2, inReg, SQLITE_STOREP2 | p5, + sqlite3VdbeAddOp2(v, OP_Integer, 1, inReg); + codeCompare(pParse, pLeft, pExpr->pRight, op, r1, r2, + sqlite3VdbeCurrentAddr(v)+2, p5, ExprHasProperty(pExpr,EP_Commuted)); + if( p5==SQLITE_NULLEQ ){ + sqlite3VdbeAddOp2(v, OP_Integer, 0, inReg); + }else{ + sqlite3VdbeAddOp3(v, OP_ZeroOrNull, r1, inReg, r2); + } assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt); assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le); assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt); diff --git a/src/vdbe.c b/src/vdbe.c index 57cbf864f..a132fd67c 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2502,6 +2502,24 @@ case OP_IsNull: { /* same as TK_ISNULL, jump, in1 */ break; } +/* Opcode: ZeroOrNull P1 P2 P3 * * +** Synopsis: r[P2] = (P1,P3 NOT NULL) ? 0 : NULL; +** +** If both registers P1 and P3 are NOT NULL, then store a zero in +** register P2. If either register P1 or register P3 or both contain +** a NULL then store a NULL in register P2. +*/ +case OP_ZeroOrNull: { /* in1, out2, in3 */ + if( (aMem[pOp->p1].flags & MEM_Null)!=0 + || (aMem[pOp->p3].flags & MEM_Null)!=0 + ){ + sqlite3VdbeMemSetNull(aMem + pOp->p2); + }else{ + sqlite3VdbeMemSetInt64(aMem + pOp->p2, 0); + } + break; +} + /* Opcode: NotNull P1 P2 * * * ** Synopsis: if r[P1]!=NULL goto P2 ** |