[MDEV-3335] LP:849776 - Wrong result with semijoin + "Impossible where" Created: 2011-09-14 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: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
The following query: select * from t5 where (a) in ( returns no rows when executed with semijoin, even though the correct result must be "8", since table t5 contains the result from the subquery. mysql 5.5 also wrongly returns an empty result, though the plan there is different. Postgresql confirms that the correct result is "8". explain:
minimal optimizer_switch: semijoin=on bzr version-info: revision-id: <email address hidden> test case: CREATE TABLE t1 ( b varchar(1), a integer) ; CREATE TABLE t2 ( a integer, b varchar(1)) ; CREATE TABLE t4 ( a integer, b varchar(1)) ; CREATE TABLE t5 ( a integer) ; set session optimizer_switch='semijoin=on'; |
| Comments |
| Comment by Sergei Petrunia [ 2011-09-20 ] |
|
Re: Wrong result with semijoin + "Impossible where" Message: select 8 AS `a` from `bug849776`.`t5` semi join (`bug849776`.`t1` join `bug849776`.`t2`) where 0 the outer-to-inner conversion is made by simplify_joins(). I don't yet understand why this happens. |
| Comment by Sergei Petrunia [ 2011-09-21 ] |
|
Re: Wrong result with semijoin + "Impossible where" (gdb) p (Item*)conds That is, the condition conds has form: 1 AND t2.b NOT IN ( SELECT t4.b FROM t4 WHERE t4.b < t1.b ) AND t5.a=t1.a not_null_tables() attribute seems to be wrong: (gdb) p/t conds->not_null_tables()
(gdb) p ((Item*)conds)
|
| Comment by Sergei Petrunia [ 2011-09-21 ] |
|
Re: Wrong result with semijoin + "Impossible where" (gdb) wher 1 Item_in_optimizer inherits fix_after_pullout() from Item_func::fix_after_pullout. The latter function assumes that NOT-null attributes of its arguments should be spread to itself, i.e. argument->not_null_tables() & BIT ==> this->not_null_tables() & BIT which is not true, particularly for IN that's inside NOT. |
| Comment by Rasmus Johansson (Inactive) [ 2011-12-13 ] |
|
Launchpad bug id: 849776 |