[Commits] 5a215ba: MDEV-10716: Assertion `real_type() != FIELD_ITEM' failed in Item_ref::build_equal_items(THD*, COND_EQUAL*, bool, COND_EQUAL**)

Oleksandr Byelkin sanja at mariadb.com
Thu Sep 22 18:52:05 EEST 2016


revision-id: 5a215bae7d77eb6bd9d51e3e7fc6d94b6959d27d (mariadb-10.1.17-14-g5a215ba)
parent(s): ec7e0b7b30ecd301da5990495cdf18b39425a7c6
committer: Oleksandr Byelkin
timestamp: 2016-09-22 17:52:05 +0200
message:

MDEV-10716: Assertion `real_type() != FIELD_ITEM' failed in Item_ref::build_equal_items(THD*, COND_EQUAL*, bool, COND_EQUAL**)


Degenerated condition in AND should be treated in the same
way as in WHERE/HAVING alone (i.e reference should be
processed as well as fields)

---
 mysql-test/r/having.result | 12 ++++++++++++
 mysql-test/t/having.test   | 11 +++++++++++
 sql/item_cmpfunc.cc        |  3 ++-
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result
index eda6746..ab90f88 100644
--- a/mysql-test/r/having.result
+++ b/mysql-test/r/having.result
@@ -709,3 +709,15 @@ c1	c2
 x	x
 DROP TABLE t1,t2;
 End of 10.0 tests
+#
+# MDEV-10716: Assertion `real_type() != FIELD_ITEM' failed in
+# Item_ref::build_equal_items(THD*, COND_EQUAL*, bool, COND_EQUAL**)
+#
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1),(2);
+SELECT i, COUNT(*) FROM t1 GROUP BY i HAVING i<>0 AND 1;
+i	COUNT(*)
+1	1
+2	1
+DROP TABLE t1;
+End of 10.1 tests
diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test
index 0f6be0b..4e939c4 100644
--- a/mysql-test/t/having.test
+++ b/mysql-test/t/having.test
@@ -743,3 +743,14 @@ SELECT * FROM t1 JOIN t2 ON c1 = c2 HAVING c2 > 'a' ORDER BY c2 LIMIT 1;
 DROP TABLE t1,t2;
 
 --echo End of 10.0 tests
+
+--echo #
+--echo # MDEV-10716: Assertion `real_type() != FIELD_ITEM' failed in
+--echo # Item_ref::build_equal_items(THD*, COND_EQUAL*, bool, COND_EQUAL**)
+--echo #
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1),(2);
+SELECT i, COUNT(*) FROM t1 GROUP BY i HAVING i<>0 AND 1;
+DROP TABLE t1;
+
+--echo End of 10.1 tests
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index bd1e8b7..a222335 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -4507,7 +4507,8 @@ Item_cond::fix_fields(THD *thd, Item **ref)
         was:    <field>
         become: <field> = 1
     */
-    if (item->type() == FIELD_ITEM)
+    Item::Type type= item->type();
+    if (type == Item::FIELD_ITEM || type == Item::REF_ITEM)
     {
       Query_arena backup, *arena;
       Item *new_item;


More information about the commits mailing list