MCPcopy Create free account
hub / github.com/MariaDB/server / open_and_process_routine

Function open_and_process_routine

sql/sql_base.cc:3886–4017  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3884*/
3885
3886static bool
3887open_and_process_routine(THD *thd, Query_tables_list *prelocking_ctx,
3888 Sroutine_hash_entry *rt,
3889 Prelocking_strategy *prelocking_strategy,
3890 bool has_prelocking_list,
3891 Open_table_context *ot_ctx,
3892 bool *need_prelocking, bool *routine_modifies_data)
3893{
3894 MDL_key::enum_mdl_namespace mdl_type= rt->mdl_request.key.mdl_namespace();
3895 DBUG_ENTER("open_and_process_routine");
3896
3897 *routine_modifies_data= false;
3898
3899 switch (mdl_type)
3900 {
3901 case MDL_key::PACKAGE_BODY:
3902 DBUG_ASSERT(rt != prelocking_ctx->sroutines_list.first);
3903 /*
3904 No need to cache the package body itself.
3905 It gets cached during open_and_process_routine()
3906 for the first used package routine. See the package related code
3907 in the "case" below.
3908 */
3909 if (sp_acquire_mdl(thd, rt, ot_ctx))
3910 DBUG_RETURN(TRUE);
3911 break;
3912 case MDL_key::FUNCTION:
3913 case MDL_key::PROCEDURE:
3914 {
3915 sp_head *sp;
3916 /*
3917 Try to get MDL lock on the routine.
3918 Note that we do not take locks on top-level CALLs as this can
3919 lead to a deadlock. Not locking top-level CALLs does not break
3920 the binlog as only the statements in the called procedure show
3921 up there, not the CALL itself.
3922 */
3923 if (rt != prelocking_ctx->sroutines_list.first ||
3924 mdl_type != MDL_key::PROCEDURE)
3925 {
3926 /*
3927 TODO: If this is a package routine, we should not put MDL
3928 TODO: on the routine itself. We should put only the package MDL.
3929 */
3930 if (sp_acquire_mdl(thd, rt, ot_ctx))
3931 DBUG_RETURN(TRUE);
3932
3933 /* Ensures the routine is up-to-date and cached, if exists. */
3934 if (rt->sp_cache_routine(thd, &sp))
3935 DBUG_RETURN(TRUE);
3936
3937 /* Remember the version of the routine in the parse tree. */
3938 if (check_and_update_routine_version(thd, rt, sp))
3939 DBUG_RETURN(TRUE);
3940
3941 /* 'sp' is NULL when there is no such routine. */
3942 if (sp)
3943 {

Callers 1

open_tablesFunction · 0.85

Calls 6

sp_acquire_mdlFunction · 0.85
mdl_namespaceMethod · 0.80
modifies_dataMethod · 0.80
sp_cache_routineMethod · 0.45
handle_routineMethod · 0.45

Tested by

no test coverage detected