diff options
author | drh <drh@noemail.net> | 2018-09-24 15:39:30 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2018-09-24 15:39:30 +0000 |
commit | 53988068894e24ff1bf7749b0efdb80be34fef78 (patch) | |
tree | 10cd6c4a293e2d7d852aea7577a43092fecb47ca /src/expr.c | |
parent | 2fae1504024f9f9f0b66b24f17e9c6c3ddca2062 (diff) | |
download | sqlite-53988068894e24ff1bf7749b0efdb80be34fef78.tar.gz sqlite-53988068894e24ff1bf7749b0efdb80be34fef78.zip |
Slightly smaller and faster alternative to [507d892c3a40a0bacbd47] that
fixes a problem with views that use window function as part of complex
expressions.
FossilOrigin-Name: d7c816ae15f05f21b9b213161e1044aaefc56f17e7bc4b7b551a9e04efc05855
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/expr.c b/src/expr.c index 4d92ab8a1..b2854f9a5 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1270,21 +1270,24 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){ } /* Fill in pNew->pLeft and pNew->pRight. */ - zAlloc += dupedExprNodeSize(p, dupFlags); - if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly) ){ + if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly|EP_WinFunc) ){ + zAlloc += dupedExprNodeSize(p, dupFlags); if( !ExprHasProperty(pNew, EP_TokenOnly|EP_Leaf) ){ pNew->pLeft = p->pLeft ? exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc) : 0; pNew->pRight = p->pRight ? exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc) : 0; } - }else{ #ifndef SQLITE_OMIT_WINDOWFUNC if( ExprHasProperty(p, EP_WinFunc) ){ pNew->y.pWin = sqlite3WindowDup(db, pNew, p->y.pWin); assert( ExprHasProperty(pNew, EP_WinFunc) ); } #endif /* SQLITE_OMIT_WINDOWFUNC */ + if( pzBuffer ){ + *pzBuffer = zAlloc; + } + }else{ if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){ if( pNew->op==TK_SELECT_COLUMN ){ pNew->pLeft = p->pLeft; @@ -1296,9 +1299,6 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){ pNew->pRight = sqlite3ExprDup(db, p->pRight, 0); } } - if( pzBuffer ){ - *pzBuffer = zAlloc; - } } return pNew; } |