summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2012-05-25 01:20:40 +0400
committerSergey Petrunya <psergey@askmonty.org>2012-05-25 01:20:40 +0400
commit5b73a17b3ac6324f5d67c20fb6c2b8b06920444b (patch)
tree454ebcc67041310dc6155c27da81c86133a3a4e2 /mysql-test
parenta834af8c236a7aef1a74558b4bc34a39dccfbaf2 (diff)
downloadmariadb-git-5b73a17b3ac6324f5d67c20fb6c2b8b06920444b.tar.gz
BUG#1002630: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SELECT
- In JOIN::exec(), make the having->update_used_tables() call before we've made the JOIN::cleanup(full=true) call. The latter frees SJ-Materialization structures, which correlated subquery predicate items attempt to walk afterwards.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/subselect_sj.result14
-rw-r--r--mysql-test/r/subselect_sj_jcl6.result14
-rw-r--r--mysql-test/t/subselect_sj.test17
3 files changed, 45 insertions, 0 deletions
diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result
index 3933100a7aa..ad2d5f760e8 100644
--- a/mysql-test/r/subselect_sj.result
+++ b/mysql-test/r/subselect_sj.result
@@ -2743,4 +2743,18 @@ AND ( alias1.a1, alias2.a1 ) IN ( SELECT c1, c1 FROM t3 )
GROUP BY field1;
field1
DROP TABLE t1,t3,t2;
+#
+# BUG#1002630: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SELECT
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(7);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (4),(6);
+SELECT ( SELECT SUM(a) FROM t1 ) AS t1sum, b
+FROM t2
+WHERE (1,1) IN ( SELECT MAX(a), MIN(a) FROM t1 )
+GROUP BY b
+HAVING t1sum <> 1;
+t1sum b
+DROP TABLE t1, t2;
set optimizer_switch=@subselect_sj_tmp;
diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result
index 8cc9352bfa3..34388db5c3b 100644
--- a/mysql-test/r/subselect_sj_jcl6.result
+++ b/mysql-test/r/subselect_sj_jcl6.result
@@ -2757,6 +2757,20 @@ AND ( alias1.a1, alias2.a1 ) IN ( SELECT c1, c1 FROM t3 )
GROUP BY field1;
field1
DROP TABLE t1,t3,t2;
+#
+# BUG#1002630: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SELECT
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(7);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (4),(6);
+SELECT ( SELECT SUM(a) FROM t1 ) AS t1sum, b
+FROM t2
+WHERE (1,1) IN ( SELECT MAX(a), MIN(a) FROM t1 )
+GROUP BY b
+HAVING t1sum <> 1;
+t1sum b
+DROP TABLE t1, t2;
set optimizer_switch=@subselect_sj_tmp;
#
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
diff --git a/mysql-test/t/subselect_sj.test b/mysql-test/t/subselect_sj.test
index 63bb29a2e13..2facb089718 100644
--- a/mysql-test/t/subselect_sj.test
+++ b/mysql-test/t/subselect_sj.test
@@ -2445,5 +2445,22 @@ GROUP BY field1;
DROP TABLE t1,t3,t2;
+--echo #
+--echo # BUG#1002630: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SELECT
+--echo #
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(7);
+
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (4),(6);
+
+SELECT ( SELECT SUM(a) FROM t1 ) AS t1sum, b
+FROM t2
+WHERE (1,1) IN ( SELECT MAX(a), MIN(a) FROM t1 )
+GROUP BY b
+HAVING t1sum <> 1;
+
+DROP TABLE t1, t2;
+
# The following command must be the last one the file
set optimizer_switch=@subselect_sj_tmp;