MDEV-31255: Crash with fulltext search subquery in explain delete#4523
Merged
bsrikanth-mariadb merged 1 commit into10.11from Jan 27, 2026
Conversation
bd69d0f to
ce070d1
Compare
65b276c to
5fcae12
Compare
Member
|
After the patch, the reader will see this in both sql_update and sql_delete: if (select_lex->optimize_constant_subqueries())
DBUG_RETURN(TRUE);
/* Apply the IN=>EXISTS transformation to all subqueries and optimize them. */
if (select_lex->optimize_unflattened_subqueries(false))
DBUG_RETURN(TRUE);The comment in the middle looks mis-placed. In both files, make it be /*
Apply the IN=>EXISTS and other transformations to all subqueries and
optimize them.
Constant subqueries are treated in a special way here: they can be
evaluated even in EXPLAIN statement, so their query plan must be
fully initialized for computation.
*/
if (select_lex->optimize_constant_subqueries())
DBUG_RETURN(TRUE);
if (select_lex->optimize_unflattened_subqueries(false))
DBUG_RETURN(TRUE); |
spetrunia
approved these changes
Jan 27, 2026
Member
spetrunia
left a comment
There was a problem hiding this comment.
Ok to push after the above is addressed.
ft_handler isn't getting initialized for subqueries inside explain delete/update queries. However, ft_handler is accessed inside ha_ft_read(), and is the reason for NULL pointer exception. This is not the case with non-explain delete/update queries, as well as explain/non-explain select queries. Follow the approach the SELECT statements are using in JOIN::optimize_constant_subqueries(): remove SELECT_DESCRIBE flag when invoking optimization of constant subqueries. Single-table UPDATE/DELETEs have SELECT_LEX but don't have JOIN. So, we make optimize_constant_subqueries() not to be a member of JOIN class, and instead move it to SELECT_LEX, and then invoke it from single-table UPDATE/DELETE as well as for SELECT queries.
5fcae12 to
dc28140
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ft_handler isn't getting initialized for subqueries inside explain
delete/update queries. However, ft_handler is accessed inside ha_ft_read(),
and is the reason for NULL pointer exception.
This is not the case with non-explain delete/update queries, as
well as explain/non-explain select queries.
Follow the approach the SELECT statements are using in
JOIN::optimize_constant_subqueries(): remove SELECT_DESCRIBE
flag when invoking optimization of constant subqueries.
Single-table UPDATE/DELETEs have SELECT_LEX but don't have JOIN.
So, we make optimize_constant_subqueries() not to be a member
of JOIN class, and instead move it to SELECT_LEX, and then
invoke it from single-table UPDATE/DELETE as well as for SELECT queries.