[MDEV-2886] LP:817384 - Wrong result with outer join + subquery in ON clause +unique key in maria-5.3 Created: 2011-07-28 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: | Timour Katchaounov (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
Not repeatable in maria-5.2,maria-5.1,mysql-5.5 Even after the fix for 813447, the following query: SELECT t2.b FROM t1 returns "a" which is wrong since the second part of the ON predicate is FALSE for all rows. explain:
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 test case: CREATE TABLE t1 ( c int NOT NULL , b varchar(32) NOT NULL ) ; CREATE TABLE t2 ( a int NOT NULL , b varchar(32) NOT NULL , PRIMARY KEY (a)) ; SELECT t2.b FROM t1 |
| Comments |
| Comment by Timour Katchaounov (Inactive) [ 2011-08-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Wrong result with outer join + subquery in ON clause +unique key in maria-5.3 CREATE TABLE t1 ( c int NOT NULL , b char(1) NOT NULL ) ; CREATE TABLE t2 ( a int NOT NULL , b char(1) NOT NULL , PRIMARY KEY (a)) ; create table t3 (c1 char(1), c2 char(2)); SELECT t2.b | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Timour Katchaounov (Inactive) [ 2011-08-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Wrong result with outer join + subquery in ON clause +unique key in maria-5.3 The following simple queries demonstrates that the wrong result is a This query incorrectly produces a value:
---
--- while this query works correctly:
---
--- In the wrong query constant optimization finds that the condition t2.a = 1 can be used When execution of the outer query reaches do_select(), control flow enter the branch: This branch checks only the WHERE and HAVING clauses, but doesn't check the ON Consider the second query that works correctly. In this query the second table is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Rasmus Johansson (Inactive) [ 2011-08-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Launchpad bug id: 817384 |