[MDEV-6892] WHERE does not apply Created: 2014-10-18 Updated: 2019-06-22 Resolved: 2015-04-23 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 5.3.12, 5.5.40, 10.0.12, 10.0.14 |
| Fix Version/s: | 5.5.43, 10.0.18 |
| Type: | Bug | Priority: | Critical |
| Reporter: | erkan yanar | Assignee: | Oleksandr Byelkin |
| Resolution: | Fixed | Votes: | 3 |
| Labels: | None | ||
| Environment: |
Ubunut/LXC |
||
| Issue Links: |
|
||||||||||||||||||||||||
| Description |
|
Thx to Andreas Kretschmer for pointing out.
|
| Comments |
| Comment by Elena Stepanova [ 2014-10-18 ] | |||||||||||||||||||||||||||||||||||||
|
Thanks for the report. As a workaround, please try to set optimizer_switch='derived_merge=off'. | |||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2014-10-18 ] | |||||||||||||||||||||||||||||||||||||
|
Also reproducible with merge views instead of subqueries. | |||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2014-12-12 ] | |||||||||||||||||||||||||||||||||||||
|
I think here situation is even more interesting:
| |||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2014-12-12 ] | |||||||||||||||||||||||||||||||||||||
|
T@5 : | | | | | | | >optimize_cond WHERE:(original) 0x7f6ea801e1b8 (`message` is not null) WHERE:(after equal_items) 0x7f6ea801e1b8 (`message` is not null) WHERE:(after const change) 0x7f6ea801e1b8 (`message` is not null) WHERE:(after remove) (nil) | |||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2014-12-12 ] | |||||||||||||||||||||||||||||||||||||
|
in the very beginning of optimize: WHERE:(VERY VERY original) 0x7f069001e0a8 (1 is not null) it looks like derived table substituted but ability to be NULL is lost somewhere... | |||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2014-12-12 ] | |||||||||||||||||||||||||||||||||||||
|
It merged view, and substituted 1 (constant). Wrapper for a view field should take into account that view row is NULL but it does not somehow. | |||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2014-12-14 ] | |||||||||||||||||||||||||||||||||||||
|
This patch fixes the problem but it is too strict (should be limited by left joins only)
| |||||||||||||||||||||||||||||||||||||
| Comment by Nathan Parrish [ 2015-02-02 ] | |||||||||||||||||||||||||||||||||||||
|
Here's another test case that demonstrates the problem. This is similar to the type of query generated by Microsoft's EntityFramework. The workaround mentioned above does work.
| |||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-03-04 ] | |||||||||||||||||||||||||||||||||||||
|
was changing the wrong bug | |||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-03-04 ] | |||||||||||||||||||||||||||||||||||||
|
.. Review feedback sent. Cannot push yet. | |||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2015-04-15 ] | |||||||||||||||||||||||||||||||||||||
|
revision-id: b9426b304b2900b0dd95a41c52d5d1ac90357cfe
Taking into account implicit dependence of constant view field from nullable table of left join added. Fixed finding real table to check if it turned to NULL (materialized view & derived taken into account) Removed incorrect uninitialization. — | |||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-04-21 ] | |||||||||||||||||||||||||||||||||||||
|
The fix for this bug may be useful for | |||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-04-22 ] | |||||||||||||||||||||||||||||||||||||
|
The first bit of review feedback is the same as during the previous iteration: check_null_ref analyzes null_ref_table->null_row which is generally not set | |||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2015-04-22 ] | |||||||||||||||||||||||||||||||||||||
|
Sorry, I just forget to remove the line revision-id: 21f2a0e32bca94bdacc0c56a9b3531e7f264886c
Taking into account implicit dependence of constant view field from nullable table of left join added. Fixed finding real table to check if it turned to NULL (materialized view & derived taken into account) Removed incorrect uninitialization. — | |||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-04-22 ] | |||||||||||||||||||||||||||||||||||||
|
Ok to push. | |||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2019-06-20 ] | |||||||||||||||||||||||||||||||||||||
|
It looks like still have some problems with a variant of the reported query:
I would expect conversion of left join into inner join here as the condition message <> 0 rejects null complements. I will fix the problem in the patch for |