Commit b2c63d2f authored by Igor Babaev's avatar Igor Babaev

Fixed bug mdev-10882.

The implementation of the virtual method build_clone for
the class Item_cache was missing.
parent cc577f81
...@@ -7626,3 +7626,65 @@ EXPLAIN ...@@ -7626,3 +7626,65 @@ EXPLAIN
} }
DROP VIEW v1,v2; DROP VIEW v1,v2;
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
#
# MDEV-10882: pushdown of the predicate with cached value
#
CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL) ENGINE=MyISAM;
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1,2),(3,4);
CREATE TABLE t2 (c INT NOT NULL) ENGINE=MyISAM;
INSERT INTO t2 VALUES (5),(6);
SELECT a, GROUP_CONCAT(b) FROM v1
WHERE b IN ( SELECT COUNT(c) FROM t2 ) GROUP BY a;
a GROUP_CONCAT(b)
1 2
EXPLAIN FORMAT=JSON
SELECT a, GROUP_CONCAT(b) FROM v1
WHERE b IN ( SELECT COUNT(c) FROM t2 ) GROUP BY a;
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "<subquery2>",
"access_type": "system",
"rows": 1,
"filtered": 100,
"materialized": {
"unique": 1,
"query_block": {
"select_id": 2,
"table": {
"message": "Select tables optimized away"
}
}
}
},
"read_sorted_file": {
"filesort": {
"sort_key": "v1.a",
"table": {
"table_name": "<derived3>",
"access_type": "ALL",
"rows": 2,
"filtered": 100,
"attached_condition": "(v1.b = 2)",
"materialized": {
"query_block": {
"select_id": 3,
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows": 2,
"filtered": 100,
"attached_condition": "(t1.b = 2)"
}
}
}
}
}
}
}
}
DROP VIEW v1;
DROP TABLE t1,t2;
...@@ -1126,3 +1126,24 @@ SELECT ( SELECT COUNT(*) FROM v2 WHERE s < t2.b ) AS f FROM t2 GROUP BY f; ...@@ -1126,3 +1126,24 @@ SELECT ( SELECT COUNT(*) FROM v2 WHERE s < t2.b ) AS f FROM t2 GROUP BY f;
DROP VIEW v1,v2; DROP VIEW v1,v2;
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
--echo #
--echo # MDEV-10882: pushdown of the predicate with cached value
--echo #
CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL) ENGINE=MyISAM;
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1,2),(3,4);
CREATE TABLE t2 (c INT NOT NULL) ENGINE=MyISAM;
INSERT INTO t2 VALUES (5),(6);
SELECT a, GROUP_CONCAT(b) FROM v1
WHERE b IN ( SELECT COUNT(c) FROM t2 ) GROUP BY a;
EXPLAIN FORMAT=JSON
SELECT a, GROUP_CONCAT(b) FROM v1
WHERE b IN ( SELECT COUNT(c) FROM t2 ) GROUP BY a;
DROP VIEW v1;
DROP TABLE t1,t2;
...@@ -5456,6 +5456,15 @@ class Item_cache: public Item_basic_constant, ...@@ -5456,6 +5456,15 @@ class Item_cache: public Item_basic_constant,
example->split_sum_func2(thd, ref_pointer_array, fields, &example, flags); example->split_sum_func2(thd, ref_pointer_array, fields, &example, flags);
} }
Item *get_example() const { return example; } Item *get_example() const { return example; }
Item* build_clone(THD *thd, MEM_ROOT *mem_root)
{
Item_cache *copy= (Item_cache *) get_copy(thd, mem_root);
if (!copy)
return 0;
if (!( copy->example= example->build_clone(thd, mem_root)))
return 0;
return copy;
}
}; };
......
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