From: drh <> Date: Thu, 12 May 2022 11:56:44 +0000 (+0000) Subject: Ensure that ON clauses are applied to the correct outer join. X-Git-Tag: version-3.39.0~150 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d631c6af80fa779c504a53d29666540fc87bea93;p=thirdparty%2Fsqlite.git Ensure that ON clauses are applied to the correct outer join. FossilOrigin-Name: c7e3a13a3288c577209be99c630fbe924e19880e8af1aa8a83b517acaa8b43d7 --- diff --git a/manifest b/manifest index 33ab787219..cfd91f551a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sIS\sNOT\sDISTINCT\sFROM\sand\sIS\sDISTINCT\sFROM\sbinary\soperators\swhich\sare\nequivalent\sto\sIS\sand\sIS\sNOT,\srespectively,\sfor\scompatability\swith\sPostgreSQL\nand\shence\sstandard\sSQL. -D 2022-05-12T11:45:20.320 +C Ensure\sthat\sON\sclauses\sare\sapplied\sto\sthe\scorrect\souter\sjoin. +D 2022-05-12T11:56:44.510 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -642,7 +642,7 @@ F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b F src/where.c aa585b89bd65a81e44bdfb871b55f65bf8fda88e1bc85efda6c236fe8d2bd788 F src/whereInt.h 8da918f392bf202ccc0ee61291455b33ad171d209445f1ff3eaf62e0b6f6b363 -F src/wherecode.c 72f8eeed5527450c8e2258160a7bd04534a76c161230d100da0f43a86c6e29ac +F src/wherecode.c c1f7210872a75f0c79323133168faef4bafd4ecbd78594374f21738fdb9bb72e F src/whereexpr.c e036477ac8424de50ae5b36a71103405d3f86b33ba11125ec7a2a99d501b0622 F src/window.c fff1b51757438c664e471d5184634e48dcdf8ea34b640f3b1b0810b1e06de18c F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -1148,7 +1148,7 @@ F test/join4.test 1a352e4e267114444c29266ce79e941af5885916 F test/join5.test d22b6cba8fb59ab3f1c82701434c360705eb12d4ce200c449f37b018fc47681a F test/join6.test f809c025fa253f9e150c0e9afd4cef8813257bceeb6f46e04041228c9403cc2c F test/join7.test 8e72de4b45e5e930d18c305c7efe86015fb2552731e4e03ea226353036b0dab0 -F test/join8.test fef259c42d56bbe150b777726b185b0bc060d4290daf9f879abc68321f8ad6db +F test/join8.test 9b83dc70b7e9f7d4ee0022a0fe44ec1858f103530c7eb253c10adb63aad16ec4 F test/join9.test 9056ddd3b0c0f4f9d658f4521038d9a37dc23ead8ca9a505d0b0db2b6a471e05 F test/joinA.test 7eab225dc1c1ab258a5e62513a4ed7cabbd3db971d59d5d92f4fb6fa14c12f6a F test/joinB.test 1b2ba3fc8568b49411787fccbf540570c148e9b6a53a30f80691cb6268098ded @@ -1953,8 +1953,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 cf7fdabdba3a7600ea730263ca80ba80154645dfa15c31c037b780d6cb70e530 -R 3d6af656fb4de79992bd7eb88f082265 +P db27611e172102483eaede3981d473e3d5bf93d98bc68f480398b1573876349d +R afe0cdc3523728a1b8ae188a6e9f6b30 U drh -Z 3682303474f6dcc00e17a0b96d46c4cc +Z 2be2867ba128a1ce436a897eb9d120e9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index d36477989d..75e5a275dd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -db27611e172102483eaede3981d473e3d5bf93d98bc68f480398b1573876349d \ No newline at end of file +c7e3a13a3288c577209be99c630fbe924e19880e8af1aa8a83b517acaa8b43d7 \ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index a942e6e7fb..979944e2ea 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -2621,7 +2621,8 @@ Bitmask sqlite3WhereCodeOneLoopStart( pE = pTerm->pExpr; assert( pE!=0 ); if( (pTabItem->fg.jointype & (JT_LEFT|JT_LTORJ)) - && !ExprHasProperty(pE,EP_FromJoin|EP_InnerJoin) + && (!ExprHasProperty(pE,EP_FromJoin|EP_InnerJoin) + || pE->w.iJoin!=pTabItem->iCursor) ){ continue; } diff --git a/test/join8.test b/test/join8.test index ab05722912..05d400470a 100644 --- a/test/join8.test +++ b/test/join8.test @@ -260,4 +260,27 @@ do_execsql_test join8-7020 { ORDER BY coalesce(t0.a, t0.y+200, t4.d); } {/.*BLOOM FILTER ON t2.*BLOOM FILTER ON t3.*BLOOM FILTER ON t4.*/} +# 2022-05-12 Difference with PG found (by Dan) while exploring +# https://sqlite.org/forum/forumpost/677a0ab93fcd9ccd +# +reset_db +do_execsql_test join8-8000 { + CREATE TABLE t1(a INT, b INT); + CREATE TABLE t2(c INT, d INT); + CREATE TABLE t3(e INT, f INT); + INSERT INTO t1 VALUES(1, 2); + INSERT INTO t2 VALUES(3, 4); + INSERT INTO t3 VALUES(5, 6); +} {} +do_execsql_test join8-8010 { + SELECT * + FROM t3 LEFT JOIN t2 ON true + JOIN t1 ON (t3.e IS t2.c); +} {} +do_execsql_test join8-8020 { + SELECT * + FROM t3 LEFT JOIN t2 ON true + JOIN t1 ON (t3.e IS NOT DISTINCT FROM t2.c); +} {} + finish_test