aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <Dan Kennedy>2022-10-26 21:14:21 +0000
committerdan <Dan Kennedy>2022-10-26 21:14:21 +0000
commit195687f1bfaf15460da345d0b5faae31a0c1eff3 (patch)
tree016e854841307c4fac7afeb8994752f8e0688372 /src
parent07dd4810105350e92ccc8b513b3b64cc7ae819f8 (diff)
downloadsqlite-195687f1bfaf15460da345d0b5faae31a0c1eff3.tar.gz
sqlite-195687f1bfaf15460da345d0b5faae31a0c1eff3.zip
Disable the push-down optimization for sub-queries that are INTERSECT, UNION or EXCEPT compounds. dbsqlfuzz a34f455c91ad75a0cf8cd9476841903f42930a7a.
FossilOrigin-Name: 346a3b12b861ce7ba369e98cd336f79a1d4f7a7bb9acd7a4f63f37b391755bf5
Diffstat (limited to 'src')
-rw-r--r--src/select.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/select.c b/src/select.c
index 42a476c00..0925f102e 100644
--- a/src/select.c
+++ b/src/select.c
@@ -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{