[MDEV-3159] LP:823826 - Wrong result / WHERE not observed with derived_merge and inner join in maria-5.3 Created: 2011-08-10  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: Critical
Reporter: Philip Stoev (Inactive) Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug823826.xml    

 Description   

The following query:

SELECT * FROM ( SELECT t2.* FROM t1 , t2 ) AS alias1 WHERE b IS NULL;

returns rows for which b IS NOT NULL

MariaDB [test]> explain SELECT * FROM ( SELECT t2.* FROM t1 , t2 ) AS alias1 WHERE b IS NULL ;
------------------------------------------------------------------------------------------+

id select_type table type possible_keys key key_len ref rows Extra

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

1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)

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

minimal optimizer switch:derived_merge=on
full 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=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,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=off,table_elimination=on

bzr version-info
revision-id: <email address hidden>
date: 2011-08-09 18:34:26 +0300
build-date: 2011-08-10 13:04:33 +0300
revno: 3148
branch-nick: maria-5.3

test case:

CREATE TABLE t1 (a int) ;
INSERT INTO t1 VALUES (1),(1);

CREATE TABLE t2 (b int) ;
INSERT INTO t2 VALUES (NULL),(6);

SET SESSION optimizer_switch='derived_merge=on';

SELECT * FROM ( SELECT t2.* FROM t1 , t2 ) AS alias1 WHERE b IS NULL;



 Comments   
Comment by Igor Babaev [ 2011-08-11 ]

Re: Wrong result / WHERE not observed with derived_merge and inner join in maria-5.3
The same problem can be reproduced with a view:

MariaDB [test]> create view v2 as select * from t1,t2;
Query OK, 0 rows affected (0.01 sec)

MariaDB [test]> select * from v2;
----------+

a b

----------+

1 NULL
1 NULL
1 6
1 6

----------+
4 rows in set (0.00 sec)

MariaDB [test]> select * from v2 where b is null;
----------+

a b

----------+

1 NULL
1 NULL
1 6
1 6

----------+
4 rows in set (0.00 sec)

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

Launchpad bug id: 823826

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