diff options
author | drh <drh@noemail.net> | 2013-09-06 15:23:29 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-09-06 15:23:29 +0000 |
commit | cca9f3d291179e8126f29622f1a5c43105d1a045 (patch) | |
tree | 1a42774e29913694f47f65b6fe916fb253b147e0 /src/expr.c | |
parent | d36e1041120280adfc9612d8f6e4ade318b3ffa0 (diff) | |
download | sqlite-cca9f3d291179e8126f29622f1a5c43105d1a045.tar.gz sqlite-cca9f3d291179e8126f29622f1a5c43105d1a045.zip |
Initial implementation of the unlikely() SQL function used as a hint to
the query planner.
FossilOrigin-Name: 036fc37a034093a4c6fc190633bd41c2b7230d77
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/expr.c b/src/expr.c index 6587ee1f7..ece029384 100644 --- a/src/expr.c +++ b/src/expr.c @@ -89,8 +89,16 @@ Expr *sqlite3ExprAddCollateString(Parse *pParse, Expr *pExpr, const char *zC){ ** an expression. */ Expr *sqlite3ExprSkipCollate(Expr *pExpr){ - while( pExpr && (pExpr->op==TK_COLLATE || pExpr->op==TK_AS) ){ - pExpr = pExpr->pLeft; + while( pExpr ){ + if( pExpr->op==TK_COLLATE || pExpr->op==TK_AS ){ + pExpr = pExpr->pLeft; + }else if( ExprHasAnyProperty(pExpr, EP_Hint) ){ + assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); + assert( pExpr->x.pList->nExpr>0 ); + pExpr = pExpr->x.pList->a[0].pExpr; + }else{ + break; + } } return pExpr; } @@ -2649,6 +2657,14 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ break; } + /* The UNLIKELY() function is a no-op. The result is the value + ** of the first argument. + */ + if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){ + assert( nFarg>=1 ); + sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target); + break; + } if( pFarg ){ r1 = sqlite3GetTempRange(pParse, nFarg); |