Commit adbe1c5f authored by Varun Gupta's avatar Varun Gupta

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.
parent 3990e55f
...@@ -2483,5 +2483,18 @@ select 1 from dual where null not in (select 1 from t2); ...@@ -2483,5 +2483,18 @@ select 1 from dual where null not in (select 1 from t2);
1 1
1 1
drop table t1,t2; drop table t1,t2;
#
# MDEV-6486: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))'
# failed with SELECT SQ, TEXT field
#
CREATE TABLE t1 (a VARCHAR(8), KEY(a)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('foo'),( 'bar');
CREATE TABLE t2 (b VARCHAR(8), c TINYTEXT, KEY(b)) ENGINE=MyISAM;
INSERT INTO t2 VALUES ('baz','baz'),('qux', 'qux');
SELECT ( SELECT COUNT(*) FROM t1 WHERE a = c ) AS field, COUNT(DISTINCT c)
FROM t2 WHERE b <= 'quux' GROUP BY field;
field COUNT(DISTINCT c)
0 1
drop table t1,t2;
SET optimizer_switch= @@global.optimizer_switch; SET optimizer_switch= @@global.optimizer_switch;
set @@tmp_table_size= @@global.tmp_table_size; set @@tmp_table_size= @@global.tmp_table_size;
...@@ -2019,5 +2019,21 @@ select 1 from dual where null not in (select 1 from t1); ...@@ -2019,5 +2019,21 @@ select 1 from dual where null not in (select 1 from t1);
select 1 from dual where null not in (select 1 from t2); select 1 from dual where null not in (select 1 from t2);
drop table t1,t2; drop table t1,t2;
--echo #
--echo # MDEV-6486: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))'
--echo # failed with SELECT SQ, TEXT field
--echo #
CREATE TABLE t1 (a VARCHAR(8), KEY(a)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('foo'),( 'bar');
CREATE TABLE t2 (b VARCHAR(8), c TINYTEXT, KEY(b)) ENGINE=MyISAM;
INSERT INTO t2 VALUES ('baz','baz'),('qux', 'qux');
SELECT ( SELECT COUNT(*) FROM t1 WHERE a = c ) AS field, COUNT(DISTINCT c)
FROM t2 WHERE b <= 'quux' GROUP BY field;
drop table t1,t2;
SET optimizer_switch= @@global.optimizer_switch; SET optimizer_switch= @@global.optimizer_switch;
set @@tmp_table_size= @@global.tmp_table_size; set @@tmp_table_size= @@global.tmp_table_size;
...@@ -3694,6 +3694,11 @@ class Item_copy :public Item ...@@ -3694,6 +3694,11 @@ class Item_copy :public Item
virtual double val_real() = 0; virtual double val_real() = 0;
virtual longlong val_int() = 0; virtual longlong val_int() = 0;
virtual int save_in_field(Field *field, bool no_conversions) = 0; virtual int save_in_field(Field *field, bool no_conversions) = 0;
bool walk(Item_processor processor, bool walk_subquery, uchar *args)
{
return (item->walk(processor, walk_subquery, args)) ||
(this->*processor)(args);
}
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment