[MDEV-25254] JSON_TABLE: Inconsistent name resolution with right joins Created: 2021-03-25 Updated: 2021-04-21 Resolved: 2021-04-08 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | JSON, Optimizer |
| Affects Version/s: | N/A |
| Fix Version/s: | 10.6.0 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Elena Stepanova | Assignee: | Sergei Petrunia |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
This works:
But via a view doesn't, it complains about an unknown table (the query within the view definition is the same):
And with InnoDB istead of MyISAM (or with a non-empty MyISAM table) it also doesn't, now it complains about a cross-dependency:
All this seems to be inconsistent, or at least not obvious. Either there should be a simple rule for what is allowed or not, or it should be clearly stated that name resolution is non-deterministic as it depends on an execution plan (or whatever else). In MySQL all three variants fail with the same ER_UNKNOWN_TABLE (and the variant with view fails upon the view creation):
|
| Comments |
| Comment by Sergei Petrunia [ 2021-04-01 ] | ||||
|
Analysis:
What the first example shows is a special case:
Here, t is an empty MyISAM table which has no records, and is a single In this case, the optimizer changes the outer join into inner with table t having NULL-complemented row. Then, the query is not rejected. | ||||
| Comment by Sergei Petrunia [ 2021-04-01 ] | ||||
|
The fact that CREATE VIEW is accepted is not surprising as the check for ER_WRONG_OUTER_JOIN is located in make_join_statistics(), which is called from JOIN::optimize, which is not called when one is creating a VIEW... This got me wondering, how about other queries (ones w/o JSON_TABLE) - they ought to have the same property, ER_WRONG_OUTER_JOIN is produced when the query is executed, and not produced if one is just creating a VIEW... | ||||
| Comment by Sergei Petrunia [ 2021-04-01 ] | ||||
|
Well, grepping for error name (ER_WRONG_OUTER_JOIN) or text ("Cross dependency found in OUTER JOIN; examine your ON conditions") in the testsuite finds nothing, neither in 10.6 nor in 5.5 tree. The warning seems to be dead code. | ||||
| Comment by Sergei Petrunia [ 2021-04-08 ] | ||||
|
Closed as part of |