mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 03:17:20 +02:00
MDEV-9935: Window functions: assertion failure with empty OVER () clause
Make window functions work with an empty over clause by forcing a sort on the first column of the current join_tab. This is a temporary fix until we get window functions to work with big tables.
This commit is contained in:
parent
e992464f27
commit
3dd3a5da0e
4 changed files with 237 additions and 3 deletions
66
mysql-test/t/win_empty_over.test
Normal file
66
mysql-test/t/win_empty_over.test
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
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, row_number() over () from t1;
|
||||
explain FORMAT=JSON select pk, row_number() over () from t1;
|
||||
explain FORMAT=JSON select row_number() over (), pk from t1;
|
||||
|
||||
select row_number() over () from (select 4) as t;
|
||||
|
||||
--sorted_result
|
||||
select min(a) over (), max(a) over (), a, row_number() over ()
|
||||
from t1
|
||||
where a = 0;
|
||||
|
||||
--sorted_result
|
||||
select a, min(a) over (), max(a) over (), row_number() over ()
|
||||
from t1
|
||||
where a = 0;
|
||||
|
||||
--sorted_result
|
||||
select min(a) over () + 1, max(a) over (), row_number() over ()
|
||||
from t1
|
||||
where a = 0;
|
||||
|
||||
--sorted_result
|
||||
select min(a) over () + a, max(a) over (), row_number() over ()
|
||||
from t1
|
||||
where a = 1;
|
||||
|
||||
--sorted_result
|
||||
select a + min(a) over (), max(a) over (), row_number() over ()
|
||||
from t1
|
||||
where a = 1;
|
||||
|
||||
select a + min(a) over () from t1 where a = 1;
|
||||
|
||||
create view win_view
|
||||
as (select a, min(a) over () from t1 where a = 1);
|
||||
select * from win_view;
|
||||
drop view win_view;
|
||||
|
||||
create view win_view
|
||||
as (select a, max(a + 1) over () from t1 where a = 1);
|
||||
select * from win_view;
|
||||
drop view win_view;
|
||||
|
||||
drop table t1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue