diff --git a/manifest b/manifest index 867860bee6..c8dd5c396b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sremember(V,PTR)\sextension\sfunction\swhich\scopies\san\sSQL\svalue\sinto\nan\sapplication\svariable. -D 2016-11-30T16:54:52.848 +C Avoid\sclearing\sthe\sEP_FromJoin\sflag\sfrom\sterms\sin\sON\sclauses\swhen\sflattening\nsub-selects.\sPossible\sfix\sfor\s[2df0107b]. +D 2016-12-01T19:38:05.478 F Makefile.in 7639c6a09da11a9c7c6f2630fc981ee588d1072d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -388,7 +388,7 @@ F src/printf.c f94da4935d1dd25420ac50c6745db1deb35e07c1 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c bb070cf5f23611c44ab7e4788803684e385fc3fb F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac -F src/select.c 668c6865b16813dab5f9c18d3672fed11a5c34c5 +F src/select.c 403775526d5e0e420924fe89f34256dc1dd98d48 F src/shell.c a3fc2c719ed6d381895cbdb66a4a9b6a791cb02e F src/sqlite.h.in e8e2d108d82647f0a812fdb74accf91c1ec08ddc F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -881,7 +881,7 @@ F test/join.test f9d4a28dec81c6e9dc21b73518e024d73b5ebf57 F test/join2.test f2171c265e57ee298a27e57e7051d22962f9f324 F test/join3.test 6f0c774ff1ba0489e6c88a3e77b9d3528fb4fda0 F test/join4.test 1a352e4e267114444c29266ce79e941af5885916 -F test/join5.test 8a5c0be6f0c260a5c7177c3b8f07c7856141038a +F test/join5.test bc98ea4b4e5003f5b1453701ebb8cd7d1c01a550 F test/join6.test cfe6503791ceb0cbb509966740286ec423cbf10b F test/journal1.test 69abc726c51b4a0409189f9a85191205297c0577 F test/journal2.test 9dac6b4ba0ca79c3b21446bbae993a462c2397c4 @@ -1536,8 +1536,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3816bb415ecfd4f36430d0fcbc878e382975de60 f0942c362f45ca1e986e142dbdd3ad957626dfb1 -R cd510c86291ec9069bea94544a3e0b95 -T +closed f0942c362f45ca1e986e142dbdd3ad957626dfb1 -U drh -Z 6b290cfef4656939d1e961e713e76c69 +P d2d30914d81022d7d4e1670caf9326524520deaf +R 1ad7b1a9bc1f307af71495d29fca4162 +T *branch * left-join-fix +T *sym-left-join-fix * +T -sym-trunk * +U dan +Z 70e2f22a0ab5072019cd24cf4ad22371 diff --git a/manifest.uuid b/manifest.uuid index 305748dc68..9c4dc93c62 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d2d30914d81022d7d4e1670caf9326524520deaf \ No newline at end of file +8bed4cd549759a93c4a087d8d8c08c0068ba8d59 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 8e6022c9cd..e0b8fccc53 100644 --- a/src/select.c +++ b/src/select.c @@ -3164,6 +3164,10 @@ static Expr *substExpr( assert( pEList!=0 && pExpr->iColumnnExpr ); assert( pExpr->pLeft==0 && pExpr->pRight==0 ); pNew = sqlite3ExprDup(db, pEList->a[pExpr->iColumn].pExpr, 0); + if( pNew && (pExpr->flags & EP_FromJoin) ){ + pNew->iRightJoinTable = pExpr->iRightJoinTable; + pNew->flags |= EP_FromJoin; + } sqlite3ExprDelete(db, pExpr); pExpr = pNew; } diff --git a/test/join5.test b/test/join5.test index 543cd4d27f..352ffd40a6 100644 --- a/test/join5.test +++ b/test/join5.test @@ -13,10 +13,10 @@ # This file implements tests for left outer joins containing ON # clauses that restrict the scope of the left term of the join. # -# $Id: join5.test,v 1.2 2007/06/08 00:20:48 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix join5 do_test join5-1.1 { @@ -184,4 +184,32 @@ do_execsql_test join6-4.2 { LEFT JOIN (SELECT 1) ON fruit='banana'; } {apple {} banana 1} +#------------------------------------------------------------------------- +do_execsql_test 5.0 { + CREATE TABLE y1(x, y, z); + INSERT INTO y1 VALUES(0, 0, 1); + CREATE TABLE y2(a); +} + +do_execsql_test 5.1 { + SELECT count(z) FROM y1 LEFT JOIN y2 ON x GROUP BY y; +} 1 + +do_execsql_test 5.2 { + SELECT count(z) FROM ( SELECT * FROM y1 ) LEFT JOIN y2 ON x GROUP BY y; +} 1 + +do_execsql_test 5.3 { + CREATE VIEW v1 AS SELECT x, y, z FROM y1; + SELECT count(z) FROM v1 LEFT JOIN y2 ON x GROUP BY y; +} 1 + +do_execsql_test 5.4 { + SELECT count(z) FROM ( SELECT * FROM y1 ) LEFT JOIN y2 ON x +} 1 + +do_execsql_test 5.5 { + SELECT * FROM ( SELECT * FROM y1 ) LEFT JOIN y2 ON x +} {0 0 1 {}} + finish_test