mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Do not flatten subqueries where the subquery has a LIMIT and the outer
query has a WHERE clause. Ticket #3334. (CVS 5613) FossilOrigin-Name: 4995a1d1c9530be9ce647d338169620cd95a72eb
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
** This file contains C code routines that are called by the parser
|
||||
** to handle SELECT statements in SQLite.
|
||||
**
|
||||
** $Id: select.c,v 1.470 2008/08/25 17:23:29 drh Exp $
|
||||
** $Id: select.c,v 1.471 2008/08/26 12:56:14 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -2525,6 +2525,9 @@ static void substSelect(
|
||||
** ORDER by clause of the parent must be simple references to
|
||||
** columns of the sub-query.
|
||||
**
|
||||
** (19) The subquery does not use LIMIT or the outer query does not
|
||||
** have a WHERE clause.
|
||||
**
|
||||
** 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.
|
||||
@@ -2590,6 +2593,7 @@ static int flattenSubquery(
|
||||
return 0; /* Restriction (11) */
|
||||
}
|
||||
if( isAgg && pSub->pOrderBy ) return 0; /* Restriction (16) */
|
||||
if( pSub->pLimit && p->pWhere ) return 0; /* Restriction (19) */
|
||||
|
||||
/* OBSOLETE COMMENT 1:
|
||||
** Restriction 3: If the subquery is a join, make sure the subquery is
|
||||
|
||||
Reference in New Issue
Block a user