mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
reporting empty result added in case of max/min optimisation of ALL/ANY/SOME subqueries
fixed null processing in NOT operation used in ALL subquery (Bug #6247) mysql-test/r/subselect.result: new tests of ALL/ANY wiews mysql-test/t/subselect.test: new tests of ALL/ANY wiews sql/item_cmpfunc.cc: fixed special NOT ALL processing fixed processing max/min optimized subqueries with empty results (added methods to detect empty results) and special NOP operation to process them for SOME/ANY sobqueries sql/item_cmpfunc.h: fixed processing max/min optimized subqueries with empty results (added methods to detect empty results) and special NOP operation to process them for SOME/ANY sobqueries sql/item_subselect.cc: reporting empty result added for max/min subqueries sql/item_subselect.h: reporting empty result added for max/min subqueries sql/item_sum.cc: reporting empty result added fox max/min aggregate functions sql/item_sum.h: reporting empty result added fox max/min aggregate functions sql/sql_class.cc: reporting empty result added for max/min subqueries sql/sql_parse.cc: reporting empty result added for max/min subqueries sql/sql_union.cc: reporting empty result added for max/min subqueries
This commit is contained in:
@ -269,7 +269,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 3
|
||||
Warnings:
|
||||
Note 1003 select test.t3.a AS `a` from test.t3 where (test.t3.a >= (select min(test.t2.b) from test.t2))
|
||||
Note 1003 select test.t3.a AS `a` from test.t3 where <nop>((test.t3.a >= (select min(test.t2.b) from test.t2)))
|
||||
select * from t3 where a >= all (select b from t2);
|
||||
a
|
||||
7
|
||||
@ -1488,6 +1488,71 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
Warnings:
|
||||
Note 1003 select test.t3.a AS `a` from test.t3 where <not>((test.t3.a < (select max(test.t2.b) from test.t2)))
|
||||
select * from t3 where a >= some (select b from t2);
|
||||
a
|
||||
6
|
||||
7
|
||||
3
|
||||
explain extended select * from t3 where a >= some (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
Warnings:
|
||||
Note 1003 select test.t3.a AS `a` from test.t3 where <nop>((test.t3.a >= (select min(test.t2.b) from test.t2)))
|
||||
select * from t3 where a >= all (select b from t2 group by 1);
|
||||
a
|
||||
6
|
||||
7
|
||||
3
|
||||
explain extended select * from t3 where a >= all (select b from t2 group by 1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
Warnings:
|
||||
Note 1003 select test.t3.a AS `a` from test.t3 where <not>((test.t3.a < <max>(select test.t2.b AS `b` from test.t2 group by test.t2.b)))
|
||||
select * from t3 where a >= some (select b from t2 group by 1);
|
||||
a
|
||||
6
|
||||
7
|
||||
3
|
||||
explain extended select * from t3 where a >= some (select b from t2 group by 1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
Warnings:
|
||||
Note 1003 select test.t3.a AS `a` from test.t3 where <nop>((test.t3.a >= <min>(select test.t2.b AS `b` from test.t2 group by test.t2.b)))
|
||||
select * from t3 where NULL >= any (select b from t2);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
Warnings:
|
||||
Note 1003 select test.t3.a AS `a` from test.t3
|
||||
select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
Warnings:
|
||||
Note 1003 select test.t3.a AS `a` from test.t3
|
||||
select * from t3 where NULL >= some (select b from t2);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
Warnings:
|
||||
Note 1003 select test.t3.a AS `a` from test.t3
|
||||
select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
Warnings:
|
||||
Note 1003 select test.t3.a AS `a` from test.t3
|
||||
insert into t2 values (2,2), (2,1), (3,3), (3,1);
|
||||
select * from t3 where a > all (select max(b) from t2 group by a);
|
||||
a
|
||||
@ -1990,3 +2055,12 @@ ac
|
||||
700
|
||||
NULL
|
||||
drop tables t1,t2;
|
||||
create table t1 (s1 int);
|
||||
insert into t1 values (1),(null);
|
||||
select * from t1 where s1 < all (select s1 from t1);
|
||||
s1
|
||||
select s1, s1 < all (select s1 from t1) from t1;
|
||||
s1 s1 < all (select s1 from t1)
|
||||
1 0
|
||||
NULL NULL
|
||||
drop table t1;
|
||||
|
@ -911,7 +911,20 @@ create table t3 (a int);
|
||||
insert into t3 values (6),(7),(3);
|
||||
select * from t3 where a >= all (select b from t2);
|
||||
explain extended select * from t3 where a >= all (select b from t2);
|
||||
|
||||
select * from t3 where a >= some (select b from t2);
|
||||
explain extended select * from t3 where a >= some (select b from t2);
|
||||
select * from t3 where a >= all (select b from t2 group by 1);
|
||||
explain extended select * from t3 where a >= all (select b from t2 group by 1);
|
||||
select * from t3 where a >= some (select b from t2 group by 1);
|
||||
explain extended select * from t3 where a >= some (select b from t2 group by 1);
|
||||
select * from t3 where NULL >= any (select b from t2);
|
||||
explain extended select * from t3 where NULL >= any (select b from t2);
|
||||
select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
select * from t3 where NULL >= some (select b from t2);
|
||||
explain extended select * from t3 where NULL >= some (select b from t2);
|
||||
select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
#
|
||||
# optimized static ALL/ANY with grouping
|
||||
#
|
||||
@ -1282,3 +1295,12 @@ INSERT INTO `t2` VALUES (6,5,12,7,'a'),(12,0,0,7,'a'),(12,1,0,7,'a'),(12,5,5,7,'
|
||||
SELECT b.sc FROM (SELECT (SELECT a.access FROM t1 a WHERE a.map = op.map AND a.slave = op.pid AND a.master = 1) ac FROM t2 op WHERE op.id = 12 AND op.map = 0) b;
|
||||
SELECT b.ac FROM (SELECT (SELECT a.access FROM t1 a WHERE a.map = op.map AND a.slave = op.pid AND a.master = 1) ac FROM t2 op WHERE op.id = 12 AND op.map = 0) b;
|
||||
drop tables t1,t2;
|
||||
|
||||
#
|
||||
# ALL/ANY with NULL
|
||||
#
|
||||
create table t1 (s1 int);
|
||||
insert into t1 values (1),(null);
|
||||
select * from t1 where s1 < all (select s1 from t1);
|
||||
select s1, s1 < all (select s1 from t1) from t1;
|
||||
drop table t1;
|
||||
|
Reference in New Issue
Block a user