Fixes for "ROWS BETWEEN <expr> FOLLOWING AND <expr> FOLLOWING" and "ROWS
BETWEEN <expr> FOLLOWING AND UNBOUNDED FOLLOWING" FossilOrigin-Name: 5ac44872fd5c4f92851e7bf57d7207bb4d67de88ea2b5c746ff97f20bd6352e1
This commit is contained in:
parent
31f5639fb7
commit
e105dd7622
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C Allow\s"<expr>\sPRECEDING"\sto\sbe\sused\sto\sspecify\sthe\send\sof\sa\swindow\sframe.
|
||||
D 2018-05-24T21:10:57.618
|
||||
C Fixes\sfor\s"ROWS\sBETWEEN\s<expr>\sFOLLOWING\sAND\s<expr>\sFOLLOWING"\sand\s"ROWS\nBETWEEN\s<expr>\sFOLLOWING\sAND\sUNBOUNDED\sFOLLOWING"
|
||||
D 2018-05-25T09:29:11.361
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F Makefile.in bfc40f350586923e0419d2ea4b559c37ec10ee4b6e210e08c14401f8e340f0da
|
||||
@ -582,7 +582,7 @@ F src/where.c 60ec752fcbe9f9e0271ac60548d159a540a1ee47a4f9fedc85e88a3d0e392dd1
|
||||
F src/whereInt.h cbae2bcd37cfebdb7812a8b188cdb19634ced2b9346470d1c270556b0c33ea53
|
||||
F src/wherecode.c 728c7f70731430ccdac807a79969873e1af6968bf1c4745dff3f9dd35f636cc8
|
||||
F src/whereexpr.c e90b2e76dcabc81edff56633bf281bc01d93b71e0c81482dc06925ce39f5844a
|
||||
F src/window.c e4441e8ee3f83df85ff542048d3eed1c199ce6f90f3edcfeb1c4c1f53991b125
|
||||
F src/window.c 4f9f7ceffb08db3a51d3b6450d464206de335122ac9a3e1e70545eda27abd34f
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd
|
||||
F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d
|
||||
@ -1615,8 +1615,8 @@ F test/win32lock.test fbf107c91d8f5512be5a5b87c4c42ab9fdd54972
|
||||
F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d
|
||||
F test/win32nolock.test ac4f08811a562e45a5755e661f45ca85892bdbbc
|
||||
F test/window1.test 5705337783d220b47f6fb4432264543b7557a05be8013d772f57d71f2fded271
|
||||
F test/window2.tcl 6df00293e3691a0d17624de339ce91632252e160701d9be663c21e3706f1dfd0
|
||||
F test/window2.test ee542c30bf8502f6df6f1a7304c2ca1d44143dfdd82dfad331f0b3b287de414c
|
||||
F test/window2.tcl fd079901ac103a99761803477161834208a243bdd6ec0fbbbd0fc93c7dca1945
|
||||
F test/window2.test 4f5efb59714ec741e510f12a24a3196316b90715860d79acb904fb5cc45a3dca
|
||||
F test/with1.test 58475190cd8caaeebea8cfeb2a264ec97a0c492b8ffe9ad20cefbb23df462f96
|
||||
F test/with2.test e0030e2f0267a910d6c0e4f46f2dfe941c1cc0d4f659ba69b3597728e7e8f1ab
|
||||
F test/with3.test 5e8ce2c585170bbbc0544e2a01a4941fa0be173ba5265e5c92eb588cd99a232d
|
||||
@ -1733,7 +1733,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P ec7b648c7f0ee266653561bbb9daa45b9be0d8a1a14f11dc93bce467c35154e6
|
||||
R cae23b80a7b926c27766da973f4ae9e5
|
||||
P 7b709a989c188dbcf429989a0785294b36c8a7e89b5de8cefc25decf1f5b7f5a
|
||||
R 5f959d7a0a7f70c41b9ccac874921e95
|
||||
U dan
|
||||
Z 6786b4d33cda910bcdf7493ef1afdc20
|
||||
Z ca20d77c2db1ab2eada699a4eb9123fb
|
||||
|
@ -1 +1 @@
|
||||
7b709a989c188dbcf429989a0785294b36c8a7e89b5de8cefc25decf1f5b7f5a
|
||||
5ac44872fd5c4f92851e7bf57d7207bb4d67de88ea2b5c746ff97f20bd6352e1
|
22
src/window.c
22
src/window.c
@ -163,13 +163,13 @@ static void windowAggStep(
|
||||
** Aggstep (csrEnd)
|
||||
** Next(csrEnd) // if EOF fall-through
|
||||
** if( (regEnd--)<=0 ){
|
||||
** AggStep (csrStart, xInverse)
|
||||
** Next (csrStart)
|
||||
** if( (regStart--)<=0 ){
|
||||
** AggFinal (xValue)
|
||||
** Gosub addrGosub
|
||||
** Next(csr) // if EOF goto flush_partition_done
|
||||
** }
|
||||
** AggStep (csrStart, xInverse)
|
||||
** Next (csrStart)
|
||||
** }
|
||||
**
|
||||
** ROWS BETWEEN <expr> PRECEDING AND <expr> PRECEDING
|
||||
@ -222,6 +222,7 @@ static void windowCodeRowExprStep(
|
||||
|
||||
assert( pMWin->eStart==TK_PRECEDING
|
||||
|| pMWin->eStart==TK_CURRENT
|
||||
|| pMWin->eStart==TK_FOLLOWING
|
||||
|| pMWin->eStart==TK_UNBOUNDED
|
||||
);
|
||||
assert( pMWin->eEnd==TK_FOLLOWING
|
||||
@ -283,13 +284,16 @@ static void windowCodeRowExprStep(
|
||||
/* If either regStart or regEnd are not non-negative integers, throw
|
||||
** an exception. */
|
||||
if( pMWin->pStart ){
|
||||
assert( pMWin->eStart==TK_PRECEDING );
|
||||
sqlite3ExprCode(pParse, pMWin->pStart, regStart);
|
||||
windowCheckFrameValue(pParse, regStart, 0);
|
||||
}
|
||||
if( pMWin->pEnd ){
|
||||
sqlite3ExprCode(pParse, pMWin->pEnd, regEnd);
|
||||
windowCheckFrameValue(pParse, regEnd, 1);
|
||||
if( pMWin->pStart && pMWin->eStart==TK_FOLLOWING ){
|
||||
assert( pMWin->eEnd==TK_FOLLOWING );
|
||||
sqlite3VdbeAddOp3(v, OP_Subtract, regStart, regEnd, regEnd);
|
||||
}
|
||||
}
|
||||
|
||||
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
|
||||
@ -327,7 +331,11 @@ static void windowCodeRowExprStep(
|
||||
if( pMWin->eEnd==TK_FOLLOWING ){
|
||||
addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);
|
||||
}
|
||||
if( pMWin->eStart==TK_FOLLOWING ){
|
||||
addrIfPos2 = sqlite3VdbeAddOp3(v, OP_IfPos, regStart, 0 , 1);
|
||||
}
|
||||
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
|
||||
sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
|
||||
sqlite3VdbeAddOp3(v,
|
||||
OP_AggFinal, pWin->regAccum, pWin->nArg, pWin->regResult
|
||||
);
|
||||
@ -336,8 +344,14 @@ static void windowCodeRowExprStep(
|
||||
sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
|
||||
sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)+2);
|
||||
sqlite3VdbeAddOp2(v, OP_Goto, 0, lblFlushDone);
|
||||
if( pMWin->eStart==TK_FOLLOWING ){
|
||||
sqlite3VdbeJumpHere(v, addrIfPos2);
|
||||
}
|
||||
|
||||
if( pMWin->eStart==TK_CURRENT || pMWin->eStart==TK_PRECEDING ){
|
||||
if( pMWin->eStart==TK_CURRENT
|
||||
|| pMWin->eStart==TK_PRECEDING
|
||||
|| pMWin->eStart==TK_FOLLOWING
|
||||
){
|
||||
if( pMWin->eStart==TK_PRECEDING ){
|
||||
addrIfPos2 = sqlite3VdbeAddOp3(v, OP_IfPos, regStart, 0 , 1);
|
||||
}
|
||||
|
@ -258,32 +258,60 @@ execsql_test 2.18 {
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.19 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 FOLLOWING AND 3 FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.20 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.21 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 2.22 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
==========
|
||||
|
||||
puts $::fd finish_test
|
||||
==========
|
||||
|
||||
execsql_test 3.1 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b ORDER BY d
|
||||
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 3.2 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY b
|
||||
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
|
||||
execsql_test 3.3 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
}
|
||||
# execsql_test 3.1 {
|
||||
# SELECT a, sum(d) OVER (
|
||||
# PARTITION BY b ORDER BY d
|
||||
# RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
# ) FROM t1
|
||||
# }
|
||||
#
|
||||
# execsql_test 3.2 {
|
||||
# SELECT a, sum(d) OVER (
|
||||
# ORDER BY b
|
||||
# RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
# ) FROM t1
|
||||
# }
|
||||
#
|
||||
# execsql_test 3.3 {
|
||||
# SELECT a, sum(d) OVER (
|
||||
# ORDER BY d
|
||||
# ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
# ) FROM t1
|
||||
# }
|
||||
|
||||
finish_test
|
||||
|
||||
|
@ -169,30 +169,39 @@ do_execsql_test 2.18 {
|
||||
) FROM t1
|
||||
} {2 {} 4 {} 6 2 1 {} 3 {} 5 1}
|
||||
|
||||
#==========================================================================
|
||||
|
||||
finish_test
|
||||
#==========================================================================
|
||||
|
||||
do_execsql_test 3.1 {
|
||||
do_execsql_test 2.19 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b ORDER BY d
|
||||
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 FOLLOWING AND 3 FOLLOWING
|
||||
) FROM t1
|
||||
} {2 12 4 10 6 6 1 9 3 8 5 5}
|
||||
} {2 10 4 6 6 {} 1 8 3 5 5 {}}
|
||||
|
||||
do_execsql_test 3.2 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY b
|
||||
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
} {2 21 4 21 6 21 1 9 3 9 5 9}
|
||||
|
||||
do_execsql_test 3.3 {
|
||||
do_execsql_test 2.20 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING
|
||||
) FROM t1
|
||||
} {1 21 2 21 3 21 4 21 5 21 6 21}
|
||||
} {1 5 2 7 3 9 4 11 5 6 6 {}}
|
||||
|
||||
do_execsql_test 2.21 {
|
||||
SELECT a, sum(d) OVER (
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
} {1 20 2 18 3 15 4 11 5 6 6 {}}
|
||||
|
||||
do_execsql_test 2.22 {
|
||||
SELECT a, sum(d) OVER (
|
||||
PARTITION BY b
|
||||
ORDER BY d
|
||||
ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING
|
||||
) FROM t1
|
||||
} {2 10 4 6 6 {} 1 8 3 5 5 {}}
|
||||
|
||||
#==========================================================================
|
||||
|
||||
finish_test
|
||||
#==========================================================================
|
||||
|
||||
finish_test
|
||||
|
Loading…
Reference in New Issue
Block a user