mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
0574bc894b
Analysis: The send_data method of the result sink class used to collect data statistics about materialized subqueries incorrectly assumed that duplicate rows are removed prior to calling send_data. As a result the collected statistics was wrong, which resulted in an incorrect maximal number of keys in the Ordered_key buffer. Solution: Try to insert each row into the materialized temp table before collecting statistics, and if the insertion results in a duplicate row, do not count the current row.
72 lines
2.4 KiB
Text
72 lines
2.4 KiB
Text
#
|
|
# Tests for
|
|
# MWL#68: Subquery optimization: Efficient NOT IN execution with NULLs
|
|
#
|
|
|
|
--disable_warnings
|
|
drop table if exists t1, t2;
|
|
--enable_warnings
|
|
|
|
--echo #
|
|
--echo # LP BUG#608744
|
|
--echo #
|
|
set @save_optimizer_switch=@@optimizer_switch;
|
|
set @@optimizer_switch="materialization=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=off";
|
|
create table t1 (a1 char(1), a2 char(1));
|
|
insert into t1 values (NULL, 'b');
|
|
create table t2 (b1 char(1), b2 char(2));
|
|
insert into t2 values ('a','b'), ('c', 'd');
|
|
select * from t1 where (a1, a2) NOT IN (select b1, b2 from t2);
|
|
drop table t1,t2;
|
|
set @@optimizer_switch=@save_optimizer_switch;
|
|
|
|
|
|
--echo #
|
|
--echo # LP BUG#601156
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (a1 int DEFAULT NULL, a2 int DEFAULT NULL);
|
|
INSERT INTO t1 VALUES (NULL,2);
|
|
INSERT INTO t1 VALUES (4,NULL);
|
|
CREATE TABLE t2 (b1 int DEFAULT NULL, b2 int DEFAULT NULL);
|
|
INSERT INTO t2 VALUES (6,NULL);
|
|
INSERT INTO t2 VALUES (NULL,0);
|
|
|
|
set @save_optimizer_switch=@@optimizer_switch;
|
|
set @@optimizer_switch='materialization=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on';
|
|
|
|
EXPLAIN EXTENDED
|
|
SELECT * FROM (SELECT * FROM t1 WHERE a1 NOT IN (SELECT b2 FROM t2)) table1;
|
|
|
|
DROP TABLE t1, t2;
|
|
set @@optimizer_switch=@save_optimizer_switch;
|
|
|
|
--echo #
|
|
--echo # LP BUG#613009 Crash in Ordered_key::get_field_idx
|
|
--echo #
|
|
|
|
set @save_optimizer_switch=@@optimizer_switch;
|
|
set @@optimizer_switch='materialization=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=off';
|
|
|
|
create table t1 (a1 char(3) DEFAULT NULL, a2 char(3) DEFAULT NULL);
|
|
insert into t1 values (NULL, 'a21'), (NULL, 'a22');
|
|
explain select * from t1 where (a1, a2) not in (select a1, a2 from t1);
|
|
select * from t1 where (a1, a2) not in (select a1, a2 from t1);
|
|
drop table t1;
|
|
set @@optimizer_switch=@save_optimizer_switch;
|
|
|
|
--echo #
|
|
--echo # LP BUG#680058 void Ordered_key::add_key(rownum_t):
|
|
--echo # Assertion `key_buff_elements && cur_key_idx < key_buff_elements' failed
|
|
--echo #
|
|
|
|
create table t1 (f1 char(1), f2 char(1));
|
|
insert into t1 values ('t', '0'), ('0', 't');
|
|
create table t2 (f3 char(1), f4 char(1));
|
|
insert into t2 values ('t', NULL), ('t', NULL), ('d', 'y');
|
|
|
|
set @save_optimizer_switch=@@optimizer_switch;
|
|
SET @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off,semijoin=off';
|
|
select * from t1 where (f1, f2) not in (select * from t2);
|
|
set @@optimizer_switch=@save_optimizer_switch;
|
|
drop table t1, t2;
|