MySQL 9.1.0
Source Code Documentation
Rewriter Class Reference

Implementation of the post parse query rewriter. More...

#include <rewriter.h>

Public Member Functions

 Rewriter ()
 
int get_number_loaded_rules () const
 The number of rules currently loaded in the hash table. More...
 
 ~Rewriter ()
 
Rewrite_result rewrite_query (MYSQL_THD thd, const uchar *key)
 Attempts to rewrite thd's current query with digest in 'key'. More...
 
longlong refresh (MYSQL_THD thd)
 Empty the hashtable and reload all rules from disk table. More...
 
void do_refresh (MYSQL_THD session_thd)
 Implementation of the loading procedure. More...
 

Private Member Functions

bool load_rule (MYSQL_THD thd, Persisted_rule *diskrule)
 Loads the rule retrieved from the database in the hash table. More...
 

Private Attributes

longlong m_refresh_status
 
malloc_unordered_multimap< std::string, std::unique_ptr< Rule > > m_digests
 The in-memory rules hash table. More...
 

Detailed Description

Implementation of the post parse query rewriter.

The public interface consists of two operations: refresh(), which loads the rules from the disk table, and rewrite_query(), which rewrites a query if applicable.

Constructor & Destructor Documentation

◆ Rewriter()

Rewriter::Rewriter ( )
default

◆ ~Rewriter()

Rewriter::~Rewriter ( )
default

Member Function Documentation

◆ do_refresh()

void Rewriter::do_refresh ( MYSQL_THD  session_thd)

Implementation of the loading procedure.

The server doesn't handle different sessions in the same thread, so we load the rules into the hash table in this function, intended to be run in a new thread. The main thread will do join().

Parameters
session_thdThe session to be used for loading rules.

◆ get_number_loaded_rules()

int Rewriter::get_number_loaded_rules ( ) const
inline

The number of rules currently loaded in the hash table.

In case of rules that fail to load, this number will be lower than the number of rows in the database.

◆ load_rule()

bool Rewriter::load_rule ( MYSQL_THD  thd,
Persisted_rule diskrule 
)
private

Loads the rule retrieved from the database in the hash table.

◆ refresh()

longlong Rewriter::refresh ( MYSQL_THD  thd)

Empty the hashtable and reload all rules from disk table.

◆ rewrite_query()

Rewrite_result Rewriter::rewrite_query ( MYSQL_THD  thd,
const uchar key 
)

Attempts to rewrite thd's current query with digest in 'key'.

Returns
A Rewrite_result object.

Member Data Documentation

◆ m_digests

malloc_unordered_multimap<std::string, std::unique_ptr<Rule> > Rewriter::m_digests
private
Initial value:
{
static constexpr unsigned PSI_INSTRUMENT_ME
Definition: psi_bits.h:43

The in-memory rules hash table.

◆ m_refresh_status

longlong Rewriter::m_refresh_status
private

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