diff options
author | drh <drh@noemail.net> | 2018-02-26 03:20:18 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2018-02-26 03:20:18 +0000 |
commit | 007c843b0f9b832c21eac4274b361173544c9bb7 (patch) | |
tree | b254ec129a48c7d9c9f6c883a1c70a978abd1e19 /src/expr.c | |
parent | 5facffbc70893cea166235f87ac3c2ae7ee6fbe1 (diff) | |
download | sqlite-007c843b0f9b832c21eac4274b361173544c9bb7.tar.gz sqlite-007c843b0f9b832c21eac4274b361173544c9bb7.zip |
Experimental implementation of IS TRUE and IS FALSE operators. All TRUE and
FALSE to act like constants if the names do not resolve to a column name.
FossilOrigin-Name: 40314bc999af08ab10e654241208842b4bb95b19858d11249444372250ea4160
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/expr.c b/src/expr.c index 1b8773492..5079035ca 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3543,6 +3543,14 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ codeInteger(pParse, pExpr, 0, target); return target; } + case TK_TRUE: { + sqlite3VdbeAddOp2(v, OP_Integer, 1, target); + return target; + } + case TK_FALSE: { + sqlite3VdbeAddOp2(v, OP_Integer, 0, target); + return target; + } #ifndef SQLITE_OMIT_FLOATING_POINT case TK_FLOAT: { assert( !ExprHasProperty(pExpr, EP_IntValue) ); @@ -3698,6 +3706,13 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ sqlite3VdbeAddOp2(v, op, r1, inReg); break; } + case TK_ISTRUE: { + r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); + testcase( regFree1==0 ); + sqlite3VdbeAddOp2(v, OP_Not, r1, inReg); + sqlite3VdbeAddOp2(v, OP_Not, inReg, inReg); + break; + } case TK_ISNULL: case TK_NOTNULL: { int addr; @@ -4473,6 +4488,11 @@ void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){ sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull); break; } + case TK_ISTRUE: { + testcase( jumpIfNull==0 ); + sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull); + break; + } case TK_IS: case TK_ISNOT: testcase( op==TK_IS ); @@ -4627,6 +4647,11 @@ void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){ sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull); break; } + case TK_ISTRUE: { + testcase( jumpIfNull==0 ); + sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull); + break; + } case TK_IS: case TK_ISNOT: testcase( pExpr->op==TK_IS ); |