diff options
author | drh <> | 2021-03-09 19:52:15 +0000 |
---|---|---|
committer | drh <> | 2021-03-09 19:52:15 +0000 |
commit | 45e4cb8e775af60599ab81b1f5c261bb2d176447 (patch) | |
tree | 203c8fbc42893edaa3cda8d37c6d1d5492b8565f /src/resolve.c | |
parent | 6d0053cfa7b15df34e71be19861ca575adee57a0 (diff) | |
download | sqlite-45e4cb8e775af60599ab81b1f5c261bb2d176447.tar.gz sqlite-45e4cb8e775af60599ab81b1f5c261bb2d176447.zip |
Improved comments on the NOT NULL strength reduction optimization.
FossilOrigin-Name: a85d72293914b48edbb39171fd591d37ffb09570d8103140a052203ec71d49ee
Diffstat (limited to 'src/resolve.c')
-rw-r--r-- | src/resolve.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/resolve.c b/src/resolve.c index 668498cb9..32914befb 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -788,16 +788,19 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ break; } - /* An "<expr> IS NOT NULL" or "<expr> IS NULL". After resolving the - ** LHS, check if there is a NOT NULL constraint in the schema that - ** means the value of the expression can be determined immediately. - ** If that is the case, replace the current expression node with - ** a TK_TRUEFALSE node. + /* An optimization: Attempt to convert ** - ** If the node is replaced with a TK_TRUEFALSE node, then also restore - ** the NameContext ref-counts to the state they where in before the - ** LHS expression was resolved. This prevents the current select - ** from being erroneously marked as correlated in some cases. + ** "expr IS NOT NULL" --> "TRUE" + ** "expr IS NULL" --> "FALSE" + ** + ** if we can prove that "expr" is never NULL. Call this the + ** "NOT NULL strength reduction optimization". + ** + ** If this optimization occurs, also restore the NameContext ref-counts + ** to the state they where in before the "column" LHS expression was + ** resolved. This prevents "column" from being counted as having been + ** referenced, which might prevent a SELECT from being erroneously + ** marked as correlated. */ case TK_NOTNULL: case TK_ISNULL: { |