[MDEV-32320] Server crashes at TABLE::add_tmp_key Created: 2023-09-30 Updated: 2023-12-15 Resolved: 2023-10-15 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.4, 10.5, 10.6, 10.9, 10.10, 10.11, 11.0, 11.1, 11.2, 11.1.2, 11.2.1 |
| Fix Version/s: | 10.4.32, 10.5.23, 10.6.16, 10.10.7, 10.11.6, 11.0.4, 11.1.3 |
| Type: | Bug | Priority: | Major |
| Reporter: | Jingzhou Fu | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu 20.04 x86-64, docker image mariadb:11.1.2 |
||
| Description |
|
PoC:
docker log:
|
| Comments |
| Comment by Alice Sherepa [ 2023-10-09 ] | ||||||||||||||||||||||||||||||||||||
|
Thanks! I repeated on 10.4-11.2:
| ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-10-12 ] | ||||||||||||||||||||||||||||||||||||
|
Execution eventually reaches
The list of items passed to create_tmp_table is:
create_tmp_field() returns NULL for Item_row, the "(1,1.000000)" . This means, the temptable is created with 3 fields, not 4. Then add_tmp_key() crashes when it tries to add an index on fields with indexes 1,2,and 3. (field with index 0 is subquery's result). | ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-10-12 ] | ||||||||||||||||||||||||||||||||||||
|
( x , 1.000000 ) is not a scalar here ... should this have produced an error on name resolution phase? | ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-10-12 ] | ||||||||||||||||||||||||||||||||||||
|
A smaller testcase:
Doesn't produce an error. It produces:
| ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-10-12 ] | ||||||||||||||||||||||||||||||||||||
|
If I change the query in any way, e.g.
to WHERE 1, I get the correct result:
| ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-10-12 ] | ||||||||||||||||||||||||||||||||||||
|
In the failing query: JOIN::choose_tableless_subquery_plan() is called with select_number=2.
It does NOT reach these lines:
While for the subquery with WHERE 1 is does reach them, and we get here:
in here:
| ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2023-10-13 ] | ||||||||||||||||||||||||||||||||||||
|
bb-10.4- | ||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2023-10-13 ] | ||||||||||||||||||||||||||||||||||||
|
OK to push |