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

Method handle_sql_condition

sql/sp_rcontext.cc:516–648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514
515
516bool sp_rcontext::handle_sql_condition(THD *thd,
517 uint *ip,
518 const sp_instr *cur_spi)
519{
520 DBUG_ENTER("sp_rcontext::handle_sql_condition");
521
522 /*
523 If this is a fatal sub-statement error, and this runtime
524 context corresponds to a sub-statement, no CONTINUE/EXIT
525 handlers from this context are applicable: try to locate one
526 in the outer scope.
527 */
528 if (unlikely(thd->is_fatal_sub_stmt_error) && m_in_sub_stmt)
529 DBUG_RETURN(false);
530
531 Diagnostics_area *da= thd->get_stmt_da();
532 const sp_handler *found_handler= NULL;
533 const Sql_condition *found_condition= NULL;
534
535 if (unlikely(thd->is_error()))
536 {
537 found_handler=
538 cur_spi->m_ctx->find_handler(da->get_error_condition_identity());
539
540 if (found_handler)
541 found_condition= da->get_error_condition();
542
543 /*
544 Found condition can be NULL if the diagnostics area was full
545 when the error was raised. It can also be NULL if
546 Diagnostics_area::set_error_status(uint sql_error) was used.
547 In these cases, make a temporary Sql_condition here so the
548 error can be handled.
549 */
550 if (!found_condition)
551 {
552 found_condition=
553 new (callers_arena->mem_root) Sql_condition(callers_arena->mem_root,
554 da->get_error_condition_identity(),
555 da->message(),
556 da->current_row_for_warning());
557 }
558 }
559 else if (da->current_statement_warn_count())
560 {
561 Diagnostics_area::Sql_condition_iterator it= da->sql_conditions();
562 const Sql_condition *c;
563
564 // Here we need to find the last warning/note from the stack.
565 // In MySQL most substantial warning is the last one.
566 // (We could have used a reverse iterator here if one existed)
567
568 while ((c= it++))
569 {
570 if (c->get_level() == Sql_condition::WARN_LEVEL_WARN ||
571 c->get_level() == Sql_condition::WARN_LEVEL_NOTE)
572 {
573 const sp_handler *handler= cur_spi->m_ctx->find_handler(*c);

Callers 1

executeMethod · 0.80

Calls 15

get_stmt_daMethod · 0.80
sql_conditionsMethod · 0.80
get_levelMethod · 0.80
get_handlerMethod · 0.80
reset_killedMethod · 0.80
is_errorMethod · 0.45
find_handlerMethod · 0.45
get_error_conditionMethod · 0.45
messageMethod · 0.45

Tested by

no test coverage detected