diff options
author | drh <drh@noemail.net> | 2020-01-01 15:43:30 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2020-01-01 15:43:30 +0000 |
commit | 171c50ec381c5fb4ff1e8b258a49fbf810917011 (patch) | |
tree | 23abd670e94f1accb03348a16463ccda9f60fab0 /src/expr.c | |
parent | 25c4296bd97072f7b5a13f4eda021bd2782bcc45 (diff) | |
download | sqlite-171c50ec381c5fb4ff1e8b258a49fbf810917011.tar.gz sqlite-171c50ec381c5fb4ff1e8b258a49fbf810917011.zip |
New test-only SQL functions: implies_nonnull_row(), expr_compare(), and
expr_implies_expr(). The SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test-control
is modified to toggle internal function access on and off for a single
database connection.
FossilOrigin-Name: 473892a8eceacf24d57fd0c72ff2a0b8be4e0d75e0af7a30bdb24fbc3b453601
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/expr.c b/src/expr.c index 629768f3a..da7e4bc34 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3608,15 +3608,52 @@ static int exprCodeInlineFunction( break; } - case INLINEFUNC_unlikely: { + default: { /* The UNLIKELY() function is a no-op. The result is the value ** of the first argument. */ - assert( nFarg>=1 ); + assert( nFarg==1 || nFarg==2 ); target = sqlite3ExprCodeTarget(pParse, pFarg->a[0].pExpr, target); break; } + /*********************************************************************** + ** Test-only SQL functions that are only usable if enabled + ** via SQLITE_TESTCTRL_INTERNAL_FUNCTIONS + */ + case INLINEFUNC_expr_compare: { + /* Compare two expressions using sqlite3ExprCompare() */ + assert( nFarg==2 ); + sqlite3VdbeAddOp2(v, OP_Integer, + sqlite3ExprCompare(0,pFarg->a[0].pExpr, pFarg->a[1].pExpr,-1), + target); + break; + } + + case INLINEFUNC_expr_implies_expr: { + /* Compare two expressions using sqlite3ExprImpliesExpr() */ + assert( nFarg==2 ); + sqlite3VdbeAddOp2(v, OP_Integer, + sqlite3ExprImpliesExpr(pParse,pFarg->a[0].pExpr, pFarg->a[1].pExpr,-1), + target); + break; + } + + case INLINEFUNC_implies_nonnull_row: { + /* REsult of sqlite3ExprImpliesNonNullRow() */ + Expr *pA1; + assert( nFarg==2 ); + pA1 = pFarg->a[1].pExpr; + if( pA1->op==TK_COLUMN ){ + sqlite3VdbeAddOp2(v, OP_Integer, + sqlite3ExprImpliesNonNullRow(pFarg->a[0].pExpr,pA1->iTable), + target); + }else{ + sqlite3VdbeAddOp2(v, OP_Null, 0, target); + } + break; + } + #ifdef SQLITE_DEBUG case INLINEFUNC_affinity: { /* The AFFINITY() function evaluates to a string that describes |