[MDEV-30706] Different results of selects from view and CTE with same definition Created: 2023-02-22 Updated: 2024-02-01 Resolved: 2023-03-07 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Views |
| Affects Version/s: | 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11 |
| Fix Version/s: | 10.11.3, 11.0.2, 10.4.29, 10.5.20, 10.6.13, 10.8.8, 10.9.6, 10.10.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Igor Babaev | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Description |
|
Different results can be observed for selects from a view and a CTE with the same specification as for the view:
This can be demonstrated with the following test case:
Note that the first select returns a wrong result.
|
| Comments |
| Comment by Igor Babaev [ 2023-02-24 ] | ||||||||||||||||||||||||||||||
|
If we look at EXPLAIN output for the reported queries
we see that for the query with CTE the table cte is materialized while for the other query the view v is not materialized and considered as mergeable. The specification of view is a select with implicit grouping. With the current merging technique such select is not considered as mergeable because it requires creation of Item_ref objects for set functions aggregated in this select. | ||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2023-03-02 ] | ||||||||||||||||||||||||||||||
|
OK to push |