Commit a9ed132a authored by Sergei Petrunia's avatar Sergei Petrunia

More testcases, fixed comments

parent 64ab10ff
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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment