Skip to content

Commit 63cbca3

Browse files
MDEV-35913 Assertion `m_comparator.cmp_type() != ROW_RESULT' in Item_func_in
Check earlier that a column is a virtual column, before checking that all arguments are constants, to avoid this assertion in the case of non-virtual columns.
1 parent 665c4fc commit 63cbca3

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

mysql-test/main/type_row.result

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,20 @@ SET sql_mode=DEFAULT;
7272
#
7373
# End of 10.7 tests
7474
#
75+
#
76+
# Start of 11.8 tests
77+
#
78+
#
79+
# MDEV-35913 Assertion `m_comparator.cmp_type() != ROW_RESULT'
80+
#
81+
CREATE TABLE t1 (a TEXT UNIQUE);
82+
INSERT INTO t1 VALUES('1');
83+
SELECT 1 FROM t1 WHERE ROW(a, (a,a)) IN ((1, (1,1)),(2, (2,1)));
84+
1
85+
1
86+
DROP TABLE t1;
87+
CREATE TABLE t1 (a INT KEY,b INT,vb DATE AS (b) VIRTUAL,KEY(vb));
88+
SELECT * FROM t1 WHERE b<7 AND (a,b) NOT IN ((1,2),(8,9),(5,1));
89+
a b vb
90+
DROP TABLE t1;
91+
# End of 11.8 tests

mysql-test/main/type_row.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,22 @@ SET sql_mode=DEFAULT;
8888
--echo #
8989
--echo # End of 10.7 tests
9090
--echo #
91+
92+
--echo #
93+
--echo # Start of 11.8 tests
94+
--echo #
95+
96+
--echo #
97+
--echo # MDEV-35913 Assertion `m_comparator.cmp_type() != ROW_RESULT'
98+
--echo #
99+
100+
CREATE TABLE t1 (a TEXT UNIQUE);
101+
INSERT INTO t1 VALUES('1');
102+
SELECT 1 FROM t1 WHERE ROW(a, (a,a)) IN ((1, (1,1)),(2, (2,1)));
103+
DROP TABLE t1;
104+
105+
CREATE TABLE t1 (a INT KEY,b INT,vb DATE AS (b) VIRTUAL,KEY(vb));
106+
SELECT * FROM t1 WHERE b<7 AND (a,b) NOT IN ((1,2),(8,9),(5,1));
107+
DROP TABLE t1;
108+
109+
--echo # End of 11.8 tests

sql/opt_vcol_substitution.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,14 +454,17 @@ Item* Item_func_null_predicate::vcol_subst_transformer(THD *thd, uchar *arg)
454454
Item* Item_func_in::vcol_subst_transformer(THD *thd, uchar *arg)
455455
{
456456
Vcol_subst_context *ctx= (Vcol_subst_context*)arg;
457+
Field *vcol_field= nullptr;
457458

458-
/* Check that all arguments inside IN() are constants */
459-
if (!compatible_types_scalar_bisection_possible())
459+
/*
460+
Check that the left hand side of IN() is a virtual column expression and
461+
that all arguments inside IN() are constants.
462+
*/
463+
if (!(vcol_field= is_vcol_expr(ctx, args[0])) ||
464+
!compatible_types_scalar_bisection_possible())
460465
return this;
461466

462-
Field *vcol_field;
463-
if ((vcol_field= is_vcol_expr(ctx, args[0])))
464-
subst_vcol_if_compatible(ctx, this, &args[0], vcol_field);
467+
subst_vcol_if_compatible(ctx, this, &args[0], vcol_field);
465468
return this;
466469
}
467470

0 commit comments

Comments
 (0)