2016-03-17 19:51:00 +01:00
|
|
|
drop table if exists t0,t1;
|
|
|
|
create table t0(a int primary key);
|
|
|
|
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
|
|
|
create table t1(
|
|
|
|
pk int,
|
|
|
|
a int,
|
|
|
|
key(pk)
|
|
|
|
);
|
|
|
|
insert into t1
|
|
|
|
select
|
|
|
|
A.a + B.a* 10 + C.a * 100,
|
|
|
|
1
|
|
|
|
from t0 A, t0 B, t0 C;
|
|
|
|
select
|
|
|
|
pk,
|
2023-10-13 11:15:14 +02:00
|
|
|
count(a) over (order by pk rows between 2 preceding and 2 following) as exp
|
2016-03-17 19:51:00 +01:00
|
|
|
from t1
|
|
|
|
where pk between 1 and 30
|
|
|
|
order by pk desc
|
|
|
|
limit 4;
|
2023-10-13 11:15:14 +02:00
|
|
|
pk exp
|
2016-03-17 19:51:00 +01:00
|
|
|
30 3
|
|
|
|
29 4
|
|
|
|
28 5
|
|
|
|
27 5
|
|
|
|
drop table t0,t1;
|
2023-01-19 21:43:29 +01:00
|
|
|
#
|
|
|
|
# MDEV-30052: Crash with a query containing nested WINDOW clauses
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (c INT);
|
|
|
|
insert into t1 values (1),(2);
|
|
|
|
UPDATE t1 SET c=1
|
|
|
|
WHERE c=2
|
|
|
|
ORDER BY
|
|
|
|
(1 IN ((
|
|
|
|
SELECT *
|
|
|
|
FROM (SELECT * FROM t1) AS v1
|
|
|
|
GROUP BY c
|
|
|
|
WINDOW v2 AS (ORDER BY
|
|
|
|
(SELECT *
|
|
|
|
FROM t1
|
|
|
|
GROUP BY c
|
|
|
|
WINDOW v3 AS (PARTITION BY c)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
))
|
|
|
|
);
|
|
|
|
drop table t1;
|
|
|
|
#
|
|
|
|
# MDEV-29359: Server crashed with heap-use-after-free in
|
|
|
|
# Field::is_null(long long) const (Just testcase)
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (id int);
|
|
|
|
INSERT INTO t1 VALUES (-1),(0),(84);
|
|
|
|
SELECT
|
|
|
|
id IN (SELECT id
|
|
|
|
FROM t1
|
|
|
|
WINDOW w AS (ORDER BY (SELECT 1
|
|
|
|
FROM t1
|
|
|
|
WHERE
|
|
|
|
EXISTS ( SELECT id
|
|
|
|
FROM t1
|
|
|
|
GROUP BY id
|
|
|
|
WINDOW w2 AS (ORDER BY id)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2023-10-13 11:15:14 +02:00
|
|
|
) as exp
|
2023-01-19 21:43:29 +01:00
|
|
|
FROM t1;
|
2023-10-13 11:15:14 +02:00
|
|
|
exp
|
2023-01-19 21:43:29 +01:00
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
DROP TABLE t1;
|
|
|
|
#
|
|
|
|
# End of 10.3 tests
|
|
|
|
#
|