dan | 680f6e8 | 2019-03-04 21:07:11 +0000 | [diff] [blame] | 1 | # 2019 March 01 |
| 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 | # This file implements regression tests for SQLite library. |
| 12 | # |
| 13 | |
| 14 | #################################################### |
| 15 | # DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED! |
| 16 | #################################################### |
| 17 | |
| 18 | set testdir [file dirname $argv0] |
| 19 | source $testdir/tester.tcl |
| 20 | set testprefix windowerr |
| 21 | |
| 22 | ifcapable !windowfunc { finish_test ; return } |
| 23 | do_execsql_test 1.0 { |
| 24 | DROP TABLE IF EXISTS t1; |
| 25 | CREATE TABLE t1(a INTEGER, b INTEGER); |
dan | 72b9fdc | 2019-03-09 20:49:17 +0000 | [diff] [blame] | 26 | INSERT INTO t1 VALUES(1, 1); |
| 27 | INSERT INTO t1 VALUES(2, 2); |
| 28 | INSERT INTO t1 VALUES(3, 3); |
| 29 | INSERT INTO t1 VALUES(4, 4); |
| 30 | INSERT INTO t1 VALUES(5, 5); |
dan | 680f6e8 | 2019-03-04 21:07:11 +0000 | [diff] [blame] | 31 | } {} |
| 32 | |
dan | 72b9fdc | 2019-03-09 20:49:17 +0000 | [diff] [blame] | 33 | # PG says ERROR: frame starting offset must not be negative |
dan | 680f6e8 | 2019-03-04 21:07:11 +0000 | [diff] [blame] | 34 | do_test 1.1 { catch { execsql { |
| 35 | SELECT a, sum(b) OVER ( |
| 36 | ORDER BY a ROWS BETWEEN -1 PRECEDING AND 1 FOLLOWING |
dan | 72b9fdc | 2019-03-09 20:49:17 +0000 | [diff] [blame] | 37 | ) FROM t1 ORDER BY 1 |
dan | 680f6e8 | 2019-03-04 21:07:11 +0000 | [diff] [blame] | 38 | } } } 1 |
| 39 | |
dan | 72b9fdc | 2019-03-09 20:49:17 +0000 | [diff] [blame] | 40 | # PG says ERROR: frame ending offset must not be negative |
dan | 680f6e8 | 2019-03-04 21:07:11 +0000 | [diff] [blame] | 41 | do_test 1.2 { catch { execsql { |
| 42 | SELECT a, sum(b) OVER ( |
| 43 | ORDER BY a ROWS BETWEEN 1 PRECEDING AND -1 FOLLOWING |
dan | 72b9fdc | 2019-03-09 20:49:17 +0000 | [diff] [blame] | 44 | ) FROM t1 ORDER BY 1 |
dan | 680f6e8 | 2019-03-04 21:07:11 +0000 | [diff] [blame] | 45 | } } } 1 |
| 46 | |
dan | 72b9fdc | 2019-03-09 20:49:17 +0000 | [diff] [blame] | 47 | # PG says ERROR: invalid preceding or following size in window function |
dan | 680f6e8 | 2019-03-04 21:07:11 +0000 | [diff] [blame] | 48 | do_test 1.3 { catch { execsql { |
| 49 | SELECT a, sum(b) OVER ( |
| 50 | ORDER BY a RANGE BETWEEN -1 PRECEDING AND 1 FOLLOWING |
dan | 72b9fdc | 2019-03-09 20:49:17 +0000 | [diff] [blame] | 51 | ) FROM t1 ORDER BY 1 |
dan | 680f6e8 | 2019-03-04 21:07:11 +0000 | [diff] [blame] | 52 | } } } 1 |
| 53 | |
dan | 72b9fdc | 2019-03-09 20:49:17 +0000 | [diff] [blame] | 54 | # PG says ERROR: invalid preceding or following size in window function |
dan | 680f6e8 | 2019-03-04 21:07:11 +0000 | [diff] [blame] | 55 | do_test 1.4 { catch { execsql { |
| 56 | SELECT a, sum(b) OVER ( |
| 57 | ORDER BY a RANGE BETWEEN 1 PRECEDING AND -1 FOLLOWING |
dan | 72b9fdc | 2019-03-09 20:49:17 +0000 | [diff] [blame] | 58 | ) FROM t1 ORDER BY 1 |
dan | 680f6e8 | 2019-03-04 21:07:11 +0000 | [diff] [blame] | 59 | } } } 1 |
| 60 | |
dan | 72b9fdc | 2019-03-09 20:49:17 +0000 | [diff] [blame] | 61 | # PG says ERROR: frame starting offset must not be negative |
dan | 680f6e8 | 2019-03-04 21:07:11 +0000 | [diff] [blame] | 62 | do_test 1.5 { catch { execsql { |
| 63 | SELECT a, sum(b) OVER ( |
| 64 | ORDER BY a GROUPS BETWEEN -1 PRECEDING AND 1 FOLLOWING |
dan | 72b9fdc | 2019-03-09 20:49:17 +0000 | [diff] [blame] | 65 | ) FROM t1 ORDER BY 1 |
dan | 680f6e8 | 2019-03-04 21:07:11 +0000 | [diff] [blame] | 66 | } } } 1 |
| 67 | |
dan | 72b9fdc | 2019-03-09 20:49:17 +0000 | [diff] [blame] | 68 | # PG says ERROR: frame ending offset must not be negative |
dan | 680f6e8 | 2019-03-04 21:07:11 +0000 | [diff] [blame] | 69 | do_test 1.6 { catch { execsql { |
| 70 | SELECT a, sum(b) OVER ( |
| 71 | ORDER BY a GROUPS BETWEEN 1 PRECEDING AND -1 FOLLOWING |
dan | 72b9fdc | 2019-03-09 20:49:17 +0000 | [diff] [blame] | 72 | ) FROM t1 ORDER BY 1 |
| 73 | } } } 1 |
| 74 | |
| 75 | # PG says ERROR: RANGE with offset PRECEDING/FOLLOWING requires exactly one ORDER BY column |
| 76 | do_test 1.7 { catch { execsql { |
| 77 | SELECT a, sum(b) OVER ( |
| 78 | ORDER BY a,b RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING |
| 79 | ) FROM t1 ORDER BY 1 |
dan | 680f6e8 | 2019-03-04 21:07:11 +0000 | [diff] [blame] | 80 | } } } 1 |
| 81 | |
dan | 0525b6f | 2019-03-18 21:19:40 +0000 | [diff] [blame] | 82 | # PG says ERROR: RANGE with offset PRECEDING/FOLLOWING requires exactly one ORDER BY column |
| 83 | do_test 1.8 { catch { execsql { |
| 84 | SELECT a, sum(b) OVER ( |
| 85 | PARTITION BY a RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING |
| 86 | ) FROM t1 ORDER BY 1 |
| 87 | } } } 1 |
| 88 | |
dan | 4ded26a | 2019-03-28 16:15:05 +0000 | [diff] [blame] | 89 | # PG says ERROR: aggregate function calls cannot contain window function calls |
| 90 | do_test 2.1 { catch { execsql { |
| 91 | SELECT sum( sum(a) OVER () ) FROM t1; |
| 92 | } } } 1 |
| 93 | |
| 94 | # PG says ERROR: column "xyz" does not exist |
| 95 | do_test 2.2 { catch { execsql { |
| 96 | SELECT sum(a) OVER () AS xyz FROM t1 ORDER BY sum(xyz); |
| 97 | } } } 1 |
| 98 | |
dan | 1d07f1d | 2019-04-01 17:24:20 +0000 | [diff] [blame] | 99 | # PG says ERROR: invalid input syntax for integer: "hello" |
| 100 | do_test 3.0 { catch { execsql { |
| 101 | SELECT sum(a) OVER win FROM t1 |
| 102 | WINDOW win AS (ROWS BETWEEN 'hello' PRECEDING AND 10 FOLLOWING) |
| 103 | } } } 1 |
| 104 | |
| 105 | # PG says ERROR: argument of ROWS must be type bigint, not type bit |
| 106 | do_test 3.2 { catch { execsql { |
| 107 | SELECT sum(a) OVER win FROM t1 |
| 108 | WINDOW win AS (ROWS BETWEEN 10 PRECEDING AND x'ABCD' FOLLOWING) |
| 109 | } } } 1 |
| 110 | |
dan | 5e61c1b | 2019-07-13 17:45:25 +0000 | [diff] [blame] | 111 | # PG says ERROR: function row_number(integer) does not exist |
| 112 | do_test 3.3 { catch { execsql { |
| 113 | SELECT row_number(a) OVER () FROM t1; |
| 114 | } } } 1 |
| 115 | |
dan | 680f6e8 | 2019-03-04 21:07:11 +0000 | [diff] [blame] | 116 | finish_test |