Wrong result with DISTINCT + multipart keys after WL#106

Bug #809206 reported by Philip Stoev
6
This bug affects 1 person
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=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=on,derived_with_keys=on,firstmatch=off,loosescan=off,materialization=on,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on

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,'j'),(29,8,'c');

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
Revision history for this message
Philip Stoev (pstoev-askmonty) wrote :

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;
CREATE TABLE t2 (a int) ;
INSERT INTO t2 VALUES (NULL),(NULL),(NULL),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0);

SET SESSION join_cache_level=0;

SELECT DISTINCT t2.a FROM t1 , t2;
SELECT * FROM ( SELECT DISTINCT t2.a FROM t1 , t2 ) AS alias1 ;

Changed in maria:
status: In Progress → Fix Committed
Changed in maria:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.