diff options
author | drh <drh@noemail.net> | 2015-08-31 17:34:41 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2015-08-31 17:34:41 +0000 |
commit | 1d85e405e6c7674d0df4d4a720ceaeb47273b9ba (patch) | |
tree | b520a7ea51eb23018633ef354b4ba47d56e2e89b /src/resolve.c | |
parent | 47991425cb67375e341d5c8179f14a47e2c1188d (diff) | |
download | sqlite-1d85e405e6c7674d0df4d4a720ceaeb47273b9ba.tar.gz sqlite-1d85e405e6c7674d0df4d4a720ceaeb47273b9ba.zip |
Make the distinction between truly deterministic functions and date/time
functions which only return the same answer for a single query. Only truly
deterministic functions are allowed in indexes. Add new expression index
test cases.
FossilOrigin-Name: c77554b5c42327106a7b90334e9cc3c07b007c76
Diffstat (limited to 'src/resolve.c')
-rw-r--r-- | src/resolve.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/resolve.c b/src/resolve.c index eb4339645..0b8dde7cc 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -732,9 +732,15 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ return WRC_Prune; } #endif - if( pDef->funcFlags & SQLITE_FUNC_CONSTANT ){ + if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_DATETIME) ){ + /* For the purposes of the EP_ConstFunc flag, date and time + ** functions are considered constant because the the time does + ** not change for the duration of a query. */ ExprSetProperty(pExpr,EP_ConstFunc); - }else{ + } + if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){ + /* DATETIME functions are considered non-deterministic because of + ** the 'now' capability */ notValid(pParse, pNC, "non-deterministic functions", NC_IdxExpr, 0); } } |