#include <rpl_filter.h>
Collaboration diagram for Rpl_filter:

Definition at line 36 of file rpl_filter.h.
| Rpl_filter::Rpl_filter | ( | ) |
Definition at line 23 of file rpl_filter.cc.
References do_db, I_List< T >::empty(), ignore_db, and rewrite_db.
00023 : 00024 table_rules_on(0), do_table_inited(0), ignore_table_inited(0), 00025 wild_do_table_inited(0), wild_ignore_table_inited(0) 00026 { 00027 do_db.empty(); 00028 ignore_db.empty(); 00029 rewrite_db.empty(); 00030 }
Here is the call graph for this function:

| Rpl_filter::~Rpl_filter | ( | ) |
Definition at line 33 of file rpl_filter.cc.
References do_db, do_table, do_table_inited, free_list(), free_string_array(), hash_free(), ignore_db, ignore_table, ignore_table_inited, rewrite_db, wild_do_table, wild_do_table_inited, wild_ignore_table, and wild_ignore_table_inited.
00034 { 00035 if (do_table_inited) 00036 hash_free(&do_table); 00037 if (ignore_table_inited) 00038 hash_free(&ignore_table); 00039 if (wild_do_table_inited) 00040 free_string_array(&wild_do_table); 00041 if (wild_ignore_table_inited) 00042 free_string_array(&wild_ignore_table); 00043 free_list(&do_db); 00044 free_list(&ignore_db); 00045 free_list(&rewrite_db); 00046 }
Here is the call graph for this function:

| Rpl_filter::Rpl_filter | ( | Rpl_filter const & | ) |
| void Rpl_filter::add_db_rewrite | ( | const char * | from_db, | |
| const char * | to_db | |||
| ) |
Definition at line 301 of file rpl_filter.cc.
References I_List< T >::push_back(), and rewrite_db.
Referenced by get_one_option().
00302 { 00303 i_string_pair *db_pair = new i_string_pair(from_db, to_db); 00304 rewrite_db.push_back(db_pair); 00305 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void Rpl_filter::add_do_db | ( | const char * | db_spec | ) |
Definition at line 350 of file rpl_filter.cc.
References db, DBUG_ENTER, do_db, and I_List< T >::push_back().
Referenced by get_one_option().
00351 { 00352 DBUG_ENTER("Rpl_filter::add_do_db"); 00353 i_string *db = new i_string(table_spec); 00354 do_db.push_back(db); 00355 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int Rpl_filter::add_do_table | ( | const char * | table_spec | ) |
Definition at line 257 of file rpl_filter.cc.
References add_table_rule(), DBUG_ENTER, DBUG_RETURN, do_table, do_table_inited, init_table_rule_hash(), and table_rules_on.
Referenced by get_one_option().
00258 { 00259 DBUG_ENTER("Rpl_filter::add_do_table"); 00260 if (!do_table_inited) 00261 init_table_rule_hash(&do_table, &do_table_inited); 00262 table_rules_on= 1; 00263 DBUG_RETURN(add_table_rule(&do_table, table_spec)); 00264 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void Rpl_filter::add_ignore_db | ( | const char * | db_spec | ) |
Definition at line 359 of file rpl_filter.cc.
References db, DBUG_ENTER, ignore_db, and I_List< T >::push_back().
Referenced by get_one_option().
00360 { 00361 DBUG_ENTER("Rpl_filter::add_ignore_db"); 00362 i_string *db = new i_string(table_spec); 00363 ignore_db.push_back(db); 00364 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int Rpl_filter::add_ignore_table | ( | const char * | table_spec | ) |
Definition at line 268 of file rpl_filter.cc.
References add_table_rule(), DBUG_ENTER, DBUG_RETURN, ignore_table, ignore_table_inited, init_table_rule_hash(), and table_rules_on.
Referenced by get_one_option().
00269 { 00270 DBUG_ENTER("Rpl_filter::add_ignore_table"); 00271 if (!ignore_table_inited) 00272 init_table_rule_hash(&ignore_table, &ignore_table_inited); 00273 table_rules_on= 1; 00274 DBUG_RETURN(add_table_rule(&ignore_table, table_spec)); 00275 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int Rpl_filter::add_table_rule | ( | HASH * | h, | |
| const char * | table_spec | |||
| ) | [private] |
Definition at line 309 of file rpl_filter.cc.
References e, h, memcpy, my_hash_insert(), my_malloc(), MY_WME, MYF, strchr(), and strlen().
Referenced by add_do_table(), and add_ignore_table().
00310 { 00311 const char* dot = strchr(table_spec, '.'); 00312 if (!dot) return 1; 00313 // len is always > 0 because we know the there exists a '.' 00314 uint len = (uint)strlen(table_spec); 00315 TABLE_RULE_ENT* e = (TABLE_RULE_ENT*)my_malloc(sizeof(TABLE_RULE_ENT) 00316 + len, MYF(MY_WME)); 00317 if (!e) return 1; 00318 e->db= (char*)e + sizeof(TABLE_RULE_ENT); 00319 e->tbl_name= e->db + (dot - table_spec) + 1; 00320 e->key_len= len; 00321 memcpy(e->db, table_spec, len); 00322 00323 return my_hash_insert(h, (byte*)e); 00324 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int Rpl_filter::add_wild_do_table | ( | const char * | table_spec | ) |
Definition at line 279 of file rpl_filter.cc.
References add_wild_table_rule(), DBUG_ENTER, DBUG_RETURN, init_table_rule_array(), table_rules_on, wild_do_table, and wild_do_table_inited.
Referenced by get_one_option().
00280 { 00281 DBUG_ENTER("Rpl_filter::add_wild_do_table"); 00282 if (!wild_do_table_inited) 00283 init_table_rule_array(&wild_do_table, &wild_do_table_inited); 00284 table_rules_on= 1; 00285 DBUG_RETURN(add_wild_table_rule(&wild_do_table, table_spec)); 00286 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int Rpl_filter::add_wild_ignore_table | ( | const char * | table_spec | ) |
Definition at line 290 of file rpl_filter.cc.
References add_wild_table_rule(), DBUG_ENTER, DBUG_RETURN, init_table_rule_array(), table_rules_on, wild_ignore_table, and wild_ignore_table_inited.
Referenced by get_one_option().
00291 { 00292 DBUG_ENTER("Rpl_filter::add_wild_ignore_table"); 00293 if (!wild_ignore_table_inited) 00294 init_table_rule_array(&wild_ignore_table, &wild_ignore_table_inited); 00295 table_rules_on= 1; 00296 DBUG_RETURN(add_wild_table_rule(&wild_ignore_table, table_spec)); 00297 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int Rpl_filter::add_wild_table_rule | ( | DYNAMIC_ARRAY * | a, | |
| const char * | table_spec | |||
| ) | [private] |
Definition at line 332 of file rpl_filter.cc.
References e, insert_dynamic(), memcpy, my_malloc(), MY_WME, MYF, strchr(), and strlen().
Referenced by add_wild_do_table(), and add_wild_ignore_table().
00333 { 00334 const char* dot = strchr(table_spec, '.'); 00335 if (!dot) return 1; 00336 uint len = (uint)strlen(table_spec); 00337 TABLE_RULE_ENT* e = (TABLE_RULE_ENT*)my_malloc(sizeof(TABLE_RULE_ENT) 00338 + len, MYF(MY_WME)); 00339 if (!e) return 1; 00340 e->db= (char*)e + sizeof(TABLE_RULE_ENT); 00341 e->tbl_name= e->db + (dot - table_spec) + 1; 00342 e->key_len= len; 00343 memcpy(e->db, table_spec, len); 00344 insert_dynamic(a, (gptr)&e); 00345 return 0; 00346 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool Rpl_filter::db_ok | ( | const char * | db | ) |
Definition at line 147 of file rpl_filter.cc.
References DBUG_ENTER, DBUG_RETURN, do_db, ignore_db, I_List< T >::is_empty(), i_string::ptr, and strcmp().
Referenced by mysql_execute_command(), and MYSQL_BIN_LOG::write().
00148 { 00149 DBUG_ENTER("Rpl_filter::db_ok"); 00150 00151 if (do_db.is_empty() && ignore_db.is_empty()) 00152 DBUG_RETURN(1); // Ok to replicate if the user puts no constraints 00153 00154 /* 00155 If the user has specified restrictions on which databases to replicate 00156 and db was not selected, do not replicate. 00157 */ 00158 if (!db) 00159 DBUG_RETURN(0); 00160 00161 if (!do_db.is_empty()) // if the do's are not empty 00162 { 00163 I_List_iterator<i_string> it(do_db); 00164 i_string* tmp; 00165 00166 while ((tmp=it++)) 00167 { 00168 if (!strcmp(tmp->ptr, db)) 00169 DBUG_RETURN(1); // match 00170 } 00171 DBUG_RETURN(0); 00172 } 00173 else // there are some elements in the don't, otherwise we cannot get here 00174 { 00175 I_List_iterator<i_string> it(ignore_db); 00176 i_string* tmp; 00177 00178 while ((tmp=it++)) 00179 { 00180 if (!strcmp(tmp->ptr, db)) 00181 DBUG_RETURN(0); // match 00182 } 00183 DBUG_RETURN(1); 00184 } 00185 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool Rpl_filter::db_ok_with_wild_table | ( | const char * | db | ) |
Definition at line 219 of file rpl_filter.cc.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, find_wild(), hash_key(), NAME_LEN, strmov(), wild_do_table, wild_do_table_inited, wild_ignore_table, and wild_ignore_table_inited.
Referenced by mysql_execute_command().
00220 { 00221 DBUG_ENTER("Rpl_filter::db_ok_with_wild_table"); 00222 00223 char hash_key[NAME_LEN+2]; 00224 char *end; 00225 int len; 00226 end= strmov(hash_key, db); 00227 *end++= '.'; 00228 len= end - hash_key ; 00229 if (wild_do_table_inited && find_wild(&wild_do_table, hash_key, len)) 00230 { 00231 DBUG_PRINT("return",("1")); 00232 DBUG_RETURN(1); 00233 } 00234 if (wild_ignore_table_inited && find_wild(&wild_ignore_table, hash_key, len)) 00235 { 00236 DBUG_PRINT("return",("0")); 00237 DBUG_RETURN(0); 00238 } 00239 00240 /* 00241 If no explicit rule found and there was a do list, do not replicate. 00242 If there was no do list, go ahead 00243 */ 00244 DBUG_PRINT("return",("db=%s,retval=%d", db, !wild_do_table_inited)); 00245 DBUG_RETURN(!wild_do_table_inited); 00246 }
Here is the call graph for this function:

Here is the caller graph for this function:

| TABLE_RULE_ENT * Rpl_filter::find_wild | ( | DYNAMIC_ARRAY * | a, | |
| const char * | key, | |||
| int | len | |||
| ) | [private] |
Definition at line 404 of file rpl_filter.cc.
References e, st_dynamic_array::elements, get_dynamic(), key_end(), my_wildcmp, system_charset_info, wild_many, and wild_one.
Referenced by db_ok_with_wild_table(), and tables_ok().
00405 { 00406 uint i; 00407 const char* key_end= key + len; 00408 00409 for (i= 0; i < a->elements; i++) 00410 { 00411 TABLE_RULE_ENT* e ; 00412 get_dynamic(a, (gptr)&e, i); 00413 if (!my_wildcmp(system_charset_info, key, key_end, 00414 (const char*)e->db, 00415 (const char*)(e->db + e->key_len), 00416 '\\',wild_one,wild_many)) 00417 return e; 00418 } 00419 00420 return 0; 00421 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void Rpl_filter::free_string_array | ( | DYNAMIC_ARRAY * | a | ) | [private] |
Definition at line 425 of file rpl_filter.cc.
References delete_dynamic(), st_dynamic_array::elements, get_dynamic(), my_free, MY_WME, MYF, and p.
Referenced by ~Rpl_filter().
00426 { 00427 uint i; 00428 for (i= 0; i < a->elements; i++) 00429 { 00430 char* p; 00431 get_dynamic(a, (gptr) &p, i); 00432 my_free(p, MYF(MY_WME)); 00433 } 00434 delete_dynamic(a); 00435 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void Rpl_filter::get_do_table | ( | String * | str | ) |
Definition at line 488 of file rpl_filter.cc.
References do_table, do_table_inited, and table_rule_ent_hash_to_str().
00489 { 00490 table_rule_ent_hash_to_str(str, &do_table, do_table_inited); 00491 }
Here is the call graph for this function:

Definition at line 543 of file rpl_filter.cc.
References ignore_db.
00544 { 00545 return &ignore_db; 00546 }
| void Rpl_filter::get_ignore_table | ( | String * | str | ) |
Definition at line 495 of file rpl_filter.cc.
References ignore_table, ignore_table_inited, and table_rule_ent_hash_to_str().
00496 { 00497 table_rule_ent_hash_to_str(str, &ignore_table, ignore_table_inited); 00498 }
Here is the call graph for this function:

| const char * Rpl_filter::get_rewrite_db | ( | const char * | db, | |
| uint * | new_len | |||
| ) |
Definition at line 516 of file rpl_filter.cc.
References I_List< T >::is_empty(), i_string_pair::key, rewrite_db, strcmp(), strlen(), and i_string_pair::val.
00517 { 00518 if (rewrite_db.is_empty() || !db) 00519 return db; 00520 I_List_iterator<i_string_pair> it(rewrite_db); 00521 i_string_pair* tmp; 00522 00523 while ((tmp=it++)) 00524 { 00525 if (!strcmp(tmp->key, db)) 00526 { 00527 *new_len= strlen(tmp->val); 00528 return tmp->val; 00529 } 00530 } 00531 return db; 00532 }
Here is the call graph for this function:

| void Rpl_filter::get_wild_do_table | ( | String * | str | ) |
Definition at line 502 of file rpl_filter.cc.
References table_rule_ent_dynamic_array_to_str(), wild_do_table, and wild_do_table_inited.
00503 { 00504 table_rule_ent_dynamic_array_to_str(str, &wild_do_table, wild_do_table_inited); 00505 }
Here is the call graph for this function:

| void Rpl_filter::get_wild_ignore_table | ( | String * | str | ) |
Definition at line 509 of file rpl_filter.cc.
References table_rule_ent_dynamic_array_to_str(), wild_ignore_table, and wild_ignore_table_inited.
00510 { 00511 table_rule_ent_dynamic_array_to_str(str, &wild_ignore_table, wild_ignore_table_inited); 00512 }
Here is the call graph for this function:

| void Rpl_filter::init_table_rule_array | ( | DYNAMIC_ARRAY * | a, | |
| bool * | a_inited | |||
| ) | [private] |
Definition at line 395 of file rpl_filter.cc.
References my_init_dynamic_array, and TABLE_RULE_ARR_SIZE.
Referenced by add_wild_do_table(), and add_wild_ignore_table().
00396 { 00397 my_init_dynamic_array(a, sizeof(TABLE_RULE_ENT*), TABLE_RULE_ARR_SIZE, 00398 TABLE_RULE_ARR_SIZE); 00399 *a_inited = 1; 00400 }
Here is the caller graph for this function:

Definition at line 386 of file rpl_filter.cc.
References free_table_ent(), get_table_key(), h, hash_init, system_charset_info, and TABLE_RULE_HASH_SIZE.
Referenced by add_do_table(), and add_ignore_table().
00387 { 00388 hash_init(h, system_charset_info,TABLE_RULE_HASH_SIZE,0,0, 00389 get_table_key, free_table_ent, 0); 00390 *h_inited = 1; 00391 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool Rpl_filter::is_on | ( | ) |
Definition at line 250 of file rpl_filter.cc.
References table_rules_on.
Referenced by change_password(), mysql_grant(), mysql_routine_grant(), mysql_table_grant(), and open_grant_tables().
00251 { 00252 return table_rules_on; 00253 }
Here is the caller graph for this function:

| Rpl_filter& Rpl_filter::operator= | ( | Rpl_filter const & | ) |
| void Rpl_filter::table_rule_ent_dynamic_array_to_str | ( | String * | s, | |
| DYNAMIC_ARRAY * | a, | |||
| bool | inited | |||
| ) | [private] |
Definition at line 469 of file rpl_filter.cc.
References String::append(), e, st_dynamic_array::elements, get_dynamic(), and String::length().
Referenced by get_wild_do_table(), and get_wild_ignore_table().
00471 { 00472 s->length(0); 00473 if (inited) 00474 { 00475 for (uint i= 0; i < a->elements; i++) 00476 { 00477 TABLE_RULE_ENT* e; 00478 get_dynamic(a, (gptr)&e, i); 00479 if (s->length()) 00480 s->append(','); 00481 s->append(e->db,e->key_len); 00482 } 00483 } 00484 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 452 of file rpl_filter.cc.
References String::append(), e, h, hash_element(), and String::length().
Referenced by get_do_table(), and get_ignore_table().
00453 { 00454 s->length(0); 00455 if (inited) 00456 { 00457 for (uint i= 0; i < h->records; i++) 00458 { 00459 TABLE_RULE_ENT* e= (TABLE_RULE_ENT*) hash_element(h, i); 00460 if (s->length()) 00461 s->append(','); 00462 s->append(e->db,e->key_len); 00463 } 00464 } 00465 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool Rpl_filter::tables_ok | ( | const char * | db, | |
| TABLE_LIST * | tables | |||
| ) |
Definition at line 88 of file rpl_filter.cc.
References st_table_list::db, DBUG_ENTER, DBUG_RETURN, do_table, do_table_inited, find_wild(), hash_key(), hash_search(), ignore_table, ignore_table_inited, NAME_LEN, st_table_list::next_global, strmov(), st_table_list::table_name, st_table_list::updating, wild_do_table, wild_do_table_inited, wild_ignore_table, and wild_ignore_table_inited.
Referenced by change_password(), mysql_grant(), mysql_routine_grant(), mysql_table_grant(), and open_grant_tables().
00089 { 00090 bool some_tables_updating= 0; 00091 DBUG_ENTER("Rpl_filter::tables_ok"); 00092 00093 for (; tables; tables= tables->next_global) 00094 { 00095 char hash_key[2*NAME_LEN+2]; 00096 char *end; 00097 uint len; 00098 00099 if (!tables->updating) 00100 continue; 00101 some_tables_updating= 1; 00102 end= strmov(hash_key, tables->db ? tables->db : db); 00103 *end++= '.'; 00104 len= (uint) (strmov(end, tables->table_name) - hash_key); 00105 if (do_table_inited) // if there are any do's 00106 { 00107 if (hash_search(&do_table, (byte*) hash_key, len)) 00108 DBUG_RETURN(1); 00109 } 00110 if (ignore_table_inited) // if there are any ignores 00111 { 00112 if (hash_search(&ignore_table, (byte*) hash_key, len)) 00113 DBUG_RETURN(0); 00114 } 00115 if (wild_do_table_inited && 00116 find_wild(&wild_do_table, hash_key, len)) 00117 DBUG_RETURN(1); 00118 if (wild_ignore_table_inited && 00119 find_wild(&wild_ignore_table, hash_key, len)) 00120 DBUG_RETURN(0); 00121 } 00122 00123 /* 00124 If no table was to be updated, ignore statement (no reason we play it on 00125 slave, slave is supposed to replicate _changes_ only). 00126 If no explicit rule found and there was a do list, do not replicate. 00127 If there was no do list, go ahead 00128 */ 00129 DBUG_RETURN(some_tables_updating && 00130 !do_table_inited && !wild_do_table_inited); 00131 }
Here is the call graph for this function:

Here is the caller graph for this function:

I_List<i_string> Rpl_filter::do_db [private] |
Definition at line 108 of file rpl_filter.h.
Referenced by add_do_db(), db_ok(), get_do_db(), Rpl_filter(), and ~Rpl_filter().
HASH Rpl_filter::do_table [private] |
Definition at line 98 of file rpl_filter.h.
Referenced by add_do_table(), get_do_table(), tables_ok(), and ~Rpl_filter().
bool Rpl_filter::do_table_inited [private] |
Definition at line 103 of file rpl_filter.h.
Referenced by add_do_table(), get_do_table(), tables_ok(), and ~Rpl_filter().
I_List<i_string> Rpl_filter::ignore_db [private] |
Definition at line 109 of file rpl_filter.h.
Referenced by add_ignore_db(), db_ok(), get_ignore_db(), Rpl_filter(), and ~Rpl_filter().
HASH Rpl_filter::ignore_table [private] |
Definition at line 99 of file rpl_filter.h.
Referenced by add_ignore_table(), get_ignore_table(), tables_ok(), and ~Rpl_filter().
bool Rpl_filter::ignore_table_inited [private] |
Definition at line 104 of file rpl_filter.h.
Referenced by add_ignore_table(), get_ignore_table(), tables_ok(), and ~Rpl_filter().
I_List<i_string_pair> Rpl_filter::rewrite_db [private] |
Definition at line 111 of file rpl_filter.h.
Referenced by add_db_rewrite(), get_rewrite_db(), Rpl_filter(), and ~Rpl_filter().
bool Rpl_filter::table_rules_on [private] |
Definition at line 79 of file rpl_filter.h.
Referenced by add_do_table(), add_ignore_table(), add_wild_do_table(), add_wild_ignore_table(), and is_on().
DYNAMIC_ARRAY Rpl_filter::wild_do_table [private] |
Definition at line 100 of file rpl_filter.h.
Referenced by add_wild_do_table(), db_ok_with_wild_table(), get_wild_do_table(), tables_ok(), and ~Rpl_filter().
bool Rpl_filter::wild_do_table_inited [private] |
Definition at line 105 of file rpl_filter.h.
Referenced by add_wild_do_table(), db_ok_with_wild_table(), get_wild_do_table(), tables_ok(), and ~Rpl_filter().
DYNAMIC_ARRAY Rpl_filter::wild_ignore_table [private] |
Definition at line 101 of file rpl_filter.h.
Referenced by add_wild_ignore_table(), db_ok_with_wild_table(), get_wild_ignore_table(), tables_ok(), and ~Rpl_filter().
bool Rpl_filter::wild_ignore_table_inited [private] |
Definition at line 106 of file rpl_filter.h.
Referenced by add_wild_ignore_table(), db_ok_with_wild_table(), get_wild_ignore_table(), tables_ok(), and ~Rpl_filter().
1.4.7

