• Dmitry Shulga's avatar
    MDEV-14959: Fixed memory leak relating with view and IS · d0a872c2
    Dmitry Shulga authored
    Fixed memory leak taken place on executing a prepared statement or
    a stored routine that querying a view and this view constructed
    on an information schema table. For example,
    
    Lets consider the following definition of the view 'v1'
    CREATE VIEW v1 AS SELECT table_name FROM information_schema.views
    ORDER BY table_name;
    
    Querying this view in PS mode result in hit of assert.
    PREPARE stmt FROM "SELECT * FROM v1";
    EXECUTE stmt;
    EXECUTE stmt; (*)
    
    Running the statement marked with (*) leads to a crash in case
    server build with mode to control allocation of a memory from SP/PS
    memory root on the second and following executions of PS/SP.
    
    The reason of leaking the memory is that a memory allocated on
    processing of FRM file for the view requested from a PS/PS memory
    root meaning that this memory be released only when a stored routine
    be evicted from SP-cache or a prepared statement be deallocated
    that typically happens on termination of a user session.
    
    To fix the issue switch to a memory root specially created for
    allocation of short-lived objects that requested on parsing FRM.
    d0a872c2
sql_show.cc 353 KB