diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2012-03-12 18:21:14 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2012-03-12 18:21:14 +0400 |
commit | 223483aedf0c53bc66cb6833210228b46448003a (patch) | |
tree | d00eb77bebb08e55ceafe79b525879830503b3c0 | |
parent | 4ac230e557a2939af6bf33273141ba6f11d3f7e2 (diff) | |
parent | 50ff30d892215457c91730cb96c2a8940892114e (diff) | |
download | mariadb-git-223483aedf0c53bc66cb6833210228b46448003a.tar.gz |
Merge
-rw-r--r-- | mysql-test/r/subselect_mat.result | 22 | ||||
-rw-r--r-- | mysql-test/r/subselect_sj_mat.result | 22 | ||||
-rw-r--r-- | mysql-test/t/subselect_sj_mat.test | 22 | ||||
-rw-r--r-- | sql/sql_base.cc | 11 |
4 files changed, 77 insertions, 0 deletions
diff --git a/mysql-test/r/subselect_mat.result b/mysql-test/r/subselect_mat.result index 35b46ab975f..9c928fd81f6 100644 --- a/mysql-test/r/subselect_mat.result +++ b/mysql-test/r/subselect_mat.result @@ -1964,6 +1964,28 @@ a c SET optimizer_switch=@save_optimizer_switch; SET join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; +# +# BUG#952297: Server crashes on 2nd execution of PS in Field::is_null with semijoin+materialization +# +CREATE TABLE t1 ( a VARCHAR(1) ); +INSERT INTO t1 VALUES ('y'),('z'); +CREATE TABLE t2 ( b VARCHAR(1), c VARCHAR(1) ); +INSERT INTO t2 VALUES ('v','v'),('v','v'); +CREATE VIEW v2 AS SELECT * FROM t2; +PREPARE ps FROM ' +SELECT a FROM t1, v2 +WHERE ( c, b ) IN ( SELECT b, b FROM t2 ) +GROUP BY a '; +EXECUTE ps; +a +y +z +EXECUTE ps; +a +y +z +DROP VIEW v2; +DROP TABLE t1, t2; # This must be at the end: set optimizer_switch=@subselect_sj_mat_tmp; set join_cache_level=@save_join_cache_level; diff --git a/mysql-test/r/subselect_sj_mat.result b/mysql-test/r/subselect_sj_mat.result index d13482e9b2d..e60851775c0 100644 --- a/mysql-test/r/subselect_sj_mat.result +++ b/mysql-test/r/subselect_sj_mat.result @@ -2004,6 +2004,28 @@ a c SET optimizer_switch=@save_optimizer_switch; SET join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; +# +# BUG#952297: Server crashes on 2nd execution of PS in Field::is_null with semijoin+materialization +# +CREATE TABLE t1 ( a VARCHAR(1) ); +INSERT INTO t1 VALUES ('y'),('z'); +CREATE TABLE t2 ( b VARCHAR(1), c VARCHAR(1) ); +INSERT INTO t2 VALUES ('v','v'),('v','v'); +CREATE VIEW v2 AS SELECT * FROM t2; +PREPARE ps FROM ' +SELECT a FROM t1, v2 +WHERE ( c, b ) IN ( SELECT b, b FROM t2 ) +GROUP BY a '; +EXECUTE ps; +a +y +z +EXECUTE ps; +a +y +z +DROP VIEW v2; +DROP TABLE t1, t2; # This must be at the end: set optimizer_switch=@subselect_sj_mat_tmp; set join_cache_level=@save_join_cache_level; diff --git a/mysql-test/t/subselect_sj_mat.test b/mysql-test/t/subselect_sj_mat.test index ba260b7d8c3..a077e9b5af5 100644 --- a/mysql-test/t/subselect_sj_mat.test +++ b/mysql-test/t/subselect_sj_mat.test @@ -1642,6 +1642,28 @@ SET join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; +--echo # +--echo # BUG#952297: Server crashes on 2nd execution of PS in Field::is_null with semijoin+materialization +--echo # +CREATE TABLE t1 ( a VARCHAR(1) ); +INSERT INTO t1 VALUES ('y'),('z'); + +CREATE TABLE t2 ( b VARCHAR(1), c VARCHAR(1) ); +INSERT INTO t2 VALUES ('v','v'),('v','v'); + +CREATE VIEW v2 AS SELECT * FROM t2; + +PREPARE ps FROM ' +SELECT a FROM t1, v2 +WHERE ( c, b ) IN ( SELECT b, b FROM t2 ) +GROUP BY a '; + +EXECUTE ps; +EXECUTE ps; + +DROP VIEW v2; +DROP TABLE t1, t2; + --echo # This must be at the end: set optimizer_switch=@subselect_sj_mat_tmp; set join_cache_level=@save_join_cache_level; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 877c3dfa82e..19fabd27d72 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8506,6 +8506,17 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves, goto err_no_arena; select_lex->cond_count++; } + /* + If it's a semi-join nest, fix its "left expression", as it is used by + the SJ-Materialization + */ + if (embedded->sj_subq_pred) + { + Item **left_expr= &embedded->sj_subq_pred->left_expr; + if (!(*left_expr)->fixed && (*left_expr)->fix_fields(thd, left_expr)) + goto err_no_arena; + } + embedding= embedded->embedding; } while (embedding && |