summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/subselect_debug.result7
-rw-r--r--mysql-test/t/subselect_debug.test10
-rw-r--r--sql/opt_subselect.cc6
3 files changed, 19 insertions, 4 deletions
diff --git a/mysql-test/r/subselect_debug.result b/mysql-test/r/subselect_debug.result
index 54610d51d78..e3b5ff657b2 100644
--- a/mysql-test/r/subselect_debug.result
+++ b/mysql-test/r/subselect_debug.result
@@ -11,3 +11,10 @@ REVERSE(EXISTS(SELECT RAND() FROM t1))
0
SET GLOBAL debug=@orig_debug;
DROP TABLE t1;
+create table t1 (i int);
+insert into t1 values (1),(2);
+select * from t1 where (i < 200 or i = 300) and i in (select i from t1);
+i
+1
+2
+drop table t1;
diff --git a/mysql-test/t/subselect_debug.test b/mysql-test/t/subselect_debug.test
index ee515733afa..3c9d8e80da8 100644
--- a/mysql-test/t/subselect_debug.test
+++ b/mysql-test/t/subselect_debug.test
@@ -15,3 +15,13 @@ SELECT SUM(EXISTS(SELECT RAND() FROM t1)) FROM t1;
SELECT REVERSE(EXISTS(SELECT RAND() FROM t1));
SET GLOBAL debug=@orig_debug;
DROP TABLE t1;
+
+#
+# MDEV-5284 Assertion `!(*expr)->fixed' fails in replace_where_subcondition with IN suquery
+#
+
+create table t1 (i int);
+insert into t1 values (1),(2);
+select * from t1 where (i < 200 or i = 300) and i in (select i from t1);
+drop table t1;
+
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index c5f692f8128..74bb2875638 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -420,9 +420,7 @@ Currently, solution #2 is implemented.
static
bool subquery_types_allow_materialization(Item_in_subselect *in_subs);
-static bool replace_where_subcondition(JOIN *join, Item **expr,
- Item *old_cond, Item *new_cond,
- bool do_fix_fields);
+static bool replace_where_subcondition(JOIN *, Item **, Item *, Item *, bool);
static int subq_sj_candidate_cmp(Item_in_subselect* el1, Item_in_subselect* el2,
void *arg);
static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred);
@@ -1293,7 +1291,7 @@ static bool replace_where_subcondition(JOIN *join, Item **expr,
}
else if (item->type() == Item::COND_ITEM)
{
- DBUG_ASSERT(!(*expr)->fixed);
+ DBUG_ASSERT(!do_fix_fields || !(*expr)->fixed);
replace_where_subcondition(join, li.ref(),
old_cond, new_cond,
do_fix_fields);