summaryrefslogtreecommitdiffstats
path: root/test/windowerr.test
blob: 40d994de85a40dfa09fe50947cc4b612044d3256 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# 2019 March 01
#
# 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.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#

####################################################
# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
####################################################

set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix windowerr

ifcapable !windowfunc { finish_test ; return }
do_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);
} {}

# PG says ERROR:  frame starting offset must not be negative
do_test 1.1 { catch { execsql {
  SELECT a, sum(b) OVER (
    ORDER BY a ROWS BETWEEN -1 PRECEDING AND 1 FOLLOWING
  ) FROM t1 ORDER BY 1
} } } 1

# PG says ERROR:  frame ending offset must not be negative
do_test 1.2 { catch { execsql {
  SELECT a, sum(b) OVER (
    ORDER BY a ROWS BETWEEN  1 PRECEDING AND -1 FOLLOWING
  ) FROM t1 ORDER BY 1
} } } 1

# PG says ERROR:  invalid preceding or following size in window function
do_test 1.3 { catch { execsql {
  SELECT a, sum(b) OVER (
    ORDER BY a RANGE BETWEEN -1 PRECEDING AND 1 FOLLOWING
  ) FROM t1 ORDER BY 1
} } } 1

# PG says ERROR:  invalid preceding or following size in window function
do_test 1.4 { catch { execsql {
  SELECT a, sum(b) OVER (
    ORDER BY a RANGE BETWEEN  1 PRECEDING AND -1 FOLLOWING
  ) FROM t1 ORDER BY 1
} } } 1

# PG says ERROR:  frame starting offset must not be negative
do_test 1.5 { catch { execsql {
  SELECT a, sum(b) OVER (
    ORDER BY a GROUPS BETWEEN -1 PRECEDING AND 1 FOLLOWING
  ) FROM t1 ORDER BY 1
} } } 1

# PG says ERROR:  frame ending offset must not be negative
do_test 1.6 { catch { execsql {
  SELECT a, sum(b) OVER (
    ORDER BY a GROUPS BETWEEN  1 PRECEDING AND -1 FOLLOWING
  ) FROM t1 ORDER BY 1
} } } 1

# PG says ERROR:  RANGE with offset PRECEDING/FOLLOWING requires exactly one ORDER BY column
do_test 1.7 { catch { execsql {
  SELECT a, sum(b) OVER (
    ORDER BY a,b RANGE BETWEEN  1 PRECEDING AND 1 FOLLOWING
  ) FROM t1 ORDER BY 1
} } } 1

# PG says ERROR:  RANGE with offset PRECEDING/FOLLOWING requires exactly one ORDER BY column
do_test 1.8 { catch { execsql {
  SELECT a, sum(b) OVER (
    PARTITION BY a RANGE BETWEEN  1 PRECEDING AND 1 FOLLOWING
  ) FROM t1 ORDER BY 1
} } } 1

# PG says ERROR:  aggregate function calls cannot contain window function calls
do_test 2.1 { catch { execsql {
  SELECT sum( sum(a) OVER () ) FROM t1;
} } } 1

# PG says ERROR:  column "xyz" does not exist
do_test 2.2 { catch { execsql {
  SELECT sum(a) OVER () AS xyz FROM t1 ORDER BY sum(xyz);
} } } 1

# PG says ERROR:  invalid input syntax for integer: "hello"
do_test 3.0 { catch { execsql {
  SELECT sum(a) OVER win FROM t1
  WINDOW win AS (ROWS BETWEEN 'hello' PRECEDING AND 10 FOLLOWING)
} } } 1

# PG says ERROR:  argument of ROWS must be type bigint, not type bit
do_test 3.2 { catch { execsql {
  SELECT sum(a) OVER win FROM t1
  WINDOW win AS (ROWS BETWEEN 10 PRECEDING AND x'ABCD' FOLLOWING)
} } } 1

# PG says ERROR:  function row_number(integer) does not exist
do_test 3.3 { catch { execsql {
  SELECT row_number(a) OVER () FROM t1;
} } } 1

finish_test