MySQL  8.0.27
Source Code Documentation
rpl_filter.h
Go to the documentation of this file.
1 /* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef RPL_FILTER_H
24 #define RPL_FILTER_H
25 
26 #include "my_config.h"
27 
28 #include <stddef.h>
29 #include <sys/types.h>
30 #include <atomic>
31 #include <memory>
32 #include <string>
33 #include <vector>
34 
35 #include "map_helpers.h"
36 #include "my_inttypes.h"
37 #include "my_sqlcommand.h"
38 #include "prealloced_array.h" // Prealloced_arrray
39 #include "sql/options_mysqld.h" // options_mysqld
40 #include "sql/rpl_gtid.h"
41 #include "sql/sql_cmd.h" // Sql_cmd
42 #include "sql/sql_list.h" // I_List
43 #include "sql_string.h"
44 
45 class Item;
46 class THD;
47 struct TABLE_LIST;
48 template <class T>
49 class mem_root_deque;
50 
51 /*
52 There are five classes related to replication filters:
53 - Rpl_filter contains all the seven filters do-db, ignore-db, do-table,
54  ignore-table, wild-do-table, wild-ignore-table, rewrite-db. We
55  instantiate one Rpl_filter for each replication channel and one for
56  the binlog. This contains member functions to apply the filters.
57 - Rpl_pfs_filter has one instance for each row in
58  P_S.replication_applier_filters and one instance for each row of
59  P_S.replication_applier_global_filters.
60 - Rpl_filter_statistics contains the data other than the key for each
61  P_S row. Each Rpl_filter object owns seven instances of this class
62  (one for each filter type) and each Rpl_pfs_filter points to one of
63  those instances.
64 - Rpl_channel_filters contains a map that maps channel names to
65  Rpl_filter objects, as well as a vector that references all
66  the Rpl_pfs_filter objects used to represent
67  P_S.replication_applier_filters.
68 - Rpl_global_filter is a Rpl_filter representing global replication
69  filters, with a vector that references all Rpl_pfs_filter objects
70  used to represent P_S.replication_applier_global_filters table.
71 
72 The vectors of Rpl_pfs_filters objects are rebuilt whenever filters
73 are modified (i.e., channels created/dropped or filters changed).
74 */
75 
77  char *db;
78  char *tbl_name;
80 };
81 
82 /** Enum values for CONFIGURED_BY column. */
88 };
89 
90 /**
91  The class Rpl_filter_statistics encapsulates the following three
92  statistics of replication filter:
93  The configured_by indicates that how the rpl filter is configured.
94  The active_since indicates when the configuration took place.
95  The counter indicates the hit amount of the filter since last
96  configuration.
97  Instances of this class are created in Rpl_filter for each filter
98  type for each channel and the global filter, and have the same
99  life cycle as the instance of Rpl_filter.
100  The reference of this class is used in Rpl_pfs_filter for
101  displaying the three statistics of replication filter in
102  performance_schema.replication_applier_filters table and
103  performance_schema.replication_applier_global_filters table.
104 */
106  public:
109  void reset();
110  /*
111  Set all member variables. The caller just needs to pass argument
112  for configured_by, since counter and active_since are set in the
113  funtion. We do that, since counter must be set to 0 and
114  active_since must be set to current time for any case.
115  */
116  void set_all(enum_configured_by configured_by);
117 
122 
123  private:
124  /*
125  The replication filters can be configured with the following four states:
126  STARTUP_OPTIONS, //STARTUP_OPTIONS: --REPLICATE-*
127  CHANGE_REPLICATION_FILTER, //CHANGE REPLICATION FILTER filter [, filter...]
128  STARTUP_OPTIONS_FOR_CHANNEL, //STARTUP_OPTIONS: --REPLICATE-* (FOR_CHANNEL)
129  CHANGE_REPLICATION_FILTER_FOR_CHANNEL //CHANGE REPLICATION FILTER filter [,
130  filter...] FOR CHANNEL <channel_name>
131  */
133 
134  /* Timestamp of when the configuration took place */
136 
137  /*
138  The hit amount of the filter since last configuration.
139  The m_atomic_counter may be increased by concurrent slave
140  workers, so we use the atomic<uint64>.
141  */
142  std::atomic<uint64> m_atomic_counter{0};
143 
144  /* Prevent user from invoking default constructor function. */
146 
147  /* Prevent user from invoking default assignment function. */
149 };
150 
151 /**
152  The class Rpl_pfs_filter is introduced to serve the
153  performance_schema.replication_applier_filters table
154  and performance_schema.replication_applier_global_filters
155  table to collect data for a row. The class Rpl_filter
156  does not use it directly, since it contains channel_name,
157  which does not belong to Rpl_filter. To decouple code,
158  it depends on Rpl_filter_statistics, does not inherit
159  Rpl_filter_statistics.
160  Instances of this class are created in Rpl_filter for
161  each filter type for each channel and the global filter.
162  Each instance is created when creating, changing or
163  deleting the filter, destroyed when creating, changing
164  or deleting the filter next time.
165 */
167  public:
168  Rpl_pfs_filter();
169  Rpl_pfs_filter(const char *channel_name, const char *filter_name,
170  const String &filter_rule,
171  Rpl_filter_statistics *rpl_filter_statistics);
172  Rpl_pfs_filter(const Rpl_pfs_filter &other);
174 
175  const char *get_channel_name() { return m_channel_name; }
176  const char *get_filter_name() { return m_filter_name; }
177  const String &get_filter_rule() { return m_filter_rule; }
180  }
181 
182  private:
183  /* A pointer to the channel name. */
184  const char *m_channel_name;
185 
186  /* A pointer to the filer name. */
187  const char *m_filter_name;
188 
189  /* A pointer to replication filter statistics. */
191 
192  /* A filter rule. */
194 
195  /* Prevent user from invoking default assignment function. */
197 };
198 
199 /**
200  Rpl_filter
201 
202  Inclusion and exclusion rules of tables and databases.
203  Also handles rewrites of db.
204  Used for replication and binlogging.
205  - Instances of this class are created in Rpl_channel_filters
206  for replication filter for each channel. Each instance is
207  created when the channel is configured, destroyed when the
208  channel is removed.
209  - There is one instance, binlog_filter, created for binlog filter.
210  The instance is created when the server is started, destroyed
211  when the server is stopped.
212  */
213 class Rpl_filter {
214  public:
215  Rpl_filter();
216  virtual ~Rpl_filter();
219 
220  /* Checks - returns true if ok to replicate/log */
221 
222  bool tables_ok(const char *db, TABLE_LIST *tables);
223  bool db_ok(const char *db, bool need_increase_counter = true);
224  bool db_ok_with_wild_table(const char *db);
225 
226  bool is_on();
227  /**
228  Check if the replication filter is empty or not.
229 
230  @retval true if the replication filter is empty.
231  @retval false if the replication filter is not empty.
232  */
233  bool is_empty();
234  /**
235  Copy global replication filters to its per-channel replication filters
236  if there are no per-channel replication filters and there are global
237  filters on the filter type on channel creation.
238 
239  @retval 0 OK
240  @retval 1 Error
241  */
243 
244  bool is_rewrite_empty();
245 
246  /* Setters - add filtering rules */
247  int build_do_table_hash();
249 
250  int add_string_list(I_List<i_string> *list, const char *spec);
251  int add_string_pair_list(I_List<i_string_pair> *list, const char *key,
252  const char *val);
253  int add_do_table_array(const char *table_spec);
254  int add_ignore_table_array(const char *table_spec);
255 
256  int add_wild_do_table(const char *table_spec);
257  int add_wild_ignore_table(const char *table_spec);
258 
259  int set_do_db(mem_root_deque<Item *> *list, enum_configured_by configured_by);
261  enum_configured_by configured_by);
263  enum_configured_by configured_by);
265  enum_configured_by configured_by);
267  enum_configured_by configured_by);
269  enum_configured_by configured_by);
271  enum_configured_by configured_by);
272  typedef int (Rpl_filter::*Add_filter)(char const *);
274  /**
275  Execute the specified func with elements of the list as input.
276 
277  @param list A list with I_List<i_string> type
278  @param add A function with Add_filter type
279 
280  @retval 0 OK
281  @retval 1 Error
282  */
284  int add_do_db(const char *db_spec);
285  int add_ignore_db(const char *db_spec);
286 
287  int add_db_rewrite(const char *from_db, const char *to_db);
288 
289  /* Getters - to get information about current rules */
290 
291  void get_do_table(String *str);
292  void get_ignore_table(String *str);
293 
296 
297  const char *get_rewrite_db(const char *db, size_t *new_len);
298  void get_rewrite_db(String *str);
299 
301  /*
302  Get do_db rule.
303 
304  @param[out] str the db_db rule.
305  */
306  void get_do_db(String *str);
307 
309  /*
310  Get ignore_db rule.
311 
312  @param[out] str the ignore_db rule.
313  */
314  void get_ignore_db(String *str);
315  /*
316  Get rewrite_db_statistics.
317 
318  @retval A pointer to a rewrite_db_statistics object.
319  */
321  return &rewrite_db_statistics;
322  }
323 
326 
327 #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
328  /**
329  Put replication filters with attached channel name into a vector.
330 
331  @param rpl_pfs_filter_vec the vector.
332  @param channel_name the name of the channel attached or NULL if
333  there is no channel attached.
334  */
335  void put_filters_into_vector(std::vector<Rpl_pfs_filter> &rpl_pfs_filter_vec,
336  const char *channel_name);
337 #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
338 
339  /**
340  Acquire the write lock.
341  */
343 
344  /**
345  Acquire the read lock.
346  */
348 
349  /**
350  Release the lock (whether it is a write or read lock).
351  */
353 
354  /**
355  Assert that some thread holds the write lock.
356  */
358 
359  /**
360  Assert that some thread holds the read lock.
361  */
363 
364  /**
365  Check if the relation between the per-channel filter and
366  the channel's Relay_log_info is established.
367 
368  @retval true if the relation is established
369  @retval false if the relation is not established
370  */
371  bool is_attached() { return attached; }
372 
373  /**
374  Set attached to true when the relation between the per-channel filter
375  and the channel's Relay_log_info is established.
376  */
377  void set_attached() { attached = true; }
378 
379  void reset();
380 
388 
389  private:
391  /*
392  State if the relation between the per-channel filter
393  and the channel's Relay_log_info is established.
394  */
395  bool attached;
396 
397  /*
398  While slave is not running after server startup, the replication filter
399  can be modified by CHANGE REPLICATION FILTER filter [, filter...]
400  [FOR CHANNEL <channel_name>] and CHANGE MASTER TO ... FOR CHANNEL,
401  and read by querying P_S.replication_applier_global_filters,
402  querying P_S.replication_applier_filters, and SHOW SLAVE STATUS
403  [FOR CHANNEL <channel_name>]. So the lock is introduced to protect
404  some member functions called by above commands. See below.
405 
406  The read lock should be held when calling the following member functions:
407  get_do_table(String* str); // SHOW SLAVE STATUS
408  get_ignore_table(String* str); // SHOW SLAVE STATUS
409  get_wild_do_table(String* str); // SHOW SLAVE STATUS
410  get_wild_ignore_table(String* str); // SHOW SLAVE STATUS
411  get_rewrite_db(const char* db, size_t *new_len); // SHOW SLAVE STATUS
412  get_rewrite_db(String *str); // SHOW SLAVE STATUS
413  get_do_db(); // SHOW SLAVE STATUS
414  get_do_db(String *str); // SHOW SLAVE STATUS
415  get_ignore_db(); // SHOW SLAVE STATUS
416  get_ignore_db(String *str); // SHOW SLAVE STATUS
417  put_filters_into_vector(...); // query P_S tables
418  get_filter_count(); // query P_S tables
419 
420  The write lock should be held when calling the following member functions:
421  set_do_db(mem_root_deque<Item *> *list); // CHANGE REPLICATION FILTER
422  set_ignore_db(mem_root_deque<Item *> *list); // CHANGE REPLICATION FILTER
423  set_do_table(mem_root_deque<Item *> *list); // CHANGE REPLICATION FILTER
424  set_ignore_table(mem_root_deque<Item *> *list); // CHANGE RPL. FILTER
425  set_wild_do_table(mem_root_deque<Item *> *list); // CHANGE RPL. FILTER
426  set_wild_ignore_table(mem_root_deque<Item *> *list); // CHANGE RPL. FILTER
427  set_db_rewrite(mem_root_deque<Item *> *list); // CHANGE RPL. FILTER
428  copy_global_replication_filters(); // CHANGE MASTER TO ... FOR CHANNEL
429 
430  Please acquire a wrlock when modifying the replication filter (CHANGE
431  REPLICATION FILTER filter [, filter...] [FOR CHANNEL <channel_name>]
432  and CHANGE MASTER TO ... FOR CHANNEL).
433  Please acqurie a rdlock when reading the replication filter (
434  SELECT * FROM performance_schema.replication_applier_global_filters,
435  SELECT * FROM performance_schema.replication_applier_filters and
436  SHOW SLAVE STATUS [FOR CHANNEL <channel_name>]).
437 
438  Other member functions do not need the protection of the lock and we can
439  access thd->rli_slave->rpl_filter to filter log event without the
440  protection of the lock while slave is running, since the replication
441  filter is read/modified by a single thread during server startup and
442  there is no command can change it while slave is running.
443  */
445 
447  typedef collation_unordered_map<std::string,
450 
451  void init_table_rule_hash(Table_rule_hash **h, bool *h_inited);
452  void init_table_rule_array(Table_rule_array *, bool *a_inited);
453 
454  int add_table_rule_to_array(Table_rule_array *a, const char *table_spec);
455  int add_table_rule_to_hash(Table_rule_hash *h, const char *table_spec,
456  uint len);
457 
459 
461  /**
462  Builds a Table_rule_array from a hash of TABLE_RULE_ENT. Cannot be used for
463  any other hash, as it assumes that the hash entries are TABLE_RULE_ENT.
464 
465  @param table_array Pointer to the Table_rule_array to fill
466  @param h Pointer to the hash to read
467  @param inited True if the hash is initialized
468 
469  @retval 0 OK
470  @retval 1 Error
471  */
473  Table_rule_hash *h, bool inited);
474  /**
475  Builds a destination Table_rule_array from a source Table_rule_array
476  of TABLE_RULE_ENT.
477 
478  @param dest_array Pointer to the destination Table_rule_array to fill
479  @param source_array Pointer to the source Table_rule_array to read
480  @param inited True if the source Table_rule_array is initialized
481 
482  @retval 0 OK
483  @retval 1 Error
484  */
486  Table_rule_array *source_array,
487  bool inited);
489  bool inited);
490  TABLE_RULE_ENT *find_wild(Table_rule_array *a, const char *key, size_t len);
491 
493  Table_rule_hash **table_hash,
494  bool array_inited, bool *hash_inited);
495 
496  /*
497  Those 6 structures below are uninitialized memory unless the
498  corresponding *_inited variables are "true".
499  */
500  /* For quick search */
503 
506 
509 
516 
519 
521 };
522 
523 /**
524  The class is a Rpl_filter representing global replication filters,
525  with a vector that references all Rpl_pfs_filter objects used to
526  represent P_S.replication_applier_global_filters table.
527  There is one instance, rpl_global_filter, created globally for
528  replication global filter. The rpl_global_filter is created when
529  the server is started, destroyed when the server is stopped.
530 */
532  public:
533  Rpl_global_filter() = default;
534  ~Rpl_global_filter() override = default;
535 
536 #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
537  /**
538  Used only by replication performance schema indices to get the count
539  of global replication filters.
540 
541  @retval the count of global replication filters.
542  */
544  /**
545  Used only by replication performance schema indices to get the global
546  replication filter at the position 'pos' from the
547  rpl_pfs_filter_vec vector.
548 
549  @param pos the index in the rpl_pfs_filter_vec vector.
550 
551  @retval Rpl_pfs_filter A pointer to a Rpl_pfs_filter, or NULL if it
552  arrived the end of the rpl_pfs_filter_vec.
553  */
555  /**
556  This member function is called everytime the rules of the global
557  repliation filter are changed. Once that happens the PFS view of
558  global repliation filter is recreated.
559  */
560  void reset_pfs_view();
561 #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
562 
563  private:
564  /*
565  Store pointers of all Rpl_pfs_filter objects in
566  replication filter.
567  */
568  std::vector<Rpl_pfs_filter> rpl_pfs_filter_vec;
569  /* Prevent user from invoking default assignment function. */
571  /* Prevent user from invoking default copy constructor function. */
573 };
574 
575 /** Sql_cmd_change_repl_filter represents the command CHANGE REPLICATION
576  * FILTER.
577  */
579  public:
580  /** Constructor. */
582  : do_db_list(nullptr),
589 
590  ~Sql_cmd_change_repl_filter() override = default;
591 
594  }
595  bool execute(THD *thd) override;
596 
598  options_mysqld filter_type);
599  bool change_rpl_filter(THD *thd);
600 
601  private:
609 };
610 
611 extern Rpl_filter *rpl_filter;
612 extern Rpl_filter *binlog_filter;
613 
614 #endif // RPL_FILTER_H
This has the functionality of mysql_rwlock_t, with two differences:
Definition: rpl_gtid.h:306
void rdlock()
Acquire the read lock.
Definition: rpl_gtid.h:441
void wrlock()
Acquire the write lock.
Definition: rpl_gtid.h:450
void assert_some_rdlock() const
Assert that some thread holds the read lock.
Definition: rpl_gtid.h:529
void unlock()
Release the lock (whether it is a write or read lock).
Definition: rpl_gtid.h:461
void assert_some_wrlock() const
Assert that some thread holds the write lock.
Definition: rpl_gtid.h:531
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:802
The class Rpl_filter_statistics encapsulates the following three statistics of replication filter: Th...
Definition: rpl_filter.h:105
Rpl_filter_statistics(Rpl_filter_statistics const &)
enum_configured_by get_configured_by()
Definition: rpl_filter.h:118
void increase_counter()
Definition: rpl_filter.h:121
enum_configured_by m_configured_by
Definition: rpl_filter.h:132
void reset()
Definition: rpl_filter.cc:95
void set_all(enum_configured_by configured_by)
Definition: rpl_filter.cc:101
ulonglong m_active_since
Definition: rpl_filter.h:135
Rpl_filter_statistics & operator=(Rpl_filter_statistics const &)
ulonglong get_active_since()
Definition: rpl_filter.h:119
ulonglong get_counter()
Definition: rpl_filter.h:120
Rpl_filter_statistics()
Definition: rpl_filter.cc:91
std::atomic< uint64 > m_atomic_counter
Definition: rpl_filter.h:142
Rpl_filter.
Definition: rpl_filter.h:213
int build_ignore_table_hash()
Definition: rpl_filter.cc:641
bool is_attached()
Check if the relation between the per-channel filter and the channel's Relay_log_info is established.
Definition: rpl_filter.h:371
int add_string_list(I_List< i_string > *list, const char *spec)
Definition: rpl_filter.cc:906
collation_unordered_map< std::string, unique_ptr_my_free< TABLE_RULE_ENT > > Table_rule_hash
Definition: rpl_filter.h:449
int add_string_pair_list(I_List< i_string_pair > *list, const char *key, const char *val)
Definition: rpl_filter.cc:925
void free_string_pair_list(I_List< i_string_pair > *l)
Definition: rpl_filter.cc:1012
void get_wild_do_table(String *str)
Definition: rpl_filter.cc:1145
bool is_empty()
Check if the replication filter is empty or not.
Definition: rpl_filter.cc:178
void unlock()
Release the lock (whether it is a write or read lock).
Definition: rpl_filter.h:352
int(Rpl_filter::* Add_filter)(char const *)
Definition: rpl_filter.h:272
Rpl_filter_statistics wild_ignore_table_statistics
Definition: rpl_filter.h:384
void set_attached()
Set attached to true when the relation between the per-channel filter and the channel's Relay_log_inf...
Definition: rpl_filter.h:377
void free_string_list(I_List< i_string > *l)
Definition: rpl_filter.cc:999
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 bee...
Definition: rpl_filter.cc:672
int set_db_rewrite(mem_root_deque< Item * > *list, enum_configured_by configured_by)
Definition: rpl_filter.cc:883
I_List< i_string > * get_do_db()
Definition: rpl_filter.cc:1192
void init_table_rule_hash(Table_rule_hash **h, bool *h_inited)
Definition: rpl_filter.cc:964
virtual ~Rpl_filter()
Definition: rpl_filter.cc:144
Table_rule_hash * do_table_hash
Definition: rpl_filter.h:501
int set_ignore_table(mem_root_deque< Item * > *list, enum_configured_by configured_by)
Definition: rpl_filter.cc:817
Rpl_filter_statistics ignore_table_statistics
Definition: rpl_filter.h:382
bool wild_ignore_table_inited
Definition: rpl_filter.h:515
Table_rule_array wild_ignore_table
Definition: rpl_filter.h:508
bool tables_ok(const char *db, TABLE_LIST *tables)
Definition: rpl_filter.cc:394
int build_do_table_hash()
Definition: rpl_filter.cc:617
Rpl_filter()
Definition: rpl_filter.cc:120
Rpl_filter(Rpl_filter const &)
int set_do_table(mem_root_deque< Item * > *list, enum_configured_by configured_by)
Definition: rpl_filter.cc:791
bool ignore_table_hash_inited
Definition: rpl_filter.h:511
Rpl_filter_statistics * get_rewrite_db_statistics()
Definition: rpl_filter.h:320
bool is_on()
Definition: rpl_filter.cc:566
Rpl_filter_statistics do_table_statistics
Definition: rpl_filter.h:381
const char * get_rewrite_db(const char *db, size_t *new_len)
Definition: rpl_filter.cc:1173
I_List< i_string > ignore_db
Definition: rpl_filter.h:518
void assert_some_wrlock()
Assert that some thread holds the write lock.
Definition: rpl_filter.h:357
I_List< i_string_pair > rewrite_db
Definition: rpl_filter.h:520
int add_do_db(const char *db_spec)
Definition: rpl_filter.cc:952
I_List< i_string > * get_ignore_db()
Definition: rpl_filter.cc:1208
bool db_ok(const char *db, bool need_increase_counter=true)
Definition: rpl_filter.cc:455
void get_do_table(String *str)
Definition: rpl_filter.cc:1137
Rpl_filter_statistics wild_do_table_statistics
Definition: rpl_filter.h:383
bool do_table_array_inited
Definition: rpl_filter.h:512
bool ignore_table_array_inited
Definition: rpl_filter.h:513
int set_do_db(mem_root_deque< Item * > *list, enum_configured_by configured_by)
Definition: rpl_filter.cc:769
int parse_filter_list(mem_root_deque< Item * > *item_list, Add_filter func)
Definition: rpl_filter.cc:742
bool do_table_hash_inited
Definition: rpl_filter.h:510
int add_ignore_table_array(const char *table_spec)
Definition: rpl_filter.cc:578
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.
Definition: rpl_filter.cc:1061
int set_wild_ignore_table(mem_root_deque< Item * > *list, enum_configured_by configured_by)
Definition: rpl_filter.cc:863
I_List< i_string > do_db
Definition: rpl_filter.h:517
Table_rule_array do_table_array
Definition: rpl_filter.h:504
bool wild_do_table_inited
Definition: rpl_filter.h:514
int add_do_table_array(const char *table_spec)
Definition: rpl_filter.cc:570
void wrlock()
Acquire the write lock.
Definition: rpl_filter.h:342
bool is_rewrite_empty()
Definition: rpl_filter.cc:568
void reset()
Definition: rpl_filter.cc:149
Rpl_filter_statistics do_db_statistics
Definition: rpl_filter.h:385
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.
Definition: rpl_filter.cc:1226
int add_db_rewrite(const char *from_db, const char *to_db)
Definition: rpl_filter.cc:603
bool db_ok_with_wild_table(const char *db)
Definition: rpl_filter.cc:537
bool attached
Definition: rpl_filter.h:395
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.
Definition: rpl_filter.cc:1093
Rpl_filter_statistics ignore_db_statistics
Definition: rpl_filter.h:386
int set_ignore_db(mem_root_deque< Item * > *list, enum_configured_by configured_by)
Definition: rpl_filter.cc:780
Prealloced_array< TABLE_RULE_ENT *, 16 > Table_rule_array
Definition: rpl_filter.h:446
void get_wild_ignore_table(String *str)
Definition: rpl_filter.cc:1150
Table_rule_array ignore_table_array
Definition: rpl_filter.h:505
int add_wild_do_table(const char *table_spec)
Definition: rpl_filter.cc:586
Rpl_filter_statistics rewrite_db_statistics
Definition: rpl_filter.h:387
void init_table_rule_array(Table_rule_array *, bool *a_inited)
Definition: rpl_filter.cc:969
void get_ignore_table(String *str)
Definition: rpl_filter.cc:1141
Checkable_rwlock * m_rpl_filter_lock
Definition: rpl_filter.h:444
int add_table_rule_to_array(Table_rule_array *a, const char *table_spec)
Definition: rpl_filter.cc:722
Table_rule_hash * ignore_table_hash
Definition: rpl_filter.h:502
void rdlock()
Acquire the read lock.
Definition: rpl_filter.h:347
void assert_some_rdlock()
Assert that some thread holds the read lock.
Definition: rpl_filter.h:362
TABLE_RULE_ENT * find_wild(Table_rule_array *a, const char *key, size_t len)
Definition: rpl_filter.cc:974
Rpl_filter & operator=(Rpl_filter const &)
int copy_global_replication_filters()
Copy global replication filters to its per-channel replication filters if there are no per-channel re...
Definition: rpl_filter.cc:189
void table_rule_ent_dynamic_array_to_str(String *s, Table_rule_array *a, bool inited)
Definition: rpl_filter.cc:1124
bool table_rules_on
Definition: rpl_filter.h:390
int set_wild_do_table(mem_root_deque< Item * > *list, enum_configured_by configured_by)
Definition: rpl_filter.cc:844
int add_wild_ignore_table(const char *table_spec)
Definition: rpl_filter.cc:594
int add_table_rule_to_hash(Table_rule_hash *h, const char *table_spec, uint len)
Added one table rule to hash.
Definition: rpl_filter.cc:700
void table_rule_ent_hash_to_str(String *s, Table_rule_hash *h, bool inited)
Definition: rpl_filter.cc:1035
Table_rule_array wild_do_table
Definition: rpl_filter.h:507
int add_ignore_db(const char *db_spec)
Definition: rpl_filter.cc:958
void free_string_array(Table_rule_array *a)
Definition: rpl_filter.cc:994
The class is a Rpl_filter representing global replication filters, with a vector that references all ...
Definition: rpl_filter.h:531
Rpl_pfs_filter * get_filter_at_pos(uint pos)
Used only by replication performance schema indices to get the global replication filter at the posit...
Definition: rpl_filter.cc:1293
~Rpl_global_filter() override=default
std::vector< Rpl_pfs_filter > rpl_pfs_filter_vec
Definition: rpl_filter.h:568
uint get_filter_count()
Used only by replication performance schema indices to get the count of global replication filters.
Definition: rpl_filter.cc:1303
Rpl_global_filter(const Rpl_global_filter &info)
void reset_pfs_view()
This member function is called everytime the rules of the global repliation filter are changed.
Definition: rpl_filter.cc:1283
Rpl_global_filter & operator=(const Rpl_global_filter &info)
Rpl_global_filter()=default
The class Rpl_pfs_filter is introduced to serve the performance_schema.replication_applier_filters ta...
Definition: rpl_filter.h:166
const char * m_filter_name
Definition: rpl_filter.h:187
Rpl_pfs_filter & operator=(Rpl_pfs_filter const &)
Rpl_filter_statistics * get_rpl_filter_statistics()
Definition: rpl_filter.h:178
const char * get_filter_name()
Definition: rpl_filter.h:176
const char * get_channel_name()
Definition: rpl_filter.h:175
const String & get_filter_rule()
Definition: rpl_filter.h:177
Rpl_filter_statistics * m_rpl_filter_statistics
Definition: rpl_filter.h:190
const char * m_channel_name
Definition: rpl_filter.h:184
String m_filter_rule
Definition: rpl_filter.h:193
Rpl_pfs_filter()
Definition: rpl_filter.cc:66
Sql_cmd_change_repl_filter represents the command CHANGE REPLICATION FILTER.
Definition: rpl_filter.h:578
mem_root_deque< Item * > * wild_do_table_list
Definition: rpl_filter.h:606
~Sql_cmd_change_repl_filter() override=default
mem_root_deque< Item * > * ignore_table_list
Definition: rpl_filter.h:605
mem_root_deque< Item * > * ignore_db_list
Definition: rpl_filter.h:603
Sql_cmd_change_repl_filter()
Constructor.
Definition: rpl_filter.h:581
void set_filter_value(mem_root_deque< Item * > *item_list, options_mysqld filter_type)
Definition: rpl_filter.cc:1318
mem_root_deque< Item * > * do_db_list
Definition: rpl_filter.h:602
mem_root_deque< Item * > * rewrite_db_pair_list
Definition: rpl_filter.h:608
mem_root_deque< Item * > * do_table_list
Definition: rpl_filter.h:604
bool execute(THD *thd) override
Execute this SQL statement.
Definition: rpl_filter.cc:1312
bool change_rpl_filter(THD *thd)
Execute a CHANGE REPLICATION FILTER statement to set filter rules.
Definition: rpl_filter.cc:1359
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: rpl_filter.h:592
mem_root_deque< Item * > * wild_ignore_table_list
Definition: rpl_filter.h:607
Representation of an SQL command.
Definition: sql_cmd.h:64
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:165
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:821
std::unordered_map, but with my_malloc and collation-aware comparison.
Definition: map_helpers.h:209
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:109
Dialog Client Authentication nullptr
Definition: dialog.cc:352
char * pos
Definition: do_ctype.cc:76
static bool inited
Definition: log_filter_dragnet.cc:121
std::unique_ptr< T, My_free_deleter > unique_ptr_my_free
std::unique_ptr, but with my_free as deleter.
Definition: map_helpers.h:96
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
enum_sql_command
Definition: my_sqlcommand.h:45
@ SQLCOM_CHANGE_REPLICATION_FILTER
Definition: my_sqlcommand.h:109
Log info(cout, "NOTE")
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1056
static mysql_service_status_t add(reference_caching_channel channel, const char *implementation_name) noexcept
Definition: component.cc:134
options_mysqld
only options that need special treatment in get_one_option() deserve to be listed below
Definition: options_mysqld.h:30
required string key
Definition: replication_asynchronous_connection_failover.proto:59
Rpl_filter * rpl_filter
Rpl_filter * binlog_filter
Definition: mysqld.cc:1501
enum_configured_by
Enum values for CONFIGURED_BY column.
Definition: rpl_filter.h:83
@ CONFIGURED_BY_CHANGE_REPLICATION_FILTER
Definition: rpl_filter.h:85
@ CONFIGURED_BY_STARTUP_OPTIONS
Definition: rpl_filter.h:84
@ CONFIGURED_BY_STARTUP_OPTIONS_FOR_CHANNEL
Definition: rpl_filter.h:86
@ CONFIGURED_BY_CHANGE_REPLICATION_FILTER_FOR_CHANNEL
Definition: rpl_filter.h:87
Representation of an SQL command.
Our own string classes, used pervasively throughout the executor.
Definition: table.h:2694
Definition: rpl_filter.h:76
char * tbl_name
Definition: rpl_filter.h:78
uint key_len
Definition: rpl_filter.h:79
char * db
Definition: rpl_filter.h:77
unsigned int uint
Definition: uca-dump.cc:29