Skip to content
Permalink
Browse files

MDEV-6486: Assertion `!table || (!table->read_set || bitmap_is_set(ta…

…ble->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.
  • Loading branch information...
varunraiko committed Mar 14, 2017
1 parent 3990e55 commit adbe1c5fe986392e5a6159e4711b99d2275be81b
Showing with 34 additions and 0 deletions.
  1. +13 −0 mysql-test/r/subselect4.result
  2. +16 −0 mysql-test/t/subselect4.test
  3. +5 −0 sql/item.h
@@ -2483,5 +2483,18 @@ select 1 from dual where null not in (select 1 from t2);
1
1
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 @@tmp_table_size= @@global.tmp_table_size;
@@ -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);
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 @@tmp_table_size= @@global.tmp_table_size;
@@ -3694,6 +3694,11 @@ class Item_copy :public Item
virtual double val_real() = 0;
virtual longlong val_int() = 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);
}
};

/**

0 comments on commit adbe1c5

Please sign in to comment.
You can’t perform that action at this time.