Fix the query flattener to deal with a RIGHT JOIN corner case described

by [forum:/forumpost/323f86cc30|forum post 323f86cc30].

FossilOrigin-Name: 3f45007d544e5f787d5837b4d9f484ba473d69cdba83c229228e9c2f6b972b75
This commit is contained in:
drh 2022-06-07 13:09:58 +00:00
parent bb1369037b
commit 33b2cb9aec
4 changed files with 10 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C Test\scases\sfor\s[forum:/forumpost/323f86cc30|forum\spost\s323f86cc30]\sadded\nto\sjoin8.test,\sthough\scommented\sout\sso\sthat\sthey\sdo\snot\s(yet)\srun.
D 2022-06-07T11:02:43.551
C Fix\sthe\squery\sflattener\sto\sdeal\swith\sa\sRIGHT\sJOIN\scorner\scase\sdescribed\nby\s[forum:/forumpost/323f86cc30|forum\spost\s323f86cc30].
D 2022-06-07T13:09:58.839
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -570,7 +570,7 @@ F src/printf.c 6166a30417b05c5b2f82e1f183f75faa2926ad60531c0b688a57dbc951441a20
F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c
F src/resolve.c a4eb3c617027fd049b07432f3b942ea7151fa793a332a11a7d0f58c9539e104f
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
F src/select.c 8b98d3e5511d2789880ea4a12a4637803f69db5df04c81e1e93a5aac75c89b2a
F src/select.c 37d984cb3e007349ee5da55b3f3c9196e032e08938c9a58fd272acf1df873e61
F src/shell.c.in 5d5f27f88c4661b2b6e6859890e9c7fe00eac9a628743a12c44632705fc38309
F src/sqlite.h.in 172528c287399a34f188154017b7268bf82c6d5b780902e361958d2318c4e37c
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
@ -1166,7 +1166,7 @@ F test/join4.test 1a352e4e267114444c29266ce79e941af5885916
F test/join5.test d22b6cba8fb59ab3f1c82701434c360705eb12d4ce200c449f37b018fc47681a
F test/join6.test f809c025fa253f9e150c0e9afd4cef8813257bceeb6f46e04041228c9403cc2c
F test/join7.test 2268dcbb54b724391dda3748ea95c60d960607ffeed67885675998e7117697f6
F test/join8.test 60cd6d63124b0254cbb4faf43d6fab9b223707879cd2a716135a616c97cf5454
F test/join8.test d799d60485852037f496fefb513c39d027d5649c39045fb5b31bda521436439c
F test/join9.test 9056ddd3b0c0f4f9d658f4521038d9a37dc23ead8ca9a505d0b0db2b6a471e05
F test/joinA.test 7eab225dc1c1ab258a5e62513a4ed7cabbd3db971d59d5d92f4fb6fa14c12f6a
F test/joinB.test 1b2ba3fc8568b49411787fccbf540570c148e9b6a53a30f80691cb6268098ded
@ -1975,8 +1975,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 3f6a442099b8264cc788e8aa2b12cc583439a5263c4fe433fd22b7af1be2458e
R 456305c702927200f2fee67acf182787
P 7f97cb67d01a11f1b7e5b5f05824f9adbc6e4689d1809d60ceda50a595ba6d4a
R 413a4b040170a880590160583cee3c05
U drh
Z 682e6419407c26105f7222191b1daa94
Z 0662644a85d84e671b5268c6a964cd54
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
7f97cb67d01a11f1b7e5b5f05824f9adbc6e4689d1809d60ceda50a595ba6d4a
3f45007d544e5f787d5837b4d9f484ba473d69cdba83c229228e9c2f6b972b75

View File

@ -3763,9 +3763,10 @@ static Expr *substExpr(
Expr *pExpr /* Expr in which substitution occurs */
){
if( pExpr==0 ) return 0;
if( ExprHasProperty(pExpr, EP_OuterON)
if( ExprHasProperty(pExpr, EP_OuterON|EP_InnerON)
&& pExpr->w.iJoin==pSubst->iTable
){
testcase( ExprHasProperty(pExpr, EP_InnerON) );
pExpr->w.iJoin = pSubst->iNewTable;
}
if( pExpr->op==TK_COLUMN

View File

@ -626,7 +626,6 @@ do_execsql_test join8-19010 {
SELECT * FROM t1 LEFT JOIN t2 ON true INNER JOIN t3 ON (b IS NOT NULL)=0;
}
if 0 {
# 2022-06-07
# https://sqlite.org/forum/forumpost/323f86cc30
reset_db
@ -657,6 +656,5 @@ do_execsql_test join8-20060 {
SELECT count(*)
FROM (SELECT 99 as "m" FROM t2 JOIN v0 ON z<>'' RIGHT JOIN t1 ON z<>'' ORDER BY z) AS "t3";
} {1}
}
finish_test