mariadb/mysql-test/r/ndb_subquery.result
unknown 5f97dc6e9e BUG#24127: (a,b) IN (SELECT c,d ...) can produce wrong results if a and/or b are NULLs:
- Make the code produce correct result: use an array of triggers to turn on/off equalities for each
  compared column. Also turn on/off optimizations based on those equalities.
- Make EXPLAIN output show "Full scan on NULL key" for tables for which we switch between
  ref/unique_subquery/index_subquery and ALL access.
- index_subquery engine now has HAVING clause when it is needed, and it is
  displayed in EXPLAIN EXTENDED
- Fix incorrect presense of "Using index" for index/unique-based subqueries (BUG#22930)
// bk trigger note: this commit refers to BUG#24127


mysql-test/r/ndb_subquery.result:
  BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...)
  - Updated test results (checked)
mysql-test/r/subselect.result:
  BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...)
  - Updated test results (checked)
mysql-test/r/subselect2.result:
  BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...)
  - Updated test results (checked)
mysql-test/r/subselect3.result:
  BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...)
  - Testcases
mysql-test/t/subselect3.test:
  BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...)
  - Testcases
sql/item_cmpfunc.cc:
  BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...)
  - For row-based IN subqueries, use one flag per each column. Set the flags appropriately before
    running the subquery.
sql/item_cmpfunc.h:
  BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...)
   - Added Item_func_trig_cond::get_triv_var()
sql/item_subselect.cc:
  BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...)
  - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter
    anymore - now Item_subselect owns the pushed down predicates guard flags.
  - A correct set of conditional predicates is now pushed into row-based IN 
    subquery.
  - select_indexsubquery_engine now has "HAVING clause" (needed for correct query
    results), and it is shown in EXPLAIN EXTENDED
sql/item_subselect.h:
  BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...)
  - Item_subselect::exec() and subselect_*_engine::exec() don't have parameter
    anymore - now Item_subselect owns the pushed down predicates guard flags.
  - A correct set of conditional predicates is now pushed into row-based IN 
    subquery.
  - select_indexsubquery_engine now has "HAVING clause" (needed for correct query
    results), and it is shown in EXPLAIN EXTENDED
sql/mysql_priv.h:
  BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...)
  - Added "in_having_cond" special Item name
sql/mysqld.cc:
  BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...)
  - Added "in_having_cond" special Item name
sql/sql_lex.h:
  BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...)
sql/sql_select.cc:
  BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...)
  - Make "ref" analyzer be able to work with conditional equalities
  - Fix subquery optimization code to match the changes in what kinds of 
    conditions are pushed down into subqueries 
  - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
sql/sql_select.h:
  BUG#24127: wrong result for (null,not-null) IN (SELECT a,b ...)
  - Make "ref" analyzer be able to work with conditional equalities
  - Fix wrong EXPLAIN output in some queries with subquery (BUG#22390)
2007-01-12 23:22:41 +03:00

61 lines
2.1 KiB
Text

drop table if exists t1;
drop table if exists t2;
create table t1 (p int not null primary key, u int not null, o int not null,
unique (u), key(o)) engine=ndb;
create table t2 (p int not null primary key, u int not null, o int not null,
unique (u), key(o)) engine=ndb;
insert into t1 values (1,1,1),(2,2,2),(3,3,3);
insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5);
explain select * from t2 where p NOT IN (select p from t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1
select * from t2 where p NOT IN (select p from t1) order by p;
p u o
4 4 4
5 5 5
explain select * from t2 where p NOT IN (select u from t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where
2 DEPENDENT SUBQUERY t1 unique_subquery u u 4 func 1
select * from t2 where p NOT IN (select u from t1) order by p;
p u o
4 4 4
5 5 5
explain select * from t2 where p NOT IN (select o from t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where
2 DEPENDENT SUBQUERY t1 index_subquery o o 4 func 1
select * from t2 where p NOT IN (select o from t1) order by p;
p u o
4 4 4
5 5 5
explain select * from t2 where p NOT IN (select p+0 from t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
select * from t2 where p NOT IN (select p+0 from t1) order by p;
p u o
4 4 4
5 5 5
drop table t1;
drop table t2;
create table t1 (p int not null primary key, u int not null) engine=ndb;
insert into t1 values (1,1),(2,2),(3,3);
create table t2 as
select t1.*
from t1 as t1, t1 as t2, t1 as t3, t1 as t4, t1 as t5, t1 as t6, t1 as t7, t1 as t8
where t1.u = t2.u
and t2.u = t3.u
and t3.u = t4.u
and t4.u = t5.u
and t5.u = t6.u
and t6.u = t7.u
and t7.u = t8.u;
select * from t2 order by 1;
p u
1 1
2 2
3 3
drop table t1;
drop table t2;