From 9881155d54149f0a905a198e9aa52105337f7999 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 3 Apr 2018 14:04:48 +0000 Subject: [PATCH] Change the LEFT JOIN strength reduction optimization so that assumes that virtual table constraints can be true even if terms within the constraint are NULL. This works around dodgy virtual table implementations. FossilOrigin-Name: cbb977fe1908431f3aad8e67668588b119e7d491724f2042af436f509a4f6623 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/expr.c | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 2802bd747a..ebec2f1e00 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.23.0 -D 2018-04-02T11:04:16.044 +C Change\sthe\sLEFT\sJOIN\sstrength\sreduction\soptimization\sso\sthat\sassumes\sthat\nvirtual\stable\sconstraints\scan\sbe\strue\seven\sif\sterms\swithin\sthe\sconstraint\nare\sNULL.\s\sThis\sworks\saround\sdodgy\svirtual\stable\simplementations. +D 2018-04-03T14:04:48.605 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 7016fc56c6b9bfe5daac4f34be8be38d8c0b5fab79ccbfb764d3b23bf1c6fff3 @@ -443,7 +443,7 @@ F src/date.c ebe1dc7c8a347117bb02570f1a931c62dd78f4a2b1b516f4837d45b7d6426957 F src/dbpage.c 8db4c97f630e7d83f884ea75caf1ffd0988c160e9d530194d93721c80821e0f6 F src/dbstat.c edabb82611143727511a45ca0859b8cd037851ebe756ae3db289859dd18b6f91 F src/delete.c 20c8788451dc737a967c87ea53ad43544d617f5b57d32ccce8bd52a0daf9e89b -F src/expr.c 51500461dcd4d0873a938bf188d03076d6712d70ff00a0f0d65621edf4e521c6 +F src/expr.c 0d4345e0e153cd6082ece69b4a0fdd0934d15bcd3925c74063cb8f65219a6f3c F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c d617daf66b5515e2b42c1405b2b4984c30ca50fb705ab164271a9bf66c69e331 F src/func.c 94f42cba2cc1c34aeaa441022ba0170ec3fec4bba54db4e0ded085c6dc0fdc51 @@ -1717,10 +1717,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b850dd159918af568c55c00ff146ba9c9c04d33ff384fe1eb0ad74164bc401bb -R 7b7a30931830e96714db59b77704b857 -T +bgcolor * #d0c0ff -T +sym-release * -T +sym-version-3.23.0 * +P 736b53f57f70b23172c30880186dce7ad9baa3b74e3838cae5847cffb98f5cd2 +R a6d2722715be08607b96fd599acd9dc9 U drh -Z 386b4344740e610e0c3078bd00d99ed8 +Z 96e5d106455d94d4a1b52de8a15d2af8 diff --git a/manifest.uuid b/manifest.uuid index 8710d6d235..6f3888b7ab 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -736b53f57f70b23172c30880186dce7ad9baa3b74e3838cae5847cffb98f5cd2 \ No newline at end of file +cbb977fe1908431f3aad8e67668588b119e7d491724f2042af436f509a4f6623 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 14bd06a860..5180044a5d 100644 --- a/src/expr.c +++ b/src/expr.c @@ -5037,6 +5037,27 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){ return WRC_Abort; } return WRC_Prune; + + /* Virtual tables are allowed to use constraints like x=NULL. So + ** a term of the form x=y does not prove that y is not null if x + ** is the column of a virtual table */ + case TK_EQ: + case TK_NE: + case TK_LT: + case TK_LE: + case TK_GT: + case TK_GE: + testcase( pExpr->op==TK_EQ ); + testcase( pExpr->op==TK_NE ); + testcase( pExpr->op==TK_LT ); + testcase( pExpr->op==TK_LE ); + testcase( pExpr->op==TK_GT ); + testcase( pExpr->op==TK_GE ); + if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->pTab)) + || (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->pTab)) + ){ + return WRC_Prune; + } default: return WRC_Continue; }