MySQL  8.0.17
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 ()
 

Private Attributes

bool m_invalidated
 

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

◆ is_invalidated()

bool Reprepare_observer::is_invalidated ( ) const
inline

◆ 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_invalidated

bool Reprepare_observer::m_invalidated
private

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