You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This failure may occur when we have a cursor created inside a
stored procedure and need to recreate the temporary table behind
the cursor because the storage limitation of the primary temporary
table is exceeded. In that case, the code that populates the temporary
table will recreate the temporary table in another storage engine, move
the contents of the primary table to the new one, and insert the
remaining part of the query result to this new table.
However, the handler for the new table is created on the current
THD's mem_root, which may not provide the storage lifetime expected
by cursors. Cursor objects exist over several roundtrips and we need
to enforce proper lifetime for them. For the primary temporay table,
this is ensured by using a special mem_root created in the cursor object.
However, we have no control over when the new temporary table may be
created, thus we may use the wrong mem_root for the allocation.
The fix is to save the memory allocator used when instantiating the
primary temporary table, and ensure to use the same allocator when
recreating the table with a different storage engine.
The pointer to the memory allocator is stored in the TABLE_SHARE object
and is only used for internal temporary tables.
Reviewed by: Sergey Glukhov <sergey.glukhov@oracle.com>
0 commit comments