1680f6e8eSdan# 2019 March 01 2680f6e8eSdan# 3680f6e8eSdan# The author disclaims copyright to this source code. In place of 4680f6e8eSdan# a legal notice, here is a blessing: 5680f6e8eSdan# 6680f6e8eSdan# May you do good and not evil. 7680f6e8eSdan# May you find forgiveness for yourself and forgive others. 8680f6e8eSdan# May you share freely, never taking more than you give. 9680f6e8eSdan# 10680f6e8eSdan#*********************************************************************** 11680f6e8eSdan# This file implements regression tests for SQLite library. 12680f6e8eSdan# 13680f6e8eSdan 14680f6e8eSdan#################################################### 15680f6e8eSdan# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED! 16680f6e8eSdan#################################################### 17680f6e8eSdan 18680f6e8eSdanset testdir [file dirname $argv0] 19680f6e8eSdansource $testdir/tester.tcl 20680f6e8eSdanset testprefix windowerr 21680f6e8eSdan 22680f6e8eSdanifcapable !windowfunc { finish_test ; return } 23680f6e8eSdando_execsql_test 1.0 { 24680f6e8eSdan DROP TABLE IF EXISTS t1; 25680f6e8eSdan CREATE TABLE t1(a INTEGER, b INTEGER); 2672b9fdcfSdan INSERT INTO t1 VALUES(1, 1); 2772b9fdcfSdan INSERT INTO t1 VALUES(2, 2); 2872b9fdcfSdan INSERT INTO t1 VALUES(3, 3); 2972b9fdcfSdan INSERT INTO t1 VALUES(4, 4); 3072b9fdcfSdan INSERT INTO t1 VALUES(5, 5); 31680f6e8eSdan} {} 32680f6e8eSdan 3372b9fdcfSdan# PG says ERROR: frame starting offset must not be negative 34680f6e8eSdando_test 1.1 { catch { execsql { 35680f6e8eSdan SELECT a, sum(b) OVER ( 36680f6e8eSdan ORDER BY a ROWS BETWEEN -1 PRECEDING AND 1 FOLLOWING 3772b9fdcfSdan ) FROM t1 ORDER BY 1 38680f6e8eSdan} } } 1 39680f6e8eSdan 4072b9fdcfSdan# PG says ERROR: frame ending offset must not be negative 41680f6e8eSdando_test 1.2 { catch { execsql { 42680f6e8eSdan SELECT a, sum(b) OVER ( 43680f6e8eSdan ORDER BY a ROWS BETWEEN 1 PRECEDING AND -1 FOLLOWING 4472b9fdcfSdan ) FROM t1 ORDER BY 1 45680f6e8eSdan} } } 1 46680f6e8eSdan 4772b9fdcfSdan# PG says ERROR: invalid preceding or following size in window function 48680f6e8eSdando_test 1.3 { catch { execsql { 49680f6e8eSdan SELECT a, sum(b) OVER ( 50680f6e8eSdan ORDER BY a RANGE BETWEEN -1 PRECEDING AND 1 FOLLOWING 5172b9fdcfSdan ) FROM t1 ORDER BY 1 52680f6e8eSdan} } } 1 53680f6e8eSdan 5472b9fdcfSdan# PG says ERROR: invalid preceding or following size in window function 55680f6e8eSdando_test 1.4 { catch { execsql { 56680f6e8eSdan SELECT a, sum(b) OVER ( 57680f6e8eSdan ORDER BY a RANGE BETWEEN 1 PRECEDING AND -1 FOLLOWING 5872b9fdcfSdan ) FROM t1 ORDER BY 1 59680f6e8eSdan} } } 1 60680f6e8eSdan 6172b9fdcfSdan# PG says ERROR: frame starting offset must not be negative 62680f6e8eSdando_test 1.5 { catch { execsql { 63680f6e8eSdan SELECT a, sum(b) OVER ( 64680f6e8eSdan ORDER BY a GROUPS BETWEEN -1 PRECEDING AND 1 FOLLOWING 6572b9fdcfSdan ) FROM t1 ORDER BY 1 66680f6e8eSdan} } } 1 67680f6e8eSdan 6872b9fdcfSdan# PG says ERROR: frame ending offset must not be negative 69680f6e8eSdando_test 1.6 { catch { execsql { 70680f6e8eSdan SELECT a, sum(b) OVER ( 71680f6e8eSdan ORDER BY a GROUPS BETWEEN 1 PRECEDING AND -1 FOLLOWING 7272b9fdcfSdan ) FROM t1 ORDER BY 1 7372b9fdcfSdan} } } 1 7472b9fdcfSdan 7572b9fdcfSdan# PG says ERROR: RANGE with offset PRECEDING/FOLLOWING requires exactly one ORDER BY column 7672b9fdcfSdando_test 1.7 { catch { execsql { 7772b9fdcfSdan SELECT a, sum(b) OVER ( 7872b9fdcfSdan ORDER BY a,b RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING 7972b9fdcfSdan ) FROM t1 ORDER BY 1 80680f6e8eSdan} } } 1 81680f6e8eSdan 820525b6f4Sdan# PG says ERROR: RANGE with offset PRECEDING/FOLLOWING requires exactly one ORDER BY column 830525b6f4Sdando_test 1.8 { catch { execsql { 840525b6f4Sdan SELECT a, sum(b) OVER ( 850525b6f4Sdan PARTITION BY a RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING 860525b6f4Sdan ) FROM t1 ORDER BY 1 870525b6f4Sdan} } } 1 880525b6f4Sdan 894ded26a5Sdan# PG says ERROR: aggregate function calls cannot contain window function calls 904ded26a5Sdando_test 2.1 { catch { execsql { 914ded26a5Sdan SELECT sum( sum(a) OVER () ) FROM t1; 924ded26a5Sdan} } } 1 934ded26a5Sdan 944ded26a5Sdan# PG says ERROR: column "xyz" does not exist 954ded26a5Sdando_test 2.2 { catch { execsql { 964ded26a5Sdan SELECT sum(a) OVER () AS xyz FROM t1 ORDER BY sum(xyz); 974ded26a5Sdan} } } 1 984ded26a5Sdan 991d07f1d8Sdan# PG says ERROR: invalid input syntax for integer: "hello" 1001d07f1d8Sdando_test 3.0 { catch { execsql { 1011d07f1d8Sdan SELECT sum(a) OVER win FROM t1 1021d07f1d8Sdan WINDOW win AS (ROWS BETWEEN 'hello' PRECEDING AND 10 FOLLOWING) 1031d07f1d8Sdan} } } 1 1041d07f1d8Sdan 1051d07f1d8Sdan# PG says ERROR: argument of ROWS must be type bigint, not type bit 1061d07f1d8Sdando_test 3.2 { catch { execsql { 1071d07f1d8Sdan SELECT sum(a) OVER win FROM t1 1081d07f1d8Sdan WINDOW win AS (ROWS BETWEEN 10 PRECEDING AND x'ABCD' FOLLOWING) 1091d07f1d8Sdan} } } 1 1101d07f1d8Sdan 111*5e61c1b7Sdan# PG says ERROR: function row_number(integer) does not exist 112*5e61c1b7Sdando_test 3.3 { catch { execsql { 113*5e61c1b7Sdan SELECT row_number(a) OVER () FROM t1; 114*5e61c1b7Sdan} } } 1 115*5e61c1b7Sdan 116680f6e8eSdanfinish_test 117