Fix a false-postive in the sqlite3ExprImpliesNonNullRow() decision routine,

that resulted in an incorrect LEFT JOIN strength reduction when the
WHERE clause contained a row-value comparison.
Ticket [02aa2bd02f97d0f2]

FossilOrigin-Name: ea20068e6d97c9349ebcc7d0a01e99ebf08c6f44363f71a0218a1abea209adc5
This commit is contained in:
drh 2019-11-04 02:05:52 +00:00
parent db535390db
commit 6c68d7592f
4 changed files with 33 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C The\soptimization\sof\scheck-in\s[9b2879629c34fc0a]\sis\sincorrectly\sreasoned.\nThe\sWHERE\sclause\sof\sthe\spartial\sindex\smight\snot\sbe\strue\sif\sthe\stable\sof\nthe\spartial\sindex\sis\sthe\sright\stable\sof\sa\sleft\sjoin.\s\sSo\sdisable\sthe\noptimization\sin\sthat\scase.\s\sTicket\s[623eff57e76d45f6]
D 2019-11-03T00:07:41.595
C Fix\sa\sfalse-postive\sin\sthe\ssqlite3ExprImpliesNonNullRow()\sdecision\sroutine,\nthat\sresulted\sin\san\sincorrect\sLEFT\sJOIN\sstrength\sreduction\swhen\sthe\nWHERE\sclause\scontained\sa\srow-value\scomparison.\nTicket\s[02aa2bd02f97d0f2]
D 2019-11-04T02:05:52.518
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -478,7 +478,7 @@ F src/date.c e1d8ac7102f3f283e63e13867acb0efa33861cf34f0faf4cdbaf9fa7a1eb7041
F src/dbpage.c 135eb3b5e74f9ef74bde5cec2571192c90c86984fa534c88bf4a055076fa19b7
F src/dbstat.c c12833de69cb655751487d2c5a59607e36be1c58ba1f4bd536609909ad47b319
F src/delete.c c371a9f3517a4dd6a0b56ebab9588408eddf1eac0277b67b09e030bff99ee1fa
F src/expr.c a02db128337ca28c34fc3574a640f247881bc4d14c1debf5adc3ecf25dd74992
F src/expr.c 254238a94328ab88b473dcce4b656afd488cb03fced627ad90fb4676c5fe417f
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c 92a248ec0fa4ed8ab60c98d9b188ce173aaf218f32e7737ba77deb2a684f9847
F src/func.c ed33e38cd642058182a31a3f518f2e34f4bbe53aa483335705c153c4d3e50b12
@ -1262,7 +1262,7 @@ F test/round1.test 768018b04522ca420b1aba8a24bd76091d269f3bce3902af3ec6ebcee41ab
F test/rowallock.test 3f88ec6819489d0b2341c7a7528ae17c053ab7cc
F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81
F test/rowid.test bfbd7b97d9267660be3c8f28507c4ed7f205196b8877c0db42df347c2e8845e3
F test/rowvalue.test 92dc2c5fad808d6764c8e5fa14360b89dacb3cb33ba1498a52f226f89a04a868
F test/rowvalue.test c39cc0be5e33f5294fc9224216198d6709d713ea948fdf8f42d89568e97912c9
F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b
F test/rowvalue3.test 3068f508753af69884b12125995f023da0dbb256
F test/rowvalue4.test 02e35f7762371c2f57ebd856aa056eac56cb27ef7715a0bb31eac1895a745356
@ -1849,7 +1849,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 9c795c4d2b042d2932774bd1274fa0167ca2dc9838e127e0cf31eb9273a32f2c
R 5e53c74cccd75d696adb47595d7bc2ca
P 3be19e1151af1850b65991edb82420f9412a7798dd756c86eaa9ffdde573263a
R a30fee6557c8c0c73b7fe40e3d78c678
U drh
Z 9c91bb1be2f76e50e900200e5b535282
Z 03f3426d008bb8fbab5050ae611b4dd0

View File

@ -1 +1 @@
3be19e1151af1850b65991edb82420f9412a7798dd756c86eaa9ffdde573263a
ea20068e6d97c9349ebcc7d0a01e99ebf08c6f44363f71a0218a1abea209adc5

View File

@ -5212,7 +5212,7 @@ int sqlite3ExprImpliesExpr(Parse *pParse, Expr *pE1, Expr *pE2, int iTab){
}
/*
** This is the Expr node callback for sqlite3ExprImpliesNotNullRow().
** This is the Expr node callback for sqlite3ExprImpliesNonNullRow().
** If the expression node requires that the table at pWalker->iCur
** have one or more non-NULL column, then set pWalker->eCode to 1 and abort.
**
@ -5230,6 +5230,7 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){
case TK_NOTNULL:
case TK_IS:
case TK_OR:
case TK_VECTOR:
case TK_CASE:
case TK_IN:
case TK_FUNCTION:
@ -5239,6 +5240,7 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){
testcase( pExpr->op==TK_NOTNULL );
testcase( pExpr->op==TK_IS );
testcase( pExpr->op==TK_OR );
testcase( pExpr->op==TK_VECTOR );
testcase( pExpr->op==TK_CASE );
testcase( pExpr->op==TK_IN );
testcase( pExpr->op==TK_FUNCTION );

View File

@ -616,5 +616,27 @@ do_execsql_test 25.40 {
SELECT 2 FROM t0 WHERE (t0.c0 COLLATE nocase, 0) < ('B', 0);
} {1 2}
# 2019-11-04 Ticket 02aa2bd02f97d0f2
# The TK_VECTOR operator messes up sqlite3ExprImpliesNonNull() which
# causes incorrect LEFT JOIN strength reduction. TK_VECTOR should be
# treated the same as TK_OR.
#
db close
sqlite3 db :memory:
do_execsql_test 26.10 {
CREATE TABLE t0(c0);
CREATE TABLE t1(c1);
INSERT INTO t1(c1) VALUES (0);
SELECT (c0, x'') != (NULL, 0) FROM t1 LEFT JOIN t0;
} {1}
do_execsql_test 26.20 {
SELECT 2 FROM t1 LEFT JOIN t0 ON (c0, x'') != (NULL, 0);
} {2}
do_execsql_test 26.30 {
SELECT 3 FROM t1 LEFT JOIN t0 WHERE (c0, x'') != (NULL, 0);
} {3}
finish_test