aboutsummaryrefslogtreecommitdiff
path: root/src/window.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2019-12-27 15:31:47 +0000
committerdan <dan@noemail.net>2019-12-27 15:31:47 +0000
commitd8d2fb92227dcb65004980bf51b6b06fa83db22c (patch)
tree9d3d4c833890f38d19fa18d91c4b03614e3c07f9 /src/window.c
parent09bee5743dc30891e08591f237c23c6964c0a0aa (diff)
downloadsqlite-d8d2fb92227dcb65004980bf51b6b06fa83db22c.tar.gz
sqlite-d8d2fb92227dcb65004980bf51b6b06fa83db22c.zip
Do not mistake constant integers in a PARTITION BY expression for references to ORDER BY style references to values returned by the SELECT statement.
FossilOrigin-Name: 45c64d39d5afed7fdc6b1de19408559740d1fba1f5e0269ab68b132366a289e4
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/window.c b/src/window.c
index ab8f2c867..83dd40532 100644
--- a/src/window.c
+++ b/src/window.c
@@ -894,9 +894,10 @@ static ExprList *exprListAppendList(
int i;
int nInit = pList ? pList->nExpr : 0;
for(i=0; i<pAppend->nExpr; i++){
+ int iDummy;
Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0);
assert( pDup==0 || !ExprHasProperty(pDup, EP_MemToken) );
- if( bIntToNull && pDup && pDup->op==TK_INTEGER ){
+ if( bIntToNull && pDup && sqlite3ExprIsInteger(pDup, &iDummy) ){
pDup->op = TK_NULL;
pDup->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse);
pDup->u.zToken = 0;
@@ -947,7 +948,7 @@ int sqlite3WindowRewrite(Parse *pParse, Select *p){
/* Create the ORDER BY clause for the sub-select. This is the concatenation
** of the window PARTITION and ORDER BY clauses. Then, if this makes it
** redundant, remove the ORDER BY from the parent SELECT. */
- pSort = sqlite3ExprListDup(db, pMWin->pPartition, 0);
+ pSort = exprListAppendList(pParse, 0, pMWin->pPartition, 1);
pSort = exprListAppendList(pParse, pSort, pMWin->pOrderBy, 1);
if( pSort && p->pOrderBy && p->pOrderBy->nExpr<=pSort->nExpr ){
int nSave = pSort->nExpr;