MySQL  8.0.27
Source Code Documentation
Plugin_error_handler Class Reference

This class implements the framework needed for the callback function that handles conditions that may arise during parsing via the parser service. More...

Inheritance diagram for Plugin_error_handler:
Internal_error_handler

Public Member Functions

 Plugin_error_handler (THD *thd, sql_condition_handler_function handle_error, void *state)
 
bool handle_condition (THD *, uint sql_errno_u, const char *sqlstate, Sql_condition::enum_severity_level *, const char *msg) override
 Handle a sql condition. More...
 
const char * get_message ()
 
 ~Plugin_error_handler () override
 

Private Attributes

THDm_thd
 
const char * m_message
 
const sql_condition_handler_function m_handle_error
 
void * m_state
 

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

This class implements the framework needed for the callback function that handles conditions that may arise during parsing via the parser service.

See also
mysql_parser_visit_tree

Constructor & Destructor Documentation

◆ Plugin_error_handler()

Plugin_error_handler::Plugin_error_handler ( THD thd,
sql_condition_handler_function  handle_error,
void *  state 
)
inline

◆ ~Plugin_error_handler()

Plugin_error_handler::~Plugin_error_handler ( )
inlineoverride

Member Function Documentation

◆ get_message()

const char* Plugin_error_handler::get_message ( )
inline

◆ handle_condition()

bool Plugin_error_handler::handle_condition ( THD thd,
uint  sql_errno,
const char *  sqlstate,
Sql_condition::enum_severity_level level,
const char *  msg 
)
inlineoverridevirtual

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_handle_error

const sql_condition_handler_function Plugin_error_handler::m_handle_error
private

◆ m_message

const char* Plugin_error_handler::m_message
private

◆ m_state

void* Plugin_error_handler::m_state
private

◆ m_thd

THD* Plugin_error_handler::m_thd
private

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