Duplicate results with semijoin=on and materialization=off
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Invalid
|
High
|
Sergey Petrunia |
Bug Description
When executing the test case for mysql BUG#45191 in subselect_sj.test
with 'semijoin=
result with duplicate rows.
Test case copied from subselect_sj.test, the only difference is the explicit
optimizer_switch:
CREATE TABLE t0 (
int_key int(11) DEFAULT NULL,
varchar_key varchar(1) DEFAULT NULL,
varchar_nokey varchar(1) DEFAULT NULL,
KEY int_key (int_key),
KEY varchar_key (varchar_
);
INSERT INTO t0 VALUES
(1,'m','m'),
(40,'h','h'),
(1,'r','r'),
(1,'h','h'),
(9,'x','x'),
(NULL,'q','q'),
(NULL,'k','k'),
(7,'l','l'),
(182,'k','k'),
(202,'a','a'),
(7,'x','x'),
(6,'j','j'),
(119,'z','z'),
(4,'d','d'),
(5,'h','h'),
(1,'u','u'),
(3,'q','q'),
(7,'a','a'),
(3,'e','e'),
(6,'l','l');
CREATE TABLE t1 (
int_key int(11) DEFAULT NULL,
varchar_key varchar(1) DEFAULT NULL,
varchar_nokey varchar(1) DEFAULT NULL,
KEY int_key (int_key),
KEY varchar_key (varchar_
);
INSERT INTO t1 VALUES (7,NULL,
CREATE TABLE t2 (
int_key int(11) DEFAULT NULL,
varchar_key varchar(1) DEFAULT NULL,
varchar_nokey varchar(1) DEFAULT NULL,
KEY int_key (int_key),
KEY varchar_key (varchar_
);
INSERT INTO t2 VALUES (123,NULL,NULL);
set @@optimizer_
SELECT t0.int_key
FROM t0
WHERE t0.varchar_nokey IN (
SELECT t1_1 .varchar_key
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
);
/*
Produces:
+---------+
| int_key |
+---------+
| 9 |
| 9 |
| 7 |
| 7 |
+---------+
Should be:
+---------+
| int_key |
+---------+
| 9 |
| 7 |
+---------+
*/
Changed in maria: | |
milestone: | none → 5.3 |
assignee: | nobody → Sergey Petrunia (sergefp) |
Changed in maria: | |
importance: | Undecided → High |
EXPLAIN:
+--+--- ------- -+----- +-----+ ------- ------+ ------- ----+-- -----+- ---+--- -+----- ------- ------- ------- ------- ------- ------- ------- ------- ----+ type|table| type |possible_keys|key |key_len|ref |rows|Extra | ------- -+----- +-----+ ------- ------+ ------- ----+-- -----+- ---+--- -+----- ------- ------- ------- ------- ------- ------- ------- ------- ----+ ------- -+----- +-----+ ------- ------+ ------- ----+-- -----+- ---+--- -+----- ------- ------- ------- ------- ------- ------- ------- ------- ----+
|id|select_
+--+---
| 1|PRIMARY |t1_1 |index|varchar_key |varchar_key|9 |NULL| 2|Using where; Using index; LooseScan |
| 1|PRIMARY |t1_2 |index|NULL |int_key |5 |NULL| 2|Using index; FirstMatch(t1_1); Using join buffer (flat, BNL join)|
| 1|PRIMARY |t0 |ALL |NULL |NULL |NULL |NULL| 20|Using where; Using join buffer (flat, BNL join) |
+--+---
3 rows in set (0.00 sec)