[Commits] 9a749d1e36f: MDEV-17362: SIGSEGV in JOIN::optimize_inner or Assertion `fixed == 0'
revision-id: 9a749d1e36f0ec6d1af0cb302cf48164ccdd975e (mariadb-10.4.3-108-g9a749d1e36f) parent(s): 11fa88ef67bea74bd13ad688938a03d5b266db64 author: Galina Shalygina committer: Galina Shalygina timestamp: 2019-04-12 10:58:02 +0300 message: MDEV-17362: SIGSEGV in JOIN::optimize_inner or Assertion `fixed == 0' failed in Item_equal::fix_fields, server crashes after 2nd execution of PS Fixed the bug when pushdown into materialized IN subquery is made only in the first execution of statetement. --- mysql-test/main/in_subq_cond_pushdown.result | 18 ++++++++++++++++++ mysql-test/main/in_subq_cond_pushdown.test | 22 ++++++++++++++++++++++ mysql-test/main/subselect_innodb.result | 13 +++++++++++++ mysql-test/main/subselect_innodb.test | 16 ++++++++++++++++ sql/opt_subselect.cc | 1 + 5 files changed, 70 insertions(+) diff --git a/mysql-test/main/in_subq_cond_pushdown.result b/mysql-test/main/in_subq_cond_pushdown.result index eef320d2d04..eec85ca9c23 100644 --- a/mysql-test/main/in_subq_cond_pushdown.result +++ b/mysql-test/main/in_subq_cond_pushdown.result @@ -3887,3 +3887,21 @@ i1 2 1 DROP TABLE t1,t2,t3; +# +# MDEV-17362: SIGSEGV in JOIN::optimize_inner or Assertion `fixed == 0' +# failed in Item_equal::fix_fields, server crashes after 2nd execution +# of PS +# +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (x int, y int); +INSERT INTO t1 VALUES (1,1),(2,2); +INSERT INTO t2 VALUES (1,1),(2,2),(2,3); +PREPARE stmt FROM " +SELECT * FROM t1 +WHERE a = b + AND (a,b) IN (SELECT t2.x, COUNT(t2.y) FROM t2 WHERE 1=2 GROUP BY t2.x);"; +EXECUTE stmt; +a b +EXECUTE stmt; +a b +DROP TABLE t1,t2; diff --git a/mysql-test/main/in_subq_cond_pushdown.test b/mysql-test/main/in_subq_cond_pushdown.test index 7763201cda1..3b78dd9461c 100644 --- a/mysql-test/main/in_subq_cond_pushdown.test +++ b/mysql-test/main/in_subq_cond_pushdown.test @@ -860,3 +860,25 @@ SELECT t3.i1 FROM t3 GROUP BY i1 HAVING t.i1 < 3)); DROP TABLE t1,t2,t3; + +--echo # +--echo # MDEV-17362: SIGSEGV in JOIN::optimize_inner or Assertion `fixed == 0' +--echo # failed in Item_equal::fix_fields, server crashes after 2nd execution +--echo # of PS +--echo # + +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (x int, y int); + +INSERT INTO t1 VALUES (1,1),(2,2); +INSERT INTO t2 VALUES (1,1),(2,2),(2,3); + +PREPARE stmt FROM " +SELECT * FROM t1 +WHERE a = b + AND (a,b) IN (SELECT t2.x, COUNT(t2.y) FROM t2 WHERE 1=2 GROUP BY t2.x);"; + +EXECUTE stmt; +EXECUTE stmt; + +DROP TABLE t1,t2; diff --git a/mysql-test/main/subselect_innodb.result b/mysql-test/main/subselect_innodb.result index 518158e3a04..474217c652a 100644 --- a/mysql-test/main/subselect_innodb.result +++ b/mysql-test/main/subselect_innodb.result @@ -636,3 +636,16 @@ execute stmt; execute stmt; 1 drop table t1,t2,t3; +CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB; +CREATE TABLE t2 (x int, y int) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1),(2,2); +INSERT INTO t2 VALUES (1,1),(2,2),(2,3); +PREPARE stmt FROM " +SELECT * FROM t1 +WHERE a = b + AND (a,b) IN (SELECT t2.x, COUNT(t2.y) FROM t2 WHERE 1=2 GROUP BY t2.x);"; +EXECUTE stmt; +a b +EXECUTE stmt; +a b +DROP TABLE t1,t2; diff --git a/mysql-test/main/subselect_innodb.test b/mysql-test/main/subselect_innodb.test index 214d692e793..d76051cadfc 100644 --- a/mysql-test/main/subselect_innodb.test +++ b/mysql-test/main/subselect_innodb.test @@ -635,3 +635,19 @@ execute stmt; execute stmt; drop table t1,t2,t3; + +CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB; +CREATE TABLE t2 (x int, y int) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (1,1),(2,2); +INSERT INTO t2 VALUES (1,1),(2,2),(2,3); + +PREPARE stmt FROM " +SELECT * FROM t1 +WHERE a = b + AND (a,b) IN (SELECT t2.x, COUNT(t2.y) FROM t2 WHERE 1=2 GROUP BY t2.x);"; + +EXECUTE stmt; +EXECUTE stmt; + +DROP TABLE t1,t2; diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index a1d60aff6ef..664a230c518 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -5954,6 +5954,7 @@ bool setup_degenerate_jtbm_semi_joins(JOIN *join, if ((subq_pred= table->jtbm_subselect)) { + subq_pred->is_jtbm_const_tab= FALSE; JOIN *subq_join= subq_pred->unit->first_select()->join; if (!subq_join->tables_list || !subq_join->table_count)
participants (1)
-
Galina