diff options
author | unknown <dlenev@brandersnatch.localdomain> | 2005-03-05 16:31:58 +0300 |
---|---|---|
committer | unknown <dlenev@brandersnatch.localdomain> | 2005-03-05 16:31:58 +0300 |
commit | e3bc9d82e6c58aea14aa1106adc6c609a5026b89 (patch) | |
tree | c5edb86c94bf138a7049952573b7f5752324da7a /sql/sp_head.cc | |
parent | f76b64f540fe7ee2505f14d8cd0c19aac0cead44 (diff) | |
download | mariadb-git-e3bc9d82e6c58aea14aa1106adc6c609a5026b89.tar.gz |
Fix for yet another memleak caused by SP-locking patch.
Improved handling of situations when we encounter error during
CREATE PROCEDURE (FUNCTION/TRIGGER/...) and bail out of yyparse()
without restoring proper THD::lex.
sql/sp.cc:
We do not need to call sp_head::restore_lex() explicitly to restore right
value of THD::lex in case when we have encountered error during parsing.
Now we do this in sp_head::~sp_head() instead.
sql/sp_head.cc:
sp_head::destroy():
Fixed cleaning up of stack of auxilary LEXes.
We also restore right value of THD::lex during this process now.
sql/sql_parse.cc:
We do not need to call sp_head::restore_lex() explicitly to restore right
value of THD::lex in case when we have encountered error during parsing.
Now we do this in sp_head::~sp_head() instead.
sql/sql_prepare.cc:
We do not need to call sp_head::restore_lex() explicitly to restore right
value of THD::lex in case when we have encountered error during parsing.
Now we do this in sp_head::~sp_head() instead.
sql/sql_trigger.cc:
We do not need to call sp_head::restore_lex() explicitly to restore right
value of THD::lex in case when we have encountered error during parsing.
Now we do this in sp_head::~sp_head() instead.
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r-- | sql/sp_head.cc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 59cdac1b153..2c4b222262f 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -459,11 +459,22 @@ sp_head::destroy() delete_dynamic(&m_instr); m_pcont->destroy(); free_items(free_list); + + /* + If we have non-empty LEX stack then we just came out of parser with + error. Now we should delete all auxilary LEXes and restore original + THD::lex (In this case sp_head::restore_thd_mem_root() was not called + too, so m_thd points to the current thread context). + It is safe to not update LEX::ptr because further query string parsing + and execution will be stopped anyway. + */ + DBUG_ASSERT(m_lex.is_empty() || m_thd); while ((lex= (LEX *)m_lex.pop())) { - if (lex != &m_thd->main_lex) // We got interrupted and have lex'es left - delete lex; + delete m_thd->lex; + m_thd->lex= lex; } + hash_free(&m_sptabs); hash_free(&m_spfuns); hash_free(&m_spprocs); |