Add testcases for frames with bound1 > bound2.

This commit is contained in:
Sergei Petrunia 2016-03-16 12:03:43 +03:00
parent 5eee8bbe87
commit 72a4969eca
2 changed files with 92 additions and 0 deletions

View file

@ -1118,3 +1118,62 @@ pk a CNT
7 13 4
8 14 3
drop table t1;
#
# Try ranges that have bound1 > bound2. The standard actually allows them
#
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1 (pk int, c int);
insert into t1 select a+1,1 from t0;
update t1 set c=2 where pk not in (1,2,3,4);
select * from t1;
pk c
1 1
2 1
3 1
4 1
5 2
6 2
7 2
8 2
9 2
10 2
select
pk, c,
count(*) over (partition by c
order by pk
rows between 1 preceding
and 2 preceding)
as cnt
from t1;
pk c cnt
1 1 0
2 1 0
3 1 0
4 1 0
5 2 0
6 2 0
7 2 0
8 2 0
9 2 0
10 2 0
select
pk, c,
count(*) over (partition by c
order by pk
range between 1 preceding
and 2 preceding)
as cnt
from t1;
pk c cnt
1 1 0
2 1 0
3 1 0
4 1 0
5 2 0
6 2 0
7 2 0
8 2 0
9 2 0
10 2 0
drop table t0, t1;

View file

@ -664,3 +664,36 @@ select
and 2 following) as CNT
from t1;
drop table t1;
--echo #
--echo # Try ranges that have bound1 > bound2. The standard actually allows them
--echo #
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1 (pk int, c int);
insert into t1 select a+1,1 from t0;
update t1 set c=2 where pk not in (1,2,3,4);
select * from t1;
select
pk, c,
count(*) over (partition by c
order by pk
rows between 1 preceding
and 2 preceding)
as cnt
from t1;
select
pk, c,
count(*) over (partition by c
order by pk
range between 1 preceding
and 2 preceding)
as cnt
from t1;
drop table t0, t1;