aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2020-01-18 21:34:31 +0000
committerdrh <drh@noemail.net>2020-01-18 21:34:31 +0000
commitfe7046044cb94686eaba8291c24267d17d1357b7 (patch)
tree55d802b489442912ec151c64520aae3d860c2360 /src
parentf71eb2091fdb165ab97f7e50cb8cbdc6d39a0a86 (diff)
downloadsqlite-fe7046044cb94686eaba8291c24267d17d1357b7.tar.gz
sqlite-fe7046044cb94686eaba8291c24267d17d1357b7.zip
Allow non-deterministic function in CHECK constraints. It turns out that
PostgreSQL, MySQL, and SQLServer all allow this. We should be the the exception. Ticket [830277d9db6c3ba1] FossilOrigin-Name: 8c8ce526adb60b8061e55151599ca8b11f1ec2e968d3bacc73a2a249e9e95ee1
Diffstat (limited to 'src')
-rw-r--r--src/resolve.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/resolve.c b/src/resolve.c
index 3e5ac16e2..119a07fd2 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -868,11 +868,14 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
ExprSetProperty(pExpr,EP_ConstFunc);
}
if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){
- /* Date/time functions that use 'now', and other functions like
+ /* Clearly non-deterministic functions like random(), but also
+ ** date/time functions that use 'now', and other functions like
** sqlite_version() that might change over time cannot be used
- ** in an index. */
+ ** in an index or generated column. Curiously, they can be used
+ ** in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all
+ ** all this. */
sqlite3ResolveNotValid(pParse, pNC, "non-deterministic functions",
- NC_SelfRef, 0);
+ NC_IdxExpr|NC_PartIdx|NC_GenCol, 0);
}else{
assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */
pExpr->op2 = pNC->ncFlags & NC_SelfRef;