• Sergei Petrunia's avatar
    MDEV-7040: Crash in field_conv, memcpy_field_possible, part#2 · b74795b0
    Sergei Petrunia authored
    The problem was with Materialized_cursor and temporary table it uses.
    Temorary table's fields had Field::orig_table pointing to the tables
    that were used in the query that produced data for the cursor.
    When "FETCH INTO sp_var" statement is executed, those original tables
    were already closed.  However, copying from Materialized_cursor's table
    into SP variable may cause field_conv() to be invoked which calls
    field->type() which may access field->orig_table (for certain field types).
    
    Fixed by setting Materialized_cursor->table->field[i]->orig_table to point
    to Materialized_cursor->table.  (this is how it is done for regular base
    tables)
    b74795b0
sql_cursor.cc 13.1 KB