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

Do not optimize views with an ORDER BY clause if they are used in a UNION ALL

that also has an ORDER BY clause.  Ticket #1444. (CVS 2723)

FossilOrigin-Name: 6cc57fcf15cfa3ce73c78b1cac90f7806e5bae40
This commit is contained in:
drh
2005-09-19 17:35:53 +00:00
parent a7aa59e097
commit 4b14b4d720
5 changed files with 65 additions and 11 deletions

View File

@@ -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.270 2005/09/19 15:37:07 drh Exp $
** $Id: select.c,v 1.271 2005/09/19 17:35:53 drh Exp $
*/
#include "sqliteInt.h"
@@ -1571,6 +1571,7 @@ static int multiSelect(
}
p->pPrior = 0;
p->pOrderBy = 0;
p->disallowOrderBy = pOrderBy!=0;
pLimit = p->pLimit;
p->pLimit = 0;
pOffset = p->pOffset;
@@ -1971,7 +1972,7 @@ static int flattenSubquery(
return 0;
}
if( p->isDistinct && subqueryIsAgg ) return 0;
if( p->pOrderBy && pSub->pOrderBy ) return 0;
if( (p->disallowOrderBy || p->pOrderBy) && pSub->pOrderBy ) return 0;
/* Restriction 3: If the subquery is a join, make sure the subquery is
** not used as the right operand of an outer join. Examples of why this