From c6d85289abd9589d6400cfa22b0ecf3ffce0b1db Mon Sep 17 00:00:00 2001 From: "lars@mysql.com" <> Date: Mon, 21 Mar 2005 22:09:42 +0100 Subject: [PATCH] WL#2472: Renamed Table_filter to Rpl_filter Eliminated very annoying memory leak --- sql/Makefile.am | 11 ++-- sql/log.cc | 2 +- sql/log_event.cc | 2 +- sql/mysqld.cc | 15 +++--- sql/repl_failsafe.cc | 2 +- sql/{table_filter.cc => rpl_filter.cc} | 74 +++++++++++++------------- sql/{table_filter.h => rpl_filter.h} | 16 +++--- sql/slave.cc | 2 +- sql/slave.h | 4 +- sql/sql_acl.h | 2 +- sql/sql_parse.cc | 2 +- sql/sql_repl.cc | 2 +- sql/sql_repl.h | 4 +- 13 files changed, 70 insertions(+), 68 deletions(-) rename sql/{table_filter.cc => rpl_filter.cc} (86%) rename sql/{table_filter.h => rpl_filter.h} (93%) diff --git a/sql/Makefile.am b/sql/Makefile.am index 152957da1e4..802006e7462 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -55,10 +55,10 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ ha_ndbcluster.h opt_range.h protocol.h \ sql_select.h structs.h table.h sql_udf.h hash_filo.h\ lex.h lex_symbol.h sql_acl.h sql_crypt.h \ - log_event.h sql_repl.h slave.h \ + log_event.h sql_repl.h slave.h rpl_filter.h \ stacktrace.h sql_sort.h sql_cache.h set_var.h \ - spatial.h gstream.h client_settings.h tzfile.h \ - table_filter.h tztime.h \ + spatial.h gstream.h client_settings.h tzfile.h + tztime.h \ sp_head.h sp_pcontext.h sp_rcontext.h sp.h sp_cache.h \ parse_file.h sql_view.h sql_trigger.h \ examples/ha_example.h examples/ha_archive.h \ @@ -90,12 +90,13 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \ sql_db.cc sql_table.cc sql_rename.cc sql_crypt.cc \ sql_load.cc mf_iocache.cc field_conv.cc sql_show.cc \ sql_udf.cc sql_analyse.cc sql_analyse.h sql_cache.cc \ - slave.cc sql_repl.cc sql_union.cc sql_derived.cc \ + slave.cc sql_repl.cc rpl_filter.cc \ + sql_union.cc sql_derived.cc \ client.c sql_client.cc mini_client_errors.c pack.c\ stacktrace.c repl_failsafe.h repl_failsafe.cc \ sql_olap.cc sql_view.cc \ gstream.cc spatial.cc sql_help.cc protocol_cursor.cc \ - table_filter.cc tztime.cc my_time.c \ + tztime.cc my_time.c \ sp_head.cc sp_pcontext.cc sp_rcontext.cc sp.cc \ sp_cache.cc parse_file.cc sql_trigger.cc \ examples/ha_example.cc examples/ha_archive.cc \ diff --git a/sql/log.cc b/sql/log.cc index c0f508adfe7..55307ea8523 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -24,7 +24,7 @@ #include "mysql_priv.h" #include "sql_repl.h" -#include "table_filter.h" +#include "rpl_filter.h" #include "ha_innodb.h" // necessary to cut the binlog when crash recovery #include diff --git a/sql/log_event.cc b/sql/log_event.cc index bc9501a8292..9dd7e1e2f58 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -21,7 +21,7 @@ #endif #include "mysql_priv.h" #include "slave.h" -#include "table_filter.h" +#include "rpl_filter.h" #include #endif /* MYSQL_CLIENT */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 942fce711d4..5ec529f82fc 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -19,7 +19,7 @@ #include #include "slave.h" #include "sql_repl.h" -#include "table_filter.h" +#include "rpl_filter.h" #include "repl_failsafe.h" #include "stacktrace.h" #include "mysqld_suffix.h" @@ -385,8 +385,8 @@ FILE *bootstrap_file; I_List threads,thread_cache; I_List key_caches; -Table_filter* rpl_filter; -Table_filter* binlog_filter; +Rpl_filter* rpl_filter; +Rpl_filter* binlog_filter; struct system_variables global_system_variables; struct system_variables max_system_variables; @@ -994,6 +994,8 @@ void clean_up(bool print_message) #ifdef HAVE_REPLICATION end_slave_list(); #endif + delete binlog_filter; + delete rpl_filter; #ifdef HAVE_OPENSSL if (ssl_acceptor_fd) my_free((gptr) ssl_acceptor_fd, MYF(MY_ALLOW_ZERO_PTR)); @@ -2963,8 +2965,8 @@ int main(int argc, char **argv) { DEBUGGER_OFF; - rpl_filter= new Table_filter; - binlog_filter= new Table_filter; + rpl_filter= new Rpl_filter; + binlog_filter= new Rpl_filter; if (!rpl_filter || !binlog_filter) { sql_perror("Could not allocate replication and binlog filters"); @@ -3215,9 +3217,6 @@ we force server id to 2, but this MySQL server will not act as a slave."); clean_up_mutexes(); my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); - delete rpl_filter; - delete binlog_filter; - exit(0); return(0); /* purecov: deadcode */ } diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index f9eb0bde1e7..ec4682e37b5 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -20,7 +20,7 @@ #include "repl_failsafe.h" #include "sql_repl.h" #include "slave.h" -#include "table_filter.h" +#include "rpl_filter.h" #include "log_event.h" #include diff --git a/sql/table_filter.cc b/sql/rpl_filter.cc similarity index 86% rename from sql/table_filter.cc rename to sql/rpl_filter.cc index 51b10f13cfc..f9f8a3e98a7 100644 --- a/sql/table_filter.cc +++ b/sql/rpl_filter.cc @@ -15,12 +15,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "mysql_priv.h" -#include "table_filter.h" +#include "rpl_filter.h" #define TABLE_RULE_HASH_SIZE 16 #define TABLE_RULE_ARR_SIZE 16 -Table_filter::Table_filter() : +Rpl_filter::Rpl_filter() : table_rules_on(0), do_table_inited(0), ignore_table_inited(0), wild_do_table_inited(0), wild_ignore_table_inited(0) { @@ -30,7 +30,7 @@ Table_filter::Table_filter() : } -Table_filter::~Table_filter() +Rpl_filter::~Rpl_filter() { if (do_table_inited) hash_free(&do_table); @@ -85,10 +85,10 @@ Table_filter::~Table_filter() */ bool -Table_filter::tables_ok(const char* db, TABLE_LIST* tables) +Rpl_filter::tables_ok(const char* db, TABLE_LIST* tables) { bool some_tables_updating= 0; - DBUG_ENTER("Table_filter::tables_ok"); + DBUG_ENTER("Rpl_filter::tables_ok"); for (; tables; tables= tables->next_global) { @@ -144,9 +144,9 @@ Table_filter::tables_ok(const char* db, TABLE_LIST* tables) */ bool -Table_filter::db_ok(const char* db) +Rpl_filter::db_ok(const char* db) { - DBUG_ENTER("Table_filter::db_ok"); + DBUG_ENTER("Rpl_filter::db_ok"); if (do_db.is_empty() && ignore_db.is_empty()) DBUG_RETURN(1); // Ok to replicate if the user puts no constraints @@ -216,9 +216,9 @@ Table_filter::db_ok(const char* db) */ bool -Table_filter::db_ok_with_wild_table(const char *db) +Rpl_filter::db_ok_with_wild_table(const char *db) { - DBUG_ENTER("Table_filter::db_ok_with_wild_table"); + DBUG_ENTER("Rpl_filter::db_ok_with_wild_table"); char hash_key[NAME_LEN+2]; char *end; @@ -247,16 +247,16 @@ Table_filter::db_ok_with_wild_table(const char *db) bool -Table_filter::is_on() +Rpl_filter::is_on() { return table_rules_on; } int -Table_filter::add_do_table(const char* table_spec) +Rpl_filter::add_do_table(const char* table_spec) { - DBUG_ENTER("Table_filter::add_do_table"); + DBUG_ENTER("Rpl_filter::add_do_table"); if (!do_table_inited) init_table_rule_hash(&do_table, &do_table_inited); table_rules_on= 1; @@ -265,9 +265,9 @@ Table_filter::add_do_table(const char* table_spec) int -Table_filter::add_ignore_table(const char* table_spec) +Rpl_filter::add_ignore_table(const char* table_spec) { - DBUG_ENTER("Table_filter::add_ignore_table"); + DBUG_ENTER("Rpl_filter::add_ignore_table"); if (!ignore_table_inited) init_table_rule_hash(&ignore_table, &ignore_table_inited); table_rules_on= 1; @@ -276,9 +276,9 @@ Table_filter::add_ignore_table(const char* table_spec) int -Table_filter::add_wild_do_table(const char* table_spec) +Rpl_filter::add_wild_do_table(const char* table_spec) { - DBUG_ENTER("Table_filter::add_wild_do_table"); + DBUG_ENTER("Rpl_filter::add_wild_do_table"); if (!wild_do_table_inited) init_table_rule_array(&wild_do_table, &wild_do_table_inited); table_rules_on= 1; @@ -287,9 +287,9 @@ Table_filter::add_wild_do_table(const char* table_spec) int -Table_filter::add_wild_ignore_table(const char* table_spec) +Rpl_filter::add_wild_ignore_table(const char* table_spec) { - DBUG_ENTER("Table_filter::add_wild_ignore_table"); + DBUG_ENTER("Rpl_filter::add_wild_ignore_table"); if (!wild_ignore_table_inited) init_table_rule_array(&wild_ignore_table, &wild_ignore_table_inited); table_rules_on= 1; @@ -298,7 +298,7 @@ Table_filter::add_wild_ignore_table(const char* table_spec) void -Table_filter::add_db_rewrite(const char* from_db, const char* to_db) +Rpl_filter::add_db_rewrite(const char* from_db, const char* to_db) { i_string_pair *db_pair = new i_string_pair(from_db, to_db); rewrite_db.push_back(db_pair); @@ -306,7 +306,7 @@ Table_filter::add_db_rewrite(const char* from_db, const char* to_db) int -Table_filter::add_table_rule(HASH* h, const char* table_spec) +Rpl_filter::add_table_rule(HASH* h, const char* table_spec) { const char* dot = strchr(table_spec, '.'); if (!dot) return 1; @@ -329,7 +329,7 @@ Table_filter::add_table_rule(HASH* h, const char* table_spec) */ int -Table_filter::add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec) +Rpl_filter::add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec) { const char* dot = strchr(table_spec, '.'); if (!dot) return 1; @@ -347,16 +347,18 @@ Table_filter::add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec) void -Table_filter::add_do_db(const char* table_spec) +Rpl_filter::add_do_db(const char* table_spec) { + DBUG_ENTER("Rpl_filter::add_do_db"); i_string *db = new i_string(table_spec); do_db.push_back(db); } void -Table_filter::add_ignore_db(const char* table_spec) +Rpl_filter::add_ignore_db(const char* table_spec) { + DBUG_ENTER("Rpl_filter::add_ignore_db"); i_string *db = new i_string(table_spec); ignore_db.push_back(db); } @@ -381,7 +383,7 @@ static void free_table_ent(void* a) void -Table_filter::init_table_rule_hash(HASH* h, bool* h_inited) +Rpl_filter::init_table_rule_hash(HASH* h, bool* h_inited) { hash_init(h, system_charset_info,TABLE_RULE_HASH_SIZE,0,0, get_table_key, free_table_ent, 0); @@ -390,7 +392,7 @@ Table_filter::init_table_rule_hash(HASH* h, bool* h_inited) void -Table_filter::init_table_rule_array(DYNAMIC_ARRAY* a, bool* a_inited) +Rpl_filter::init_table_rule_array(DYNAMIC_ARRAY* a, bool* a_inited) { my_init_dynamic_array(a, sizeof(TABLE_RULE_ENT*), TABLE_RULE_ARR_SIZE, TABLE_RULE_ARR_SIZE); @@ -399,7 +401,7 @@ Table_filter::init_table_rule_array(DYNAMIC_ARRAY* a, bool* a_inited) TABLE_RULE_ENT* -Table_filter::find_wild(DYNAMIC_ARRAY *a, const char* key, int len) +Rpl_filter::find_wild(DYNAMIC_ARRAY *a, const char* key, int len) { uint i; const char* key_end= key + len; @@ -420,7 +422,7 @@ Table_filter::find_wild(DYNAMIC_ARRAY *a, const char* key, int len) void -Table_filter::free_string_array(DYNAMIC_ARRAY *a) +Rpl_filter::free_string_array(DYNAMIC_ARRAY *a) { uint i; for (i= 0; i < a->elements; i++) @@ -447,7 +449,7 @@ Table_filter::free_string_array(DYNAMIC_ARRAY *a) */ void -Table_filter::table_rule_ent_hash_to_str(String* s, HASH* h) +Rpl_filter::table_rule_ent_hash_to_str(String* s, HASH* h) { s->length(0); for (uint i= 0; i < h->records; i++) @@ -461,7 +463,7 @@ Table_filter::table_rule_ent_hash_to_str(String* s, HASH* h) void -Table_filter::table_rule_ent_dynamic_array_to_str(String* s, DYNAMIC_ARRAY* a) +Rpl_filter::table_rule_ent_dynamic_array_to_str(String* s, DYNAMIC_ARRAY* a) { s->length(0); for (uint i= 0; i < a->elements; i++) @@ -476,35 +478,35 @@ Table_filter::table_rule_ent_dynamic_array_to_str(String* s, DYNAMIC_ARRAY* a) void -Table_filter::get_do_table(String* str) +Rpl_filter::get_do_table(String* str) { table_rule_ent_hash_to_str(str, &do_table); } void -Table_filter::get_ignore_table(String* str) +Rpl_filter::get_ignore_table(String* str) { table_rule_ent_hash_to_str(str, &ignore_table); } void -Table_filter::get_wild_do_table(String* str) +Rpl_filter::get_wild_do_table(String* str) { table_rule_ent_dynamic_array_to_str(str, &wild_do_table); } void -Table_filter::get_wild_ignore_table(String* str) +Rpl_filter::get_wild_ignore_table(String* str) { table_rule_ent_dynamic_array_to_str(str, &wild_ignore_table); } const char* -Table_filter::get_rewrite_db(const char* db, uint32 *new_len) +Rpl_filter::get_rewrite_db(const char* db, uint32 *new_len) { if (rewrite_db.is_empty() || !db) return db; @@ -524,14 +526,14 @@ Table_filter::get_rewrite_db(const char* db, uint32 *new_len) I_List* -Table_filter::get_do_db() +Rpl_filter::get_do_db() { return &do_db; } I_List* -Table_filter::get_ignore_db() +Rpl_filter::get_ignore_db() { return &ignore_db; } diff --git a/sql/table_filter.h b/sql/rpl_filter.h similarity index 93% rename from sql/table_filter.h rename to sql/rpl_filter.h index 471ab8c366e..70bb137790e 100644 --- a/sql/table_filter.h +++ b/sql/rpl_filter.h @@ -14,8 +14,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __TABLE_FILTER_H__ -#define __TABLE_FILTER_H__ +#ifndef __RPL_FILTER_H__ +#define __RPL_FILTER_H__ #include "mysql.h" #include "my_list.h" @@ -28,19 +28,19 @@ typedef struct st_table_rule_ent } TABLE_RULE_ENT; /* - Table_filter + Rpl_filter Inclusion and exclusion rules of tables and databases. Also handles rewrites of db. Used for replication and binlogging. */ -class Table_filter +class Rpl_filter { public: - Table_filter(); - ~Table_filter(); - Table_filter(Table_filter const&); - Table_filter& operator=(Table_filter const&); + Rpl_filter(); + ~Rpl_filter(); + Rpl_filter(Rpl_filter const&); + Rpl_filter& operator=(Rpl_filter const&); /* Checks - returns true if ok to replicate/log */ diff --git a/sql/slave.cc b/sql/slave.cc index 618dcfeb5af..4f9533108af 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -22,7 +22,7 @@ #include #include "slave.h" #include "sql_repl.h" -#include "table_filter.h" +#include "rpl_filter.h" #include "repl_failsafe.h" #include #include diff --git a/sql/slave.h b/sql/slave.h index 12a90355237..9be5a1144f6 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -21,13 +21,13 @@ #include "mysql.h" #include "my_list.h" -#include "table_filter.h" +#include "rpl_filter.h" #define SLAVE_NET_TIMEOUT 3600 #define MAX_SLAVE_ERRMSG 1024 #define MAX_SLAVE_ERROR 2000 -extern Table_filter *rpl_filter; +extern Rpl_filter *rpl_filter; /***************************************************************************** diff --git a/sql/sql_acl.h b/sql/sql_acl.h index 465f88ca760..c0fc1c333a1 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "slave.h" // for tables_ok(), rpl_filter -extern Table_filter *rpl_filter; +extern Rpl_filter *rpl_filter; #define SELECT_ACL (1L << 0) #define INSERT_ACL (1L << 1) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index de156521193..509bf130fcb 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -16,7 +16,7 @@ #include "mysql_priv.h" #include "sql_repl.h" -#include "table_filter.h" +#include "rpl_filter.h" #include "repl_failsafe.h" #include #include diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index ca1c50f95d7..4fda18284da 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -19,7 +19,7 @@ #include "sql_repl.h" #include "log_event.h" -#include "table_filter.h" +#include "rpl_filter.h" #include int max_binlog_dump_events = 0; // unlimited diff --git a/sql/sql_repl.h b/sql/sql_repl.h index 363e36c55a4..447e470ff1c 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -17,8 +17,8 @@ #ifdef HAVE_REPLICATION #include "slave.h" -extern Table_filter *binlog_filter; -extern Table_filter *rpl_filter; +extern Rpl_filter *binlog_filter; +extern Rpl_filter *rpl_filter; typedef struct st_slave_info {