Skip to content

Commit 691214a

Browse files
committed
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.
1 parent ebe5a38 commit 691214a

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

mysql-test/r/derived_cond_pushdown.result

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7221,3 +7221,44 @@ EXPLAIN
72217221
}
72227222
DROP VIEW v2;
72237223
DROP TABLE t1,t2;
7224+
#
7225+
# MDEV-11103: pushdown condition with ANY subquery
7226+
#
7227+
CREATE TABLE t1 (i INT);
7228+
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
7229+
INSERT INTO t1 VALUES (1),(2);
7230+
EXPLAIN FORMAT=JSON
7231+
SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
7232+
EXPLAIN
7233+
{
7234+
"query_block": {
7235+
"select_id": 1,
7236+
"table": {
7237+
"table_name": "<derived3>",
7238+
"access_type": "ALL",
7239+
"rows": 2,
7240+
"filtered": 100,
7241+
"attached_condition": "<nop>((v1.i <= 3))",
7242+
"materialized": {
7243+
"query_block": {
7244+
"select_id": 3,
7245+
"table": {
7246+
"table_name": "t1",
7247+
"access_type": "ALL",
7248+
"rows": 2,
7249+
"filtered": 100,
7250+
"attached_condition": "<nop>((t1.i <= 3))"
7251+
}
7252+
}
7253+
}
7254+
}
7255+
}
7256+
}
7257+
Warnings:
7258+
Note 1249 Select 2 was reduced during optimization
7259+
SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
7260+
i
7261+
1
7262+
2
7263+
DROP VIEW v1;
7264+
DROP TABLE t1;

mysql-test/t/derived_cond_pushdown.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,3 +1011,19 @@ SELECT * FROM t1 LEFT JOIN v2 ON a = b WHERE b IS NULL;
10111011

10121012
DROP VIEW v2;
10131013
DROP TABLE t1,t2;
1014+
1015+
--echo #
1016+
--echo # MDEV-11103: pushdown condition with ANY subquery
1017+
--echo #
1018+
1019+
CREATE TABLE t1 (i INT);
1020+
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
1021+
INSERT INTO t1 VALUES (1),(2);
1022+
1023+
EXPLAIN FORMAT=JSON
1024+
SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
1025+
1026+
SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
1027+
1028+
DROP VIEW v1;
1029+
DROP TABLE t1;

sql/item_cmpfunc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,8 @@ class Item_func_nop_all :public Item_func_not_all
649649
longlong val_int();
650650
const char *func_name() const { return "<nop>"; }
651651
Item *neg_transformer(THD *thd);
652+
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
653+
{ return get_item_copy<Item_func_nop_all>(thd, mem_root, this); }
652654
};
653655

654656

0 commit comments

Comments
 (0)