[MDEV-3488] LP:809206 - Wrong result with DISTINCT + multipart keys after WL#106 Created: 2011-07-12  Updated: 2015-02-02  Resolved: 2012-10-04

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Philip Stoev (Inactive) Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug809206.xml    

 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;



 Comments   
Comment by Philip Stoev (Inactive) [ 2011-07-13 ]

Re: Wrong result with DISTINCT + multipart keys after WL#106
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 ;

Comment by Rasmus Johansson (Inactive) [ 2011-12-13 ]

Launchpad bug id: 809206

Generated at Thu Feb 08 06:49:00 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.