diff options
author | Igor Babaev <igor@askmonty.org> | 2016-09-23 14:22:20 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2016-09-23 14:23:17 -0700 |
commit | 4872ec6177fa56417d7921cb2019677ab32c05f8 (patch) | |
tree | 30f7254add0457ff0a2d3b79cc1f94c640b2748d /mysql-test/t/win.test | |
parent | 78f58792ac4517614fbe7b19e541ad7107a43c99 (diff) | |
download | mariadb-git-4872ec6177fa56417d7921cb2019677ab32c05f8.tar.gz |
Fixed bug mdev-10874.
In some cases the method Window_funcs_sort::setup() did
not build the sequence of sorting keys correctly.
Diffstat (limited to 'mysql-test/t/win.test')
-rw-r--r-- | mysql-test/t/win.test | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test index de03dd10253..10c673ac1b3 100644 --- a/mysql-test/t/win.test +++ b/mysql-test/t/win.test @@ -1262,3 +1262,51 @@ select pk, from t1; drop table t1; + +--echo # +--echo # MDEV-10874: two window functions with ccompatible sorting +--echo # + +create table t1 ( +pk int primary key, +a int, +b int, +c char(10), +d decimal(10, 3), +e real +); +insert into t1 values +( 1, 0, 1, 'one', 0.1, 0.001), +( 2, 0, 2, 'two', 0.2, 0.002), +( 3, 0, 3, 'three', 0.3, 0.003), +( 4, 1, 2, 'three', 0.4, 0.004), +( 5, 1, 1, 'two', 0.5, 0.005), +( 6, 1, 1, 'one', 0.6, 0.006), +( 7, 2, NULL, 'n_one', 0.5, 0.007), +( 8, 2, 1, 'n_two', NULL, 0.008), +( 9, 2, 2, NULL, 0.7, 0.009), +(10, 2, 0, 'n_four', 0.8, 0.010), +(11, 2, 10, NULL, 0.9, NULL); + +select pk, a, d, + sum(d) over (partition by a order by pk + ROWS between 1 preceding and current row) as sum_1, + sum(d) over (order by a + ROWS BETWEEN 1 preceding and 2 following) as sum_2 +from t1; +explain format=json +select pk, a, d, + sum(d) over (partition by a order by pk + ROWS between 1 preceding and current row) as sum_1, + sum(d) over (order by a + ROWS BETWEEN 1 preceding and 2 following) as sum_2 +from t1; + +select pk, a, d, + sum(d) over (partition by a order by pk desc + ROWS between 1 preceding and current row) as sum_1, + sum(d) over (order by a + ROWS BETWEEN 1 preceding and 2 following) as sum_2 +from t1; + +drop table t1; |