[MDEV-28965] Assertion failure when preparing UPDATE with derived table in WHERE Created: 2022-06-27 Updated: 2023-03-16 Resolved: 2022-07-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Delete, Data Manipulation - Update |
| Affects Version/s: | N/A |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Critical |
| Reporter: | Alice Sherepa | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
|
| Comments |
| Comment by Igor Babaev [ 2022-06-28 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
The same problem we see for single-table DELETE statements with mergeable derived tables used in their WHERE clauses.
At the server side we have:
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2022-07-02 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
The following patch fixes this problem:
With this patch we have:
Or, if we force the subquery to return 1 row we have:
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2022-07-02 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
However, if we look at the output of EXPLAIN commands for the queries we see
This is not good because there are no reasons why the mergeable derived tables is not merged here into the embedding subquery.
The same behavior we see before the patch for | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2022-07-02 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Interesting that any mergeable derived table in the FROM list of a subquery used in the WHERE condition of multi-table UPDATE/DELETE is always materialized , no matter whether the tables used in the derived table are to be updated or not.
The same behavior we see before the patch for | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2022-07-03 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
I've noticed that when processing the following query from update_use_source.test
the single-table update is processed as a multi-table update where the conversion of IN predicands to semi-joins is supported. The EXPLAIN for this query demonstrates this:
This processing of such queries appeared after the patch for
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2022-07-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
For the delete statement with the same where condition as for the update statement
we don't see any conversion of the IN predicate into semi-join either after the commit for
I fact the patch for | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2022-07-12 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
A fix for this bug was pushed into bb-10.10- | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2022-07-21 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
The bug is confirmed fixed in bb-10.10- |