MySQL 8.4.0
Source Code Documentation
dd::sdi_utils::Closure_error_handler< CONDITION_HANDLER_CLOS > Class Template Reference

Class template which derives from Internal_error_handler and overrides handle_condition with the CONDITION_HANDLER_CLOS template parameter. More...

#include <sdi_utils.h>

Inheritance diagram for dd::sdi_utils::Closure_error_handler< CONDITION_HANDLER_CLOS >:
[legend]

Public Member Functions

 Closure_error_handler (CONDITION_HANDLER_CLOS &&ch)
 

Private Member Functions

bool handle_condition (THD *, uint sql_errno, const char *sqlstate, Sql_condition::enum_severity_level *level, const char *msg) override
 Handle a sql condition. More...
 

Private Attributes

CONDITION_HANDLER_CLOS m_ch
 

Additional Inherited Members

- Protected Member Functions inherited from Internal_error_handler
 Internal_error_handler ()
 
Internal_error_handlerprev_internal_handler () const
 
virtual ~Internal_error_handler ()=default
 

Detailed Description

template<typename CONDITION_HANDLER_CLOS>
class dd::sdi_utils::Closure_error_handler< CONDITION_HANDLER_CLOS >

Class template which derives from Internal_error_handler and overrides handle_condition with the CONDITION_HANDLER_CLOS template parameter.

Constructor & Destructor Documentation

◆ Closure_error_handler()

template<typename CONDITION_HANDLER_CLOS >
dd::sdi_utils::Closure_error_handler< CONDITION_HANDLER_CLOS >::Closure_error_handler ( CONDITION_HANDLER_CLOS &&  ch)
inlineexplicit

Member Function Documentation

◆ handle_condition()

template<typename CONDITION_HANDLER_CLOS >
bool dd::sdi_utils::Closure_error_handler< CONDITION_HANDLER_CLOS >::handle_condition ( THD thd,
uint  sql_errno,
const char *  sqlstate,
Sql_condition::enum_severity_level level,
const char *  msg 
)
inlineoverrideprivatevirtual

Handle a sql condition.

This method can be implemented by a subclass to achieve any of the following:

  • mask a warning/error internally, prevent exposing it to the user,
  • mask a warning/error and throw another one instead. When this method returns true, the sql condition is considered 'handled', and will not be propagated to upper layers. It is the responsibility of the code installing an internal handler to then check for trapped conditions, and implement logic to recover from the anticipated conditions trapped during runtime.

This mechanism is similar to C++ try/throw/catch:

  • 'try' correspond to THD::push_internal_handler(),
  • 'throw' correspond to my_error(), which invokes my_message_sql(),
  • 'catch' correspond to checking how/if an internal handler was invoked, before removing it from the exception stack with THD::pop_internal_handler().
Parameters
thdthe calling thread
sql_errnothe error number for the condition raised.
sqlstatethe SQLSTATE for the condition raised.
levelthe severity level for the condition raised.
msgthe error message for the condition raised.
Returns
true if the condition is handled

Implements Internal_error_handler.

Member Data Documentation

◆ m_ch

template<typename CONDITION_HANDLER_CLOS >
CONDITION_HANDLER_CLOS dd::sdi_utils::Closure_error_handler< CONDITION_HANDLER_CLOS >::m_ch
private

The documentation for this class was generated from the following file: