mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Backport of:
------------------------------------------------------------ revno: 2617.68.24 committer: Dmitry Lenev <dlenev@mysql.com> branch nick: mysql-next-bg-pre2-2 timestamp: Wed 2009-09-16 17:25:29 +0400 message: Pre-requisite patch for fixing bug #30977 "Concurrent statement using stored function and DROP FUNCTION breaks SBR". Added MDL_request for stored routine as member to Sroutine_hash_entry in order to be able perform metadata locking for stored routines in future (Sroutine_hash_entry is an equivalent of TABLE_LIST class for stored routines). (WL#4284, follow up fixes). sql/mdl.cc: Introduced version of MDL_request::init() method which initializes lock request using pre-built MDL key. MDL_key::table_name/table_name_length() getters were renamed to reflect the fact that MDL_key objects are now created not only for tables. sql/mdl.h: Extended enum_mdl_namespace enum with values which correspond to namespaces for stored functions and triggers. Renamed MDL_key::table_name/table_name_length() getters to MDL_key::name() and name_length() correspondingly to reflect the fact that MDL_key objects are now created not only for tables. Added MDL_key::mdl_namespace() getter. Also added version of MDL_request::init() method which initializes lock request using pre-built MDL key. sql/sp.cc: Added MDL_request for stored routine as member to Sroutine_hash_entry. Changed code to use MDL_key from this request as a key for LEX::sroutines set. Removed separate "key" member from Sroutine_hash_entry as it became unnecessary. sql/sp.h: Added MDL_request for stored routine as member to Sroutine_hash_entry in order to be able perform metadata locking for stored routines in future (Sroutine_hash_entry is an equivalent of TABLE_LIST class for stored routines). Removed Sroutine_hash_entry::key member as now we can use MDL_key from this request as a key for LEX::sroutines set. sql/sp_head.cc: Removed sp_name::m_sroutines_key member and set_routine_type() method. Since key for routine in LEX::sroutines set has no longer sp_name::m_qname as suffix we won't save anything by creating it at sp_name construction time. Adjusted sp_name constructor used for creating temporary objects for lookups in SP-cache to accept MDL_key as parameter and to avoid any memory allocation. Finally, removed sp_head::m_soutines_key member for reasons similar to why sp_name::m_sroutines_key was removed sql/sp_head.h: Removed sp_name::m_sroutines_key member and set_routine_type() method. Since key for routine in LEX::sroutines set has no longer sp_name::m_qname as suffix we won't save anything by creating it at sp_name construction time. Adjusted sp_name constructor used for creating temporary objects for lookups in SP-cache to accept MDL_key as parameter and to avoid any memory allocation. Finally, removed sp_head::m_soutines_key member for reasons similar to why sp_name::m_sroutines_key was removed. sql/sql_base.cc: Adjusted code to the fact that we now use MDL_key from Sroutine_hash_entry::mdl_request as a key for LEX::sroutines set. MDL_key::table_name/table_name_length() getters were renamed to reflect the fact that MDL_key objects are now created not only for tables. sql/sql_trigger.cc: sp_add_used_routine() now takes MDL_key as parameter as now we use instance of this class as a key for LEX::sroutines set.
This commit is contained in:
@@ -2055,17 +2055,21 @@ add_tables_and_routines_for_triggers(THD *thd,
|
||||
/* We can have only one trigger per action type currently */
|
||||
sp_head *trigger= table_list->table->triggers->bodies[i][j];
|
||||
|
||||
if (trigger && sp_add_used_routine(prelocking_ctx, thd->stmt_arena,
|
||||
&trigger->m_sroutines_key,
|
||||
table_list->belong_to_view))
|
||||
if (trigger)
|
||||
{
|
||||
trigger->add_used_tables_to_table_list(thd,
|
||||
&prelocking_ctx->query_tables_last,
|
||||
table_list->belong_to_view);
|
||||
sp_update_stmt_used_routines(thd, prelocking_ctx,
|
||||
&trigger->m_sroutines,
|
||||
table_list->belong_to_view);
|
||||
trigger->propagate_attributes(prelocking_ctx);
|
||||
MDL_key key(MDL_TRIGGER, trigger->m_db.str, trigger->m_name.str);
|
||||
|
||||
if (sp_add_used_routine(prelocking_ctx, thd->stmt_arena,
|
||||
&key, table_list->belong_to_view))
|
||||
{
|
||||
trigger->add_used_tables_to_table_list(thd,
|
||||
&prelocking_ctx->query_tables_last,
|
||||
table_list->belong_to_view);
|
||||
sp_update_stmt_used_routines(thd, prelocking_ctx,
|
||||
&trigger->m_sroutines,
|
||||
table_list->belong_to_view);
|
||||
trigger->propagate_attributes(prelocking_ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user