summaryrefslogtreecommitdiff
path: root/sql/sql_trigger.cc
diff options
context:
space:
mode:
authorunknown <kostja@vajra.(none)>2007-04-13 16:35:56 -0400
committerunknown <kostja@vajra.(none)>2007-04-13 16:35:56 -0400
commitc1b6e128ccae21cec31bf4f4a60594d0e13a13ea (patch)
tree2e4250999c91bd00cc528ff5cfa90710860bc97f /sql/sql_trigger.cc
parentd4744eb9dda6deb09c6c90c8beb0e0390f7ce568 (diff)
downloadmariadb-git-c1b6e128ccae21cec31bf4f4a60594d0e13a13ea.tar.gz
An attempt to fix a sporadic valgrind memory leak in Event Scheduler:
streamline the event worker thread work flow and try to eliminate possibilities for memory corruptions that might have been lurking in previous (complicated) code. This patch: * removes Event_job_data::compile that was never used * cleans up Event_job_data::execute to minimize juggling with thread context and eliminate unneded code paths * Implements Security_context::change/restore_security_context to be able to re-use these methods in all stored programs This is to maybe fix Bug#27733 "Valgrind failures in remove_table_from_cache". Review comments applied. sql/event_data_objects.cc: Remove Event_job_data::compile, which was never used without Event_job_data::execute(). Merge the implementation of compile() with Event_job_data::execute(). Reuse existing functions to prepare the event worker thread for execution instead of some previously copy-pasted code. Do not change and restore the current database inside Event_job_data::execute(), just set the current database in the thread, that is enough to parse and execute an event. sql/event_data_objects.h: Update declarations. sql/event_scheduler.cc: Allocate Event_job_data on stack. sql/item_func.cc: Update to match the new declaration of restore_security_context() sql/sp_head.cc: Update to match the new declaration of change/restore_security_context() sql/sql_class.cc: Move change/restore_security_context to class Security_context. Add more comments. sql/sql_class.h: Make change/restore_security_context methods of Security_context. That allows us to reuse them in Event Scheduler (instead of a copy-paste presently used there). sql/sql_trigger.cc: Update to match the new declaration of change/restore_security_context()
Diffstat (limited to 'sql/sql_trigger.cc')
-rw-r--r--sql/sql_trigger.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 66132efb8e4..8da1137ff36 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -1543,9 +1543,15 @@ bool Table_triggers_list::process_triggers(THD *thd, trg_event_type event,
old_field= trigger_table->field;
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS
+ Security_context *sctx= &sp_trigger->m_security_ctx;
Security_context *save_ctx;
- if (sp_change_security_context(thd, sp_trigger, &save_ctx))
+
+ if (sctx->change_security_context(thd,
+ &sp_trigger->m_definer_user,
+ &sp_trigger->m_definer_host,
+ &sp_trigger->m_db,
+ &save_ctx))
return TRUE;
/*
@@ -1570,7 +1576,7 @@ bool Table_triggers_list::process_triggers(THD *thd, trg_event_type event,
thd->security_ctx->priv_user, thd->security_ctx->host_or_ip,
trigger_table->s->table_name.str);
- sp_restore_security_context(thd, save_ctx);
+ sctx->restore_security_context(thd, save_ctx);
return TRUE;
}
#endif // NO_EMBEDDED_ACCESS_CHECKS
@@ -1582,7 +1588,7 @@ bool Table_triggers_list::process_triggers(THD *thd, trg_event_type event,
thd->restore_sub_statement_state(&statement_state);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
- sp_restore_security_context(thd, save_ctx);
+ sctx->restore_security_context(thd, save_ctx);
#endif // NO_EMBEDDED_ACCESS_CHECKS
}