Skip to content

Commit a9ed132

Browse files
committed
More testcases, fixed comments
1 parent 64ab10f commit a9ed132

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

mysql-test/r/win.result

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
drop table if exists t1,t2;
2+
# ########################################################################
3+
# # Parser tests
4+
# ########################################################################
25
#
36
# Check what happens when one attempts to use window function without OVER clause
4-
#
57
create table t1 (a int, b int);
68
insert into t1 values (1,1),(2,2);
79
select row_number() from t1;
810
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'from t1' at line 1
911
select rank() from t1;
1012
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'from t1' at line 1
13+
# Attempt to use window function in the WHERE clause
14+
select * from t1 where 1=rank() over (order by a);
15+
ERROR HY000: Invalid use of group function
16+
select * from t1 where 1>row_number() over (partition by b order by a);
17+
ERROR HY000: Invalid use of group function
1118
drop table t1;
19+
# ########################################################################
20+
# # Functionality tests
21+
# ########################################################################
1222
#
13-
# Check if basic window functions work
14-
#
23+
# Check if ROW_NUMBER() works in basic cases
1524
create table t1(a int, b int, x char(32));
1625
insert into t1 values (2, 10, 'xx');
1726
insert into t1 values (2, 10, 'zz');

mysql-test/t/win.test

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
drop table if exists t1,t2;
77
--enable_warnings
88

9+
--echo # ########################################################################
10+
--echo # # Parser tests
11+
--echo # ########################################################################
912
--echo #
1013
--echo # Check what happens when one attempts to use window function without OVER clause
11-
--echo #
1214
create table t1 (a int, b int);
1315
insert into t1 values (1,1),(2,2);
1416

@@ -17,11 +19,18 @@ select row_number() from t1;
1719
--error ER_PARSE_ERROR
1820
select rank() from t1;
1921

22+
--echo # Attempt to use window function in the WHERE clause
23+
--error ER_INVALID_GROUP_FUNC_USE
24+
select * from t1 where 1=rank() over (order by a);
25+
--error ER_INVALID_GROUP_FUNC_USE
26+
select * from t1 where 1>row_number() over (partition by b order by a);
2027
drop table t1;
2128

29+
--echo # ########################################################################
30+
--echo # # Functionality tests
31+
--echo # ########################################################################
2232
--echo #
23-
--echo # Check if basic window functions work
24-
--echo #
33+
--echo # Check if ROW_NUMBER() works in basic cases
2534
create table t1(a int, b int, x char(32));
2635
insert into t1 values (2, 10, 'xx');
2736
insert into t1 values (2, 10, 'zz');

sql/sql_window.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,6 @@ bool JOIN::process_window_functions(List<Item> *curr_fields_list)
286286
return true;
287287

288288
item_win->setup_partition_border_check(thd);
289-
// TODO: somehow, setup_sortkey_check here (either directly here
290-
// or in the item.
291289

292290
int err;
293291
TABLE *tbl= *table;

0 commit comments

Comments
 (0)