summaryrefslogtreecommitdiff
path: root/sql/sql_trigger.cc
diff options
context:
space:
mode:
authorKonstantin Osipov <kostja@sun.com>2010-07-27 14:25:53 +0400
committerKonstantin Osipov <kostja@sun.com>2010-07-27 14:25:53 +0400
commitec2c3bf2c1c27e4401c767a6cdcb3172453ff42c (patch)
treedaa2c75e6ac3ede954eb788e81dd95c711da1569 /sql/sql_trigger.cc
parentc67cf159e928fe63582a4233d130dada0f866cb7 (diff)
downloadmariadb-git-ec2c3bf2c1c27e4401c767a6cdcb3172453ff42c.tar.gz
A pre-requisite patch for the fix for Bug#52044.
This patch also fixes Bug#55452 "SET PASSWORD is replicated twice in RBR mode". The goal of this patch is to remove the release of metadata locks from close_thread_tables(). This is necessary to not mistakenly release the locks in the course of a multi-step operation that involves multiple close_thread_tables() or close_tables_for_reopen(). On the same token, move statement commit outside close_thread_tables(). Other cleanups: Cleanup COM_FIELD_LIST. Don't call close_thread_tables() in COM_SHUTDOWN -- there are no open tables there that can be closed (we leave the locked tables mode in THD destructor, and this close_thread_tables() won't leave it anyway). Make open_and_lock_tables() and open_and_lock_tables_derived() call close_thread_tables() upon failure. Remove the calls to close_thread_tables() that are now unnecessary. Simplify the back off condition in Open_table_context. Streamline metadata lock handling in LOCK TABLES implementation. Add asserts to ensure correct life cycle of statement transaction in a session. Remove a piece of dead code that has also become redundant after the fix for Bug 37521.
Diffstat (limited to 'sql/sql_trigger.cc')
-rw-r--r--sql/sql_trigger.cc27
1 files changed, 14 insertions, 13 deletions
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 2f084c369b6..a5664b00287 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -540,9 +540,9 @@ end:
}
/*
- If we are under LOCK TABLES we should restore original state of meta-data
- locks. Otherwise call to close_thread_tables() will take care about both
- TABLE instance created by open_n_lock_single_table() and metadata lock.
+ If we are under LOCK TABLES we should restore original state of
+ meta-data locks. Otherwise all locks will be released along
+ with the implicit commit.
*/
if (thd->locked_tables_mode && tables && lock_upgrade_done)
mdl_ticket->downgrade_exclusive_lock(MDL_SHARED_NO_READ_WRITE);
@@ -1321,6 +1321,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
thd->reset_db((char*) db, strlen(db));
while ((trg_create_str= it++))
{
+ sp_head *sp;
trg_sql_mode= itm++;
LEX_STRING *trg_definer= it_definer++;
@@ -1357,13 +1358,14 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
*/
lex.set_trg_event_type_for_tables();
- lex.sphead->set_info(0, 0, &lex.sp_chistics, (ulong) *trg_sql_mode);
-
int event= lex.trg_chistics.event;
int action_time= lex.trg_chistics.action_time;
- lex.sphead->set_creation_ctx(creation_ctx);
- triggers->bodies[event][action_time]= lex.sphead;
+ sp= triggers->bodies[event][action_time]= lex.sphead;
+ lex.sphead= NULL; /* Prevent double cleanup. */
+
+ sp->set_info(0, 0, &lex.sp_chistics, (ulong) *trg_sql_mode);
+ sp->set_creation_ctx(creation_ctx);
if (!trg_definer->length)
{
@@ -1376,27 +1378,26 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_TRG_NO_DEFINER, ER(ER_TRG_NO_DEFINER),
(const char*) db,
- (const char*) lex.sphead->m_name.str);
+ (const char*) sp->m_name.str);
/*
Set definer to the '' to correct displaying in the information
schema.
*/
- lex.sphead->set_definer((char*) "", 0);
+ sp->set_definer((char*) "", 0);
/*
Triggers without definer information are executed under the
authorization of the invoker.
*/
- lex.sphead->m_chistics->suid= SP_IS_NOT_SUID;
+ sp->m_chistics->suid= SP_IS_NOT_SUID;
}
else
- lex.sphead->set_definer(trg_definer->str, trg_definer->length);
+ sp->set_definer(trg_definer->str, trg_definer->length);
- if (triggers->names_list.push_back(&lex.sphead->m_name,
- &table->mem_root))
+ if (triggers->names_list.push_back(&sp->m_name, &table->mem_root))
goto err_with_lex_cleanup;
if (!(on_table_name= alloc_lex_string(&table->mem_root)))