summaryrefslogtreecommitdiff
path: root/mysql-test/t/win.test
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2018-01-18 15:25:40 +0300
committerSergei Petrunia <psergey@askmonty.org>2018-01-22 13:44:31 +0300
commit9b4dfdaa5a1e1ca84a2e9e65dd3066b382f65ae7 (patch)
treee150d99dcc9534b64fe08518842b4c4c31fc7657 /mysql-test/t/win.test
parent4f8555f1f68a22f33db57c31547df4f0832d78d2 (diff)
downloadmariadb-git-9b4dfdaa5a1e1ca84a2e9e65dd3066b382f65ae7.tar.gz
MDEV-13352: Server crashes in st_join_table::remove_duplicates
join_tab->distinct=true means "Before doing record read with this join_tab, call join_tab->remove_duplicates() to eliminate duplicates". remove_duplicates() assumes that - there is a temporary table $T with rows that are to be de-duplicated - there is a previous join_tab (e.g. with join_tab->fields) which was used to populate the temp.table $T. When the query has "Impossible WHERE" and window function, then the above conditions are not met (but we still might need a window function computation step when the query has implicit grouping). The fix is to not add remove_duplicates step if the select execution is degenerate (and we'll have at most one row in the output anyway).
Diffstat (limited to 'mysql-test/t/win.test')
-rw-r--r--mysql-test/t/win.test10
1 files changed, 10 insertions, 0 deletions
diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test
index 1e747e59a1a..95ffb6d9909 100644
--- a/mysql-test/t/win.test
+++ b/mysql-test/t/win.test
@@ -2057,3 +2057,13 @@ SELECT id, window
FROM door as window;
DROP TABLE door;
+
+--echo #
+--echo # MDEV-13352: Server crashes in st_join_table::remove_duplicates
+--echo #
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1),(2);
+SELECT DISTINCT ROW_NUMBER() OVER(), i FROM t1 WHERE 0;
+SELECT ROW_NUMBER() OVER(), i FROM t1 WHERE 0;
+DROP TABLE t1;
+