mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Suppress superfluous OP_OpenTemps when flattening subqueries. (CVS 412)
FossilOrigin-Name: 000441c8fec48cc172894eb767ae9549b8ed8c34
This commit is contained in:
13
src/select.c
13
src/select.c
@ -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.72 2002/03/03 02:49:51 drh Exp $
|
||||
** $Id: select.c,v 1.73 2002/03/03 03:03:53 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -163,7 +163,7 @@ static int selectInnerLoop(
|
||||
|
||||
/* Store the result as data using a unique key.
|
||||
*/
|
||||
if( eDest==SRT_Table ){
|
||||
if( eDest==SRT_Table || eDest==SRT_TempTable ){
|
||||
sqliteVdbeAddOp(v, OP_MakeRecord, nColumn, 0);
|
||||
sqliteVdbeAddOp(v, OP_NewRecno, iParm, 0);
|
||||
sqliteVdbeAddOp(v, OP_Pull, 1, 0);
|
||||
@ -1283,8 +1283,7 @@ int sqliteSelect(
|
||||
*/
|
||||
for(i=0; i<pTabList->nId; i++){
|
||||
if( pTabList->a[i].pSelect==0 ) continue;
|
||||
sqliteVdbeAddOp(v, OP_OpenTemp, base+i, 0);
|
||||
sqliteSelect(pParse, pTabList->a[i].pSelect, SRT_Table, base+i,
|
||||
sqliteSelect(pParse, pTabList->a[i].pSelect, SRT_TempTable, base+i,
|
||||
p, i, &isAgg);
|
||||
pTabList = p->pSrc;
|
||||
pWhere = p->pWhere;
|
||||
@ -1303,6 +1302,12 @@ int sqliteSelect(
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* If the output is destined for a temporary table, open that table.
|
||||
*/
|
||||
if( eDest==SRT_TempTable ){
|
||||
sqliteVdbeAddOp(v, OP_OpenTemp, iParm, 0);
|
||||
}
|
||||
|
||||
/* Do an analysis of aggregate expressions.
|
||||
*/
|
||||
sqliteAggregateInfoReset(pParse);
|
||||
|
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** Internal interface definitions for SQLite.
|
||||
**
|
||||
** @(#) $Id: sqliteInt.h,v 1.98 2002/03/03 02:49:51 drh Exp $
|
||||
** @(#) $Id: sqliteInt.h,v 1.99 2002/03/03 03:03:53 drh Exp $
|
||||
*/
|
||||
#include "sqlite.h"
|
||||
#include "hash.h"
|
||||
@ -475,6 +475,7 @@ struct Select {
|
||||
#define SRT_Union 5 /* Store result as keys in a table */
|
||||
#define SRT_Except 6 /* Remove result from a UNION table */
|
||||
#define SRT_Table 7 /* Store result as data with a unique key */
|
||||
#define SRT_TempTable 8 /* Store result in a trasient table */
|
||||
|
||||
/*
|
||||
** When a SELECT uses aggregate functions (like "count(*)" or "avg(f1)")
|
||||
|
Reference in New Issue
Block a user