[MDEV-8642] WHERE Clause not applied on View - Empty result set returned Created: 2015-08-18 Updated: 2017-04-06 Resolved: 2017-04-05 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.0.20, 10.0, 10.1 |
| Fix Version/s: | 10.1.23, 10.0.31, 10.2.6 |
| Type: | Bug | Priority: | Major |
| Reporter: | Christian Schmid | Assignee: | Oleksandr Byelkin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | merge_view | ||
| Environment: |
Linux openSUSE |
||
| Sprint: | 10.0.25, 10.0.26, 10.0.30 |
| Description |
|
When using a WHERE Clause on a View under some circumstances (View with subqueries) results in an empty result set: Steps to reproduce:
Insert dummy data:
Create a view:
Query the view with a WHERE clause:
Actual Result
Expected Result
|
| Comments |
| Comment by Elena Stepanova [ 2015-08-18 ] | ||||||||||||||||||||
|
Thanks for the report and the test case. | ||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2015-12-15 ] | ||||||||||||||||||||
|
presence of use_case_id alone of with 'and' spoil everything:
| ||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2016-04-20 ] | ||||||||||||||||||||
|
1) repeatable with derived tables (gdb) p field->table->alias | ||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2016-04-25 ] | ||||||||||||||||||||
|
The problem is that "use_case_id = 10" got into outer_ref_condition (which evaluated first when tables are not yet setup).
| ||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2016-06-17 ] | ||||||||||||||||||||
|
The real problem is that dependence reference somehow "escapes" from WHERE expression of subquery and show up in SELECT list. | ||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2016-06-17 ] | ||||||||||||||||||||
|
revision-id: eebc42f18a7cae934252a1f241fc1cf80a383531 (mariadb-10.0.25-9-geebc42f)
Do not mark reference UP as a dependent (because it is what the DOWN items dependent from) — | ||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-04-05 ] | ||||||||||||||||||||
|
Above do not create problems in 5.5 only because merging view in the select list is not allowed | ||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-04-05 ] | ||||||||||||||||||||
|
revision-id: ea909f28407133364d98718c6650df9763e47ebd (mariadb-10.0.30-21-gea909f2)
An attempt to mark reference as dependent lead to transfering this quality to |