[MDEV-32913] Crash when query uses recursive reference to CTE in ORDER BY clause Created: 2023-11-30 Updated: 2024-01-14 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | Optimizer - CTE |
| Affects Version/s: | 10.4, 10.5 |
| Fix Version/s: | 10.4 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Igor Babaev | Assignee: | Oleksandr Byelkin |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
The following query leads to an assertion abort:
In 10.4 the abort happens in handler::ha_rnd_next():
in 10.5 the abort happens in handler::start_psi_batch_mode(). The above test case is a simplification of the test case for |
| Comments |
| Comment by Igor Babaev [ 2023-11-30 ] | |||||||||||||||||
|
It should be noted that one of the recursive references is used in the subquery of the ORDER BY clause. With default setting of the system variable standard_compliant_cte=1 we would expect the error message
The following change fixes this problem -643,6 +643,8 @@ void With_element::check_dependencies_in_unit(st_select_lex_unit *unit, { check_dependencies_in_select(sl, &unit_ctxt_elem, in_subq, dep_map); }+ if ((sl= unit->fake_select_lex)) However it does not help with the setting standard_compliant_cte=0. | |||||||||||||||||
| Comment by Igor Babaev [ 2023-11-30 ] | |||||||||||||||||
|
Here's another more natural query using a base table that causes the same problem
| |||||||||||||||||
| Comment by Alice Sherepa [ 2023-12-01 ] | |||||||||||||||||
|
This is probably the same as MDEV-32697 - could you please also check that test case after the fix. |