diff options
author | dan <dan@noemail.net> | 2019-07-22 16:20:03 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2019-07-22 16:20:03 +0000 |
commit | 75b0821e999cb14d4081a6ff8090e28e49e5bc7e (patch) | |
tree | 778d751b5c8ac70cb3800d06990a15b9dde08a8b /src/expr.c | |
parent | fd15e18d7fe9bea571c52324a6eae25f3e2b4ebc (diff) | |
download | sqlite-75b0821e999cb14d4081a6ff8090e28e49e5bc7e.tar.gz sqlite-75b0821e999cb14d4081a6ff8090e28e49e5bc7e.zip |
Remove Window objects from the corresponding Select.pWin list when they are deleted.
FossilOrigin-Name: d23f33168222dfa40a67dc7de58057418151989e81429e4af47617e86db04667
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/expr.c b/src/expr.c index 56b3148ed..571e9e494 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1326,10 +1326,17 @@ static With *withDup(sqlite3 *db, With *p){ */ static int gatherSelectWindowsCallback(Walker *pWalker, Expr *pExpr){ if( pExpr->op==TK_FUNCTION && ExprHasProperty(pExpr, EP_WinFunc) ){ - assert( pExpr->y.pWin ); + Select *pSelect = pWalker->u.pSelect; + Window *pWin = pExpr->y.pWin; + assert( pWin ); assert( IsWindowFunc(pExpr) ); - pExpr->y.pWin->pNextWin = pWalker->u.pSelect->pWin; - pWalker->u.pSelect->pWin = pExpr->y.pWin; + if( pSelect->pWin ){ + *pSelect->pWin->ppThis = pSelect->pWin->pNextWin; + pSelect->pWin->ppThis = &pWin->pNextWin; + } + pWin->pNextWin = pSelect->pWin; + pWin->ppThis = &pSelect->pWin; + pSelect->pWin = pWin; } return WRC_Continue; } |