[MDEV-3163] LP:730466 - Wrong result with OR + Range checked for each record + NOT NULL Created: 2011-03-07  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 LPexportBug730466.xml    

 Description   

The following query:

SELECT *
FROM t1 STRAIGHT_JOIN t2 ON t2.f2 = t1.f1
WHERE t1.f10 OR t1.f1 OR t1.f3 AND t1.f10 AND t1.f1 = t2.f3 ;

returns no rows when executed with jkl = 0 and "Range checked for each record (index map: 0x1)", even though there is 1 row that matches the WHERE expression and which is returned by other query plans and jkl levels.

Test case:

SET SESSION join_cache_level=0
CREATE TABLE t1 ( f1 int NOT NULL , f3 int NOT NULL , f10 int NOT NULL ) ;
INSERT IGNORE INTO t1 VALUES ('4','0','g'),('5','1','v');

CREATE TABLE t2 ( f2 int NOT NULL , f3 int NOT NULL , KEY (f3)) ;
INSERT IGNORE INTO t2 VALUES ('5','7');

SELECT * FROM t1 STRAIGHT_JOIN t2 ON t2.f2 = t1.f1 WHERE t1.f10 OR t1.f1 OR t1.f3 AND t1.f10 AND t1.f1 = t2.f3;

explain:

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

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 f3 NULL NULL NULL 1 Range checked for each record (index map: 0x1)

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

bzr version-info:

revision-id: <email address hidden>
date: 2011-03-04 18:54:30 +0300
build-date: 2011-03-07 09:19:00 +0200
revno: 2933
branch-nick: maria-5.3



 Comments   
Comment by Timour Katchaounov (Inactive) [ 2011-03-09 ]

Re: Wrong result with OR + Range checked for each record + NOT NULL
Igor, assigning this bug to you because it could be related to
https://bugs.launchpad.net/maria/+bug/729067
which you already work on.

Both this, and BUG#729067 require STRAIGHT_JOIN
to force "range checked for each record".

Comment by Igor Babaev [ 2011-03-12 ]

Re: Wrong result with OR + Range checked for each record + NOT NULL
This is a duplicate of LP bug #729067.

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

Launchpad bug id: 730466

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