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

Method resolve

sql/sql_path.cc:86–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84
85
86bool Sql_path::resolve(THD *thd, sp_head *caller, sp_name *name,
87 const Sp_handler **sph,
88 Database_qualified_name *pkgname) const
89{
90 DBUG_ASSERT(name);
91 DBUG_ASSERT(name->m_name.str[name->m_name.length] == '\0');
92
93 // Check for fully qualified name schema.pkg.routine and exit early
94 if (name->m_explicit_name && strchr(name->m_name.str, '.'))
95 return false;
96
97 DBUG_ASSERT(!name->m_explicit_name || name->m_db.str);
98 if (caller) // first, search in the current package
99 {
100 if (!name->m_explicit_name) // name()
101 {
102 sp_name tmp_name(*name);
103 tmp_name.m_db= caller->m_db;
104 const Sp_handler *pkg_routine_hndlr= nullptr;
105 if ((*sph)->sp_resolve_package_routine_implicit(thd, caller, &tmp_name,
106 &pkg_routine_hndlr,
107 pkgname))
108 return true;
109
110 if (pkg_routine_hndlr)
111 {
112 *sph= pkg_routine_hndlr;
113 *name= tmp_name;
114 return false;
115 }
116 }
117 else // name1.name2()
118 {
119 const Sp_handler *pkg_routine_hndlr= nullptr;
120 if ((*sph)->sp_resolve_package_routine_explicit(thd, caller, name,
121 &pkg_routine_hndlr,
122 pkgname))
123 return true;
124
125 if (pkg_routine_hndlr)
126 {
127 *sph= pkg_routine_hndlr;
128 return false;
129 }
130 }
131 }
132
133 bool resolved= false;
134 for (size_t i= 0; i < m_count; i++)
135 {
136 Lex_ident_db schema;
137 if (is_cur_schema(i))
138 {
139 // If PATH contains only CURRENT_SCHEMA (default), skip PATH resolution
140 // to avoid extra table operations that affect performance
141 if (m_count== 1 && !name->m_explicit_name)
142 {
143 if (!name->m_db.str && thd->db.str)

Callers 3

create_with_dbMethod · 0.45
call_statement_startMethod · 0.45

Calls 2

eq_routine_nameMethod · 0.80
copy_db_normalizedMethod · 0.45

Tested by

no test coverage detected