Commit f2e27d53 authored by Galina Shalygina's avatar Galina Shalygina

MDEV-19139: pushdown condition with Item_func_set_user_var

The bug occurs because Item_func_set_user var is allowed to be pushed
into materialized derived table/view.
To fix it excl_dep_on_table() as added to Item_func_set_user_var class
to prevent pushdown.
parent e0271a7b
......@@ -10501,4 +10501,53 @@ a b max_d c
1 2 3 1
5 6 1 5
DROP TABLE t1,t2;
#
# MDEV-19139: pushdown condition with Item_func_set_user_var
#
CREATE TABLE t1 (a INT, b INT);
CREATE VIEW v1 AS SELECT a, MAX(b) FROM t1 GROUP BY a;
SELECT * FROM (SELECT 1 FROM v1 UNION (SELECT 1 FROM v1 WHERE @a := uuid())) dt;
1
EXPLAIN FORMAT=JSON
SELECT * FROM (SELECT 1 FROM v1 UNION (SELECT 1 FROM v1 WHERE @a := uuid())) dt;
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "<derived2>",
"access_type": "ALL",
"rows": 2,
"filtered": 100,
"materialized": {
"query_block": {
"union_result": {
"table_name": "<union2,3>",
"access_type": "ALL",
"query_specifications": [
{
"query_block": {
"select_id": 2,
"table": {
"message": "no matching row in const table"
}
}
},
{
"query_block": {
"select_id": 3,
"table": {
"message": "no matching row in const table"
}
}
}
]
}
}
}
}
}
}
DROP TABLE t1;
DROP VIEW v1;
# End of 10.2 tests
......@@ -2124,4 +2124,18 @@ WHERE t1.a=tab.c AND
DROP TABLE t1,t2;
--echo #
--echo # MDEV-19139: pushdown condition with Item_func_set_user_var
--echo #
CREATE TABLE t1 (a INT, b INT);
CREATE VIEW v1 AS SELECT a, MAX(b) FROM t1 GROUP BY a;
SELECT * FROM (SELECT 1 FROM v1 UNION (SELECT 1 FROM v1 WHERE @a := uuid())) dt;
EXPLAIN FORMAT=JSON
SELECT * FROM (SELECT 1 FROM v1 UNION (SELECT 1 FROM v1 WHERE @a := uuid())) dt;
DROP TABLE t1;
DROP VIEW v1;
--echo # End of 10.2 tests
......@@ -1992,6 +1992,7 @@ class Item_func_set_user_var :public Item_func_user_var
void cleanup();
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_set_user_var>(thd, mem_root, this); }
bool excl_dep_on_table(table_map tab_map) { return false; }
};
......
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