aboutsummaryrefslogtreecommitdiff
path: root/src/select.c
diff options
context:
space:
mode:
authordrh <>2022-11-25 13:08:20 +0000
committerdrh <>2022-11-25 13:08:20 +0000
commit7960da03466d96209f53defe088fc16916ba26fc (patch)
treeafc355b8eb3bb1586d7adacc79a2902454f92370 /src/select.c
parent8683c0928111707903654278e6c87634cbee5d8c (diff)
downloadsqlite-7960da03466d96209f53defe088fc16916ba26fc.tar.gz
sqlite-7960da03466d96209f53defe088fc16916ba26fc.zip
Improved comments. Add assert()s to verify that the AggInfo structure
is unchanged after registers have been assigned. FossilOrigin-Name: 5200b84195ee1ccaa387f7032eae3d463724c48cb53ba0251bbc79e927dd9752
Diffstat (limited to 'src/select.c')
-rw-r--r--src/select.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/select.c b/src/select.c
index 2e6ad4561..e76198772 100644
--- a/src/select.c
+++ b/src/select.c
@@ -6253,6 +6253,7 @@ static void analyzeAggFuncArgs(
){
int i;
assert( pAggInfo!=0 );
+ assert( pAggInfo->iFirstReg==0 );
pNC->ncFlags |= NC_InAggFunc;
for(i=0; i<pAggInfo->nFunc; i++){
Expr *pExpr = pAggInfo->aFunc[i].pFExpr;
@@ -6281,6 +6282,7 @@ static void optimizeAggregateUseOfIndexedExpr(
AggInfo *pAggInfo, /* The aggregate info */
NameContext *pNC /* Name context used to resolve agg-func args */
){
+ assert( pAggInfo->iFirstReg==0 );
pAggInfo->nColumn = pAggInfo->nAccumulator;
if( ALWAYS(pAggInfo->nSortingColumn>0) ){
if( pAggInfo->nColumn==0 ){
@@ -6348,6 +6350,18 @@ static void aggregateConvertIndexedExprRefToColumn(AggInfo *pAggInfo){
** Allocate a block of registers so that there is one register for each
** pAggInfo->aCol[] and pAggInfo->aFunc[] entry in pAggInfo. The first
** register in this block is stored in pAggInfo->iFirstReg.
+**
+** This routine may only be called once for each AggInfo object. Prior
+** to calling this routine:
+**
+** * The aCol[] and aFunc[] arrays may be modified
+** * The AggInfoColumnReg() and AggInfoFuncReg() macros may not be used
+**
+** After clling this routine:
+**
+** * The aCol[] and aFunc[] arrays are fixed
+** * The AggInfoColumnReg() and AggInfoFuncReg() macros may be used
+**
*/
static void assignAggregateRegisters(Parse *pParse, AggInfo *pAggInfo){
assert( pAggInfo!=0 );
@@ -6369,6 +6383,7 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){
int i;
struct AggInfo_func *pFunc;
int nReg = pAggInfo->nFunc + pAggInfo->nColumn;
+ assert( pAggInfo->iFirstReg>0 );
assert( pParse->db->pParse==pParse );
assert( pParse->db->mallocFailed==0 || pParse->nErr!=0 );
if( nReg==0 ) return;
@@ -6436,6 +6451,7 @@ static void updateAccumulator(
struct AggInfo_func *pF;
struct AggInfo_col *pC;
+ assert( pAggInfo->iFirstReg>0 );
pAggInfo->directMode = 1;
for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){
int nArg;