[MDEV-3498] LP:843874 - Wrong result with views + degenerate WHERE condition Created: 2011-09-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 | ||
| Reporter: | Philip Stoev (Inactive) | Assignee: | Unassigned |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
The following degenerate query: SELECT * FROM t1 RIGHT JOIN v2 ON t1.a = v2.a WHERE ( v2.b AND v2.b = v2.b ); has the following EXPLAIN:
even though using a base table instead of a view returns the following result:
-----
and has the following explain:
The issue has also been observed with the following slightly less degenerate query: SELECT MAX( DISTINCT alias2 . `pk` ) AS field1 FROM C AS alias1 RIGHT JOIN view_DD AS alias2 ON alias1 . `col_varchar_10_utf8_key` = alias2 . `col_varchar_10_utf8_key` WHERE ( alias2 . `pk` NOT BETWEEN 1 AND ( 1 + 6 ) AND alias2 . `pk` = alias2 . `pk` ) ; 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=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=on bzr version-info Repeatable with maria-5.3. Not repeatable with maria-5.2, mysql-5.5 test case: CREATE TABLE t1 ( a int) ; CREATE TABLE t2 ( a varchar(32), b int NOT NULL ) ; CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2; |
| Comments |
| Comment by Philip Stoev (Inactive) [ 2011-09-09 ] |
|
Re: Wrong result with views + degenerate WHERE condition CREATE TABLE t1 ( a int) ; CREATE TABLE t2 ( a int NOT NULL , b int, c varchar(32)) ; A query with base tables: results in the following EXPLAIN EXTENDED: The same query with views: results in the following EXPLAIN EXTENDED: The outer join has been replaced by an inner join. The two queries return different results. |
| Comment by Igor Babaev [ 2011-09-25 ] |
|
Re: Wrong result with views + degenerate WHERE condition |
| Comment by Rasmus Johansson (Inactive) [ 2011-12-13 ] |
|
Launchpad bug id: 843874 |