Wrong result with DISTINCT + multipart keys after WL#106
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| MariaDB |
Fix Released
|
High
|
Igor Babaev | ||
Bug Description
Not repeatable before WL#106. Not repeatable with mysql-5.5 . Not repeatable without views. Not influenced by any optimizer switches.
Even after the fix for 806097 the following query:
SELECT DISTINCT t1.b FROM t2 JOIN ( t1 JOIN t3 ON t3.a = t1.d) ;
does not return all rows if executed with a derived table or a view.
explain:
| 1 | PRIMARY | <derived2> | ALL | NULL | NULL | NULL | NULL | 2 | |
| 2 | DERIVED | t2 | system | NULL | NULL | NULL | NULL | 1 | Using temporary |
| 2 | DERIVED | t3 | ALL | NULL | NULL | NULL | NULL | 2 | Using where; Distinct |
| 2 | DERIVED | t1 | ref | d | d | 5 | bug.t3.a | 1 | Using where; Distinct |
optimizer_switch:
index_merge=
bzr version-info:
revision-id: <email address hidden>
date: 2011-07-11 10:56:48 -0700
build-date: 2011-07-12 12:09:03 +0300
revno: 3100
branch-nick: maria-5.3
test case:
CREATE TABLE t1 ( b int , c int, d int , KEY (d,c) ) ;
INSERT INTO t1 VALUES (28,0,'
CREATE TABLE t2 ( a int) ;
INSERT INTO t2 VALUES (0);
CREATE TABLE t3 ( a varchar(32)) ;
INSERT INTO t3 VALUES ('j'),('c');
SELECT * FROM ( SELECT DISTINCT t1.b FROM t2 JOIN ( t1 JOIN t3 ON t3.a = t1.d) ) AS a1;
| Changed in maria: | |
| assignee: | nobody → Igor Babaev (igorb-seattle) |
| milestone: | none → 5.3 |
| Changed in maria: | |
| importance: | Undecided → High |
| status: | New → Confirmed |
| Changed in maria: | |
| status: | Confirmed → In Progress |
| Changed in maria: | |
| status: | In Progress → Fix Committed |
| Changed in maria: | |
| status: | Fix Committed → Fix Released |

Here is another example without multipart keys, requires join_cache_level=0:
CREATE TABLE t1 (a int) ;
INSERT INTO t1 VALUES (0),(0);
DROP TABLE IF EXISTS t2; (NULL), (NULL), (0),(0) ,(0),(0) ,(0),(0) ,(0),(0) ,(0),(0) ,(0),(0) ,(0),(0) ,(0),(0) ,(0);
CREATE TABLE t2 (a int) ;
INSERT INTO t2 VALUES (NULL),
SET SESSION join_cache_level=0;
SELECT DISTINCT t2.a FROM t1 , t2;
SELECT * FROM ( SELECT DISTINCT t2.a FROM t1 , t2 ) AS alias1 ;