mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Ensure that SQLite does not attempt to process incompatible window functions in a single scan. Fix for [256741a1].
FossilOrigin-Name: 4f5b2d938194fab7627486e2ced633def2c90d9d3328e3700612feb9dbfa3d9a
This commit is contained in:
21
src/window.c
21
src/window.c
@@ -1229,6 +1229,25 @@ void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Possibly link window pWin into the list at pSel->pWin (window functions
|
||||
** to be processed as part of SELECT statement pSel). The window is linked
|
||||
** in if either (a) there are no other windows already linked to this
|
||||
** SELECT, or (b) the windows already linked use a compatible window frame.
|
||||
*/
|
||||
void sqlite3WindowLink(Select *pSel, Window *pWin){
|
||||
if( 0==pSel->pWin
|
||||
|| 0==sqlite3WindowCompare(0, pSel->pWin, pWin, 0)
|
||||
){
|
||||
pWin->pNextWin = pSel->pWin;
|
||||
if( pSel->pWin ){
|
||||
pSel->pWin->ppThis = &pWin->pNextWin;
|
||||
}
|
||||
pSel->pWin = pWin;
|
||||
pWin->ppThis = &pSel->pWin;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Return 0 if the two window objects are identical, or non-zero otherwise.
|
||||
** Identical window objects can be processed in a single scan.
|
||||
@@ -1416,6 +1435,8 @@ static void windowAggStep(
|
||||
int nArg = windowArgCount(pWin);
|
||||
int i;
|
||||
|
||||
assert( bInverse==0 || pWin->eStart!=TK_UNBOUNDED );
|
||||
|
||||
for(i=0; i<nArg; i++){
|
||||
if( i!=1 || pFunc->zName!=nth_valueName ){
|
||||
sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);
|
||||
|
Reference in New Issue
Block a user