MySQL 8.4.3
Source Code Documentation
Functional_index_error_handler Class Reference

The purpose of this error handler is to print out more user friendly error messages when an error regarding a functional index happens. More...

#include <error_handler.h>

Inheritance diagram for Functional_index_error_handler:
[legend]

Public Member Functions

 Functional_index_error_handler (const Field *field, THD *thd)
 
 Functional_index_error_handler (Create_field *field, const std::string &functional_index_name, THD *thd)
 
 Functional_index_error_handler (const std::string &functional_index_name, THD *thd)
 
bool handle_condition (THD *thd, uint sql_errno, const char *, Sql_condition::enum_severity_level *level, const char *message) override
 Handle a sql condition. More...
 
 ~Functional_index_error_handler () override
 
void force_error_code (int error_code)
 

Private Attributes

std::string m_functional_index_name
 
THDm_thd
 
bool m_pop_error_handler
 
int m_force_error_code
 

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

The purpose of this error handler is to print out more user friendly error messages when an error regarding a functional index happens.

Since functional indexes are implemented as hidden generated columns with an auto-generated name, we would end up printing errors like "Out of range value for column '912ec803b2ce49e4a541068d495ab570' at row 0". With this error handler, we end up printing something like "Out of range value for functional index 'functional_index_2' at row 0" instead.

The handler keeps track of the previous error handler that was in use, and calls that error handler to get the correct severity among other things.

Constructor & Destructor Documentation

◆ Functional_index_error_handler() [1/3]

Functional_index_error_handler::Functional_index_error_handler ( const Field field,
THD thd 
)

◆ Functional_index_error_handler() [2/3]

Functional_index_error_handler::Functional_index_error_handler ( Create_field field,
const std::string &  functional_index_name,
THD thd 
)

◆ Functional_index_error_handler() [3/3]

Functional_index_error_handler::Functional_index_error_handler ( const std::string &  functional_index_name,
THD thd 
)

◆ ~Functional_index_error_handler()

Functional_index_error_handler::~Functional_index_error_handler ( )
override

Member Function Documentation

◆ force_error_code()

void Functional_index_error_handler::force_error_code ( int  error_code)
inline

◆ handle_condition()

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

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_force_error_code

int Functional_index_error_handler::m_force_error_code
private

◆ m_functional_index_name

std::string Functional_index_error_handler::m_functional_index_name
private

◆ m_pop_error_handler

bool Functional_index_error_handler::m_pop_error_handler
private

◆ m_thd

THD* Functional_index_error_handler::m_thd
private

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