-C Minor\ssimplification\sof\sthe\sEXISTS-to-IN\slogic.
-D 2021-01-17T00:13:12.097
+C More\scomments\son\sthe\sEXISTS-to-IN\soptimization\slogic.
+D 2021-01-18T00:11:20.813
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F src/where.c 0e6abb22a2323fec80b450825593c26a2ad8f4815d1ee3af9969d8f6144bf681
F src/whereInt.h 9a3f577619f07700d16d89eeb2f3d94d6b7ed7f109c2dacf0ce8844921549506
F src/wherecode.c a3a1aff30fe99a818d8e7c607980f033f40c68d890e03ed25838b9dbb7908bee
-F src/whereexpr.c 9886a16b52af66e01ded9e69e3e2913f25d8e34bdeaa5e583d7c8c9a1ffe71d2
+F src/whereexpr.c a022b4f447c0fb0674e172a9a303537ea5055df60d579f99cec7ead18e8c453f
F src/window.c edd6f5e25a1e8f2b6f5305b7f5f7da7bb35f07f0d432b255b1d4c2fcab4205aa
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P ef49ee4a3766146963bfb6b013472f9836afb9c5b0d21a8533871cf961139e38
-R ed5d5749a7ed1103ef3bdb4ce2a908bc
+P cac90a9f4ab0a8f3ff77ee1f8549213c2f97169fc3469e55d57caa564079ce2a
+R f533358ab2d88dffa58abcd3bcdbe4bd
U drh
-Z beb39ea924321eafaa423b5e3b964772
+Z 7271ac9ea9a27eaec7cf5d0a637bfec4
** This function always returns true if expression pExpr contains
** a sub-select.
**
-** If there is no sub-select and bUses is 1, then true is returned
-** if the expression contains at least one TK_COLUMN node that refers
-** to a table in pSrc.
+** If there is no sub-select in pExpr, then return true if pExpr
+** contains a TK_COLUMN node for a table that is (bUses==1)
+** or is not (bUses==0) in pSrc.
**
-** Or, if there is no sub-select and bUses is 0, then true is returned
-** if the expression contains at least one TK_COLUMN node that refers
-** to a table that is not in pSrc.
+** Said another way:
+**
+** bUses Return Meaning
+** -------- ------ ------------------------------------------------
+**
+** bUses==1 true pExpr contains either a sub-select or a
+** TK_COLUMN referencing pSrc.
+**
+** bUses==1 false pExpr contains no sub-selects and all TK_COLUMN
+** nodes reference tables not found in pSrc
+**
+** bUses==0 true pExpr contains either a sub-select or a TK_COLUMN
+** that references a table not in pSrc.
+**
+** bUses==0 false pExpr contains no sub-selects and all TK_COLUMN
+** nodes reference pSrc
*/
static int exprUsesSrclist(SrcList *pSrc, Expr *pExpr, int bUses){
Walker sWalker;
** expression tree.
*/
struct ExistsToInCtx {
- SrcList *pSrc;
- Expr *pInLhs;
- Expr *pEq;
- Expr **ppAnd;
- Expr **ppParent;
+ SrcList *pSrc; /* The tables in an EXISTS(SELECT ... FROM <here> ...) */
+ Expr *pInLhs; /* OUT: Use this as the LHS of the IN operator */
+ Expr *pEq; /* OUT: The == term that include pInLhs */
+ Expr **ppAnd; /* OUT: The AND operator that includes pEq as a child */
+ Expr **ppParent; /* The AND operator currently being examined */
};
/*
** node within the WHERE expression tree.
*/
static Expr *exprAnalyzeExistsFindEq(
- Select *pSel,
+ Select *pSel, /* The SELECT of the EXISTS */
Expr **ppEq, /* OUT: == node from WHERE clause */
Expr ***pppAnd /* OUT: Pointer to parent of ==, if any */
){