Skip to content

Commit adbe1c5

Browse files
committed
MDEV-6486: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))'
failed with SELECT SQ, TEXT field The functon find_all_keys does call Item_subselect::walk, which calls walk() for the subquery The issue is that when a field is represented by Item_outer_ref(Item_direct_ref(Item_copy_string( ...))). Item_copy_string does have a pointer to an Item_field in Item_copy::item but does not implement Item::walk method, so we are not able to set the bitmap for that field. This is the reason why the assert fails. Fixed by adding the walk method to Item_copy class.
1 parent 3990e55 commit adbe1c5

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

mysql-test/r/subselect4.result

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,5 +2483,18 @@ select 1 from dual where null not in (select 1 from t2);
24832483
1
24842484
1
24852485
drop table t1,t2;
2486+
#
2487+
# MDEV-6486: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))'
2488+
# failed with SELECT SQ, TEXT field
2489+
#
2490+
CREATE TABLE t1 (a VARCHAR(8), KEY(a)) ENGINE=MyISAM;
2491+
INSERT INTO t1 VALUES ('foo'),( 'bar');
2492+
CREATE TABLE t2 (b VARCHAR(8), c TINYTEXT, KEY(b)) ENGINE=MyISAM;
2493+
INSERT INTO t2 VALUES ('baz','baz'),('qux', 'qux');
2494+
SELECT ( SELECT COUNT(*) FROM t1 WHERE a = c ) AS field, COUNT(DISTINCT c)
2495+
FROM t2 WHERE b <= 'quux' GROUP BY field;
2496+
field COUNT(DISTINCT c)
2497+
0 1
2498+
drop table t1,t2;
24862499
SET optimizer_switch= @@global.optimizer_switch;
24872500
set @@tmp_table_size= @@global.tmp_table_size;

mysql-test/t/subselect4.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,5 +2019,21 @@ select 1 from dual where null not in (select 1 from t1);
20192019
select 1 from dual where null not in (select 1 from t2);
20202020
drop table t1,t2;
20212021

2022+
2023+
--echo #
2024+
--echo # MDEV-6486: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))'
2025+
--echo # failed with SELECT SQ, TEXT field
2026+
--echo #
2027+
2028+
CREATE TABLE t1 (a VARCHAR(8), KEY(a)) ENGINE=MyISAM;
2029+
INSERT INTO t1 VALUES ('foo'),( 'bar');
2030+
2031+
CREATE TABLE t2 (b VARCHAR(8), c TINYTEXT, KEY(b)) ENGINE=MyISAM;
2032+
INSERT INTO t2 VALUES ('baz','baz'),('qux', 'qux');
2033+
2034+
SELECT ( SELECT COUNT(*) FROM t1 WHERE a = c ) AS field, COUNT(DISTINCT c)
2035+
FROM t2 WHERE b <= 'quux' GROUP BY field;
2036+
drop table t1,t2;
2037+
20222038
SET optimizer_switch= @@global.optimizer_switch;
20232039
set @@tmp_table_size= @@global.tmp_table_size;

sql/item.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3694,6 +3694,11 @@ class Item_copy :public Item
36943694
virtual double val_real() = 0;
36953695
virtual longlong val_int() = 0;
36963696
virtual int save_in_field(Field *field, bool no_conversions) = 0;
3697+
bool walk(Item_processor processor, bool walk_subquery, uchar *args)
3698+
{
3699+
return (item->walk(processor, walk_subquery, args)) ||
3700+
(this->*processor)(args);
3701+
}
36973702
};
36983703

36993704
/**

0 commit comments

Comments
 (0)