1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Do not attempt to flatten compound sub-queries in a FROM clause into the parent if any component of the sub-query uses a window function.

FossilOrigin-Name: eeb76f621de2f930a548db0fbb9fe25b4479b73581826b8dfa2e63cd1f1ab783
This commit is contained in:
dan
2019-12-28 18:25:51 +00:00
parent 4adb1d0000
commit 997d7434b7
4 changed files with 25 additions and 8 deletions

View File

@@ -3669,6 +3669,7 @@ static void substSelect(
** (17d1) aggregate, or
** (17d2) DISTINCT, or
** (17d3) a join.
** (17e) the subquery may not contain window functions
**
** The parent and sub-query may contain WHERE clauses. Subject to
** rules (11), (13) and (14), they may also contain ORDER BY,
@@ -3853,6 +3854,7 @@ static int flattenSubquery(
if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0 /* (17b) */
|| (pSub1->pPrior && pSub1->op!=TK_ALL) /* (17a) */
|| pSub1->pSrc->nSrc<1 /* (17c) */
|| pSub1->pWin /* (17d) */
){
return 0;
}