summaryrefslogtreecommitdiff
path: root/mysql-test/t/derived_view.test
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2011-06-09 12:43:28 -0700
committerIgor Babaev <igor@askmonty.org>2011-06-09 12:43:28 -0700
commitab411f8f1c2e84082623c038eb024c15c58745b5 (patch)
treef958e360825de8f21d39a496c62c3f8e333b7461 /mysql-test/t/derived_view.test
parent7f345153f91c5395e5ab4ce5906fcabbb6d06f51 (diff)
downloadmariadb-git-ab411f8f1c2e84082623c038eb024c15c58745b5.tar.gz
Fixed LP bug #794909.
The function generate_derived_keys did not take into account the fact that the last element in the array of keyuses could be just a barrier element. In some cases it could lead to a crash of the server. Also fixed a couple of other bugs in generate_derived_keys: the inner loop in the body of if this function did not change the cycle variables properly.
Diffstat (limited to 'mysql-test/t/derived_view.test')
-rw-r--r--mysql-test/t/derived_view.test20
1 files changed, 20 insertions, 0 deletions
diff --git a/mysql-test/t/derived_view.test b/mysql-test/t/derived_view.test
index a8dd703d58c..93c2eb48fcd 100644
--- a/mysql-test/t/derived_view.test
+++ b/mysql-test/t/derived_view.test
@@ -215,3 +215,23 @@ select * from t1 join (select * from t2 group by f2) tt on t1.f1=tt.f2 join t1 x
--echo materialization on tables > MAX_TABLES merge
drop table t1,t2;
drop view v1,v2,v3,v4,v6,v7;
+
+--echo #
+--echo # LP bug #794909: crash when defining possible keys for
+--echo # a materialized view/derived_table
+--echo #
+
+CREATE TABLE t1 (f1 int) ;
+INSERT INTO t1 VALUES (149), (150), (224), (29);
+
+CREATE TABLE t2 (f1 int, KEY (f1));
+INSERT INTO t2 VALUES (149), (NULL), (224);
+
+CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+
+EXPLAIN
+SELECT * FROM v1 JOIN t2 ON v1.f1 = t2.f1;
+SELECT * FROM v1 JOIN t2 ON v1.f1 = t2.f1;
+
+DROP VIEW v1;
+DROP TABLE t1,t2;