The TK_IF_NULL_ROW expression node must be treated as a variable that

references the table Expr.iTable.
Proposed fix for ticket [7fde638e94287d2c].

FossilOrigin-Name: b30a364a12d9865242b1444984cd25ee126dc69108d5c6a2d4b35df184437fe9
This commit is contained in:
drh 2017-05-25 00:28:36 +00:00
parent 8389bff0a8
commit 074ce1e7fd
5 changed files with 38 additions and 15 deletions

View File

@ -1,5 +1,5 @@
C Increase\sthe\sversion\snumber\sto\s3.19.2\ssince\sticket\s[7fde638e94287d2]\sis\ngoing\sto\snecessitate\sanother\spatch\srelease.
D 2017-05-25T00:12:04.191
C The\sTK_IF_NULL_ROW\sexpression\snode\smust\sbe\streated\sas\sa\svariable\sthat\nreferences\sthe\stable\sExpr.iTable.\nProposed\sfix\sfor\sticket\s[7fde638e94287d2c].
D 2017-05-25T00:28:36.835
F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc
@ -356,7 +356,7 @@ F src/ctime.c 47d91a25ad8f199a71a5b1b7b169d6dd0d6e98c5719eca801568798743d1161c
F src/date.c cc42a41c7422389860d40419a5e3bce5eaf6e7835c3ba2677751dc653550a5c7
F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d
F src/delete.c 665e705641e5815c3f32d05820d1a5aa630274e568af73f377fdbc614fcf40b4
F src/expr.c c83f799f3e5e3f3863bd0716119383e4a062d00a1e34e7273a78555918840a7c
F src/expr.c 30f61b7d8236def0e99485651e5d983a102afa4cbc8b1ef0ab19ccb1f3841f99
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c db65492ae549c3b548c9ef1f279ce1684f1c473b116e1c56a90878cd5dcf968d
F src/func.c 9d52522cc8ae7f5cdadfe14594262f1618bc1f86083c4cd6da861b4cf5af6174
@ -487,7 +487,7 @@ F src/walker.c b71a992b413b3a022572eccf29ef4b4890223791
F src/where.c c6352f15be5031907c68bcbde96cad1a6da20e9f4051d10168a59235de9a8566
F src/whereInt.h 2a4b634d63ce488b46d4b0da8f2eaa8f9aeab202bc25ef76f007de5e3fba1f20
F src/wherecode.c 8ad48867660519e262a401720845dc76934f86f558ec9606335fafcd7a2554f8
F src/whereexpr.c e913aaa7b73ffcce66abcea5f197e2c538d48b5df78d0b7bba8ff4d73cc2e745
F src/whereexpr.c a2fe3811d45af45a5c6667caabc15e01054fe6228c64e86e1f7d2ba5ef5284f9
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd
F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d
@ -906,7 +906,7 @@ F test/ioerr3.test d3cec5e1a11ad6d27527d0d38573fbff14c71bdd
F test/ioerr4.test f130fe9e71008577b342b8874d52984bd04ede2c
F test/ioerr5.test 2edfa4fb0f896f733071303b42224df8bedd9da4
F test/ioerr6.test a395a6ab144b26a9e3e21059a1ab6a7149cca65b
F test/join.test a26e4c45edba5d2090216be6fc26d8d862c1a66e5729ce38308b4f286aa745e5
F test/join.test 302f164f4a41c240d16ebd780762834233be77b852f15232c9a48a6fe37ac0fa
F test/join2.test a48f723c5692e2cbb23a9297ac2720cb77d51a70
F test/join3.test 6f0c774ff1ba0489e6c88a3e77b9d3528fb4fda0
F test/join4.test 1a352e4e267114444c29266ce79e941af5885916
@ -1580,7 +1580,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P f6d7b988f40217821a382bc298180e9e6794f3ed79a83c6ef5cae048989b3f86
R aa8b19d4a564e18ac717b23869826227
P c315727acd5fffe6e83ad9a5e84360d5cfa9aa8faa10d4970ea9823c7e8126ee
Q +77fc23013cebc7797985864b91d78db5d0e2469511732044ebfaf02b891c979a
R 50fcc5200cd2c3a182c0518337e9a940
U drh
Z bb508fff94464e450ce00ac5e09de7ea
Z 6effe9b9d20277cb431b2d7d2acbdf71

View File

@ -1 +1 @@
c315727acd5fffe6e83ad9a5e84360d5cfa9aa8faa10d4970ea9823c7e8126ee
b30a364a12d9865242b1444984cd25ee126dc69108d5c6a2d4b35df184437fe9

View File

@ -1740,10 +1740,12 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
testcase( pExpr->op==TK_AGG_COLUMN );
if( pWalker->eCode==3 && pExpr->iTable==pWalker->u.iCur ){
return WRC_Continue;
}else{
pWalker->eCode = 0;
return WRC_Abort;
}
/* Fall through */
case TK_IF_NULL_ROW:
testcase( pExpr->op==TK_IF_NULL_ROW );
pWalker->eCode = 0;
return WRC_Abort;
case TK_VARIABLE:
if( pWalker->eCode==5 ){
/* Silently convert bound parameters that appear inside of CREATE

View File

@ -1375,11 +1375,11 @@ Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
Bitmask mask;
if( p==0 ) return 0;
if( p->op==TK_COLUMN ){
mask = sqlite3WhereGetMask(pMaskSet, p->iTable);
return mask;
return sqlite3WhereGetMask(pMaskSet, p->iTable);
}
mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
assert( !ExprHasProperty(p, EP_TokenOnly) );
mask = p->pRight ? sqlite3WhereExprUsage(pMaskSet, p->pRight) : 0;
if( p->pRight ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pRight);
if( p->pLeft ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pLeft);
if( ExprHasProperty(p, EP_xIsSelect) ){
mask |= exprSelectUsage(pMaskSet, p->x.pSelect);

View File

@ -743,4 +743,24 @@ do_execsql_test join-14.5 {
SELECT * FROM (SELECT 111) LEFT JOIN (SELECT c+222 FROM t1) GROUP BY 1;
} {111 {}}
# Verify the fix to ticket
# https://www.sqlite.org/src/tktview/7fde638e94287d2c948cd9389
#
db close
sqlite3 db :memory:
do_execsql_test join-14.10 {
CREATE TABLE t1(a);
INSERT INTO t1 VALUES(1),(2),(3);
CREATE VIEW v2 AS SELECT a, 1 AS b FROM t1;
CREATE TABLE t3(x);
INSERT INTO t3 VALUES(2),(4);
SELECT *, '|' FROM t3 LEFT JOIN v2 ON a=x WHERE b=1;
} {2 2 1 |}
do_execsql_test join-14.11 {
SELECT *, '|' FROM t3 LEFT JOIN v2 ON a=x WHERE b+1=x;
} {2 2 1 |}
do_execsql_test join-14.12 {
SELECT *, '|' FROM t3 LEFT JOIN v2 ON a=x ORDER BY b;
} {4 {} {} | 2 2 1 |}
finish_test