diff --git a/mysql-test/r/opt_tvc.result b/mysql-test/r/opt_tvc.result index f06669fdf85..0ecae5bf157 100644 --- a/mysql-test/r/opt_tvc.result +++ b/mysql-test/r/opt_tvc.result @@ -638,3 +638,21 @@ Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join ((values (NULL),(NULL),(NULL),(NULL),(NULL)) `tvc_0`) where `test`.`t1`.`i` = `tvc_0`.`NULL` SET in_predicate_conversion_threshold= default; DROP TABLE t1; +# +# MDEV-14835: conversion of TVC with BIGINT or YEAR values +# +SET @@in_predicate_conversion_threshold= 2; +CREATE TABLE t1 (a BIGINT); +CREATE TABLE t2 (y YEAR); +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t2 VALUES (2009), (2010), (2011); +SELECT * FROM t1 WHERE a IN ('1','5','3'); +a +1 +3 +SELECT * FROM t2 WHERE y IN ('2009','2011'); +y +2009 +2011 +DROP TABLE t1,t2; +SET @@in_predicate_conversion_threshold= default; diff --git a/mysql-test/t/opt_tvc.test b/mysql-test/t/opt_tvc.test index 6b5ffae2f70..d5c9a5cbd3d 100644 --- a/mysql-test/t/opt_tvc.test +++ b/mysql-test/t/opt_tvc.test @@ -340,3 +340,23 @@ eval EXPLAIN EXTENDED $q; SET in_predicate_conversion_threshold= default; DROP TABLE t1; + +--echo # +--echo # MDEV-14835: conversion of TVC with BIGINT or YEAR values +--echo # + +SET @@in_predicate_conversion_threshold= 2; + +CREATE TABLE t1 (a BIGINT); +CREATE TABLE t2 (y YEAR); + +INSERT INTO t1 VALUES (1), (2), (3); +INSERT INTO t2 VALUES (2009), (2010), (2011); + +SELECT * FROM t1 WHERE a IN ('1','5','3'); + +SELECT * FROM t2 WHERE y IN ('2009','2011'); + +DROP TABLE t1,t2; + +SET @@in_predicate_conversion_threshold= default; diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc index 0af5ad3cd11..7004c32e602 100644 --- a/sql/sql_tvc.cc +++ b/sql/sql_tvc.cc @@ -479,7 +479,7 @@ bool Item_func_in::create_value_list_for_tvc(THD *thd, return true; } } - else if (tvc_value->push_back(args[i])) + else if (tvc_value->push_back(args[i]->real_item())) return true; if (values->push_back(tvc_value, thd->mem_root))