summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGalina Shalygina <galina.shalygina@mariadb.com>2018-07-13 21:14:18 +0200
committerGalina Shalygina <galina.shalygina@mariadb.com>2018-07-27 19:00:53 +0200
commit2a3d3e052f63cca4548c5bf8ef48040ecc39c5cf (patch)
tree2258520b3d068c891f8ff53ff78e1b3530347d20
parent998c97e865c4efecd36c57eccf3d900135a5709f (diff)
downloadmariadb-git-2a3d3e052f63cca4548c5bf8ef48040ecc39c5cf.tar.gz
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.
-rw-r--r--mysql-test/main/in_subq_cond_pushdown.result12
-rw-r--r--mysql-test/main/in_subq_cond_pushdown.test16
-rw-r--r--sql/opt_subselect.cc3
3 files changed, 30 insertions, 1 deletions
diff --git a/mysql-test/main/in_subq_cond_pushdown.result b/mysql-test/main/in_subq_cond_pushdown.result
index a6246ec17d1..06b7de7a5ac 100644
--- a/mysql-test/main/in_subq_cond_pushdown.result
+++ b/mysql-test/main/in_subq_cond_pushdown.result
@@ -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;
diff --git a/mysql-test/main/in_subq_cond_pushdown.test b/mysql-test/main/in_subq_cond_pushdown.test
index b336f39a1c9..fe317c3bf94 100644
--- a/mysql-test/main/in_subq_cond_pushdown.test
+++ b/mysql-test/main/in_subq_cond_pushdown.test
@@ -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;
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index efc38e5fe66..de8cf1e54a1 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -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);
}
}