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

Method check_dependencies

sql/sql_cte.cc:299–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297*/
298
299bool With_clause::check_dependencies()
300{
301 if (dependencies_are_checked)
302 return false;
303 /*
304 Look for for definitions with the same query name.
305 When found report an error and return true immediately.
306 For each table T defined in this with clause look for all other tables
307 from the same with clause that are used in the specification of T.
308 For each such table set the dependency bit in the dependency map of
309 the with element for T.
310 */
311 for (With_element *with_elem= with_list.first;
312 with_elem;
313 with_elem= with_elem->next)
314 {
315 for (With_element *elem= with_list.first;
316 elem != with_elem;
317 elem= elem->next)
318 {
319 if (with_elem->get_name().streq(elem->get_name()))
320 {
321 my_error(ER_DUP_QUERY_NAME, MYF(0),
322 with_elem->get_name_str());
323 return true;
324 }
325 }
326 if (with_elem->check_dependencies_in_spec())
327 return true;
328 }
329 /* Build the transitive closure of the direct dependencies found above */
330 for (With_element *with_elem= with_list.first;
331 with_elem;
332 with_elem= with_elem->next)
333 with_elem->derived_dep_map= with_elem->base_dep_map;
334 for (With_element *with_elem= with_list.first;
335 with_elem;
336 with_elem= with_elem->next)
337 {
338 table_map with_elem_map= with_elem->get_elem_map();
339 for (With_element *elem= with_list.first; elem; elem= elem->next)
340 {
341 if (elem->derived_dep_map & with_elem_map)
342 elem->derived_dep_map |= with_elem->derived_dep_map;
343 }
344 }
345
346 /*
347 Mark those elements where tables are defined with direct or indirect
348 recursion.
349 */
350 for (With_element *with_elem= with_list.first;
351 with_elem;
352 with_elem= with_elem->next)
353 {
354 if (with_elem->derived_dep_map & with_elem->get_elem_map())
355 with_elem->is_recursive= true;
356 }

Calls 6

my_errorFunction · 0.85
get_name_strMethod · 0.80
get_elem_mapMethod · 0.80
streqMethod · 0.45
get_nameMethod · 0.45

Tested by

no test coverage detected