Skip to content

Commit 3979bd9

Browse files
committed
Bug#21547779 Assertion failed: select_lex->leaf_table_count == 0
The problem here is that we try to evaluate a subquery from the resolver. Item_is_not_null_test::update_used_tables() attempts to call is_null() on its argument because with_subselect is erroneously false. This field is wrongly updated because Item_func_make_set::update_used_tables() has a bad propagation of with_subselect: It first calls Item_func::update_used_tables() to update data for each arguments, then it calls item->update_used_tables(). But instead of accumulating data for with_subselect and with_stored_program, it assigns directly to those fields. The fix is to convert the assignments into OR assignments.
1 parent 7d4041b commit 3979bd9

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

mysql-test/r/func_set.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,9 @@ from( make_set( ( extract( minute_second from
247247
Warnings:
248248
Warning 1292 Truncated incorrect date value: '1.01'
249249
Warning 1411 Incorrect datetime value: '1.01' for function str_to_date
250+
# Bug#21547779 Assertion failed: select_lex->leaf_table_count == 0
251+
CREATE TABLE t(a INTEGER) engine=innodb;
252+
SELECT 1 IN (SELECT MAKE_SET(-1, 1, (SELECT 1 FROM t)) FROM t);
253+
1 IN (SELECT MAKE_SET(-1, 1, (SELECT 1 FROM t)) FROM t)
254+
0
255+
DROP TABLE t;

mysql-test/t/func_set.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,9 @@ trim( both(-8388607)
162162
)
163163
)
164164
;
165+
166+
--echo # Bug#21547779 Assertion failed: select_lex->leaf_table_count == 0
167+
168+
CREATE TABLE t(a INTEGER) engine=innodb;
169+
SELECT 1 IN (SELECT MAKE_SET(-1, 1, (SELECT 1 FROM t)) FROM t);
170+
DROP TABLE t;

sql/item_strfunc.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3352,8 +3352,8 @@ void Item_func_make_set::update_used_tables()
33523352
item->update_used_tables();
33533353
used_tables_cache|=item->used_tables();
33543354
const_item_cache&=item->const_item();
3355-
with_subselect= item->has_subquery();
3356-
with_stored_program= item->has_stored_program();
3355+
with_subselect|= item->has_subquery();
3356+
with_stored_program|= item->has_stored_program();
33573357
}
33583358

33593359

0 commit comments

Comments
 (0)