Add the OP_ZeroOrNull opcode and use it to compute boolean values for
scalar comparisons, rather than the SQLITE_STOREP2 parameter to the comparison opcode. FossilOrigin-Name: 93781b6f10a94fb273204b95156a8b90e07071f28c89e7966c659a0f44f60e98
This commit is contained in:
+8
-2
@@ -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);
|
||||
|
||||
+18
@@ -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
|
||||
**
|
||||
|
||||
Reference in New Issue
Block a user