[MDEV-10061] Subquery with CTE does not see tables from the outer query Created: 2016-05-12 Updated: 2019-04-26 Resolved: 2017-01-30 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer - CTE, Parser |
| Affects Version/s: | 10.2 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Minor |
| Reporter: | Elena Stepanova | Assignee: | Igor Babaev |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | CTE | ||
| Issue Links: |
|
||||||||||||
| Description |
|
Note: I'm not sure whether it's supposed to work, but it looks suspicious.
|
| Comments |
| Comment by Elena Stepanova [ 2016-09-07 ] | ||||||
|
Works in PostgreSQL. | ||||||
| Comment by Sergei Petrunia [ 2016-09-07 ] | ||||||
|
Adding a bit of formatting to the query:
so, the CTE definition has a reference to t1.i, to a field in a parent select. This is hard to implement in MySQL or MariaDB, because both of these assume that derived tables cannot be "correlated", i.e. cannot depend on outer tables. Perhaps, PostreSQL is able to handle this due to their support for "LATERAL" queries? | ||||||
| Comment by Elena Stepanova [ 2016-09-07 ] | ||||||
|
Disclaimer: I didn't check whether it works correctly in PostgreSQL, only that it does not return an error. | ||||||
| Comment by Igor Babaev [ 2017-01-30 ] | ||||||
|
This is not bug.
|