MDEV-41243, MDEV-41273 Don't freeze mem_root after engine pushdown - #5783
Open
bsrikanth-mariadb wants to merge 1 commit into
Conversation
bsrikanth-mariadb
force-pushed
the
13.2-MDEV-41243-fedx-pushdown-assert-for-upd-del-prepared-stmts
branch
from
October 5, 2026 02:48
1a678a5 to
437d6a6
Compare
When a statement is pushed down to an engine, the once-per-statement part of the optimization (e.g. the first_cond_optimization part of JOIN::optimize(), or the whole of JOIN::optimize() for a pushed down UNION) is skipped. Re-executing the same prepared statement or stored routine without pushdown then allocated from a mem_root already marked ROOT_FLAG_READ_ONLY, hitting an assertion in alloc_root(). Add LEX::dont_freeze_mem_root, set by the pushdown_handler and derived_handler constructors so it covers every engine implementing them. Prepared_statement::execute_loop(), sp_head::execute() (through sp_head::dont_freeze_mem_root) and the SP instruction reparse path no longer freeze the mem_root of such statements. The flag is only declared and used in PROTECT_STATEMENT_MEMROOT builds. Note this disables the mem_root protection for the statement for good, even if later executions are not pushed down. For a stored routine one pushed down instruction disables it for the whole routine. Add tests for prepared SELECT, UNION, UPDATE and DELETE, prepared EXPLAIN of a pushed UNION, derived tables, stored procedures, functions, triggers, cursors and metadata-invalidation reparse, with pushdown switched on and off in either order. The routine and prepared statement tests check the statements received by the remote server to verify that pushdown actually happened.
bsrikanth-mariadb
force-pushed
the
13.2-MDEV-41243-fedx-pushdown-assert-for-upd-del-prepared-stmts
branch
from
October 5, 2026 04:45
437d6a6 to
5072028
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.
When a statement is pushed down to an engine, the once-per-statement
part of the optimization (e.g. the first_cond_optimization part of
JOIN::optimize(), or the whole of JOIN::optimize() for a pushed down
UNION) is skipped. Re-executing the same prepared statement or stored
routine without pushdown then allocated from a mem_root already marked
ROOT_FLAG_READ_ONLY, hitting an assertion in alloc_root().
Add LEX::dont_freeze_mem_root, set by the pushdown_handler and
derived_handler constructors so it covers every engine implementing
them. Prepared_statement::execute_loop(), sp_head::execute() (through
sp_head::dont_freeze_mem_root) and the SP instruction reparse path no
longer freeze the mem_root of such statements. The flag is only
declared and used in PROTECT_STATEMENT_MEMROOT builds.
Note this disables the mem_root protection for the statement for good,
even if later executions are not pushed down. For a stored routine one
pushed down instruction disables it for the whole routine.
Add tests for prepared SELECT, UNION, UPDATE and DELETE, prepared EXPLAIN
of a pushed UNION, derived tables, stored procedures, functions,
triggers, cursors and metadata-invalidation reparse, with pushdown
switched on and off in either order. The routine and prepared statement
tests check the statements received by the remote server to verify that
pushdown actually happened.