1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Add comments to window.c describing how other window frames will be implemented.

FossilOrigin-Name: 16168146b202915252f9375aef38e65ca20c5d4aa906e851d4d3a484db57562d
This commit is contained in:
dan
2018-05-22 20:35:37 +00:00
parent f9eae18b56
commit 8471be3311
5 changed files with 115 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
C Begin\sadding\ssupport\sfor\smore\sesoteric\swindow\sframes.
D 2018-05-21T19:45:11.880
C Add\scomments\sto\swindow.c\sdescribing\show\sother\swindow\sframes\swill\sbe\simplemented.
D 2018-05-22T20:35:37.079
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in bfc40f350586923e0419d2ea4b559c37ec10ee4b6e210e08c14401f8e340f0da
@@ -581,7 +581,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 da24f2e57a704dd8e0ce96df18e7442145582c65b4eb1c3176367e530d665928
F src/window.c 37eb02c2af935f207ba902ef25ec27d635b68bb1567f9e5994a6720bac1c093e
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd
F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d
@@ -1614,8 +1614,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 19a7d45c4502f00917649a171a4eb1da3670657f5cb102bce7a813e15a112b3f
F test/window2.test 23daf252647d780f046a2e612d7f0492d4fe589b3302fd6c062b0abfff3743bf
F test/window2.tcl 7e0b692974a18ae0992dd2e76be83d8e1c6c5cac3190d84fa62911ab0e5c7896
F test/window2.test e1453371b605e54eeb2264fc3a4a23c5eba93e95f6c7f3230fce9d34b4b5e8a4
F test/with1.test 58475190cd8caaeebea8cfeb2a264ec97a0c492b8ffe9ad20cefbb23df462f96
F test/with2.test e0030e2f0267a910d6c0e4f46f2dfe941c1cc0d4f659ba69b3597728e7e8f1ab
F test/with3.test 5e8ce2c585170bbbc0544e2a01a4941fa0be173ba5265e5c92eb588cd99a232d
@@ -1732,7 +1732,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 19c2e4b2f164521eab84cb0a0e12984be9431eaedd001dd3671e9ea1a6212353
R 977b49583a548e1f3f37fbf1de8b5833
P bc4b81d60d40583de0f929730159011c1a7696802532ebd02220de3ace94a60d
R b67e8a3ce976e7ed7840f10e74d98764
U dan
Z 314fa758fa6aadc36a0f111ad4e55744
Z 023d577304fe302f9eee3398820219e9

View File

@@ -1 +1 @@
bc4b81d60d40583de0f929730159011c1a7696802532ebd02220de3ace94a60d
16168146b202915252f9375aef38e65ca20c5d4aa906e851d4d3a484db57562d

View File

@@ -155,21 +155,87 @@ void sqlite3WindowCodeInit(Parse *pParse, Window *pWin){
**
**========================================================================
**
** ROWS BETWEEN UNBOUNDED PRECEDING AND <expr> PRECEDING
** ROWS BETWEEN <expr> PRECEDING AND <expr> PRECEDING
** ROWS BETWEEN <expr> PRECEDING AND CURRENT ROW
** ROWS BETWEEN UNBOUNDED PRECEDING AND <expr> FOLLOWING
** ROWS BETWEEN <expr> PRECEDING AND <expr> FOLLOWING
** ROWS BETWEEN CURRENT ROW AND <expr> FOLLOWING
** ROWS BETWEEN <expr> FOLLOWING AND <expr> FOLLOWING
** ROWS BETWEEN <expr> PRECEDING AND UNBOUNDED FOLLOWING
** ROWS BETWEEN <expr> FOLLOWING AND UNBOUNDED FOLLOWING
**
** Cases that involve <expr> PRECEDING or <expr> FOLLOWING.
**
** ...
** if( new partition ){
** Gosub flush_partition
** }
** Insert (record in eph-table)
** sqlite3WhereEnd()
** Gosub flush_partition
**
** flush_partition:
** OpenDup (csr -> csr2)
** OpenDup (csr -> csr3)
** regPrec = <expr1> // PRECEDING expression
** regFollow = <expr2> // FOLLOWING expression
** if( regPrec<0 || regFollow<0 ) throw exception!
** Rewind (csr,csr2,csr3) // if EOF goto flush_partition_done
** Aggstep (csr3)
** Next(csr3) // if EOF fall-through
** if( (regFollow--)<=0 ){
** AggFinal (xValue)
** Gosub addrGosub
** Next(csr) // if EOF goto flush_partition_done
** if( (regPrec--)<=0 ){
** AggStep (csr2, xInverse)
** Next(csr2)
** }
** }
** flush_partition_done:
** Close (csr2)
** Close (csr3)
** ResetSorter (csr)
** Return
**
** ROWS BETWEEN <expr> PRECEDING AND CURRENT ROW
** ROWS BETWEEN CURRENT ROW AND <expr> FOLLOWING
** ROWS BETWEEN <expr> PRECEDING AND UNBOUNDED FOLLOWING
** ROWS BETWEEN UNBOUNDED PRECEDING AND <expr> FOLLOWING
**
** These are similar to the above. For "CURRENT ROW", intialize the
** register to 0. For "UNBOUNDED ..." to infinity.
**
** ROWS BETWEEN <expr> PRECEDING AND <expr> PRECEDING
**
** Replace the bit after "Rewind" in the above with:
**
** if( (regFollow--)<=0 ){
** AggStep (csr3)
** Next (csr3)
** }
** AggFinal (xValue)
** Gosub addrGosub
** Next(csr) // if EOF goto flush_partition_done
** if( (regPrec--)<=0 ){
** AggStep (csr2, xInverse)
** Next (csr2)
** }
**
** ROWS BETWEEN <expr> FOLLOWING AND <expr> FOLLOWING
**
** regFollow = regFollow - regPrec
** Rewind (csr,csr2,csr3) // if EOF goto flush_partition_done
** Aggstep (csr3)
** Next(csr3) // if EOF fall-through
** if( (regFollow--)<=0 ){
** AggStep (csr2, xInverse)
** Next (csr2)
** if( (regPrec--)<=0 ){
** AggFinal (xValue)
** Gosub addrGosub
** Next(csr) // if EOF goto flush_partition_done
** }
** }
**
** ROWS BETWEEN UNBOUNDED PRECEDING AND <expr> PRECEDING
** ROWS BETWEEN <expr> FOLLOWING AND UNBOUNDED FOLLOWING
**
** Similar to the above, except with regPrec or regFollow set to infinity,
** as appropriate.
**
**
**
*/
void sqlite3WindowCodeStep(

View File

@@ -160,6 +160,20 @@ execsql_test 2.3 {
) FROM t1
}
execsql_test 2.4 {
SELECT a, sum(d) OVER (
ORDER BY d
ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
) FROM t1
}
execsql_test 2.5 {
SELECT a, sum(d) OVER (
ORDER BY d
ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING
) FROM t1
}
finish_test

View File

@@ -66,4 +66,18 @@ do_execsql_test 2.3 {
) FROM t1
} {1 21 2 21 3 21 4 21 5 21 6 21}
do_execsql_test 2.4 {
SELECT a, sum(d) OVER (
ORDER BY d
ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
) FROM t1
} {1 3 2 6 3 9 4 12 5 15 6 11}
do_execsql_test 2.5 {
SELECT a, sum(d) OVER (
ORDER BY d
ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING
) FROM t1
} {1 {} 2 1 3 2 4 3 5 4 6 5}
finish_test