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

Improved comments on the NOT NULL strength reduction optimization.

FossilOrigin-Name: a85d72293914b48edbb39171fd591d37ffb09570d8103140a052203ec71d49ee
This commit is contained in:
drh
2021-03-09 19:52:15 +00:00
parent 6d0053cfa7
commit 45e4cb8e77
3 changed files with 19 additions and 16 deletions

View File

@@ -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: {