From a9ed132a0f377c5001525d6e5252289ce5cd9e01 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Sun, 7 Feb 2016 01:06:56 +0300 Subject: [PATCH] More testcases, fixed comments --- mysql-test/r/win.result | 15 ++++++++++++--- mysql-test/t/win.test | 15 ++++++++++++--- sql/sql_window.cc | 2 -- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result index 098159c4d36bb..0570459079351 100644 --- a/mysql-test/r/win.result +++ b/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'); diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test index a70b6128d810c..1161acf75a210 100644 --- a/mysql-test/t/win.test +++ b/mysql-test/t/win.test @@ -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'); diff --git a/sql/sql_window.cc b/sql/sql_window.cc index 3060cc4011c38..09fdf119ce90e 100644 --- a/sql/sql_window.cc +++ b/sql/sql_window.cc @@ -286,8 +286,6 @@ bool JOIN::process_window_functions(List *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;