Disable the push-down optimization for sub-queries that are INTERSECT, UNION or EXCEPT compounds. dbsqlfuzz a34f455c91ad75a0cf8cd9476841903f42930a7a.

FossilOrigin-Name: 346a3b12b861ce7ba369e98cd336f79a1d4f7a7bb9acd7a4f63f37b391755bf5
This commit is contained in:
dan 2022-10-26 21:14:21 +00:00
parent 07dd481010
commit 195687f1bf
4 changed files with 44 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C Remove\san\sunused\svariable\sfrom\sthe\srecovery\sextension.
D 2022-10-26T20:12:46.218
C Disable\sthe\spush-down\soptimization\sfor\ssub-queries\sthat\sare\sINTERSECT,\sUNION\sor\sEXCEPT\scompounds.\sdbsqlfuzz\sa34f455c91ad75a0cf8cd9476841903f42930a7a.
D 2022-10-26T21:14:21.853
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -635,7 +635,7 @@ F src/printf.c e99ee9741e79ae3873458146f59644276657340385ade4e76a5f5d1c25793764
F src/random.c 546d6feb15ec69c1aafe9bb351a277cbb498fd5410e646add673acb805714960
F src/resolve.c efea4e5fbecfd6d0a9071b0be0d952620991673391b6ffaaf4c277b0bb674633
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
F src/select.c e5b6f930f068c9c5362fc76c704ae5cb5ef1e3f18759c2126f23b0cf04c0e263
F src/select.c 8a709a8e19b32d2c411eaae1a10e2ee214cf740288859a9f9a362fcb2f50eaf1
F src/shell.c.in c4497295b826971f35a7ec77c5fb33aea192c935d670a690cec71379b007eca4
F src/sqlite.h.in d9c8a6243fc0a1c270d69db33758e34b810af3462f9bc5b4af113b347e07c69d
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
@ -1465,7 +1465,7 @@ F test/select6.test 9b2fb4ffedf52e1b5703cfcae1212e7a4a063f014c0458d78d29aca3db76
F test/select7.test f659f231489349e8c5734e610803d7654207318f
F test/select8.test 8c8f5ae43894c891efc5755ed905467d1d67ad5d
F test/select9.test f7586b207ce2304ab80dc93d3146469a28fd4403621dd3a82d06644563d3c812
F test/selectA.test 985df11dfc58dedd6f8124dea32754566346b93e294f26291b5c96d10c8cc889
F test/selectA.test 6aef8b2136a4ac7a3e2e4161d2b8ca7bc6ebe2779de084f9bb66ca9e2323a937
F test/selectB.test 954e4e49cf1f896d61794e440669e03a27ceea25
F test/selectC.test fec14c9015ed4ec941508bbc144f30b42e40ac34a4bb33001450369865dd0b75
F test/selectD.test 6d1909b49970bf92f45ce657505befcef5fc7cbc13544e18103a316d32189bfb
@ -2052,8 +2052,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 a820792548da596ed0f8ab3fd1c04ec16647abbe51a2a5aac9e17c4f58be6d97
R fafb14c921e326db97f2283b26832d15
U drh
Z 210311a48b0a6d9b875d5af811e3653c
P a029dddff4f4ed7275538610cbd9cea658b905b72924860ec9cda9e76dabcfac
R b53abb7e437a17a51c11b8e565290cc0
U dan
Z f234279171f2df9582a4a9e673101d04
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
a029dddff4f4ed7275538610cbd9cea658b905b72924860ec9cda9e76dabcfac
346a3b12b861ce7ba369e98cd336f79a1d4f7a7bb9acd7a4f63f37b391755bf5

View File

@ -5009,6 +5009,13 @@ static int pushDownWindowCheck(Parse *pParse, Select *pSubq, Expr *pExpr){
** be materialized. (This restriction is implemented in the calling
** routine.)
**
** (8) The subquery may not be a compound that uses UNION, INTERSECT,
** or EXCEPT. (We could, perhaps, relax this restriction to allow
** this case if none of the comparisons operators between left and
** right arms of the compound use a collation other than BINARY.
** But it is a lot of work to check that case for an obscure and
** minor optimization, so we omit it for now.)
**
** Return 0 if no changes are made and non-zero if one or more WHERE clause
** terms are duplicated into the subquery.
*/
@ -5028,6 +5035,10 @@ static int pushDownWhereTerms(
if( pSubq->pPrior ){
Select *pSel;
for(pSel=pSubq; pSel; pSel=pSel->pPrior){
u8 op = pSel->op;
assert( op==TK_ALL || op==TK_SELECT
|| op==TK_UNION || op==TK_INTERSECT || op==TK_EXCEPT );
if( op!=TK_ALL && op!=TK_SELECT ) return 0; /* restriction (8) */
if( pSel->pWin ) return 0; /* restriction (6b) */
}
}else{

View File

@ -1483,4 +1483,28 @@ do_execsql_test 8.1 {
AND (0 OR (SELECT 'xyz' INTERSECT SELECT a ORDER BY 1))
} {}
#-------------------------------------------------------------------------
# dbsqlfuzz a34f455c91ad75a0cf8cd9476841903f42930a7a
#
reset_db
do_execsql_test 9.0 {
CREATE TABLE t1(a COLLATE nocase);
CREATE TABLE t2(b COLLATE nocase);
INSERT INTO t1 VALUES('ABC');
INSERT INTO t2 VALUES('abc');
}
do_execsql_test 9.1 {
SELECT a FROM t1 INTERSECT SELECT b FROM t2;
} {ABC}
do_execsql_test 9.2 {
SELECT * FROM (
SELECT a FROM t1 INTERSECT SELECT b FROM t2
) WHERE a||'' = 'ABC';
} {ABC}
finish_test