Skip to content

Commit

Permalink
More testcases, fixed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
spetrunia committed Feb 14, 2016
1 parent 64ab10f commit a9ed132
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
15 changes: 12 additions & 3 deletions mysql-test/r/win.result
@@ -1,17 +1,26 @@
drop table if exists t1,t2;
# ########################################################################
# # Parser tests
# ########################################################################
#
# Check what happens when one attempts to use window function without OVER clause
#
create table t1 (a int, b int);
insert into t1 values (1,1),(2,2);
select row_number() from t1;
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
select rank() from t1;
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
# Attempt to use window function in the WHERE clause
select * from t1 where 1=rank() over (order by a);
ERROR HY000: Invalid use of group function
select * from t1 where 1>row_number() over (partition by b order by a);
ERROR HY000: Invalid use of group function
drop table t1;
# ########################################################################
# # Functionality tests
# ########################################################################
#
# Check if basic window functions work
#
# Check if ROW_NUMBER() works in basic cases
create table t1(a int, b int, x char(32));
insert into t1 values (2, 10, 'xx');
insert into t1 values (2, 10, 'zz');
Expand Down
15 changes: 12 additions & 3 deletions mysql-test/t/win.test
Expand Up @@ -6,9 +6,11 @@
drop table if exists t1,t2;
--enable_warnings

--echo # ########################################################################
--echo # # Parser tests
--echo # ########################################################################
--echo #
--echo # Check what happens when one attempts to use window function without OVER clause
--echo #
create table t1 (a int, b int);
insert into t1 values (1,1),(2,2);

Expand All @@ -17,11 +19,18 @@ select row_number() from t1;
--error ER_PARSE_ERROR
select rank() from t1;

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

--echo # ########################################################################
--echo # # Functionality tests
--echo # ########################################################################
--echo #
--echo # Check if basic window functions work
--echo #
--echo # Check if ROW_NUMBER() works in basic cases
create table t1(a int, b int, x char(32));
insert into t1 values (2, 10, 'xx');
insert into t1 values (2, 10, 'zz');
Expand Down
2 changes: 0 additions & 2 deletions sql/sql_window.cc
Expand Up @@ -286,8 +286,6 @@ bool JOIN::process_window_functions(List<Item> *curr_fields_list)
return true;

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

int err;
TABLE *tbl= *table;
Expand Down

0 comments on commit a9ed132

Please sign in to comment.