aboutsummaryrefslogtreecommitdiff
path: root/src/resolve.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2018-02-26 18:49:05 +0000
committerdrh <drh@noemail.net>2018-02-26 18:49:05 +0000
commit8abed7b90769a6f63ef2681cfd4ae92d617b883f (patch)
tree753870862176408c8f5871fe7e7558939c9395ae /src/resolve.c
parentbc8f68a3a05ab6e37127685177d2ca182688f60f (diff)
downloadsqlite-8abed7b90769a6f63ef2681cfd4ae92d617b883f.tar.gz
sqlite-8abed7b90769a6f63ef2681cfd4ae92d617b883f.zip
Refactor for correct NULL handling in the IS TRUE, IS FALSE, IS NOT TRUE,
and IS NOT FALSE operators. FossilOrigin-Name: cf2abd59be9971a55bd3d6c5df374c6aaa23bf81819482b42f01ee2484dcd739
Diffstat (limited to 'src/resolve.c')
-rw-r--r--src/resolve.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/resolve.c b/src/resolve.c
index fb00788dd..c6b086c3a 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -437,13 +437,9 @@ static int lookupName(
pExpr->pTab = 0;
return WRC_Prune;
}
- if( sqlite3StrICmp(zCol, "true")==0 ){
- pExpr->op = TK_TRUE;
- pExpr->pTab = 0;
- return WRC_Prune;
- }
- if( sqlite3StrICmp(zCol, "false")==0 ){
- pExpr->op = TK_FALSE;
+ if( sqlite3StrICmp(zCol, "true")==0 || sqlite3StrICmp(zCol, "false")==0 ){
+ pExpr->op = TK_TRUEFALSE;
+ pExpr->iTable = zCol[4]==0;
pExpr->pTab = 0;
return WRC_Prune;
}
@@ -796,28 +792,30 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
break;
}
case TK_IS:
- /* Handle special cases of "x IS TRUE" and "x IS FALSE". The first
- ** is transformed into "+x" and the second into "NOT x". */
- if( pExpr->pRight->op==TK_ID ){
- int rc = resolveExprStep(pWalker, pExpr->pRight);
+ case TK_ISNOT: {
+ Expr *pRight;
+ assert( !ExprHasProperty(pExpr, EP_Reduced) );
+ /* Handle special cases of "x IS TRUE", "x IS FALSE", "x IS NOT TRUE",
+ ** and "x IS NOT FALSE". */
+ if( (pRight = pExpr->pRight)->op==TK_ID ){
+ int rc = resolveExprStep(pWalker, pRight);
if( rc==WRC_Abort ) return WRC_Abort;
- if( pExpr->pRight->op==TK_TRUE ){
- pExpr->op = TK_ISTRUE;
- return WRC_Continue;
- }else if( pExpr->pRight->op==TK_FALSE ){
- pExpr->op = TK_NOT;
+ if( pRight->op==TK_TRUEFALSE ){
+ assert( pRight->iTable==0 || pRight->iTable==1 );
+ pExpr->op2 = pExpr->op;
+ pExpr->op = TK_TRUTH;
return WRC_Continue;
}
}
/* Fall thru */
+ }
case TK_BETWEEN:
case TK_EQ:
case TK_NE:
case TK_LT:
case TK_LE:
case TK_GT:
- case TK_GE:
- case TK_ISNOT: {
+ case TK_GE: {
int nLeft, nRight;
if( pParse->db->mallocFailed ) break;
assert( pExpr->pLeft!=0 );