aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2022-11-22 14:31:13 +0000
committerdrh <>2022-11-22 14:31:13 +0000
commit89e5dfac01904ef55be9f2e5c007b25d57bc0263 (patch)
tree5444eef5f821a3666fd636d5ff2a825c4a01d2ab /src
parent42b78237cdd11b79e4c37d0373a338c1409f8283 (diff)
downloadsqlite-89e5dfac01904ef55be9f2e5c007b25d57bc0263.tar.gz
sqlite-89e5dfac01904ef55be9f2e5c007b25d57bc0263.zip
Omit the unnecessary AggInfo.mnReg field.
FossilOrigin-Name: d79c58ef08b917bacc0f24d210d8eb23f659f955c219b4757af42eee8f17099b
Diffstat (limited to 'src')
-rw-r--r--src/select.c26
-rw-r--r--src/sqliteInt.h1
2 files changed, 16 insertions, 11 deletions
diff --git a/src/select.c b/src/select.c
index 0872a9545..dd0226595 100644
--- a/src/select.c
+++ b/src/select.c
@@ -6211,9 +6211,7 @@ void sqlite3SelectPrep(
static void assignAggregateRegisters(Parse *pParse, AggInfo *pAggInfo){
int i, m;
assert( pAggInfo!=0 );
- assert( pAggInfo->mnReg==0 );
m = pParse->nMem;
- pAggInfo->mnReg = m+1;
for(i=0; i<pAggInfo->nColumn; i++) pAggInfo->aCol[i].iMem = ++m;
for(i=0; i<pAggInfo->nFunc; i++) pAggInfo->aFunc[i].iMem = ++m;
pParse->nMem = m;
@@ -6230,26 +6228,34 @@ static void assignAggregateRegisters(Parse *pParse, AggInfo *pAggInfo){
static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){
Vdbe *v = pParse->pVdbe;
int i;
+ int iFirstReg;
struct AggInfo_func *pFunc;
int nReg = pAggInfo->nFunc + pAggInfo->nColumn;
assert( pParse->db->pParse==pParse );
assert( pParse->db->mallocFailed==0 || pParse->nErr!=0 );
- assert( pAggInfo->mnReg>0 ); /* assignAggregateRegisters() has been run */
if( nReg==0 ) return;
if( pParse->nErr ) return;
+ if( pAggInfo->nColumn==0 ){
+ iFirstReg = pAggInfo->aFunc[0].iMem;
+ }else{
+ iFirstReg = pAggInfo->aCol[0].iMem;
+ }
#ifdef SQLITE_DEBUG
- /* Verify that all AggInfo registers are within the range specified by
- ** AggInfo.mnReg..(AggInfo.mnReg+nReg-1) */
+ /* Verify that all AggInfo register numbers have been assigned and that
+ ** they are all sequential. */
+ assert( iFirstReg>0 );
for(i=0; i<pAggInfo->nColumn; i++){
- assert( pAggInfo->aCol[i].iMem>=pAggInfo->mnReg
- && pAggInfo->aCol[i].iMem<pAggInfo->mnReg+nReg );
+ assert( pAggInfo->aCol[i].iMem>=iFirstReg );
+ assert( i==0 || pAggInfo->aCol[i].iMem==pAggInfo->aCol[i-1].iMem+1 );
}
for(i=0; i<pAggInfo->nFunc; i++){
- assert( pAggInfo->aFunc[i].iMem>=pAggInfo->mnReg
- && pAggInfo->aFunc[i].iMem<pAggInfo->mnReg+nReg );
+ assert( pAggInfo->aFunc[i].iMem>=iFirstReg );
+ assert( i>0 || pAggInfo->nColumn==0
+ || pAggInfo->aFunc[i].iMem==pAggInfo->aCol[pAggInfo->nColumn-1].iMem+1 );
+ assert( i==0 || pAggInfo->aFunc[i].iMem==pAggInfo->aFunc[i-1].iMem+1 );
}
#endif
- sqlite3VdbeAddOp3(v, OP_Null, 0, pAggInfo->mnReg, pAggInfo->mnReg+nReg-1);
+ sqlite3VdbeAddOp3(v, OP_Null, 0, iFirstReg, iFirstReg+nReg-1);
for(pFunc=pAggInfo->aFunc, i=0; i<pAggInfo->nFunc; i++, pFunc++){
if( pFunc->iDistinct>=0 ){
Expr *pE = pFunc->pFExpr;
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index d4ffaa225..68dbb3ab9 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -2719,7 +2719,6 @@ struct AggInfo {
int sortingIdx; /* Cursor number of the sorting index */
int sortingIdxPTab; /* Cursor number of pseudo-table */
int nSortingColumn; /* Number of columns in the sorting index */
- int mnReg; /* First in a range of regsiters for aCol and aFunc */
ExprList *pGroupBy; /* The group by clause */
struct AggInfo_col { /* For each column used in source tables */
Table *pTab; /* Source table */