1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Fix a segfault caused by invoking a regular aggregate as a window-function.

And some problems with count(*) when used as a window-function.

FossilOrigin-Name: 4f3c8a82fd1c5b14d84f2301e34cfc8d52fe4b3a60840c39e895c11f2da529d9
This commit is contained in:
dan
2018-07-02 12:07:32 +00:00
parent 9f607e9c23
commit 7262ca94cb
10 changed files with 387 additions and 238 deletions

View File

@@ -1594,17 +1594,21 @@ static void windowCodeRowExprStep(
|| pMWin->eStart==TK_PRECEDING
|| pMWin->eStart==TK_FOLLOWING
){
int addrJumpHere = 0;
int lblSkipInverse = sqlite3VdbeMakeLabel(v);;
if( pMWin->eStart==TK_PRECEDING ){
addrJumpHere = sqlite3VdbeAddOp3(v, OP_IfPos, regStart, 0 , 1);
sqlite3VdbeAddOp3(v, OP_IfPos, regStart, lblSkipInverse, 1);
VdbeCoverage(v);
}
sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+1);
VdbeCoverage(v);
windowAggStep(pParse, pMWin, csrStart, 1, regArg, regSize);
if( addrJumpHere ){
sqlite3VdbeJumpHere(v, addrJumpHere);
if( pMWin->eStart==TK_FOLLOWING ){
sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+2);
VdbeCoverage(v);
sqlite3VdbeAddOp2(v, OP_Goto, 0, lblSkipInverse);
}else{
sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+1);
VdbeCoverage(v);
}
windowAggStep(pParse, pMWin, csrStart, 1, regArg, regSize);
sqlite3VdbeResolveLabel(v, lblSkipInverse);
}
if( pMWin->eEnd==TK_FOLLOWING ){
sqlite3VdbeJumpHere(v, addrIfPos1);