Details
-
Task
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
Description
After the first execution of a prepared statement or stored routine, its MEM_ROOT is marked read-only (MY_ROOT_READ_ONLY, flag 4) so that later executions cannot allocate persistent memory on it. Few code paths still try to allocate lazily on such MEM_ROOT after first execution, triggering the assert (mem_root->flags & 4) == 0.
Ex:
CREATE PROCEDURE p(x INT DEFAULT (SELECT 1)) ... |
CALL p(1); -- first exec, marks mem_root read-only |
CALL p(); -- tries to allocate on locked mem_root when executing DEFAULT |
The current workaround is to clear the flag temporarily, allocate and again mark the mem_root read-only. This bypasses the protection and need a better strategy to handle such allocations.