MySQL 8.0.40
Source Code Documentation
Reprepare_observer Class Referencefinal

An interface that is used to take an action when the locking module notices that a table version has changed since the last execution. More...

#include <sql_prepare.h>

Public Member Functions

bool report_error (THD *thd)
 Check if a change of metadata is OK. More...
 
bool is_invalidated () const
 
void reset_reprepare_observer ()
 
bool can_retry () const
 

Private Attributes

bool m_invalidated {false}
 
int m_attempt {0}
 

Static Private Attributes

static constexpr int MAX_REPREPARE_ATTEMPTS = 3
 

Detailed Description

An interface that is used to take an action when the locking module notices that a table version has changed since the last execution.

"Table" here may refer to any kind of table – a base table, a temporary table, a view or an information schema table.

When we open and lock tables for execution of a prepared statement, we must verify that they did not change since statement prepare. If some table did change, the statement parse tree may be no longer valid, e.g. in case it contains optimizations that depend on table metadata.

This class provides an interface (a method) that is invoked when such a situation takes place. The implementation of the method simply reports an error, but the exact details depend on the nature of the SQL statement.

At most 1 instance of this class is active at a time, in which case THD::m_reprepare_observer is not NULL.

See also
check_and_update_table_version() for details of the version tracking algorithm
Open_tables_state::m_reprepare_observer for the life cycle of metadata observers.

Member Function Documentation

◆ can_retry()

bool Reprepare_observer::can_retry ( ) const
inline
Returns
true if prepared statement can (and will) be retried

◆ is_invalidated()

bool Reprepare_observer::is_invalidated ( ) const
inline
Returns
true if some table metadata is changed and statement should be re-prepared.

◆ report_error()

bool Reprepare_observer::report_error ( THD thd)

Check if a change of metadata is OK.

Push an error to the error stack and return true for now.

In future the signature of this method may be extended to accept the old and the new versions, but since currently the check is very simple, we only need the THD to report an error.

◆ reset_reprepare_observer()

void Reprepare_observer::reset_reprepare_observer ( )
inline

Member Data Documentation

◆ m_attempt

int Reprepare_observer::m_attempt {0}
private

◆ m_invalidated

bool Reprepare_observer::m_invalidated {false}
private

◆ MAX_REPREPARE_ATTEMPTS

constexpr int Reprepare_observer::MAX_REPREPARE_ATTEMPTS = 3
staticconstexprprivate

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