MySQL 8.0.39
Source Code Documentation
Rule Class Reference

Internal representation of a rewrite rule. More...

#include <rule.h>

Public Types

enum  Load_status {
  OK , PATTERN_PARSE_ERROR , PATTERN_NOT_SUPPORTED_STATEMENT , PATTERN_GOT_NO_DIGEST ,
  REPLACEMENT_PARSE_ERROR , REPLACEMENT_HAS_MORE_MARKERS
}
 

Public Member Functions

const uchardigest_buffer () const
 The digest buffer. More...
 
std::string normalized_pattern ()
 The pattern in normalized form. More...
 
Load_status load (MYSQL_THD thd, const Persisted_rule *diskrule)
 Loads and parses the rule and replacement. More...
 
Rewrite_result create_new_query (MYSQL_THD thd)
 Applies the rule on a query, thereby creating a new one. More...
 
bool matches (MYSQL_THD thd) const
 Asks the parser service for the current query in normalized form and compares it to the normalized pattern. More...
 
std::string pattern_parse_error_message ()
 
std::string replacement_parse_error_message ()
 

Private Attributes

Pattern m_pattern
 
Replacement m_replacement
 

Detailed Description

Internal representation of a rewrite rule.

A rewrite rule consists of a pattern and a replacement.

Member Enumeration Documentation

◆ Load_status

Enumerator
OK 
PATTERN_PARSE_ERROR 
PATTERN_NOT_SUPPORTED_STATEMENT 
PATTERN_GOT_NO_DIGEST 
REPLACEMENT_PARSE_ERROR 
REPLACEMENT_HAS_MORE_MARKERS 

Member Function Documentation

◆ create_new_query()

Rewrite_result Rule::create_new_query ( MYSQL_THD  thd)

Applies the rule on a query, thereby creating a new one.

This is done by merging the replacement and literals from the query.

Parameters
thdPointer to the query string.
Return values
falseEverything worked, the new query is pointed to by 'query'.
trueThe query did not match the pattern, nothing is allocated.

◆ digest_buffer()

const uchar * Rule::digest_buffer ( ) const
inline

The digest buffer.

◆ load()

Load_status Rule::load ( MYSQL_THD  thd,
const Persisted_rule diskrule 
)
inline

Loads and parses the rule and replacement.

◆ matches()

bool Rule::matches ( MYSQL_THD  thd) const

Asks the parser service for the current query in normalized form and compares it to the normalized pattern.

This is the equivalent of comparing the structure of two parse trees.

Returns
True if the normalized pattern matches the current normalized query, otherwise false.

◆ normalized_pattern()

std::string Rule::normalized_pattern ( )
inline

The pattern in normalized form.

◆ pattern_parse_error_message()

std::string Rule::pattern_parse_error_message ( )
inline

◆ replacement_parse_error_message()

std::string Rule::replacement_parse_error_message ( )
inline

Member Data Documentation

◆ m_pattern

Pattern Rule::m_pattern
private

◆ m_replacement

Replacement Rule::m_replacement
private

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