dan | ac79fa1 | 2022-10-18 15:02:08 +0000 | [diff] [blame] | 1 | # 2022 October 18 |
| 2 | # |
| 3 | # The author disclaims copyright to this source code. In place of |
| 4 | # a legal notice, here is a blessing: |
| 5 | # |
| 6 | # May you do good and not evil. |
| 7 | # May you find forgiveness for yourself and forgive others. |
| 8 | # May you share freely, never taking more than you give. |
| 9 | # |
| 10 | #*********************************************************************** |
| 11 | # |
| 12 | |
| 13 | set testdir [file dirname $argv0] |
| 14 | source $testdir/tester.tcl |
| 15 | set testprefix windowE |
| 16 | |
| 17 | proc custom {a b} { return [string compare $a $b] } |
| 18 | db collate custom custom |
| 19 | |
| 20 | do_execsql_test 1.0 { |
| 21 | CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT COLLATE custom); |
| 22 | INSERT INTO t1 VALUES(1, 'one'); |
| 23 | INSERT INTO t1 VALUES(2, 'two'); |
| 24 | INSERT INTO t1 VALUES(3, 'three'); |
| 25 | INSERT INTO t1 VALUES(4, 'four'); |
| 26 | INSERT INTO t1 VALUES(5, 'five'); |
| 27 | INSERT INTO t1 VALUES(6, 'six'); |
| 28 | CREATE INDEX t1b ON t1(b); |
| 29 | } |
| 30 | |
| 31 | do_execsql_test 1.1 { |
| 32 | SELECT * FROM t1 |
| 33 | } { |
| 34 | 1 one 2 two 3 three 4 four 5 five 6 six |
| 35 | } |
| 36 | |
| 37 | do_execsql_test 1.2 { |
| 38 | SELECT group_concat(a,',') OVER win FROM t1 |
| 39 | WINDOW win AS ( |
| 40 | ORDER BY b RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING |
| 41 | ) |
| 42 | } { |
| 43 | 5 4 1 6 3 2 |
| 44 | } |
| 45 | |
| 46 | proc custom {a b} { return [string compare $b $a] } |
| 47 | |
| 48 | do_execsql_test 1.3 { |
| 49 | SELECT group_concat(a,',') OVER win FROM t1 |
| 50 | WINDOW win AS ( |
| 51 | ORDER BY b RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING |
| 52 | ) |
| 53 | } { |
| 54 | 5 5,4 5,4,1 5,4,1,6 5,4,1,6,3 5,4,1,6,3,2 |
| 55 | } |
| 56 | |
| 57 | finish_test |
| 58 | |