Skip to content

Commit 2f5ee21

Browse files
committed
Bug#35804794: mysqld assertion failure in Query_block::replace_subquery_in_expr
The fix for bug#35621842 revealed a case of missing error propagation in Item_bool_func2::replace_scalar_subquery(), when transforming a scalar subquery into a join with a derived table. Fixed by adding proper error propagation. Change-Id: I8e4ed26098b9ea765e8daaa086e6a933d832e01b
1 parent d0ca49c commit 2f5ee21

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

mysql-test/r/subquery_table_to_derived.result

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,3 +497,11 @@ c0
497497
2
498498
DROP PREPARE p;
499499
DROP TABLE t1;
500+
# Bug#35804794: mysqld assertion failure in
501+
# Query_block::replace_subquery_in_expr
502+
CREATE TABLE t1 (col varchar(1));
503+
SELECT col
504+
FROM t1
505+
WHERE col >= (SELECT MAX(CONCAT('nz' COLLATE utf8mb4_la_0900_as_cs)) FROM t1);
506+
ERROR HY000: Illegal mix of collations (utf8mb4_0900_ai_ci,IMPLICIT) and (utf8mb4_la_0900_as_cs,IMPLICIT) for operation '>='
507+
DROP TABLE t1;

mysql-test/t/subquery_table_to_derived.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,15 @@ EXECUTE p USING @n;
356356
DROP PREPARE p;
357357

358358
DROP TABLE t1;
359+
360+
--echo # Bug#35804794: mysqld assertion failure in
361+
--echo # Query_block::replace_subquery_in_expr
362+
363+
CREATE TABLE t1 (col varchar(1));
364+
365+
--error ER_CANT_AGGREGATE_2COLLATIONS
366+
SELECT col
367+
FROM t1
368+
WHERE col >= (SELECT MAX(CONCAT('nz' COLLATE utf8mb4_la_0900_as_cs)) FROM t1);
369+
370+
DROP TABLE t1;

sql/item_cmpfunc.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,9 @@ Item *Item_func_like::replace_scalar_subquery(uchar *) {
857857
}
858858

859859
Item *Item_bool_func2::replace_scalar_subquery(uchar *) {
860-
(void)set_cmp_func();
860+
if (set_cmp_func()) {
861+
return nullptr;
862+
}
861863
return this;
862864
}
863865

sql/item_subselect.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3027,7 +3027,7 @@ Item *Item_singlerow_subselect::replace_scalar_subquery(uchar *arg) {
30273027
result = new (current_thd->mem_root)
30283028
Item_ref(&info->m_outer_query_block->context, ref, scalar_item->db_name,
30293029
scalar_item->table_name, scalar_item->field_name);
3030-
// nullptr is error, but no separate return needed here
3030+
if (result == nullptr) return nullptr;
30313031
} else {
30323032
result = scalar_item;
30333033
}

0 commit comments

Comments
 (0)