Skip to content

MDEV-40573: Crash on multi-table DELETE with an impossible WHERE - #5478

Open
DaveGosselin-MariaDB wants to merge 1 commit into
11.8from
11.8-MDEV-40573-index-window-delete
Open

MDEV-40573: Crash on multi-table DELETE with an impossible WHERE#5478
DaveGosselin-MariaDB wants to merge 1 commit into
11.8from
11.8-MDEV-40573-index-window-delete

Conversation

@DaveGosselin-MariaDB

Copy link
Copy Markdown
Member

A DELETE containing a single table, an index hint, an impossible WHERE condition, and a window function will take the multi-delete code path but never initialize tables for deletion, leading to a crash. Such a statement would never delete rows from the target table. Record in the multi_delete whether it was ever initialized for execution, and don't attempt to delete anything if it wasn't initialized.

The index hint forces the single table DELETE to take the multi-table codepath. Since this case has an impossible WHERE condition, we set subq_exit_fl which later causes JOIN::optimize_stage2 to skip the multi-delete table initialization. It's not safe to attempt initialization when trying to find a "tableless" subquery plan, so defend against this case with the new multi-delete flag added by this commit.

A DELETE containing a single table, an index hint, an impossible WHERE
condition, and a window function will take the multi-delete code path
but never initialize tables for deletion, leading to a crash.  Such
a statement would never delete rows from the target table.  Record in the
multi_delete whether it was ever initialized for execution, and don't
attempt to delete anything if it wasn't initialized.

The index hint forces the single table DELETE to take the multi-table
codepath.  Since this case has an impossible WHERE condition, we set
subq_exit_fl which later causes JOIN::optimize_stage2 to skip the
multi-delete table initialization.  It's not safe to attempt
initialization when trying to find a "tableless" subquery plan, so
defend against this case with the new multi-delete flag added by
this commit.
@DaveGosselin-MariaDB
DaveGosselin-MariaDB force-pushed the 11.8-MDEV-40573-index-window-delete branch from b682a02 to 847b21f Compare August 3, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant