More fixes for different window frame types.
FossilOrigin-Name: 2c85668a0f86bcfd3de4c65847ac252e136ce97409a2249c5f4f58e3756e9a69
This commit is contained in:
parent
09590aaa1b
commit
79d4544d53
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
|||||||
C Fix\s"RANGE\sBETWEEN\sCURRENT\sROW\sAND\sUNBOUNDED\sFOLLOWING"\swindow\sframe\nprocessing.
|
C More\sfixes\sfor\sdifferent\swindow\sframe\stypes.
|
||||||
D 2018-05-25T20:30:17.495
|
D 2018-05-26T21:17:29.893
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F Makefile.in bfc40f350586923e0419d2ea4b559c37ec10ee4b6e210e08c14401f8e340f0da
|
F Makefile.in bfc40f350586923e0419d2ea4b559c37ec10ee4b6e210e08c14401f8e340f0da
|
||||||
@ -582,7 +582,7 @@ F src/where.c 60ec752fcbe9f9e0271ac60548d159a540a1ee47a4f9fedc85e88a3d0e392dd1
|
|||||||
F src/whereInt.h cbae2bcd37cfebdb7812a8b188cdb19634ced2b9346470d1c270556b0c33ea53
|
F src/whereInt.h cbae2bcd37cfebdb7812a8b188cdb19634ced2b9346470d1c270556b0c33ea53
|
||||||
F src/wherecode.c 728c7f70731430ccdac807a79969873e1af6968bf1c4745dff3f9dd35f636cc8
|
F src/wherecode.c 728c7f70731430ccdac807a79969873e1af6968bf1c4745dff3f9dd35f636cc8
|
||||||
F src/whereexpr.c e90b2e76dcabc81edff56633bf281bc01d93b71e0c81482dc06925ce39f5844a
|
F src/whereexpr.c e90b2e76dcabc81edff56633bf281bc01d93b71e0c81482dc06925ce39f5844a
|
||||||
F src/window.c 793ad5ffe29cf09f33db392f2e21f42de76f7292a1819e50b12740bff337b9d7
|
F src/window.c e613228176b84fd4a387db01d2d85382e7bd26adc97c469ef4442219dce6f59a
|
||||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||||
F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd
|
F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd
|
||||||
F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d
|
F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d
|
||||||
@ -1615,8 +1615,8 @@ F test/win32lock.test fbf107c91d8f5512be5a5b87c4c42ab9fdd54972
|
|||||||
F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d
|
F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d
|
||||||
F test/win32nolock.test ac4f08811a562e45a5755e661f45ca85892bdbbc
|
F test/win32nolock.test ac4f08811a562e45a5755e661f45ca85892bdbbc
|
||||||
F test/window1.test 5705337783d220b47f6fb4432264543b7557a05be8013d772f57d71f2fded271
|
F test/window1.test 5705337783d220b47f6fb4432264543b7557a05be8013d772f57d71f2fded271
|
||||||
F test/window2.tcl 4d0fd12b30cb1cf3f0e125dc8ff7f88c048fdc6a9301df7542abea26627c1f9a
|
F test/window2.tcl fab2f4f27d26228ccbc4d68f468f05879456e344980251fc6dc716f69b1346b9
|
||||||
F test/window2.test 47bb1eb149a605d2082794c7036bdd130a4e6c7ee59ded740748c79b37013aac
|
F test/window2.test 8fad10a74317e7dfba6e41a837ca987ab4686e84763c07d17c119dac39c76ff9
|
||||||
F test/with1.test 58475190cd8caaeebea8cfeb2a264ec97a0c492b8ffe9ad20cefbb23df462f96
|
F test/with1.test 58475190cd8caaeebea8cfeb2a264ec97a0c492b8ffe9ad20cefbb23df462f96
|
||||||
F test/with2.test e0030e2f0267a910d6c0e4f46f2dfe941c1cc0d4f659ba69b3597728e7e8f1ab
|
F test/with2.test e0030e2f0267a910d6c0e4f46f2dfe941c1cc0d4f659ba69b3597728e7e8f1ab
|
||||||
F test/with3.test 5e8ce2c585170bbbc0544e2a01a4941fa0be173ba5265e5c92eb588cd99a232d
|
F test/with3.test 5e8ce2c585170bbbc0544e2a01a4941fa0be173ba5265e5c92eb588cd99a232d
|
||||||
@ -1733,7 +1733,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 6232519899efc568465d8fcc9fcd79d46a2ce4ec05109d26d5eb1ebd239cd596
|
P b4e9c686697a5211a3bfa47e63f0684e3d4241d8c292cffe1a967bc39ad7cd8f
|
||||||
R 89fd55d38159d271a1d4c5a8e0028929
|
R 341854783e18819703bbf013f333c88d
|
||||||
U dan
|
U dan
|
||||||
Z b9c949b19ea308875db3121f11330208
|
Z da01c5822c42d130004dc2d45e5dd589
|
||||||
|
@ -1 +1 @@
|
|||||||
b4e9c686697a5211a3bfa47e63f0684e3d4241d8c292cffe1a967bc39ad7cd8f
|
2c85668a0f86bcfd3de4c65847ac252e136ce97409a2249c5f4f58e3756e9a69
|
58
src/window.c
58
src/window.c
@ -350,7 +350,6 @@ static void windowCodeRowExprStep(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
|
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
|
||||||
sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
|
|
||||||
sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
|
sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,6 +462,26 @@ static void windowCodeRowExprStep(
|
|||||||
sqlite3VdbeJumpHere(v, addrGoto);
|
sqlite3VdbeJumpHere(v, addrGoto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||||
|
**
|
||||||
|
** ...
|
||||||
|
** if( new partition ){
|
||||||
|
** AggFinal (xFinalize)
|
||||||
|
** Gosub addrGosub
|
||||||
|
** ResetSorter eph-table
|
||||||
|
** }
|
||||||
|
** else if( new peer ){
|
||||||
|
** AggFinal (xValue)
|
||||||
|
** Gosub addrGosub
|
||||||
|
** ResetSorter eph-table
|
||||||
|
** }
|
||||||
|
** AggStep
|
||||||
|
** Insert (record into eph-table)
|
||||||
|
** sqlite3WhereEnd()
|
||||||
|
** AggFinal (xFinalize)
|
||||||
|
** Gosub addrGosub
|
||||||
|
*/
|
||||||
static void windowCodeDefaultStep(
|
static void windowCodeDefaultStep(
|
||||||
Parse *pParse,
|
Parse *pParse,
|
||||||
Select *p,
|
Select *p,
|
||||||
@ -481,6 +500,10 @@ static void windowCodeDefaultStep(
|
|||||||
int regRowid = regRecord+1;
|
int regRowid = regRecord+1;
|
||||||
int addr;
|
int addr;
|
||||||
|
|
||||||
|
assert( pMWin->eType==TK_RANGE
|
||||||
|
|| (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)
|
||||||
|
);
|
||||||
|
|
||||||
pParse->nMem += nSub + 2;
|
pParse->nMem += nSub + 2;
|
||||||
|
|
||||||
/* Martial the row returned by the sub-select into an array of
|
/* Martial the row returned by the sub-select into an array of
|
||||||
@ -518,11 +541,15 @@ static void windowCodeDefaultStep(
|
|||||||
int regNewPeer = reg + pMWin->nBufferCol + nPart;
|
int regNewPeer = reg + pMWin->nBufferCol + nPart;
|
||||||
int regPeer = pMWin->regPart + nPart;
|
int regPeer = pMWin->regPart + nPart;
|
||||||
|
|
||||||
KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);
|
|
||||||
if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
|
if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
|
||||||
addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPeer, regPeer, nPeer);
|
if( pMWin->eType==TK_RANGE ){
|
||||||
sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
|
KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);
|
||||||
addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
|
addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPeer, regPeer, nPeer);
|
||||||
|
sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
|
||||||
|
addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
|
||||||
|
}else{
|
||||||
|
addrJump = 0;
|
||||||
|
}
|
||||||
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
|
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
|
||||||
sqlite3VdbeAddOp3(v,
|
sqlite3VdbeAddOp3(v,
|
||||||
OP_AggFinal, pWin->regAccum, pWin->nArg, pWin->regResult
|
OP_AggFinal, pWin->regAccum, pWin->nArg, pWin->regResult
|
||||||
@ -538,7 +565,7 @@ static void windowCodeDefaultStep(
|
|||||||
v, OP_Copy, reg+pMWin->nBufferCol, pMWin->regPart, nPart+nPeer-1
|
v, OP_Copy, reg+pMWin->nBufferCol, pMWin->regPart, nPart+nPeer-1
|
||||||
);
|
);
|
||||||
|
|
||||||
sqlite3VdbeJumpHere(v, addrJump);
|
if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Invoke step function for window functions */
|
/* Invoke step function for window functions */
|
||||||
@ -571,25 +598,6 @@ static void windowCodeDefaultStep(
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
|
||||||
**
|
|
||||||
** ...
|
|
||||||
** if( new partition ){
|
|
||||||
** AggFinal (xFinalize)
|
|
||||||
** Gosub addrGosub
|
|
||||||
** ResetSorter eph-table
|
|
||||||
** }
|
|
||||||
** else if( new peer ){
|
|
||||||
** AggFinal (xValue)
|
|
||||||
** Gosub addrGosub
|
|
||||||
** ResetSorter eph-table
|
|
||||||
** }
|
|
||||||
** AggStep
|
|
||||||
** Insert (record into eph-table)
|
|
||||||
** sqlite3WhereEnd()
|
|
||||||
** AggFinal (xFinalize)
|
|
||||||
** Gosub addrGosub
|
|
||||||
**
|
|
||||||
** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||||
**
|
**
|
||||||
** As above, except take no action for a "new peer". Invoke
|
** As above, except take no action for a "new peer". Invoke
|
||||||
|
107
test/window2.tcl
107
test/window2.tcl
@ -346,30 +346,93 @@ execsql_test 2.30 {
|
|||||||
) FROM t1
|
) FROM t1
|
||||||
}
|
}
|
||||||
|
|
||||||
==========
|
execsql_test 3.1 {
|
||||||
puts $::fd finish_test
|
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.4 {
|
||||||
|
SELECT a, sum(d) OVER (
|
||||||
|
ORDER BY d/2
|
||||||
|
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||||
|
) FROM t1
|
||||||
|
}
|
||||||
|
|
||||||
|
#puts $::fd finish_test
|
||||||
|
|
||||||
==========
|
==========
|
||||||
|
|
||||||
# execsql_test 3.1 {
|
execsql_test 4.0 {
|
||||||
# SELECT a, sum(d) OVER (
|
DROP TABLE IF EXISTS t2;
|
||||||
# PARTITION BY b ORDER BY d
|
CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER);
|
||||||
# RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
INSERT INTO t2(a, b) VALUES
|
||||||
# ) FROM t1
|
(1,0), (2,74), (3,41), (4,74), (5,23), (6,99), (7,26), (8,33), (9,2),
|
||||||
# }
|
(10,89), (11,81), (12,96), (13,59), (14,38), (15,68), (16,39), (17,62),
|
||||||
#
|
(18,91), (19,46), (20,6), (21,99), (22,97), (23,27), (24,46), (25,78),
|
||||||
# execsql_test 3.2 {
|
(26,54), (27,97), (28,8), (29,67), (30,29), (31,93), (32,84), (33,77),
|
||||||
# SELECT a, sum(d) OVER (
|
(34,23), (35,16), (36,16), (37,93), (38,65), (39,35), (40,47), (41,7),
|
||||||
# ORDER BY b
|
(42,86), (43,74), (44,61), (45,91), (46,85), (47,24), (48,85), (49,43),
|
||||||
# RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
(50,59), (51,12), (52,32), (53,56), (54,3), (55,91), (56,22), (57,90),
|
||||||
# ) FROM t1
|
(58,55), (59,15), (60,28), (61,89), (62,25), (63,47), (64,1), (65,56),
|
||||||
# }
|
(66,40), (67,43), (68,56), (69,16), (70,75), (71,36), (72,89), (73,98),
|
||||||
#
|
(74,76), (75,81), (76,4), (77,94), (78,42), (79,30), (80,78), (81,33),
|
||||||
# execsql_test 3.3 {
|
(82,29), (83,53), (84,63), (85,2), (86,87), (87,37), (88,80), (89,84),
|
||||||
# SELECT a, sum(d) OVER (
|
(90,72), (91,41), (92,9), (93,61), (94,73), (95,95), (96,65), (97,13),
|
||||||
# ORDER BY d
|
(98,58), (99,96), (100,98), (101,1), (102,21), (103,74), (104,65), (105,35),
|
||||||
# ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
(106,5), (107,73), (108,11), (109,51), (110,87), (111,41), (112,12), (113,8),
|
||||||
# ) FROM t1
|
(114,20), (115,31), (116,31), (117,15), (118,95), (119,22), (120,73),
|
||||||
# }
|
(121,79), (122,88), (123,34), (124,8), (125,11), (126,49), (127,34),
|
||||||
|
(128,90), (129,59), (130,96), (131,60), (132,55), (133,75), (134,77),
|
||||||
|
(135,44), (136,2), (137,7), (138,85), (139,57), (140,74), (141,29), (142,70),
|
||||||
|
(143,59), (144,19), (145,39), (146,26), (147,26), (148,47), (149,80),
|
||||||
|
(150,90), (151,36), (152,58), (153,47), (154,9), (155,72), (156,72), (157,66),
|
||||||
|
(158,33), (159,93), (160,75), (161,64), (162,81), (163,9), (164,23), (165,37),
|
||||||
|
(166,13), (167,12), (168,14), (169,62), (170,91), (171,36), (172,91),
|
||||||
|
(173,33), (174,15), (175,34), (176,36), (177,99), (178,3), (179,95), (180,69),
|
||||||
|
(181,58), (182,52), (183,30), (184,50), (185,84), (186,10), (187,84),
|
||||||
|
(188,33), (189,21), (190,39), (191,44), (192,58), (193,30), (194,38),
|
||||||
|
(195,34), (196,83), (197,27), (198,82), (199,17), (200,7);
|
||||||
|
}
|
||||||
|
|
||||||
|
execsql_test 4.1 {
|
||||||
|
SELECT a, sum(b) OVER (
|
||||||
|
PARTITION BY (b%10)
|
||||||
|
ORDER BY b
|
||||||
|
) FROM t2 ORDER BY a;
|
||||||
|
}
|
||||||
|
|
||||||
|
execsql_test 4.2 {
|
||||||
|
SELECT a, sum(b) OVER (
|
||||||
|
PARTITION BY (b%10)
|
||||||
|
ORDER BY b
|
||||||
|
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||||
|
) FROM t2 ORDER BY a;
|
||||||
|
}
|
||||||
|
|
||||||
|
execsql_test 4.3 {
|
||||||
|
SELECT b, sum(b) OVER (
|
||||||
|
ORDER BY b
|
||||||
|
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||||
|
) FROM t2 ORDER BY b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
|
||||||
|
@ -258,9 +258,95 @@ do_execsql_test 2.30 {
|
|||||||
) FROM t1
|
) FROM t1
|
||||||
} {2 21 4 21 6 21 1 9 3 9 5 9}
|
} {2 21 4 21 6 21 1 9 3 9 5 9}
|
||||||
|
|
||||||
|
do_execsql_test 3.1 {
|
||||||
|
SELECT a, sum(d) OVER (
|
||||||
|
PARTITION BY b ORDER BY d
|
||||||
|
RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||||
|
) FROM t1
|
||||||
|
} {2 12 4 10 6 6 1 9 3 8 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 {
|
||||||
|
SELECT a, sum(d) OVER (
|
||||||
|
ORDER BY d
|
||||||
|
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||||
|
) FROM t1
|
||||||
|
} {1 21 2 21 3 21 4 21 5 21 6 21}
|
||||||
|
|
||||||
|
do_execsql_test 3.4 {
|
||||||
|
SELECT a, sum(d) OVER (
|
||||||
|
ORDER BY d/2
|
||||||
|
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||||
|
) FROM t1
|
||||||
|
} {1 1 2 3 3 6 4 10 5 15 6 21}
|
||||||
|
|
||||||
#==========================================================================
|
#==========================================================================
|
||||||
|
|
||||||
finish_test
|
do_execsql_test 4.0 {
|
||||||
#==========================================================================
|
DROP TABLE IF EXISTS t2;
|
||||||
|
CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER);
|
||||||
|
INSERT INTO t2(a, b) VALUES
|
||||||
|
(1,0), (2,74), (3,41), (4,74), (5,23), (6,99), (7,26), (8,33), (9,2),
|
||||||
|
(10,89), (11,81), (12,96), (13,59), (14,38), (15,68), (16,39), (17,62),
|
||||||
|
(18,91), (19,46), (20,6), (21,99), (22,97), (23,27), (24,46), (25,78),
|
||||||
|
(26,54), (27,97), (28,8), (29,67), (30,29), (31,93), (32,84), (33,77),
|
||||||
|
(34,23), (35,16), (36,16), (37,93), (38,65), (39,35), (40,47), (41,7),
|
||||||
|
(42,86), (43,74), (44,61), (45,91), (46,85), (47,24), (48,85), (49,43),
|
||||||
|
(50,59), (51,12), (52,32), (53,56), (54,3), (55,91), (56,22), (57,90),
|
||||||
|
(58,55), (59,15), (60,28), (61,89), (62,25), (63,47), (64,1), (65,56),
|
||||||
|
(66,40), (67,43), (68,56), (69,16), (70,75), (71,36), (72,89), (73,98),
|
||||||
|
(74,76), (75,81), (76,4), (77,94), (78,42), (79,30), (80,78), (81,33),
|
||||||
|
(82,29), (83,53), (84,63), (85,2), (86,87), (87,37), (88,80), (89,84),
|
||||||
|
(90,72), (91,41), (92,9), (93,61), (94,73), (95,95), (96,65), (97,13),
|
||||||
|
(98,58), (99,96), (100,98), (101,1), (102,21), (103,74), (104,65), (105,35),
|
||||||
|
(106,5), (107,73), (108,11), (109,51), (110,87), (111,41), (112,12), (113,8),
|
||||||
|
(114,20), (115,31), (116,31), (117,15), (118,95), (119,22), (120,73),
|
||||||
|
(121,79), (122,88), (123,34), (124,8), (125,11), (126,49), (127,34),
|
||||||
|
(128,90), (129,59), (130,96), (131,60), (132,55), (133,75), (134,77),
|
||||||
|
(135,44), (136,2), (137,7), (138,85), (139,57), (140,74), (141,29), (142,70),
|
||||||
|
(143,59), (144,19), (145,39), (146,26), (147,26), (148,47), (149,80),
|
||||||
|
(150,90), (151,36), (152,58), (153,47), (154,9), (155,72), (156,72), (157,66),
|
||||||
|
(158,33), (159,93), (160,75), (161,64), (162,81), (163,9), (164,23), (165,37),
|
||||||
|
(166,13), (167,12), (168,14), (169,62), (170,91), (171,36), (172,91),
|
||||||
|
(173,33), (174,15), (175,34), (176,36), (177,99), (178,3), (179,95), (180,69),
|
||||||
|
(181,58), (182,52), (183,30), (184,50), (185,84), (186,10), (187,84),
|
||||||
|
(188,33), (189,21), (190,39), (191,44), (192,58), (193,30), (194,38),
|
||||||
|
(195,34), (196,83), (197,27), (198,82), (199,17), (200,7);
|
||||||
|
} {}
|
||||||
|
|
||||||
|
do_execsql_test 4.1 {
|
||||||
|
SELECT a, sum(b) OVER (
|
||||||
|
PARTITION BY (b%10)
|
||||||
|
ORDER BY b
|
||||||
|
) FROM t2 ORDER BY a;
|
||||||
|
} {1 0 2 754 3 251 4 754 5 101 6 1247 7 132 8 266 9 6 10 950 11 667 12 1052 13 535 14 128 15 428 16 250 17 336 18 1122 19 368 20 6 21 1247 22 1000 23 92 24 368 25 584 26 320 27 1000 28 24 29 478 30 133 31 1049 32 1090 33 632 34 101 35 54 36 54 37 1049 38 450 39 145 40 354 41 21 42 764 43 754 44 424 45 1122 46 930 47 42 48 930 49 352 50 535 51 42 52 118 53 536 54 6 55 1122 56 86 57 770 58 255 59 50 60 52 61 950 62 75 63 354 64 2 65 536 66 160 67 352 68 536 69 54 70 675 71 276 72 950 73 868 74 678 75 667 76 4 77 1184 78 160 79 120 80 584 81 266 82 133 83 405 84 468 85 6 86 806 87 166 88 500 89 1090 90 552 91 251 92 27 93 424 94 687 95 1215 96 450 97 32 98 360 99 1052 100 868 101 2 102 66 103 754 104 450 105 145 106 5 107 687 108 24 109 302 110 806 111 251 112 42 113 24 114 30 115 128 116 128 117 50 118 1215 119 86 120 687 121 683 122 672 123 178 124 24 125 24 126 299 127 178 128 770 129 535 130 1052 131 270 132 255 133 675 134 632 135 266 136 6 137 21 138 930 139 411 140 754 141 133 142 340 143 535 144 46 145 250 146 132 147 132 148 354 149 500 150 770 151 276 152 360 153 354 154 27 155 552 156 552 157 602 158 266 159 1049 160 675 161 384 162 667 163 27 164 101 165 166 166 32 167 42 168 18 169 336 170 1122 171 276 172 1122 173 266 174 50 175 178 176 276 177 1247 178 6 179 1215 180 604 181 360 182 212 183 120 184 210 185 1090 186 10 187 1090 188 266 189 66 190 250 191 266 192 360 193 120 194 128 195 178 196 770 197 92 198 634 199 38 200 21}
|
||||||
|
|
||||||
|
do_execsql_test 4.2 {
|
||||||
|
SELECT a, sum(b) OVER (
|
||||||
|
PARTITION BY (b%10)
|
||||||
|
ORDER BY b
|
||||||
|
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||||
|
) FROM t2 ORDER BY a;
|
||||||
|
} {1 0 2 754 3 251 4 754 5 101 6 1247 7 132 8 266 9 6 10 950 11 667 12 1052 13 535 14 128 15 428 16 250 17 336 18 1122 19 368 20 6 21 1247 22 1000 23 92 24 368 25 584 26 320 27 1000 28 24 29 478 30 133 31 1049 32 1090 33 632 34 101 35 54 36 54 37 1049 38 450 39 145 40 354 41 21 42 764 43 754 44 424 45 1122 46 930 47 42 48 930 49 352 50 535 51 42 52 118 53 536 54 6 55 1122 56 86 57 770 58 255 59 50 60 52 61 950 62 75 63 354 64 2 65 536 66 160 67 352 68 536 69 54 70 675 71 276 72 950 73 868 74 678 75 667 76 4 77 1184 78 160 79 120 80 584 81 266 82 133 83 405 84 468 85 6 86 806 87 166 88 500 89 1090 90 552 91 251 92 27 93 424 94 687 95 1215 96 450 97 32 98 360 99 1052 100 868 101 2 102 66 103 754 104 450 105 145 106 5 107 687 108 24 109 302 110 806 111 251 112 42 113 24 114 30 115 128 116 128 117 50 118 1215 119 86 120 687 121 683 122 672 123 178 124 24 125 24 126 299 127 178 128 770 129 535 130 1052 131 270 132 255 133 675 134 632 135 266 136 6 137 21 138 930 139 411 140 754 141 133 142 340 143 535 144 46 145 250 146 132 147 132 148 354 149 500 150 770 151 276 152 360 153 354 154 27 155 552 156 552 157 602 158 266 159 1049 160 675 161 384 162 667 163 27 164 101 165 166 166 32 167 42 168 18 169 336 170 1122 171 276 172 1122 173 266 174 50 175 178 176 276 177 1247 178 6 179 1215 180 604 181 360 182 212 183 120 184 210 185 1090 186 10 187 1090 188 266 189 66 190 250 191 266 192 360 193 120 194 128 195 178 196 770 197 92 198 634 199 38 200 21}
|
||||||
|
|
||||||
|
do_execsql_test 4.3 {
|
||||||
|
SELECT b, sum(b) OVER (
|
||||||
|
ORDER BY b
|
||||||
|
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||||
|
) FROM t2 ORDER BY b;
|
||||||
|
} {0 0 1 1 1 2 2 4 2 6 2 8 3 11 3 14 4 18 5 23 6 29 7 36 7 43 7 50 8 58 8 66 8 74 9 83 9 92 9 101 10 111 11 122 11 133 12 145 12 157 12 169 13 182 13 195 14 209 15 224 15 239 15 254 16 270 16 286 16 302 17 319 19 338 20 358 21 379 21 400 22 422 22 444 23 467 23 490 23 513 24 537 25 562 26 588 26 614 26 640 27 667 27 694 28 722 29 751 29 780 29 809 30 839 30 869 30 899 31 930 31 961 32 993 33 1026 33 1059 33 1092 33 1125 33 1158 34 1192 34 1226 34 1260 34 1294 35 1329 35 1364 36 1400 36 1436 36 1472 36 1508 37 1545 37 1582 38 1620 38 1658 39 1697 39 1736 39 1775 40 1815 41 1856 41 1897 41 1938 42 1980 43 2023 43 2066 44 2110 44 2154 46 2200 46 2246 47 2293 47 2340 47 2387 47 2434 49 2483 50 2533 51 2584 52 2636 53 2689 54 2743 55 2798 55 2853 56 2909 56 2965 56 3021 57 3078 58 3136 58 3194 58 3252 58 3310 59 3369 59 3428 59 3487 59 3546 60 3606 61 3667 61 3728 62 3790 62 3852 63 3915 64 3979 65 4044 65 4109 65 4174 66 4240 67 4307 68 4375 69 4444 70 4514 72 4586 72 4658 72 4730 73 4803 73 4876 73 4949 74 5023 74 5097 74 5171 74 5245 74 5319 75 5394 75 5469 75 5544 76 5620 77 5697 77 5774 78 5852 78 5930 79 6009 80 6089 80 6169 81 6250 81 6331 81 6412 82 6494 83 6577 84 6661 84 6745 84 6829 84 6913 85 6998 85 7083 85 7168 86 7254 87 7341 87 7428 88 7516 89 7605 89 7694 89 7783 90 7873 90 7963 90 8053 91 8144 91 8235 91 8326 91 8417 91 8508 93 8601 93 8694 93 8787 94 8881 95 8976 95 9071 95 9166 96 9262 96 9358 96 9454 97 9551 97 9648 98 9746 98 9844 99 9943 99 10042 99 10141}
|
||||||
|
|
||||||
|
do_execsql_test 4.4 {
|
||||||
|
SELECT b, sum(b) OVER (
|
||||||
|
ORDER BY b
|
||||||
|
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||||
|
) FROM t2 ORDER BY b;
|
||||||
|
} {0 0 1 1 1 2 2 4 2 6 2 8 3 11 3 14 4 18 5 23 6 29 7 36 7 43 7 50 8 58 8 66 8 74 9 83 9 92 9 101 10 111 11 122 11 133 12 145 12 157 12 169 13 182 13 195 14 209 15 224 15 239 15 254 16 270 16 286 16 302 17 319 19 338 20 358 21 379 21 400 22 422 22 444 23 467 23 490 23 513 24 537 25 562 26 588 26 614 26 640 27 667 27 694 28 722 29 751 29 780 29 809 30 839 30 869 30 899 31 930 31 961 32 993 33 1026 33 1059 33 1092 33 1125 33 1158 34 1192 34 1226 34 1260 34 1294 35 1329 35 1364 36 1400 36 1436 36 1472 36 1508 37 1545 37 1582 38 1620 38 1658 39 1697 39 1736 39 1775 40 1815 41 1856 41 1897 41 1938 42 1980 43 2023 43 2066 44 2110 44 2154 46 2200 46 2246 47 2293 47 2340 47 2387 47 2434 49 2483 50 2533 51 2584 52 2636 53 2689 54 2743 55 2798 55 2853 56 2909 56 2965 56 3021 57 3078 58 3136 58 3194 58 3252 58 3310 59 3369 59 3428 59 3487 59 3546 60 3606 61 3667 61 3728 62 3790 62 3852 63 3915 64 3979 65 4044 65 4109 65 4174 66 4240 67 4307 68 4375 69 4444 70 4514 72 4586 72 4658 72 4730 73 4803 73 4876 73 4949 74 5023 74 5097 74 5171 74 5245 74 5319 75 5394 75 5469 75 5544 76 5620 77 5697 77 5774 78 5852 78 5930 79 6009 80 6089 80 6169 81 6250 81 6331 81 6412 82 6494 83 6577 84 6661 84 6745 84 6829 84 6913 85 6998 85 7083 85 7168 86 7254 87 7341 87 7428 88 7516 89 7605 89 7694 89 7783 90 7873 90 7963 90 8053 91 8144 91 8235 91 8326 91 8417 91 8508 93 8601 93 8694 93 8787 94 8881 95 8976 95 9071 95 9166 96 9262 96 9358 96 9454 97 9551 97 9648 98 9746 98 9844 99 9943 99 10042 99 10141}
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
Loading…
Reference in New Issue
Block a user