• Alexander Barkov's avatar
    MDEV-16584 SP with a cursor inside a loop wastes THD memory aggressively · 724a5105
    Alexander Barkov authored
    Problem:
    
    push_handler() created sp_handler_entry instances on THD::main_mem_root,
    which is freed only after the SP instructions execution.
    So in case of a CONTINUE HANDLER inside a loop (e.g. WHILE) this approach
    leaked thread memory on every loop iteration.
    
    Changes:
    - Removing sp_handler_entry declaration, it's not really needed.
    - Fixing the data type of sp_rcontext::m_handlers from
      Dynamic_array<sp_handler_entry*> to Dynamic_array<sp_instr_hpush_jump*>
    - Fixing sp_rcontext::push_handler() to push the pointer to
      an sp_instr_hpush_jump instance to the handler stack.
      This instance contains everything we need.
      There is no a need to allocate anything else.
    724a5105
sp-condition-handler.test 1.54 KB