diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-06-28 16:55:42 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-06-28 16:55:42 +0400 |
commit | 724a5105cba31fe48bd0a2754d074d8942b21153 (patch) | |
tree | ce032fcc6a755ed17768ba8cf457e5196942391e /sql/sp_head.cc | |
parent | 445339feac2b9f0164870b3c90b20b2075d117bb (diff) | |
download | mariadb-git-724a5105cba31fe48bd0a2754d074d8942b21153.tar.gz |
MDEV-16584 SP with a cursor inside a loop wastes THD memory aggressively
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.
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r-- | sql/sp_head.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 6b116cb4550..c2d42cd830f 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -4027,7 +4027,7 @@ sp_instr_hpush_jump::execute(THD *thd, uint *nextp) { DBUG_ENTER("sp_instr_hpush_jump::execute"); - int ret= thd->spcont->push_handler(m_handler, m_ip + 1); + int ret= thd->spcont->push_handler(this); *nextp= m_dest; |