[Commits] e6f2d72: MDEV-6486: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))'

Varun varunraiko1803 at gmail.com
Sat Mar 11 06:20:56 EET 2017


revision-id: e6f2d72ed227bec40662ae6d6a42e19d65a3a80c (mariadb-10.0.28-56-ge6f2d72)
parent(s): 8725b35d897cfad6e55217ae80e7c387e8dfe8da
author: Varun Gupta
committer: Varun Gupta
timestamp: 2017-03-11 09:24:31 +0530
message:

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.

---
 mysql-test/r/subselect4.result | 13 +++++++++++++
 mysql-test/t/subselect4.test   | 16 ++++++++++++++++
 sql/item.h                     |  5 +++++
 3 files changed, 34 insertions(+)

diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result
index 6e4e8ab..9a31f82 100644
--- a/mysql-test/r/subselect4.result
+++ b/mysql-test/r/subselect4.result
@@ -2436,5 +2436,18 @@ EXECUTE stmt;
 i
 6
 drop table t1, t2, t3;
+#
+# 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;
diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test
index cb102f8..6898ff7 100644
--- a/mysql-test/t/subselect4.test
+++ b/mysql-test/t/subselect4.test
@@ -1997,5 +1997,21 @@ EXECUTE stmt;
 
 drop table t1, t2, t3;
 
+
+--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;
diff --git a/sql/item.h b/sql/item.h
index 2f8607d..4d33a0e 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -4116,6 +4116,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);
+  }
 };
 
 /**


More information about the commits mailing list