Commit 2a3d3e05 authored by Galina Shalygina's avatar Galina Shalygina

MDEV-16721: Assertion `ctx.compare_type_handler()->cmp_type() != STRING_RESULT'

failed

The bug appeared as in MDEV-12387 setup_jtbm_semi_joins() procedure had been
devided into two functions, one called before optimization of WHERE clause
and another after this optimization. When the second function was called for
a degenerated jtbm semi join equalities connecting the subselect and
the parent select were created but invocation of fix_fields() for these
equalities was missing.
parent 998c97e8
......@@ -3802,3 +3802,15 @@ EXPLAIN
}
DROP TABLE t1,t2,t3;
DROP VIEW v1,v2;
#
# MDEV-16721: IN-subquery defined with the AUTO-INCREMENT column
# and used with the ZEROFILL column
#
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t2 (b INT ZEROFILL);
INSERT INTO t2 VALUES (2), (3);
SELECT *
FROM t2
WHERE t2.b IN (SELECT MIN(t1.a) from t1);
b
DROP TABLE t1, t2;
......@@ -757,3 +757,19 @@ EVAL EXPLAIN FORMAT=JSON $query;
DROP TABLE t1,t2,t3;
DROP VIEW v1,v2;
--echo #
--echo # MDEV-16721: IN-subquery defined with the AUTO-INCREMENT column
--echo # and used with the ZEROFILL column
--echo #
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t2 (b INT ZEROFILL);
INSERT INTO t2 VALUES (2), (3);
SELECT *
FROM t2
WHERE t2.b IN (SELECT MIN(t1.a) from t1);
DROP TABLE t1, t2;
......@@ -5738,7 +5738,8 @@ bool execute_degenerate_jtbm_semi_join(THD *thd,
new (thd->mem_root) Item_func_eq(thd,
subq_pred->left_expr->element_index(i),
new_sink->row[i]);
if (!eq_cond || eq_list.push_back(eq_cond, thd->mem_root))
if (!eq_cond || eq_cond->fix_fields(thd, NULL) ||
eq_list.push_back(eq_cond, thd->mem_root))
DBUG_RETURN(TRUE);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment