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

Skip flattening if subquery has LIMIT and outer query is DISTINCT. Fix for ticket 752e1646fc.

FossilOrigin-Name: 559739998833643f589fa76d8360080691f83c18
This commit is contained in:
shaneh
2011-02-11 20:52:20 +00:00
parent da91e71308
commit a91491e5c7
6 changed files with 47 additions and 20 deletions

View File

@@ -2652,6 +2652,9 @@ static void substSelect(
** appear as unmodified result columns in the outer query. But
** have other optimizations in mind to deal with that case.
**
** (21) The subquery does not use LIMIT or the outer query is not
** DISTINCT. (See ticket [752e1646fc]).
**
** In this routine, the "p" parameter is a pointer to the outer query.
** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query
** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates.
@@ -2720,6 +2723,9 @@ static int flattenSubquery(
}
if( isAgg && pSub->pOrderBy ) return 0; /* Restriction (16) */
if( pSub->pLimit && p->pWhere ) return 0; /* Restriction (19) */
if( pSub->pLimit && (p->selFlags & SF_Distinct)!=0 ){
return 0; /* Restriction (21) */
}
/* OBSOLETE COMMENT 1:
** Restriction 3: If the subquery is a join, make sure the subquery is