1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Fix a problem with EXCLUDE clauses on window frames with no ORDER BY.

FossilOrigin-Name: e0255063799a2a8531f0eaa8790334509591a5ababc5b915035b46d2faa80363
This commit is contained in:
dan
2019-03-19 19:19:53 +00:00
parent 8eff0cc326
commit 6603342f12
5 changed files with 857 additions and 19 deletions

View File

@@ -1573,18 +1573,24 @@ static void windowFullScan(WindowCodeArg *p){
}else if( pMWin->eExclude!=TK_NO ){
int addr;
int addrEq = 0;
KeyInfo *pKeyInfo;
KeyInfo *pKeyInfo = 0;
pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pMWin->pOrderBy, 0, 0);
if( pMWin->eExclude==TK_TIES ){
addrEq = sqlite3VdbeAddOp3(v, OP_Eq, regCRowid, lblNext, regRowid);
if( pMWin->pOrderBy ){
pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pMWin->pOrderBy, 0, 0);
}
if( pMWin->eExclude==TK_TIES ){
addrEq = sqlite3VdbeAddOp3(v, OP_Eq, regCRowid, 0, regRowid);
}
if( pKeyInfo ){
windowReadPeerValues(p, csr, regPeer);
sqlite3VdbeAddOp3(v, OP_Compare, regPeer, regCPeer, nPeer);
sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
addr = sqlite3VdbeCurrentAddr(v)+1;
sqlite3VdbeAddOp3(v, OP_Jump, addr, lblNext, addr);
VdbeCoverageEqNe(v);
}else{
sqlite3VdbeAddOp2(v, OP_Goto, 0, lblNext);
}
windowReadPeerValues(p, csr, regPeer);
sqlite3VdbeAddOp3(v, OP_Compare, regPeer, regCPeer, nPeer);
sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
addr = sqlite3VdbeCurrentAddr(v)+1;
sqlite3VdbeAddOp3(v, OP_Jump, addr, lblNext, addr);
VdbeCoverageEqNe(v);
if( addrEq ) sqlite3VdbeJumpHere(v, addrEq);
}