MySQL 8.3.0
Source Code Documentation
Query_builder Class Reference

Class that builds the rewritten query by appending literals in the order they appear in the parse tree. More...

#include <query_builder.h>

Inheritance diagram for Query_builder:
[legend]

Public Member Functions

 Query_builder (const Pattern *pattern, const Replacement *replacement)
 
bool visit (MYSQL_ITEM item) override
 Implementation of the visit() function that bridges to add_next_literal(). More...
 
const std::string & get_built_query ()
 To be called after visit() has been called for all literals in the parse tree that this Query_builder was visiting. More...
 
bool matches () const
 Status of the matching of literals that are not parameter markers. More...
 
- Public Member Functions inherited from services::Literal_visitor
virtual ~Literal_visitor ()=default
 

Private Member Functions

bool add_next_literal (MYSQL_ITEM item)
 Adds a literal, assumed to be the next in the parse tree, from the query's parse tree to this Query_builder. More...
 

Private Attributes

int m_previous_slot
 The index of the character in 'm_replacement' after the last slot that we filled. More...
 
std::string m_replacement
 Query we copy from (replacement string.) More...
 
std::vector< int > m_slots
 The slots in the replacement string. More...
 
std::vector< int >::iterator m_slots_iter
 
std::vector< std::string > m_pattern_literals
 All literals in the pattern, in order of appearance in parse tree. More...
 
std::vector< std::string >::iterator m_pattern_literals_iter
 
std::string m_built_query
 The query under construction. More...
 
bool m_matches_so_far
 Whether the literals in the parse tree match those of the pattern so far. More...
 

Detailed Description

Class that builds the rewritten query by appending literals in the order they appear in the parse tree.

Constructor & Destructor Documentation

◆ Query_builder()

Query_builder::Query_builder ( const Pattern pattern,
const Replacement replacement 
)
inline

Member Function Documentation

◆ add_next_literal()

bool Query_builder::add_next_literal ( MYSQL_ITEM  item)
private

Adds a literal, assumed to be the next in the parse tree, from the query's parse tree to this Query_builder.

Parameters
itemAssumed to be a literal.
Return values
trueThe builder is finished. Either it has been detected that the current literal does not match the pattern, or no more literals are needed to build the query.

◆ get_built_query()

const std::string & Query_builder::get_built_query ( )
inline

To be called after visit() has been called for all literals in the parse tree that this Query_builder was visiting.

This function finishes the string to yield a complete query.

◆ matches()

bool Query_builder::matches ( ) const
inline

Status of the matching of literals that are not parameter markers.

Return values
trueThe parse tree matches the pattern and it is safe to continue adding literals.
falseSome literal has been found to differ between parse tree and pattern. Execution must end immediately.

◆ visit()

bool Query_builder::visit ( MYSQL_ITEM  item)
inlineoverridevirtual

Implementation of the visit() function that bridges to add_next_literal().

Parameters
itemThe current literal.

Implements services::Literal_visitor.

Member Data Documentation

◆ m_built_query

std::string Query_builder::m_built_query
private

The query under construction.

◆ m_matches_so_far

bool Query_builder::m_matches_so_far
private

Whether the literals in the parse tree match those of the pattern so far.

◆ m_pattern_literals

std::vector<std::string> Query_builder::m_pattern_literals
private

All literals in the pattern, in order of appearance in parse tree.

◆ m_pattern_literals_iter

std::vector<std::string>::iterator Query_builder::m_pattern_literals_iter
private

◆ m_previous_slot

int Query_builder::m_previous_slot
private

The index of the character in 'm_replacement' after the last slot that we filled.

◆ m_replacement

std::string Query_builder::m_replacement
private

Query we copy from (replacement string.)

◆ m_slots

std::vector<int> Query_builder::m_slots
private

The slots in the replacement string.

◆ m_slots_iter

std::vector<int>::iterator Query_builder::m_slots_iter
private

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