summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2016-02-07 01:06:56 +0300
committerSergei Petrunia <psergey@askmonty.org>2016-02-07 01:06:56 +0300
commit11112cea18d9ecb71957a0ae348ab2503ef2cdeb (patch)
tree773c909cf769393116f77ae00134a9c3e1673803
parent108555b430ac931eaeb7c4e88991e7c43802d97d (diff)
downloadmariadb-git-11112cea18d9ecb71957a0ae348ab2503ef2cdeb.tar.gz
More testcases, fixed comments
-rw-r--r--mysql-test/r/win.result15
-rw-r--r--mysql-test/t/win.test15
-rw-r--r--sql/sql_window.cc2
3 files changed, 24 insertions, 8 deletions
diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result
index 098159c4d36..05704590793 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 a70b6128d81..1161acf75a2 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 feafdc6431f..6e85f45ba8d 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -229,8 +229,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;