diff options
author | shaneh <shaneh@noemail.net> | 2011-02-11 20:52:20 +0000 |
---|---|---|
committer | shaneh <shaneh@noemail.net> | 2011-02-11 20:52:20 +0000 |
commit | a91491e5c7d559ffd30ae9fa2b4865495025b055 (patch) | |
tree | a11fb3b1ee3c626cbb4dbd9599ed4238ce8c2570 /src | |
parent | da91e71308f8d4057dc9b40f7099623370183d12 (diff) | |
download | sqlite-a91491e5c7d559ffd30ae9fa2b4865495025b055.tar.gz sqlite-a91491e5c7d559ffd30ae9fa2b4865495025b055.zip |
Skip flattening if subquery has LIMIT and outer query is DISTINCT. Fix for ticket 752e1646fc.
FossilOrigin-Name: 559739998833643f589fa76d8360080691f83c18
Diffstat (limited to 'src')
-rw-r--r-- | src/select.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/select.c b/src/select.c index 6f64df8eb..5eeedc9f9 100644 --- a/src/select.c +++ b/src/select.c @@ -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 |