[MDEV-14281] Wrong result from query with NOT IN predicate in WHERE Created: 2017-11-03  Updated: 2018-01-15  Resolved: 2017-11-06

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

Type: Bug Priority: Blocker
Reporter: Igor Babaev Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-12176 Transform [NOT] IN predicate with lon... Closed
Relates
relates to MDEV-14835 Server crashes in strlen / Field_iter... Closed

 Description   

If the system variable @@in_subquery_conversion_threshold is set to a small enough number then queries with NOT IN predicate in most cases return wrong result sets.
The following test case demonstrate this:

create table t1 (a int, b int);
insert into t1 values 
 (1,2), (4,6), (9,7),(1,1), (2,5), (7,8);
 
select * from t1
where (a,b) not in ((1,2),(8,9), (5,1));
 
set @@in_subquery_conversion_threshold= 2;
select * from t1
where (a,b) not in ((1,2),(8,9), (5,1));

When running this test we have:

MariaDB [test]> 
MariaDB [test]> select * from t1
    -> where (a,b) not in ((1,2),(8,9), (5,1));
+------+------+
| a    | b    |
+------+------+
|    4 |    6 |
|    9 |    7 |
|    1 |    1 |
|    2 |    5 |
|    7 |    8 |
+------+------+
 
MariaDB [test]> set @@in_subquery_conversion_threshold= 2;
 
MariaDB [test]> select * from t1
    -> where (a,b) not in ((1,2),(8,9), (5,1));
+------+------+
| a    | b    |
+------+------+
|    1 |    2 |
+------+------+



 Comments   
Comment by Marko Mäkelä [ 2017-11-04 ]

The parameter in_subquery_conversion_threshold was introduced in MDEV-12176.

Comment by Igor Babaev [ 2017-11-06 ]

A fix for this bug was pushed into 10.3

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