diff options
author | unknown <sasha@laptop.slkc.uswest.net> | 2000-11-11 14:50:39 -0700 |
---|---|---|
committer | unknown <sasha@laptop.slkc.uswest.net> | 2000-11-11 14:50:39 -0700 |
commit | 19d2e8ce98ed4f77f94f1cde422f3ace73f64315 (patch) | |
tree | 151539228a360db4526847582397a4c1edbdfa8d /sql | |
parent | d2ce6383e9c43589cfb900a7c49c04b20e05ac88 (diff) | |
download | mariadb-git-19d2e8ce98ed4f77f94f1cde422f3ace73f64315.tar.gz |
laptop commit, syncing with the repostitory. Fixed some bad bugs in replication
BUILD/compile-pentium-debug:
added -DEXTRA_DEBUG
sql/Makefile.am:
added slave.h
sql/log_event.h:
max_buf -> event_len in read_log_event
sql/mysql_priv.h:
moved the slave part to slave.h
sql/mysqld.cc:
changes for replcate_do/ignore_table ( does not work yet)
sql/slave.cc:
removed the stuff covered by slave.h
sql/sql_class.h:
moved slave stuff to slave.h
sql/sql_repl.h:
removed stuff covered by slave.h
BitKeeper/etc/logging_ok:
Logging to logging@openlogging.org accepted
Diffstat (limited to 'sql')
-rw-r--r-- | sql/Makefile.am | 2 | ||||
-rw-r--r-- | sql/log_event.h | 8 | ||||
-rw-r--r-- | sql/mysql_priv.h | 14 | ||||
-rw-r--r-- | sql/mysqld.cc | 13 | ||||
-rw-r--r-- | sql/slave.cc | 37 | ||||
-rw-r--r-- | sql/slave.h | 95 | ||||
-rw-r--r-- | sql/sql_class.h | 46 | ||||
-rw-r--r-- | sql/sql_repl.h | 6 |
8 files changed, 135 insertions, 86 deletions
diff --git a/sql/Makefile.am b/sql/Makefile.am index 72a8643bd41..7b56acbb773 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -48,7 +48,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ opt_range.h opt_ft.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 md5.h \ - log_event.h mini_client.h sql_repl.h + log_event.h mini_client.h sql_repl.h slave.h mysqld_SOURCES = sql_lex.cc \ item.cc item_sum.cc item_buff.cc item_func.cc \ item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \ diff --git a/sql/log_event.h b/sql/log_event.h index 4b2739d1592..33fcab4fea9 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -93,7 +93,7 @@ public: // if mutex is 0, the read will proceed without mutex static Log_event* read_log_event(FILE* file, pthread_mutex_t* log_lock); - static Log_event* read_log_event(const char* buf, int max_buf); + static Log_event* read_log_event(const char* buf, int event_len); #ifndef MYSQL_CLIENT static int read_log_event(FILE* file, String* packet, @@ -133,7 +133,7 @@ public: #endif Query_log_event(FILE* file, time_t when, uint32 server_id); - Query_log_event(const char* buf, int max_buf); + Query_log_event(const char* buf, int event_len); ~Query_log_event() { if (data_buf) @@ -273,7 +273,7 @@ public: #endif Load_log_event(FILE* file, time_t when, uint32 server_id); - Load_log_event(const char* buf, int max_buf); + Load_log_event(const char* buf, int event_len); ~Load_log_event() { if (data_buf) @@ -398,7 +398,7 @@ public: {} Rotate_log_event(FILE* file, time_t when, uint32 server_id) ; - Rotate_log_event(const char* buf, int max_buf); + Rotate_log_event(const char* buf, int event_len); ~Rotate_log_event() { if (alloced) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 2c8a91f917a..384d98de40a 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -205,19 +205,6 @@ inline THD *_current_thd(void) #include "sql_class.h" #include "opt_range.h" -int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd = -1); -// if fd is -1, dump to NET -int fetch_nx_table(THD* thd, MASTER_INFO* mi); -// retrieve non-exitent table from master -// the caller must set thd->last_nx_table and thd->last_nx_db first -int show_master_info(THD* thd); -int show_binlog_info(THD* thd); - -int db_ok(const char* db, I_List<i_string> &do_list, - I_List<i_string> &ignore_list ); -// check to see if the database is ok to operate on with respect to the -// do and ignore lists - used in replication - void mysql_create_db(THD *thd, char *db, uint create_info); void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags); @@ -522,7 +509,6 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list); void unlock_table_name(THD *thd, TABLE_LIST *table_list); bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list); -extern int flush_master_info(MASTER_INFO* mi); /* old unireg functions */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f571063a89d..e9389727e9a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -18,6 +18,7 @@ #include <mysql.h> #include <m_ctype.h> #include "sql_acl.h" +#include "slave.h" #ifdef HAVE_BERKELEY_DB #include "ha_berkeley.h" #endif @@ -179,7 +180,6 @@ static char *opt_ssl_capath = 0; static VioSSLAcceptorFd* ssl_acceptor_fd = 0; #endif /* HAVE_OPENSSL */ -extern bool slave_running; I_List <i_string_pair> replicate_rewrite_db; I_List<i_string> replicate_do_db, replicate_ignore_db; @@ -2229,7 +2229,8 @@ enum options { OPT_BINLOG_IGNORE_DB, OPT_WANT_CORE, OPT_SKIP_CONCURRENT_INSERT, OPT_MEMLOCK, OPT_MYISAM_RECOVER, OPT_REPLICATE_REWRITE_DB, OPT_SERVER_ID, OPT_SKIP_SLAVE_START, - OPT_SKIP_INNOBASE,OPT_SAFEMALLOC_MEM_LIMIT + OPT_SKIP_INNOBASE,OPT_SAFEMALLOC_MEM_LIMIT, + OPT_REPLICATE_DO_TABLE, OPT_REPLICATE_IGNORE_TABLE }; static struct option long_options[] = { @@ -2297,7 +2298,12 @@ static struct option long_options[] = { {"pid-file", required_argument, 0, (int) OPT_PID_FILE}, {"port", required_argument, 0, 'P'}, {"replicate-do-db", required_argument, 0, (int) OPT_REPLICATE_DO_DB}, - {"replicate-ignore-db", required_argument, 0, (int) OPT_REPLICATE_IGNORE_DB}, + {"replicate-do-table", required_argument, 0, + (int) OPT_REPLICATE_DO_TABLE}, + {"replicate-ignore-db", required_argument, 0, + (int) OPT_REPLICATE_IGNORE_DB}, + {"replicate-ignore-table", required_argument, 0, + (int) OPT_REPLICATE_IGNORE_TABLE}, {"replicate-rewrite-db", required_argument, 0, (int) OPT_REPLICATE_REWRITE_DB}, {"safe-mode", no_argument, 0, (int) OPT_SAFE}, @@ -3744,4 +3750,5 @@ skipp: ; template class I_List<THD>; template class I_List_iterator<THD>; template class I_List<i_string>; +template class I_List<i_string_pair>; #endif diff --git a/sql/slave.cc b/sql/slave.cc index 3474a98a0c7..a3f6f518ddc 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -18,31 +18,20 @@ #include "mysql_priv.h" #include <mysql.h> #include "mini_client.h" +#include "slave.h" #include <thr_alarm.h> #include <my_dir.h> -pthread_handler_decl(handle_slave,arg); -extern bool volatile abort_loop, abort_slave; - -// the master variables are defaults read from my.cnf or command line -extern uint master_port, master_connect_retry; -extern my_string master_user, master_password, master_host, - master_info_file; - -extern I_List<i_string> replicate_do_db, replicate_ignore_db; -extern I_List<i_string_pair> replicate_rewrite_db; -extern I_List<THD> threads; bool slave_running = 0; pthread_t slave_real_id; MASTER_INFO glob_mi; +HASH replicate_do_table, replicate_ignore_table; +bool do_table_inited = 0, ignore_table_inited = 0; -extern bool opt_log_slave_updates ; - static inline void skip_load_data_infile(NET* net); static inline bool slave_killed(THD* thd); static int init_slave_thread(THD* thd); -int init_master_info(MASTER_INFO* mi); static void safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi); static void safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi); static int safe_sleep(THD* thd, int sec); @@ -50,6 +39,26 @@ static int request_table_dump(MYSQL* mysql, char* db, char* table); static int create_table_from_dump(THD* thd, NET* net, const char* db, const char* table_name); static inline char* rewrite_db(char* db); +static void free_table_ent(TABLE_RULE_ENT* e) +{ + my_free((byte*)e, MYF(0)); +} + +static byte* get_table_key(TABLE_RULE_ENT* e, uint* len, + my_bool not_used __attribute__((unused))) +{ + *len = e->key_len; + return (byte*)e->db; +} + + +void init_table_rule_hash(HASH* h, bool* h_inited) +{ + hash_init(h, TABLE_RULE_HASH_SIZE,0,0, + (hash_get_key) get_table_key, + (void (*)(void*)) free_table_ent, 0); + *h_inited = 1; +} static inline bool slave_killed(THD* thd) { diff --git a/sql/slave.h b/sql/slave.h new file mode 100644 index 00000000000..67036b4120c --- /dev/null +++ b/sql/slave.h @@ -0,0 +1,95 @@ +#ifndef SLAVE_H +#define SLAVE_H + +typedef struct st_master_info +{ + char log_file_name[FN_REFLEN]; + ulonglong pos,pending; + FILE* file; // we keep the file open, so we need to remember the file pointer + + // the variables below are needed because we can change masters on the fly + char host[HOSTNAME_LENGTH+1]; + char user[USERNAME_LENGTH+1]; + char password[HASH_PASSWORD_LENGTH+1]; + uint port; + uint connect_retry; + pthread_mutex_t lock; + bool inited; + + st_master_info():pending(0),inited(0) + { + host[0] = 0; user[0] = 0; password[0] = 0; + pthread_mutex_init(&lock, NULL); + } + + ~st_master_info() + { + pthread_mutex_destroy(&lock); + } + + inline void inc_pending(ulonglong val) + { + pending += val; + } + inline void inc_pos(ulonglong val) + { + pthread_mutex_lock(&lock); + pos += val + pending; + pending = 0; + pthread_mutex_unlock(&lock); + } + // thread safe read of position - not needed if we are in the slave thread, + // but required otherwise + inline void read_pos(ulonglong& var) + { + pthread_mutex_lock(&lock); + var = pos; + pthread_mutex_unlock(&lock); + } +} MASTER_INFO; + +typedef struct st_table_rule_ent +{ + char* db; + char* tbl_name; + uint key_len; +} TABLE_RULE_ENT; + +#define TABLE_RULE_HASH_SIZE 16 + +int flush_master_info(MASTER_INFO* mi); + +int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd = -1); +// if fd is -1, dump to NET +int fetch_nx_table(THD* thd, MASTER_INFO* mi); +// retrieve non-exitent table from master +// the caller must set thd->last_nx_table and thd->last_nx_db first +int show_master_info(THD* thd); +int show_binlog_info(THD* thd); + +int db_ok(const char* db, I_List<i_string> &do_list, + I_List<i_string> &ignore_list ); +// check to see if the database is ok to operate on with respect to the +// do and ignore lists - used in replication + + +int init_master_info(MASTER_INFO* mi); +extern bool opt_log_slave_updates ; +pthread_handler_decl(handle_slave,arg); +extern bool volatile abort_loop, abort_slave; +extern bool slave_running; +extern pthread_t slave_real_id; +extern MASTER_INFO glob_mi; +extern HASH replicate_do_table, replicate_ignore_table; +extern bool do_table_inited, ignore_table_inited; + +// the master variables are defaults read from my.cnf or command line +extern uint master_port, master_connect_retry; +extern my_string master_user, master_password, master_host, + master_info_file; + +extern I_List<i_string> replicate_do_db, replicate_ignore_db; +extern I_List<i_string_pair> replicate_rewrite_db; +extern I_List<THD> threads; + +#endif diff --git a/sql/sql_class.h b/sql/sql_class.h index d72467aab5a..e53ce950c1f 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -50,52 +50,6 @@ typedef struct st_log_info ~st_log_info() { pthread_mutex_destroy(&lock);} } LOG_INFO; -typedef struct st_master_info -{ - char log_file_name[FN_REFLEN]; - ulonglong pos,pending; - FILE* file; // we keep the file open, so we need to remember the file pointer - - // the variables below are needed because we can change masters on the fly - char host[HOSTNAME_LENGTH+1]; - char user[USERNAME_LENGTH+1]; - char password[HASH_PASSWORD_LENGTH+1]; - uint port; - uint connect_retry; - pthread_mutex_t lock; - bool inited; - - st_master_info():inited(0),pending(0) - { - host[0] = 0; user[0] = 0; password[0] = 0; - pthread_mutex_init(&lock, NULL); - } - - ~st_master_info() - { - pthread_mutex_destroy(&lock); - } - - inline void inc_pending(ulonglong val) - { - pending += val; - } - inline void inc_pos(ulonglong val) - { - pthread_mutex_lock(&lock); - pos += val + pending; - pending = 0; - pthread_mutex_unlock(&lock); - } - // thread safe read of position - not needed if we are in the slave thread, - // but required otherwise - inline void read_pos(ulonglong& var) - { - pthread_mutex_lock(&lock); - var = pos; - pthread_mutex_unlock(&lock); - } -} MASTER_INFO; class MYSQL_LOG { public: diff --git a/sql/sql_repl.h b/sql/sql_repl.h index a0b60497773..240efb81fe4 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -1,11 +1,9 @@ #ifndef SQL_REPL_H #define SQL_REPL_H -extern bool slave_running; -extern volatile bool abort_slave; +#include "slave.h" + extern char* master_host; -extern pthread_t slave_real_id; -extern MASTER_INFO glob_mi; extern my_string opt_bin_logname, master_info_file; extern I_List<i_string> binlog_do_db, binlog_ignore_db; |