mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Avoid opening a temp table for aggregate queries with no GROUP BY clause. (CVS 1649)
FossilOrigin-Name: 4d02df63496091a1e643601f84313f42130d6282
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.194 2004/06/21 07:36:32 danielk1977 Exp $
|
||||
** $Id: select.c,v 1.195 2004/06/21 10:45:09 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -2452,17 +2452,14 @@ int sqlite3Select(
|
||||
/* Reset the aggregator
|
||||
*/
|
||||
if( isAgg ){
|
||||
int addr = sqlite3VdbeAddOp(v, OP_AggReset, 0, pParse->nAgg);
|
||||
int addr = sqlite3VdbeAddOp(v, OP_AggReset, (pGroupBy?0:1), pParse->nAgg);
|
||||
for(i=0; i<pParse->nAgg; i++){
|
||||
FuncDef *pFunc;
|
||||
if( (pFunc = pParse->aAgg[i].pFunc)!=0 && pFunc->xFinalize!=0 ){
|
||||
sqlite3VdbeOp3(v, OP_AggInit, 0, i, (char*)pFunc, P3_FUNCDEF);
|
||||
}
|
||||
}
|
||||
if( pGroupBy==0 ){
|
||||
sqlite3VdbeAddOp(v, OP_String8, 0, 0);
|
||||
sqlite3VdbeAddOp(v, OP_AggFocus, 0, 0);
|
||||
}else{
|
||||
if( pGroupBy ){
|
||||
int sz = sizeof(KeyInfo) + pGroupBy->nExpr*sizeof(CollSeq*);
|
||||
KeyInfo *pKey = (KeyInfo *)sqliteMalloc(sz);
|
||||
if( 0==pKey ){
|
||||
|
||||
Reference in New Issue
Block a user