summaryrefslogtreecommitdiff
path: root/mysql-test/t/win.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/win.test')
-rw-r--r--mysql-test/t/win.test73
1 files changed, 67 insertions, 6 deletions
diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test
index 09ddf41b4f0..de03dd10253 100644
--- a/mysql-test/t/win.test
+++ b/mysql-test/t/win.test
@@ -745,6 +745,24 @@ select
as cnt
from t1;
+select
+ pk, c,
+ sum(c) over (partition by c
+ order by pk
+ rows between 1 preceding
+ and 2 preceding)
+ as sum
+from t1;
+
+select
+ pk, c,
+ sum(c) over (partition by c
+ order by pk
+ rows between 2 following
+ and 1 following)
+ as sum
+from t1;
+
select
pk, c,
@@ -1089,14 +1107,8 @@ from
drop table t1;
---echo #
---echo # MDEV-9894: Assertion `0' failed in Window_func_runner::setup
---echo # return ER_NOT_SUPPORTED_YET for aggregates that are not yet supported
---echo # as window functions.
---echo #
create table t1 (i int);
insert into t1 values (1),(2);
---error ER_NOT_SUPPORTED_YET
SELECT MAX(i) OVER (PARTITION BY (i)) FROM t1;
drop table t1;
@@ -1201,3 +1213,52 @@ create view v1 as select 1 as i;
select rank() over (order by i) from v1;
drop view v1;
+--echo #
+--echo # MDEV-10097: Assertion `count > 0' failed in Item_sum_sum::add_helper(bool)
+--echo #
+CREATE TABLE `orders` (
+ `o_orderkey` int(11) NOT NULL,
+ `o_custkey` int(11) DEFAULT NULL,
+ PRIMARY KEY (`o_orderkey`)
+ ) DEFAULT CHARSET=latin1;
+
+INSERT INTO `orders` VALUES (59908,242);
+INSERT INTO `orders` VALUES (59940,238);
+
+SELECT o_custkey, avg(o_custkey) OVER (PARTITION BY abs(o_custkey)
+ ORDER BY o_custkey
+ RANGE BETWEEN 15 FOLLOWING
+ AND 15 FOLLOWING) from orders;
+DROP table orders;
+
+--echo #
+--echo # MDEV-10842: window functions with the same order column
+--echo # but different directions
+--echo #
+
+create table t1 (
+ pk int primary key,
+ a int,
+ b int,
+ c char(10)
+);
+
+insert into t1 values
+( 1, 0, 1, 'one'),
+( 2, 0, 2, 'two'),
+( 3, 0, 3, 'three'),
+( 4, 1, 1, 'one'),
+( 5, 1, 1, 'two'),
+( 6, 1, 2, 'three'),
+( 7, 2, NULL, 'n_one'),
+( 8, 2, 1, 'n_two'),
+( 9, 2, 2, 'n_three'),
+(10, 2, 0, 'n_four'),
+(11, 2, 10, NULL);
+
+select pk,
+ row_number() over (order by pk desc) as r_desc,
+ row_number() over (order by pk asc) as r_asc
+from t1;
+
+drop table t1;