[MDEV-2486] LP:813489 - Wrong result with outer join + nested subquery with ALL Created: 2011-07-20  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
Reporter: Philip Stoev (Inactive) Assignee: Timour Katchaounov (Inactive)
Resolution: Not a Bug Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug813489.xml    

 Description   

The query below returns no rows in maria-5.3 even though the subquery returns an empty result and therefore the ALL predicate should evaluate to TRUE. Not influenced by optimizer_switches. Not repeatable with maria-5.2, mysql-5.1. Also please check the = ALL form, as it appears to return an incorrect result as well .

test case:

CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (0);

CREATE TABLE t2 ( b int, KEY (b) );
INSERT INTO t2 VALUES (0);

CREATE TABLE t3 ( c int) ;
INSERT INTO t3 VALUES (6);

CREATE TABLE t4 (d int) ;

SELECT * FROM t1
WHERE t1.a < ALL (
SELECT b FROM t2
WHERE EXISTS (
SELECT t3.c
FROM t4
LEFT JOIN t3 ON t3.c != 0
)
);

explain:

1 PRIMARY t1 system NULL NULL NULL NULL 1  
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables

expected result:

------

a

------

0

------

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=off,derived_merge=off,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-07-20 11:56:28 +0400
build-date: 2011-07-20 15:58:31 +0300
revno: 3123
branch-nick: maria-5.3



 Comments   
Comment by Rasmus Johansson (Inactive) [ 2011-07-21 ]

Launchpad bug id: 813489

Comment by Timour Katchaounov (Inactive) [ 2011-07-21 ]

Re: Wrong result with outer join + nested subquery with ALL
The bug is no longer reproducible with the following revision:

revision-id: igor@askmonty.org-20110721074337-qeijtrwilgdmtlsv
date: 2011-07-21 00:43:37 -0700
build-date: 2011-07-21 14:26:22 +0300
revno: 3128

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