[MDEV-2510] LP:806431 - Wrong result with derived_with_keys=on and multiple WHERE conditions on the same field Created: 2011-07-06  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 LPexportBug806431.xml    

 Description   

The following query

SELECT * FROM t1 AS a1 JOIN v1 AS a2 WHERE a1.f2 = a2.f4 AND a1.f4 = a2.f4;

does not return all matching rows when executed with derived_with_keys=on. Notice that the WHERE predicate references a2.f4 twice.

test case:

CREATE TABLE t1 (f2 int, f4 int);
INSERT INTO t1 VALUES (0,0),(0,0),(3,0),(1,0);

CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT f2, f4 FROM t1 ;

SET SESSION optimizer_switch='derived_with_keys=on';
SELECT * FROM t1 AS a1 JOIN v1 AS a2 WHERE a1.f2 = a2.f4 AND a1.f4 = a2.f4;
SET SESSION optimizer_switch='derived_with_keys=off';
SELECT * FROM t1 AS a1 JOIN v1 AS a2 WHERE a1.f2 = a2.f4 AND a1.f4 = a2.f4;

explain:

-----------------------------------------------------------------------------+

id select_type table type possible_keys key key_len ref rows Extra

-----------------------------------------------------------------------------+

1 PRIMARY a1 ALL NULL NULL NULL NULL 4 Using where
1 PRIMARY <derived2> ref key0 key0 5 v_b.a1.f2 2  
2 DERIVED t1 ALL NULL NULL NULL NULL 4  

minimal optimizer switch: derived_with_keys=on;

total 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=on,derived_merge=on,derived_with_keys=on,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,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-06 10:30:51 +0400
build-date: 2011-07-06 14:24:26 +0300
revno: 3085
branch-nick: maria-5.3



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

Launchpad bug id: 806431

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