summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2012-03-13 13:49:18 -0700
committerIgor Babaev <igor@askmonty.org>2012-03-13 13:49:18 -0700
commit0f3b8ef28ed19145e0cd850ef522ddf7cf662592 (patch)
tree5a0c42cc073e31d5dcae7ede73ab1d2c58ed8b97 /mysql-test
parent6f06cef02b062f240806cad555275c54fd68eba6 (diff)
parentc1f5e25c045538309e9da7aa2d9f0e4bd189977d (diff)
downloadmariadb-git-0f3b8ef28ed19145e0cd850ef522ddf7cf662592.tar.gz
Merge.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/derived_view.result38
-rw-r--r--mysql-test/t/derived_view.test35
2 files changed, 71 insertions, 2 deletions
diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result
index 49e1422c3d4..28c4c362a9d 100644
--- a/mysql-test/r/derived_view.result
+++ b/mysql-test/r/derived_view.result
@@ -1960,6 +1960,42 @@ ON ( COLUMNS.TABLE_SCHEMA = UNIQUES.TABLE_SCHEMA);
COUNT(*) > 0
1
DROP TABLE t1;
-set SESSION optimizer_switch= @save_optimizer_switch;
+SET SESSION optimizer_switch= @save_optimizer_switch;
+#
+# LP BUG#953649: crash when estimating the cost of a look-up
+# into a derived table to be materialized
+#
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (132);
+CREATE TABLE t2 (b int, c varchar(256));
+INSERT INTO t2 VALUES (132,'test1'), (120,'text2'), (132,'text3');
+CREATE VIEW v AS
+SELECT b, GROUP_CONCAT(c) AS gc FROM t2 GROUP BY b;
+SET @save_optimizer_switch=@@optimizer_switch;
+SET SESSION optimizer_switch='derived_merge=off';
+SET SESSION optimizer_switch='derived_with_keys=off';
+EXPLAIN
+SELECT * FROM t1, v WHERE a = b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system NULL NULL NULL NULL 1
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 Using where
+2 DERIVED t2 ALL NULL NULL NULL NULL 3 Using filesort
+SELECT * FROM t1, v WHERE a = b;
+a b gc
+132 132 test1,text3
+SET SESSION optimizer_switch='derived_merge=on';
+SET SESSION optimizer_switch='derived_with_keys=on';
+EXPLAIN
+SELECT * FROM t1, v WHERE a = b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system NULL NULL NULL NULL 1
+1 PRIMARY <derived2> ref key0 key0 5 const 0
+2 DERIVED t2 ALL NULL NULL NULL NULL 3 Using filesort
+SELECT * FROM t1, v WHERE a = b;
+a b gc
+132 132 test1,text3
+SET SESSION optimizer_switch= @save_optimizer_switch;
+DROP VIEW v;
+DROP TABLE t1,t2;
set optimizer_switch=@exit_optimizer_switch;
set join_cache_level=@exit_join_cache_level;
diff --git a/mysql-test/t/derived_view.test b/mysql-test/t/derived_view.test
index 9660dd1e5f5..d1ed2ff5ba6 100644
--- a/mysql-test/t/derived_view.test
+++ b/mysql-test/t/derived_view.test
@@ -1345,7 +1345,40 @@ SELECT COUNT(*) > 0
DROP TABLE t1;
-set SESSION optimizer_switch= @save_optimizer_switch;
+SET SESSION optimizer_switch= @save_optimizer_switch;
+
+--echo #
+--echo # LP BUG#953649: crash when estimating the cost of a look-up
+--echo # into a derived table to be materialized
+--echo #
+
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (132);
+
+CREATE TABLE t2 (b int, c varchar(256));
+INSERT INTO t2 VALUES (132,'test1'), (120,'text2'), (132,'text3');
+
+CREATE VIEW v AS
+ SELECT b, GROUP_CONCAT(c) AS gc FROM t2 GROUP BY b;
+
+SET @save_optimizer_switch=@@optimizer_switch;
+
+SET SESSION optimizer_switch='derived_merge=off';
+SET SESSION optimizer_switch='derived_with_keys=off';
+EXPLAIN
+SELECT * FROM t1, v WHERE a = b;
+SELECT * FROM t1, v WHERE a = b;
+
+SET SESSION optimizer_switch='derived_merge=on';
+SET SESSION optimizer_switch='derived_with_keys=on';
+EXPLAIN
+SELECT * FROM t1, v WHERE a = b;
+SELECT * FROM t1, v WHERE a = b;
+
+SET SESSION optimizer_switch= @save_optimizer_switch;
+
+DROP VIEW v;
+DROP TABLE t1,t2;
# The following command must be the last one the file
set optimizer_switch=@exit_optimizer_switch;