Skip to content
Permalink
Browse files

More testcases, fixed comments

  • Loading branch information
spetrunia committed Feb 6, 2016
1 parent 64ab10f commit a9ed132a0f377c5001525d6e5252289ce5cd9e01
Showing with 24 additions and 8 deletions.
  1. +12 −3 mysql-test/r/win.result
  2. +12 −3 mysql-test/t/win.test
  3. +0 −2 sql/sql_window.cc
@@ -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');
@@ -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);

@@ -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');
@@ -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;

0 comments on commit a9ed132

Please sign in to comment.
You can’t perform that action at this time.