[Commits] a0a80f14adf: MDEV-22444: SIGSEGV in __strlen_avx2 from Field_iterator_table::create_item in_predicate_conversion_threshold set

revision-id: a0a80f14adfd6c67311eed68e9fc20973c038351 (mariadb-10.3.21-178-ga0a80f14adf) parent(s): f3f23b5c4bdc669ad0af4a1c79bd70c40ed9c594 author: Varun Gupta committer: Varun Gupta timestamp: 2020-07-07 21:53:50 +0530 message: MDEV-22444: SIGSEGV in __strlen_avx2 from Field_iterator_table::create_item in_predicate_conversion_threshold set With IN predicate to IN subquery conversion, make sure to set the name for the first column in the IN predicate to the original item and not to the ref item. --- mysql-test/main/opt_tvc.result | 15 +++++++++++++++ mysql-test/main/opt_tvc.test | 20 ++++++++++++++++++++ sql/sql_tvc.cc | 5 +++-- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/opt_tvc.result b/mysql-test/main/opt_tvc.result index a68e70e8a25..8ba07f1f394 100644 --- a/mysql-test/main/opt_tvc.result +++ b/mysql-test/main/opt_tvc.result @@ -732,3 +732,18 @@ a b 4 4 drop table t1; SET @@in_predicate_conversion_threshold= default; +# +# MDEV-22444: SIGSEGV in __strlen_avx2 from Json_writer::add_str on SELECT (optimized builds) +# with optimizer_trace and in_predicate_conversion_threshold set +# +SET in_predicate_conversion_threshold=2; +CREATE TABLE t1(c1 YEAR); +INSERT INTO t1 VALUES (1997), (1998); +SELECT * FROM t1; +c1 +1997 +1998 +SELECT * FROM t1 WHERE c1 IN(NOW(),NOW()); +c1 +DROP TABLE t1; +SET @@in_predicate_conversion_threshold= default; diff --git a/mysql-test/main/opt_tvc.test b/mysql-test/main/opt_tvc.test index e4e8c6d7919..7e5d585ebc7 100644 --- a/mysql-test/main/opt_tvc.test +++ b/mysql-test/main/opt_tvc.test @@ -428,3 +428,23 @@ eval $query; drop table t1; SET @@in_predicate_conversion_threshold= default; +--echo # +--echo # MDEV-22444: SIGSEGV in __strlen_avx2 from Json_writer::add_str on SELECT (optimized builds) +--echo # with optimizer_trace and in_predicate_conversion_threshold set +--echo # + +SET in_predicate_conversion_threshold=2; +CREATE TABLE t1(c1 YEAR); +INSERT INTO t1 VALUES (1997), (1998); +SELECT * FROM t1; +SELECT * FROM t1 WHERE c1 IN(NOW(),NOW()); +DROP TABLE t1; + +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW v1 as SELECT a, 1 as b from t1; +SELECT * from v1 where a IN (b,2); +DROP TABLE t1; +DROP VIEW v1; + +SET @@in_predicate_conversion_threshold= default; diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc index def519035d9..8663ae62005 100644 --- a/sql/sql_tvc.cc +++ b/sql/sql_tvc.cc @@ -547,9 +547,10 @@ bool Item_func_in::create_value_list_for_tvc(THD *thd, if (i == 1) { sprintf(col_name, "_col_%i", 1); - args[i]->set_name(thd, col_name, strlen(col_name), thd->charset()); + args[i]->real_item()->set_name(thd, col_name, + strlen(col_name), thd->charset()); } - if (tvc_value->push_back(args[i]->real_item())) + if (tvc_value->push_back(args[i]->real_item(), thd->mem_root)) return true; }
participants (1)
-
Varun