Commit 691214ae authored by Igor Babaev's avatar Igor Babaev

Fixed bug mdev-11103.

The class Item_func_nop_all missed an implementation
of the virtual method get_copy.
As a result if the condition that can be pushed into
into a materialized view / derived table contained
an ANY subselect then the pushdown condition was built
incorrectly.
parent ebe5a38e
......@@ -7221,3 +7221,44 @@ EXPLAIN
}
DROP VIEW v2;
DROP TABLE t1,t2;
#
# MDEV-11103: pushdown condition with ANY subquery
#
CREATE TABLE t1 (i INT);
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1),(2);
EXPLAIN FORMAT=JSON
SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "<derived3>",
"access_type": "ALL",
"rows": 2,
"filtered": 100,
"attached_condition": "<nop>((v1.i <= 3))",
"materialized": {
"query_block": {
"select_id": 3,
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows": 2,
"filtered": 100,
"attached_condition": "<nop>((t1.i <= 3))"
}
}
}
}
}
}
Warnings:
Note 1249 Select 2 was reduced during optimization
SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
i
1
2
DROP VIEW v1;
DROP TABLE t1;
......@@ -1011,3 +1011,19 @@ SELECT * FROM t1 LEFT JOIN v2 ON a = b WHERE b IS NULL;
DROP VIEW v2;
DROP TABLE t1,t2;
--echo #
--echo # MDEV-11103: pushdown condition with ANY subquery
--echo #
CREATE TABLE t1 (i INT);
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1),(2);
EXPLAIN FORMAT=JSON
SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
DROP VIEW v1;
DROP TABLE t1;
......@@ -649,6 +649,8 @@ class Item_func_nop_all :public Item_func_not_all
longlong val_int();
const char *func_name() const { return "<nop>"; }
Item *neg_transformer(THD *thd);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_nop_all>(thd, mem_root, this); }
};
......
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