[MDEV-19429] Wrong query result with EXISTS and LIMIT 0 Created: 2019-05-09 Updated: 2019-07-23 Resolved: 2019-07-20 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 5.5, 10.1, 10.2, 10.3, 10.4 |
| Fix Version/s: | 10.2.26, 5.5.65, 10.1.41, 10.3.17, 10.4.7 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sergei Petrunia | Assignee: | Oleksandr Byelkin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
"LIMIT 0" is a degenerate case. EXISTS (SELECT ... LIMIT 0) should evaluate to FALSE, but it evaluates to TRUE.
LIMIT 0 query:
Make it a subquery:
|
| Comments |
| Comment by Sergei Petrunia [ 2019-05-09 ] | |||||||||||||||||||
|
The problem is caused by this code in item_subselect.cc which sets LIMIT to 1:
| |||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2019-07-17 ] | |||||||||||||||||||
|
| |||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2019-07-17 ] | |||||||||||||||||||
|
I decided to do not overoptimize the EXISTS but just keep LIMIT correct. | |||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2019-07-17 ] | |||||||||||||||||||
|
commit ab5fa406b4b314705cb87ffd74111a518b549ff4 (HEAD Check EXISTS LIMIT before rewriting. | |||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2019-07-17 ] | |||||||||||||||||||
|
githib tree bb-5.5- | |||||||||||||||||||
| Comment by Sergei Petrunia [ 2019-07-19 ] | |||||||||||||||||||
|
Review input provided in email. Ok to push after it is addressed. |