blob: 294e68dc1811295f4fa3768ab4f371c48710aa66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# 2018 May 19
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
source [file join [file dirname $argv0] pg_common.tcl]
#=========================================================================
start_test windowerr "2019 March 01"
ifcapable !windowfunc
execsql_test 1.0 {
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a INTEGER, b INTEGER);
INSERT INTO t1 VALUES(1, 1);
INSERT INTO t1 VALUES(2, 2);
INSERT INTO t1 VALUES(3, 3);
INSERT INTO t1 VALUES(4, 4);
INSERT INTO t1 VALUES(5, 5);
}
foreach {tn frame} {
1 "ORDER BY a ROWS BETWEEN -1 PRECEDING AND 1 FOLLOWING"
2 "ORDER BY a ROWS BETWEEN 1 PRECEDING AND -1 FOLLOWING"
3 "ORDER BY a RANGE BETWEEN -1 PRECEDING AND 1 FOLLOWING"
4 "ORDER BY a RANGE BETWEEN 1 PRECEDING AND -1 FOLLOWING"
5 "ORDER BY a GROUPS BETWEEN -1 PRECEDING AND 1 FOLLOWING"
6 "ORDER BY a GROUPS BETWEEN 1 PRECEDING AND -1 FOLLOWING"
7 "ORDER BY a,b RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING"
8 "PARTITION BY a RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING"
} {
errorsql_test 1.$tn "
SELECT a, sum(b) OVER (
$frame
) FROM t1 ORDER BY 1
"
}
errorsql_test 2.1 {
SELECT sum( sum(a) OVER () ) FROM t1;
}
errorsql_test 2.2 {
SELECT sum(a) OVER () AS xyz FROM t1 ORDER BY sum(xyz);
}
errorsql_test 3.0 {
SELECT sum(a) OVER win FROM t1
WINDOW win AS (ROWS BETWEEN 'hello' PRECEDING AND 10 FOLLOWING)
}
errorsql_test 3.2 {
SELECT sum(a) OVER win FROM t1
WINDOW win AS (ROWS BETWEEN 10 PRECEDING AND x'ABCD' FOLLOWING)
}
errorsql_test 3.3 {
SELECT row_number(a) OVER () FROM t1;
}
finish_test
|