MySQL 9.0.0
Source Code Documentation
Diagnostics_area_handler_raii Class Reference

RAII class to manage the diagnostics area for the statement handler. More...

Public Member Functions

 Diagnostics_area_handler_raii (THD *thd, bool reset_cond_info=false)
 
 ~Diagnostics_area_handler_raii ()
 

Private Attributes

THDm_thd
 
Diagnostics_area m_stmt_da
 

Detailed Description

RAII class to manage the diagnostics area for the statement handler.

This class mainly manages diagnostics area(DA) for a statement execution (say STMT2) when an error has already occurred (say for STMT1) and not reported to a user yet. Error state from STMT1 is stored in the DA associated with THD. This class maintains the error state from STMT1 in DA by using temporary diagnostics area for the STMT2's execution.

In the destructor, if STMT2 execution is successful then temporary diagnostics are is just popped and error from STMT1 is reported to the user. But if STMT2 execution fails, then error from STMT1 is cleared and error from STMT2 is reported to the user.

If DA is clear when instance of this class instatiated then caller's DA used for statement execution.

Please note that Statement_handle::copy_warnings() must be invoked after an instance of this class is destructed to copy warnings after statement execution.

TODO: Executing a SQL statement when an error has already occurred can primarily happen from error handlers of external routines. The best place to manage DA for it is within the component supporting external routines. Once we have improved DA handling for components, this logic should be moved to the component.

Constructor & Destructor Documentation

◆ Diagnostics_area_handler_raii()

Diagnostics_area_handler_raii::Diagnostics_area_handler_raii ( THD thd,
bool  reset_cond_info = false 
)
inline

◆ ~Diagnostics_area_handler_raii()

Diagnostics_area_handler_raii::~Diagnostics_area_handler_raii ( )
inline

Member Data Documentation

◆ m_stmt_da

Diagnostics_area Diagnostics_area_handler_raii::m_stmt_da
private

◆ m_thd

THD* Diagnostics_area_handler_raii::m_thd
private

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