1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-21 09:00:59 +03:00

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
This commit is contained in:
drh
2015-08-31 17:34:41 +00:00
parent 47991425cb
commit 1d85e405e6
6 changed files with 160 additions and 43 deletions

View File

@@ -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);
}
}