MySQL 8.4.3
Source Code Documentation
Rpl_filter Class Reference

Rpl_filter. More...

#include <rpl_filter.h>

Inheritance diagram for Rpl_filter:
[legend]

Public Types

typedef int(Rpl_filter::* Add_filter) (char const *)
 

Public Member Functions

 Rpl_filter ()
 
virtual ~Rpl_filter ()
 
 Rpl_filter (Rpl_filter const &)
 
Rpl_filteroperator= (Rpl_filter const &)
 
bool tables_ok (const char *db, Table_ref *tables)
 
bool db_ok (const char *db, bool need_increase_counter=true)
 
bool db_ok_with_wild_table (const char *db)
 
bool is_on ()
 
bool is_empty ()
 Check if the replication filter is empty or not. More...
 
int copy_global_replication_filters ()
 Copy global replication filters to its per-channel replication filters if there are no per-channel replication filters and there are global filters on the filter type on channel creation. More...
 
bool is_rewrite_empty ()
 
int build_do_table_hash ()
 
int build_ignore_table_hash ()
 
int add_string_list (I_List< i_string > *list, const char *spec)
 
int add_string_pair_list (I_List< i_string_pair > *list, const char *key, const char *val)
 
int add_do_table_array (const char *table_spec)
 
int add_ignore_table_array (const char *table_spec)
 
int add_wild_do_table (const char *table_spec)
 
int add_wild_ignore_table (const char *table_spec)
 
int set_do_db (mem_root_deque< Item * > *list, enum_configured_by configured_by)
 
int set_ignore_db (mem_root_deque< Item * > *list, enum_configured_by configured_by)
 
int set_do_table (mem_root_deque< Item * > *list, enum_configured_by configured_by)
 
int set_ignore_table (mem_root_deque< Item * > *list, enum_configured_by configured_by)
 
int set_wild_do_table (mem_root_deque< Item * > *list, enum_configured_by configured_by)
 
int set_wild_ignore_table (mem_root_deque< Item * > *list, enum_configured_by configured_by)
 
int set_db_rewrite (mem_root_deque< Item * > *list, enum_configured_by configured_by)
 
int parse_filter_list (mem_root_deque< Item * > *item_list, Add_filter func)
 
int parse_filter_list (I_List< i_string > *list, Add_filter add)
 Execute the specified func with elements of the list as input. More...
 
int add_do_db (const char *db_spec)
 
int add_ignore_db (const char *db_spec)
 
int add_db_rewrite (const char *from_db, const char *to_db)
 
void get_do_table (String *str)
 
void get_ignore_table (String *str)
 
void get_wild_do_table (String *str)
 
void get_wild_ignore_table (String *str)
 
const char * get_rewrite_db (const char *db, size_t *new_len)
 
void get_rewrite_db (String *str)
 
I_List< i_string > * get_do_db ()
 
void get_do_db (String *str)
 
I_List< i_string > * get_ignore_db ()
 
void get_ignore_db (String *str)
 
Rpl_filter_statisticsget_rewrite_db_statistics ()
 
void free_string_list (I_List< i_string > *l)
 
void free_string_pair_list (I_List< i_string_pair > *l)
 
void put_filters_into_vector (std::vector< Rpl_pfs_filter > &rpl_pfs_filter_vec, const char *channel_name)
 Put replication filters with attached channel name into a vector. More...
 
void wrlock ()
 Acquire the write lock. More...
 
void rdlock ()
 Acquire the read lock. More...
 
void unlock ()
 Release the lock (whether it is a write or read lock). More...
 
void assert_some_wrlock ()
 Assert that some thread holds the write lock. More...
 
void assert_some_rdlock ()
 Assert that some thread holds the read lock. More...
 
bool is_attached ()
 Check if the relation between the per-channel filter and the channel's Relay_log_info is established. More...
 
void set_attached ()
 Set attached to true when the relation between the per-channel filter and the channel's Relay_log_info is established. More...
 
void reset ()
 

Public Attributes

Rpl_filter_statistics do_table_statistics
 
Rpl_filter_statistics ignore_table_statistics
 
Rpl_filter_statistics wild_do_table_statistics
 
Rpl_filter_statistics wild_ignore_table_statistics
 
Rpl_filter_statistics do_db_statistics
 
Rpl_filter_statistics ignore_db_statistics
 
Rpl_filter_statistics rewrite_db_statistics
 

Private Types

typedef Prealloced_array< TABLE_RULE_ENT *, 16 > Table_rule_array
 
typedef collation_unordered_map< std::string, unique_ptr_my_free< TABLE_RULE_ENT > > Table_rule_hash
 

Private Member Functions

void init_table_rule_hash (Table_rule_hash **h, bool *h_inited)
 
void init_table_rule_array (Table_rule_array *, bool *a_inited)
 
int add_table_rule_to_array (Table_rule_array *a, const char *table_spec)
 
int add_table_rule_to_hash (Table_rule_hash *h, const char *table_spec, uint len)
 Added one table rule to hash. More...
 
void free_string_array (Table_rule_array *a)
 
void table_rule_ent_hash_to_str (String *s, Table_rule_hash *h, bool inited)
 
int table_rule_ent_hash_to_array (Table_rule_array *table_array, Table_rule_hash *h, bool inited)
 Builds a Table_rule_array from a hash of TABLE_RULE_ENT. More...
 
int table_rule_ent_array_to_array (Table_rule_array *dest_array, Table_rule_array *source_array, bool inited)
 Builds a destination Table_rule_array from a source Table_rule_array of TABLE_RULE_ENT. More...
 
void table_rule_ent_dynamic_array_to_str (String *s, Table_rule_array *a, bool inited)
 
TABLE_RULE_ENTfind_wild (Table_rule_array *a, const char *key, size_t len)
 
int build_table_hash_from_array (Table_rule_array *table_array, Table_rule_hash **table_hash, bool array_inited, bool *hash_inited)
 Table rules are initially added to DYNAMIC_LIST, and then, when the charset to use for tables has been established, inserted into a hash for faster filter checking. More...
 

Private Attributes

bool table_rules_on
 
bool attached
 
Checkable_rwlockm_rpl_filter_lock
 
Table_rule_hashdo_table_hash {nullptr}
 
Table_rule_hashignore_table_hash {nullptr}
 
Table_rule_array do_table_array
 
Table_rule_array ignore_table_array
 
Table_rule_array wild_do_table
 
Table_rule_array wild_ignore_table
 
bool do_table_hash_inited
 
bool ignore_table_hash_inited
 
bool do_table_array_inited
 
bool ignore_table_array_inited
 
bool wild_do_table_inited
 
bool wild_ignore_table_inited
 
I_List< i_stringdo_db
 
I_List< i_stringignore_db
 
I_List< i_string_pairrewrite_db
 

Detailed Description

Rpl_filter.

Inclusion and exclusion rules of tables and databases. Also handles rewrites of db. Used for replication and binlogging.

  • Instances of this class are created in Rpl_channel_filters for replication filter for each channel. Each instance is created when the channel is configured, destroyed when the channel is removed.
  • There is one instance, binlog_filter, created for binlog filter. The instance is created when the server is started, destroyed when the server is stopped.

Member Typedef Documentation

◆ Add_filter

typedef int(Rpl_filter::* Rpl_filter::Add_filter) (char const *)

◆ Table_rule_array

◆ Table_rule_hash

Constructor & Destructor Documentation

◆ Rpl_filter() [1/2]

Rpl_filter::Rpl_filter ( )

◆ ~Rpl_filter()

Rpl_filter::~Rpl_filter ( )
virtual

◆ Rpl_filter() [2/2]

Rpl_filter::Rpl_filter ( Rpl_filter const &  )

Member Function Documentation

◆ add_db_rewrite()

int Rpl_filter::add_db_rewrite ( const char *  from_db,
const char *  to_db 
)

◆ add_do_db()

int Rpl_filter::add_do_db ( const char *  db_spec)

◆ add_do_table_array()

int Rpl_filter::add_do_table_array ( const char *  table_spec)

◆ add_ignore_db()

int Rpl_filter::add_ignore_db ( const char *  db_spec)

◆ add_ignore_table_array()

int Rpl_filter::add_ignore_table_array ( const char *  table_spec)

◆ add_string_list()

int Rpl_filter::add_string_list ( I_List< i_string > *  list,
const char *  spec 
)

◆ add_string_pair_list()

int Rpl_filter::add_string_pair_list ( I_List< i_string_pair > *  list,
const char *  key,
const char *  val 
)

◆ add_table_rule_to_array()

int Rpl_filter::add_table_rule_to_array ( Table_rule_array a,
const char *  table_spec 
)
private

◆ add_table_rule_to_hash()

int Rpl_filter::add_table_rule_to_hash ( Table_rule_hash h,
const char *  table_spec,
uint  len 
)
private

Added one table rule to hash.

Parameters
[in]hhash for storing table rules
[in]table_specTable name with db
[in]lenThe length of table_spec
Returns
0 ok 1 error

◆ add_wild_do_table()

int Rpl_filter::add_wild_do_table ( const char *  table_spec)

◆ add_wild_ignore_table()

int Rpl_filter::add_wild_ignore_table ( const char *  table_spec)

◆ assert_some_rdlock()

void Rpl_filter::assert_some_rdlock ( )
inline

Assert that some thread holds the read lock.

◆ assert_some_wrlock()

void Rpl_filter::assert_some_wrlock ( )
inline

Assert that some thread holds the write lock.

◆ build_do_table_hash()

int Rpl_filter::build_do_table_hash ( )

◆ build_ignore_table_hash()

int Rpl_filter::build_ignore_table_hash ( )

◆ build_table_hash_from_array()

int Rpl_filter::build_table_hash_from_array ( Table_rule_array table_array,
Table_rule_hash **  table_hash,
bool  array_inited,
bool *  hash_inited 
)
private

Table rules are initially added to DYNAMIC_LIST, and then, when the charset to use for tables has been established, inserted into a hash for faster filter checking.

Parameters
[in]table_arraydynamic array stored table rules
[in]table_hashhash for storing table rules
[in]array_initedTable rules are added to dynamic array
[in]hash_initedTable rules are added to hash
Returns
0 ok 1 error

◆ copy_global_replication_filters()

int Rpl_filter::copy_global_replication_filters ( )

Copy global replication filters to its per-channel replication filters if there are no per-channel replication filters and there are global filters on the filter type on channel creation.

Return values
0OK
1Error

◆ db_ok()

bool Rpl_filter::db_ok ( const char *  db,
bool  need_increase_counter = true 
)

◆ db_ok_with_wild_table()

bool Rpl_filter::db_ok_with_wild_table ( const char *  db)

◆ find_wild()

TABLE_RULE_ENT * Rpl_filter::find_wild ( Table_rule_array a,
const char *  key,
size_t  len 
)
private

◆ free_string_array()

void Rpl_filter::free_string_array ( Table_rule_array a)
private

◆ free_string_list()

void Rpl_filter::free_string_list ( I_List< i_string > *  l)

◆ free_string_pair_list()

void Rpl_filter::free_string_pair_list ( I_List< i_string_pair > *  l)

◆ get_do_db() [1/2]

I_List< i_string > * Rpl_filter::get_do_db ( )

◆ get_do_db() [2/2]

void Rpl_filter::get_do_db ( String str)

◆ get_do_table()

void Rpl_filter::get_do_table ( String str)

◆ get_ignore_db() [1/2]

I_List< i_string > * Rpl_filter::get_ignore_db ( )

◆ get_ignore_db() [2/2]

void Rpl_filter::get_ignore_db ( String str)

◆ get_ignore_table()

void Rpl_filter::get_ignore_table ( String str)

◆ get_rewrite_db() [1/2]

const char * Rpl_filter::get_rewrite_db ( const char *  db,
size_t *  new_len 
)

◆ get_rewrite_db() [2/2]

void Rpl_filter::get_rewrite_db ( String str)

◆ get_rewrite_db_statistics()

Rpl_filter_statistics * Rpl_filter::get_rewrite_db_statistics ( )
inline

◆ get_wild_do_table()

void Rpl_filter::get_wild_do_table ( String str)

◆ get_wild_ignore_table()

void Rpl_filter::get_wild_ignore_table ( String str)

◆ init_table_rule_array()

void Rpl_filter::init_table_rule_array ( Table_rule_array a,
bool *  a_inited 
)
private

◆ init_table_rule_hash()

void Rpl_filter::init_table_rule_hash ( Table_rule_hash **  h,
bool *  h_inited 
)
private

◆ is_attached()

bool Rpl_filter::is_attached ( )
inline

Check if the relation between the per-channel filter and the channel's Relay_log_info is established.

Return values
trueif the relation is established
falseif the relation is not established

◆ is_empty()

bool Rpl_filter::is_empty ( )

Check if the replication filter is empty or not.

Return values
trueif the replication filter is empty.
falseif the replication filter is not empty.

◆ is_on()

bool Rpl_filter::is_on ( )

◆ is_rewrite_empty()

bool Rpl_filter::is_rewrite_empty ( )

◆ operator=()

Rpl_filter & Rpl_filter::operator= ( Rpl_filter const &  )

◆ parse_filter_list() [1/2]

int Rpl_filter::parse_filter_list ( I_List< i_string > *  list,
Add_filter  add 
)

Execute the specified func with elements of the list as input.

Parameters
listA list with I_List<i_string> type
addA function with Add_filter type
Return values
0OK
1Error

◆ parse_filter_list() [2/2]

int Rpl_filter::parse_filter_list ( mem_root_deque< Item * > *  item_list,
Add_filter  func 
)

◆ put_filters_into_vector()

void Rpl_filter::put_filters_into_vector ( std::vector< Rpl_pfs_filter > &  rpl_pfs_filter_vec,
const char *  channel_name 
)

Put replication filters with attached channel name into a vector.

Parameters
rpl_pfs_filter_vecthe vector.
channel_namethe name of the channel attached or NULL if there is no channel attached.

◆ rdlock()

void Rpl_filter::rdlock ( )
inline

Acquire the read lock.

◆ reset()

void Rpl_filter::reset ( void  )

◆ set_attached()

void Rpl_filter::set_attached ( )
inline

Set attached to true when the relation between the per-channel filter and the channel's Relay_log_info is established.

◆ set_db_rewrite()

int Rpl_filter::set_db_rewrite ( mem_root_deque< Item * > *  list,
enum_configured_by  configured_by 
)

◆ set_do_db()

int Rpl_filter::set_do_db ( mem_root_deque< Item * > *  list,
enum_configured_by  configured_by 
)

◆ set_do_table()

int Rpl_filter::set_do_table ( mem_root_deque< Item * > *  list,
enum_configured_by  configured_by 
)

◆ set_ignore_db()

int Rpl_filter::set_ignore_db ( mem_root_deque< Item * > *  list,
enum_configured_by  configured_by 
)

◆ set_ignore_table()

int Rpl_filter::set_ignore_table ( mem_root_deque< Item * > *  list,
enum_configured_by  configured_by 
)

◆ set_wild_do_table()

int Rpl_filter::set_wild_do_table ( mem_root_deque< Item * > *  list,
enum_configured_by  configured_by 
)

◆ set_wild_ignore_table()

int Rpl_filter::set_wild_ignore_table ( mem_root_deque< Item * > *  list,
enum_configured_by  configured_by 
)

◆ table_rule_ent_array_to_array()

int Rpl_filter::table_rule_ent_array_to_array ( Table_rule_array dest_array,
Table_rule_array source_array,
bool  inited 
)
private

Builds a destination Table_rule_array from a source Table_rule_array of TABLE_RULE_ENT.

Parameters
dest_arrayPointer to the destination Table_rule_array to fill
source_arrayPointer to the source Table_rule_array to read
initedTrue if the source Table_rule_array is initialized
Return values
0OK
1Error

◆ table_rule_ent_dynamic_array_to_str()

void Rpl_filter::table_rule_ent_dynamic_array_to_str ( String s,
Table_rule_array a,
bool  inited 
)
private

◆ table_rule_ent_hash_to_array()

int Rpl_filter::table_rule_ent_hash_to_array ( Table_rule_array table_array,
Table_rule_hash h,
bool  inited 
)
private

Builds a Table_rule_array from a hash of TABLE_RULE_ENT.

Cannot be used for any other hash, as it assumes that the hash entries are TABLE_RULE_ENT.

Parameters
table_arrayPointer to the Table_rule_array to fill
hPointer to the hash to read
initedTrue if the hash is initialized
Return values
0OK
1Error

◆ table_rule_ent_hash_to_str()

void Rpl_filter::table_rule_ent_hash_to_str ( String s,
Table_rule_hash h,
bool  inited 
)
private

◆ tables_ok()

bool Rpl_filter::tables_ok ( const char *  db,
Table_ref tables 
)

◆ unlock()

void Rpl_filter::unlock ( )
inline

Release the lock (whether it is a write or read lock).

◆ wrlock()

void Rpl_filter::wrlock ( )
inline

Acquire the write lock.

Member Data Documentation

◆ attached

bool Rpl_filter::attached
private

◆ do_db

I_List<i_string> Rpl_filter::do_db
private

◆ do_db_statistics

Rpl_filter_statistics Rpl_filter::do_db_statistics

◆ do_table_array

Table_rule_array Rpl_filter::do_table_array
private

◆ do_table_array_inited

bool Rpl_filter::do_table_array_inited
private

◆ do_table_hash

Table_rule_hash* Rpl_filter::do_table_hash {nullptr}
private

◆ do_table_hash_inited

bool Rpl_filter::do_table_hash_inited
private

◆ do_table_statistics

Rpl_filter_statistics Rpl_filter::do_table_statistics

◆ ignore_db

I_List<i_string> Rpl_filter::ignore_db
private

◆ ignore_db_statistics

Rpl_filter_statistics Rpl_filter::ignore_db_statistics

◆ ignore_table_array

Table_rule_array Rpl_filter::ignore_table_array
private

◆ ignore_table_array_inited

bool Rpl_filter::ignore_table_array_inited
private

◆ ignore_table_hash

Table_rule_hash* Rpl_filter::ignore_table_hash {nullptr}
private

◆ ignore_table_hash_inited

bool Rpl_filter::ignore_table_hash_inited
private

◆ ignore_table_statistics

Rpl_filter_statistics Rpl_filter::ignore_table_statistics

◆ m_rpl_filter_lock

Checkable_rwlock* Rpl_filter::m_rpl_filter_lock
private

◆ rewrite_db

I_List<i_string_pair> Rpl_filter::rewrite_db
private

◆ rewrite_db_statistics

Rpl_filter_statistics Rpl_filter::rewrite_db_statistics

◆ table_rules_on

bool Rpl_filter::table_rules_on
private

◆ wild_do_table

Table_rule_array Rpl_filter::wild_do_table
private

◆ wild_do_table_inited

bool Rpl_filter::wild_do_table_inited
private

◆ wild_do_table_statistics

Rpl_filter_statistics Rpl_filter::wild_do_table_statistics

◆ wild_ignore_table

Table_rule_array Rpl_filter::wild_ignore_table
private

◆ wild_ignore_table_inited

bool Rpl_filter::wild_ignore_table_inited
private

◆ wild_ignore_table_statistics

Rpl_filter_statistics Rpl_filter::wild_ignore_table_statistics

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