1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Simplify the accumulator reset for aggregate query processing so that it

uses a single multi-register OP_Null rather than a separate OP_Null for each
register.

FossilOrigin-Name: 2c7fd9b043f5f3d9d8e22dbefa84a9770ca951d0
This commit is contained in:
drh
2013-12-20 13:11:45 +00:00
parent 1001ee8819
commit 7e61d18eb4
4 changed files with 26 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
C Do\snot\sinject\sOOM\sfaults\sinto\sSQLITE_FCNTL_COMMIT_PHASE_TWO\sfile-control\sinvocations.\sIt\scauses\sproblems\sfor\stest\sscripts.
D 2013-12-19T17:04:58.210
C Simplify\sthe\saccumulator\sreset\sfor\saggregate\squery\sprocessing\sso\sthat\sit\nuses\sa\ssingle\smulti-register\sOP_Null\srather\sthan\sa\sseparate\sOP_Null\sfor\seach\nregister.
D 2013-12-20T13:11:45.101
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -219,12 +219,12 @@ F src/printf.c 85d07756e45d7496d19439dcae3e6e9e0090f269
F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68
F src/resolve.c 7eda9097b29fcf3d2b42fdc17d1de672134e09b6
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
F src/select.c 9d13850293cf19e5ffee59b231fa372e16ce65a9
F src/select.c 819bb090c9a348d17f69f136cad2bfa9ee9cbb41
F src/shell.c 18924f6ccfa70da98bf9e388bab512c0fd1e792e
F src/sqlite.h.in 4ef56464aeaa3785a2c5ca37fb3a0fb229d68b2e
F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e
F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
F src/sqliteInt.h b7e9da87740488671cfe4c70038a8eef3a1d317e
F src/sqliteInt.h d0815177df125e900056e1e692504435e7610793
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
@@ -1147,7 +1147,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
P ca3fdfd41961d8d3d1e39d20dc628e8a95dabb2f
R b2d8ac3bed199d88ddec25ed7c70eec6
U dan
Z b85edb7cdda29606f3560dec5a14157c
P 8eb28d23e353139d24a8af78309d39249ab9eaf0
R 488c9d6501762ac1c5b904ecc4a5a8a0
U drh
Z c5be2c2c1ecdd01c10eef8b3332d3737

View File

@@ -1 +1 @@
8eb28d23e353139d24a8af78309d39249ab9eaf0
2c7fd9b043f5f3d9d8e22dbefa84a9770ca951d0

View File

@@ -3822,14 +3822,23 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){
Vdbe *v = pParse->pVdbe;
int i;
struct AggInfo_func *pFunc;
if( pAggInfo->nFunc+pAggInfo->nColumn==0 ){
return;
}
int nReg = pAggInfo->nFunc + pAggInfo->nColumn;
if( nReg==0 ) return;
#ifdef SQLITE_DEBUG
/* Verify that all AggInfo registers are within the range specified by
** AggInfo.mnReg..AggInfo.mxReg */
assert( nReg==pAggInfo->mxReg-pAggInfo->mnReg+1 );
for(i=0; i<pAggInfo->nColumn; i++){
sqlite3VdbeAddOp2(v, OP_Null, 0, pAggInfo->aCol[i].iMem);
assert( pAggInfo->aCol[i].iMem>=pAggInfo->mnReg
&& pAggInfo->aCol[i].iMem<=pAggInfo->mxReg );
}
for(i=0; i<pAggInfo->nFunc; i++){
assert( pAggInfo->aFunc[i].iMem>=pAggInfo->mnReg
&& pAggInfo->aFunc[i].iMem<=pAggInfo->mxReg );
}
#endif
sqlite3VdbeAddOp3(v, OP_Null, 0, pAggInfo->mnReg, pAggInfo->mxReg);
for(pFunc=pAggInfo->aFunc, i=0; i<pAggInfo->nFunc; i++, pFunc++){
sqlite3VdbeAddOp2(v, OP_Null, 0, pFunc->iMem);
if( pFunc->iDistinct>=0 ){
Expr *pE = pFunc->pExpr;
assert( !ExprHasProperty(pE, EP_xIsSelect) );
@@ -4407,6 +4416,7 @@ int sqlite3Select(
sNC.pParse = pParse;
sNC.pSrcList = pTabList;
sNC.pAggInfo = &sAggInfo;
sAggInfo.mnReg = pParse->nMem+1;
sAggInfo.nSortingColumn = pGroupBy ? pGroupBy->nExpr+1 : 0;
sAggInfo.pGroupBy = pGroupBy;
sqlite3ExprAnalyzeAggList(&sNC, pEList);
@@ -4421,6 +4431,7 @@ int sqlite3Select(
sqlite3ExprAnalyzeAggList(&sNC, sAggInfo.aFunc[i].pExpr->x.pList);
sNC.ncFlags &= ~NC_InAggFunc;
}
sAggInfo.mxReg = pParse->nMem;
if( db->mallocFailed ) goto select_end;
/* Processing for aggregates with GROUP BY is very different and

View File

@@ -1688,6 +1688,7 @@ 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, mxReg; /* Range of registers allocated for aCol and aFunc */
ExprList *pGroupBy; /* The group by clause */
struct AggInfo_col { /* For each column used in source tables */
Table *pTab; /* Source table */