1
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
20
#include "sql_list.h" /* I_List */
21
#include "hash.h" /* HASH */
25
typedef struct st_dynamic_array DYNAMIC_ARRAY;
27
typedef struct st_table_rule_ent
37
Inclusion and exclusion rules of tables and databases.
38
Also handles rewrites of db.
39
Used for replication and binlogging.
46
Rpl_filter(Rpl_filter const&);
47
Rpl_filter& operator=(Rpl_filter const&);
49
/* Checks - returns true if ok to replicate/log */
51
bool tables_ok(const char* db, TABLE_LIST* tables);
52
bool db_ok(const char* db);
53
bool db_ok_with_wild_table(const char *db);
57
/* Setters - add filtering rules */
59
int add_do_table(const char* table_spec);
60
int add_ignore_table(const char* table_spec);
62
int add_wild_do_table(const char* table_spec);
63
int add_wild_ignore_table(const char* table_spec);
65
void add_do_db(const char* db_spec);
66
void add_ignore_db(const char* db_spec);
68
void add_db_rewrite(const char* from_db, const char* to_db);
70
/* Getters - to get information about current rules */
72
void get_do_table(String* str);
73
void get_ignore_table(String* str);
75
void get_wild_do_table(String* str);
76
void get_wild_ignore_table(String* str);
78
const char* get_rewrite_db(const char* db, size_t *new_len);
80
I_List<i_string>* get_do_db();
81
I_List<i_string>* get_ignore_db();
86
void init_table_rule_hash(HASH* h, bool* h_inited);
87
void init_table_rule_array(DYNAMIC_ARRAY* a, bool* a_inited);
89
int add_table_rule(HASH* h, const char* table_spec);
90
int add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec);
92
void free_string_array(DYNAMIC_ARRAY *a);
94
void table_rule_ent_hash_to_str(String* s, HASH* h, bool inited);
95
void table_rule_ent_dynamic_array_to_str(String* s, DYNAMIC_ARRAY* a,
97
TABLE_RULE_ENT* find_wild(DYNAMIC_ARRAY *a, const char* key, int len);
100
Those 4 structures below are uninitialized memory unless the
101
corresponding *_inited variables are "true".
105
DYNAMIC_ARRAY wild_do_table;
106
DYNAMIC_ARRAY wild_ignore_table;
108
bool do_table_inited;
109
bool ignore_table_inited;
110
bool wild_do_table_inited;
111
bool wild_ignore_table_inited;
113
I_List<i_string> do_db;
114
I_List<i_string> ignore_db;
116
I_List<i_string_pair> rewrite_db;
119
extern Rpl_filter *rpl_filter;
120
extern Rpl_filter *binlog_filter;
122
#endif // RPL_FILTER_H