[MDEV-25002] ON expressions cannot contain outer references Created: 2021-02-26 Updated: 2021-03-23 Resolved: 2021-03-19 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Parser |
| Affects Version/s: | 10.5 |
| Fix Version/s: | 10.2.38, 10.3.29, 10.4.19, 10.5.10 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Sergei Petrunia | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Outside references in LEFT JOIN's ON expression produce "unknown column" error. Create the test dataset (As far as I'm aware, there's nothing special about this choice of tables/columns):
Run the query Q1:
Wrapping the outside reference in a subquery helps: Q2:
I've tried Q1 on MySQL 8.0.22 or PostgreSQL and it worked in both. Is it a bug MariaDB produces this error? |
| Comments |
| Comment by Igor Babaev [ 2021-03-05 ] | |||||||||||||||||||||||||||||||||||||||||||
|
A similar query
with JOIN instead of LEFT JOIN also returns an error message:
If we move the ON condition to WHERE
the query returns the expected result set:
| |||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2021-03-05 ] | |||||||||||||||||||||||||||||||||||||||||||
|
Let's add a couple of rows to t11
and run the query
we get
However if in the subquery we move t11.pk=t12.a to the ON clause
again we get an error message
| |||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2021-03-05 ] | |||||||||||||||||||||||||||||||||||||||||||
|
Apparently outer references in ON clauses cannot be identified. | |||||||||||||||||||||||||||||||||||||||||||
| Comment by Dmitry Shulga [ 2021-03-09 ] | |||||||||||||||||||||||||||||||||||||||||||
|
OK to push | |||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2021-03-09 ] | |||||||||||||||||||||||||||||||||||||||||||
|
A fix for this bug was pushed into 10.2 | |||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-03-18 ] | |||||||||||||||||||||||||||||||||||||||||||
|
igor or shulga, can you please provide a 10.4 version of this? In my opinion, fixes should be tested at least in the oldest and newest major version branch to find this kind of problems in advance. | |||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-03-19 ] | |||||||||||||||||||||||||||||||||||||||||||
|
This is now merged up to 10.4 (with adjustment provided by igor) and 10.5. |