Commit 9ff9acb3 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-10716: Assertion `real_type() != FIELD_ITEM' failed in...

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)
parent d5dfa0f1
...@@ -709,3 +709,23 @@ c1 c2 ...@@ -709,3 +709,23 @@ c1 c2
x x x x
DROP TABLE t1,t2; DROP TABLE t1,t2;
End of 10.0 tests 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
SELECT i-1 A, COUNT(*) FROM t1 GROUP BY i HAVING A AND 1;
A COUNT(*)
1 1
CREATE VIEW v1 as select i, i-1 as A from t1;
SELECT A, COUNT(*) FROM v1 GROUP BY i HAVING A AND 1;
A COUNT(*)
1 1
DROP VIEW v1;
DROP TABLE t1;
End of 10.1 tests
...@@ -743,3 +743,18 @@ SELECT * FROM t1 JOIN t2 ON c1 = c2 HAVING c2 > 'a' ORDER BY c2 LIMIT 1; ...@@ -743,3 +743,18 @@ SELECT * FROM t1 JOIN t2 ON c1 = c2 HAVING c2 > 'a' ORDER BY c2 LIMIT 1;
DROP TABLE t1,t2; DROP TABLE t1,t2;
--echo End of 10.0 tests --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;
SELECT i-1 A, COUNT(*) FROM t1 GROUP BY i HAVING A AND 1;
CREATE VIEW v1 as select i, i-1 as A from t1;
SELECT A, COUNT(*) FROM v1 GROUP BY i HAVING A AND 1;
DROP VIEW v1;
DROP TABLE t1;
--echo End of 10.1 tests
...@@ -4507,7 +4507,8 @@ Item_cond::fix_fields(THD *thd, Item **ref) ...@@ -4507,7 +4507,8 @@ Item_cond::fix_fields(THD *thd, Item **ref)
was: <field> was: <field>
become: <field> = 1 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; Query_arena backup, *arena;
Item *new_item; Item *new_item;
......
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