[MDEV-2508] LP:747278 - Wrong non-null result for [NOT] IN with an empty subquery as a left operand. Created: 2011-04-01  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: Trivial
Reporter: Timour Katchaounov (Inactive) Assignee: Oleksandr Byelkin
Resolution: Fixed Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug747278.xml     File LPexportBug747278_bug747278-2.test    

 Description   

The following queries produce an incorrect non-NULL result when
the left operand of [NOT] IN is a subquery with an empty result set.

Test case:

CREATE TABLE t1 (f1a int, f1b int) ;
INSERT IGNORE INTO t1 VALUES (1,1),(2,2);
CREATE TABLE t2 ( f2 int);
INSERT IGNORE INTO t2 VALUES (3),(4);
CREATE TABLE t3 (f3a int, f3b int);
INSERT INTO t3 VALUES (1,1),(2,2);

set @old_optimizer_switch = @@session.optimizer_switch;
set @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off,subquery_cache=off,semijoin=off';

SELECT (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) FROM t2;
SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) FROM t2;
SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1);

SET @@optimizer_switch = @old_optimizer_switch;

drop table t1, t2, t3;



 Comments   
Comment by Philip Stoev (Inactive) [ 2011-08-12 ]

Re: Wrong non-null result for [NOT] IN with an empty subquery as a left operand.
A wrong result was also observed when the subquery on the left side returns rows. On i7 test file /tmp//1313094482.test

Comment by Philip Stoev (Inactive) [ 2011-08-12 ]

Re: Wrong non-null result for [NOT] IN with an empty subquery as a left operand.
Unsimplified test case. Let me know if this test case will be used and I will simplify it.

Comment by Philip Stoev (Inactive) [ 2011-08-12 ]

Unsimplified test case. Let me know if this test case will be used and I will simplify it.

bug747278-2.test
LPexportBug747278_bug747278-2.test

Comment by Oleksandr Byelkin [ 2011-11-18 ]

Re: Wrong non-null result for [NOT] IN with an empty subquery as a left operand.
Trigger's val_int() method which should mask pushed in->exists condition to check emptiness of original query was not called.

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

Launchpad bug id: 747278

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