diff options
author | unknown <sasha@mysql.sashanet.com> | 2000-11-20 23:38:08 -0700 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2000-11-20 23:38:08 -0700 |
commit | 1100a260aa067860e1889489a69dcae0fd9907ae (patch) | |
tree | 050393cb70f23f2d613cf4a5f8134232f3a1b540 /sql | |
parent | b500ad64274dab7650c8cc243bc2ed37f94714ff (diff) | |
download | mariadb-git-1100a260aa067860e1889489a69dcae0fd9907ae.tar.gz |
fixed warning in sql_class.cc
added gdb support, mysqld options per test, and other cool stuff to mysql-test-run
added --replicate-wild-do/ignore-table
more test cases
client/mysqltest.c:
fixed a reject file bug
mysql-test/mysql-test-run:
support for gdb and running only one test case
sql/mysql_priv.h:
wild_compare needs to be global
sql/mysqld.cc:
--replicate-wild-do/ignore-table
sql/slave.cc:
wild,wild
sql/slave.h:
wild fixes
sql/sql_class.cc:
fixed compiler warning
sql/sql_string.cc:
wild stuff needs to be global
BitKeeper/etc/ignore:
Added BitKeeper/tmp/gone mysql-test/r/3.23/rpl mysql-test/r/3.23/rpl.reject mysql-test/var/lib/bar/bar.frm mysql-test/var/lib/bar/bar.MYD mysql-test/var/lib/bar/bar.MYI mysql-test/var/lib/foo/foo.frm mysql-test/var/lib/foo/foo.MYD mysql-test/var/lib/foo/foo.MYI mysql-test/var/lib/test/bar.frm mysql-test/var/lib/test/bar.MYD mysql-test/var/lib/test/bar.MYI mysql-test/var/lib/test/choo.frm mysql-test/var/lib/test/choo.MYD mysql-test/var/lib/test/choo.MYI mysql-test/var/slave-data/bar/bar.frm mysql-test/var/slave-data/bar/bar.MYD mysql-test/var/slave-data/bar/bar.MYI mysql-test/var/slave-data/foo/foo.frm mysql-test/var/slave-data/foo/foo.MYD mysql-test/var/slave-data/foo/foo.MYI mysql-test/var/slave-data/test/bar.frm mysql-test/var/slave-data/test/bar.MYD mysql-test/var/slave-data/test/bar.MYI mysql-test/var/slave-data/test/choo.frm mysql-test/var/slave-data/test/choo.MYD mysql-test/var/slave-data/test/choo.MYI mysql-test/var/tmp/README to the ignore list
Diffstat (limited to 'sql')
-rw-r--r-- | sql/mysql_priv.h | 5 | ||||
-rw-r--r-- | sql/mysqld.cc | 32 | ||||
-rw-r--r-- | sql/slave.cc | 58 | ||||
-rw-r--r-- | sql/slave.h | 3 | ||||
-rw-r--r-- | sql/sql_class.cc | 8 | ||||
-rw-r--r-- | sql/sql_string.cc | 4 |
6 files changed, 99 insertions, 11 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 0fe3b725e34..eca9eca56c4 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -583,6 +583,11 @@ bool check_column_name(const char *name); bool check_table_name(const char *name, uint length); char *get_field(MEM_ROOT *mem,TABLE *table,uint fieldnr); int wild_case_compare(const char *str,const char *wildstr); +int wild_compare(const char *str,const char *str_end, + const char *wildstr,const char *wildend,char escape); +int wild_case_compare(const char *str,const char *str_end, + const char *wildstr,const char *wildend,char escape); + /* from hostname.cc */ struct in_addr; my_string ip_to_hostname(struct in_addr *in,uint *errors); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index bbacf46dd01..8bb4cded39e 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2231,7 +2231,7 @@ enum options { OPT_REPLICATE_REWRITE_DB, OPT_SERVER_ID, OPT_SKIP_SLAVE_START, OPT_SKIP_INNOBASE,OPT_SAFEMALLOC_MEM_LIMIT, OPT_REPLICATE_DO_TABLE, OPT_REPLICATE_IGNORE_TABLE, - OPT_REPL_WILD_DO_TABLE, OPT_REPL_WILD_IGNORE_TABLE + OPT_REPLICATE_WILD_DO_TABLE, OPT_REPLICATE_WILD_IGNORE_TABLE }; static struct option long_options[] = { @@ -2302,13 +2302,13 @@ static struct option long_options[] = { {"replicate-do-table", required_argument, 0, (int) OPT_REPLICATE_DO_TABLE}, {"replicate-wild-do-table", required_argument, 0, - (int) OPT_REPL_WILD_DO_TABLE}, + (int) OPT_REPLICATE_WILD_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-wild-ignore-table", required_argument, 0, - (int) OPT_REPL_WILD_IGNORE_TABLE}, + (int) OPT_REPLICATE_WILD_IGNORE_TABLE}, {"replicate-rewrite-db", required_argument, 0, (int) OPT_REPLICATE_REWRITE_DB}, {"safe-mode", no_argument, 0, (int) OPT_SAFE}, @@ -2961,6 +2961,32 @@ static void get_options(int argc,char **argv) table_rules_on = 1; break; } + case (int)OPT_REPLICATE_WILD_DO_TABLE: + { + if(!wild_do_table_inited) + init_table_rule_array(&replicate_wild_do_table, + &wild_do_table_inited); + if(add_wild_table_rule(&replicate_wild_do_table, optarg)) + { + fprintf(stderr, "could not add do table rule '%s'\n", optarg); + exit(1); + } + table_rules_on = 1; + break; + } + case (int)OPT_REPLICATE_WILD_IGNORE_TABLE: + { + if(!wild_ignore_table_inited) + init_table_rule_array(&replicate_wild_ignore_table, + &wild_ignore_table_inited); + if(add_wild_table_rule(&replicate_wild_ignore_table, optarg)) + { + fprintf(stderr, "could not add do table rule '%s'\n", optarg); + exit(1); + } + table_rules_on = 1; + break; + } case (int)OPT_REPLICATE_IGNORE_TABLE: { if(!ignore_table_inited) diff --git a/sql/slave.cc b/sql/slave.cc index 181a6a9fc00..1e277134641 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -26,10 +26,13 @@ bool slave_running = 0; pthread_t slave_real_id; MASTER_INFO glob_mi; HASH replicate_do_table, replicate_ignore_table; +DYNAMIC_ARRAY replicate_wild_do_table, replicate_wild_ignore_table; bool do_table_inited = 0, ignore_table_inited = 0; +bool wild_do_table_inited = 0, wild_ignore_table_inited = 0; bool table_rules_on = 0; + static inline void skip_load_data_infile(NET* net); static inline bool slave_killed(THD* thd); static int init_slave_thread(THD* thd); @@ -61,6 +64,30 @@ void init_table_rule_hash(HASH* h, bool* h_inited) *h_inited = 1; } +void init_table_rule_array(DYNAMIC_ARRAY* a, bool* a_inited) +{ + init_dynamic_array(a, sizeof(TABLE_RULE_ENT*), TABLE_RULE_ARR_SIZE, + TABLE_RULE_ARR_SIZE); + *a_inited = 1; +} + +static TABLE_RULE_ENT* find_wild(DYNAMIC_ARRAY *a, const char* key, int len) +{ + uint i; + const char* key_end = key + len; + + for(i = 0; i < a->elements; i++) + { + TABLE_RULE_ENT* e ; + get_dynamic(a, (gptr)&e, i); + if(!wild_case_compare(key, key_end, (const char*)e->db, + (const char*)(e->db + e->key_len),'\\')) + return e; + } + + return 0; +} + int tables_ok(THD* thd, TABLE_LIST* tables) { for(; tables; tables = tables->next) @@ -82,9 +109,14 @@ int tables_ok(THD* thd, TABLE_LIST* tables) if(hash_search(&replicate_ignore_table, (byte*) hash_key, len)) return 0; } + if(wild_do_table_inited && find_wild(&replicate_wild_do_table, + hash_key, len)) return 1; + if(wild_ignore_table_inited && find_wild(&replicate_wild_ignore_table, + hash_key, len)) return 0; } - return !do_table_inited; // if no explicit rule found + return !do_table_inited && !wild_do_table_inited; + // if no explicit rule found // and there was a do list, do not replicate. If there was // no do list, go ahead } @@ -107,6 +139,24 @@ int add_table_rule(HASH* h, const char* table_spec) return 0; } +int add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec) +{ + char* dot = strchr(table_spec, '.'); + if(!dot) return 1; + uint len = (uint)strlen(table_spec); + if(!len) return 1; + TABLE_RULE_ENT* e = (TABLE_RULE_ENT*)my_malloc(sizeof(TABLE_RULE_ENT) + + len, MYF(MY_WME)); + if(!e) return 1; + e->db = (char*)e + sizeof(TABLE_RULE_ENT); + e->tbl_name = e->db + (dot - table_spec) + 1; + e->key_len = len; + memcpy(e->db, table_spec, len); + insert_dynamic(a, (gptr)&e); + return 0; +} + + static inline bool slave_killed(THD* thd) { return abort_slave || abort_loop || thd->killed; @@ -957,7 +1007,8 @@ pthread_handler_decl(handle_slave,arg __attribute__((unused))) goto err; thd->proc_info = "waiting to reconnect after a failed dump request"; - vio_close(mysql->net.vio); + if(mysql->net.vio) + vio_close(mysql->net.vio); safe_sleep(thd, glob_mi.connect_retry); if(slave_killed(thd)) goto err; @@ -983,7 +1034,8 @@ pthread_handler_decl(handle_slave,arg __attribute__((unused))) if (event_len == packet_error) { thd->proc_info = "waiting to reconnect after a failed read"; - vio_close(mysql->net.vio); + if(mysql->net.vio) + vio_close(mysql->net.vio); safe_sleep(thd, glob_mi.connect_retry); if(slave_killed(thd)) goto err; diff --git a/sql/slave.h b/sql/slave.h index 5df90cbf55b..47cfa77a8e4 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -56,6 +56,7 @@ typedef struct st_table_rule_ent } TABLE_RULE_ENT; #define TABLE_RULE_HASH_SIZE 16 +#define TABLE_RULE_ARR_SIZE 16 int flush_master_info(MASTER_INFO* mi); @@ -76,7 +77,9 @@ int db_ok(const char* db, I_List<i_string> &do_list, // do and ignore lists - used in replication int add_table_rule(HASH* h, const char* table_spec); +int add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec); void init_table_rule_hash(HASH* h, bool* h_inited); +void init_table_rule_array(DYNAMIC_ARRAY* a, bool* a_inited); int init_master_info(MASTER_INFO* mi); extern bool opt_log_slave_updates ; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 4ccf3481763..c7d50ee182e 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -74,13 +74,15 @@ static void free_var(user_var_entry *entry) ** Thread specific functions ****************************************************************************/ -THD::THD() +THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0), + insert_id_used(0), + bootstrap(0),in_lock_tables(0), + global_read_lock(0) { host=user=db=query=ip=0; proc_info="login"; locked=killed=count_cuted_fields=some_tables_deleted=no_errors=password= - fatal_error=query_start_used=last_insert_id_used=insert_id_used= - user_time=bootstrap=in_lock_tables=global_read_lock=0; + query_start_used=0; query_length=col_access=0; query_error=0; server_id = ::server_id; diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 4b9ebef21f1..174d07d8ec4 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -541,7 +541,7 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length) #define likeconv(A) (uchar) my_sort_order[(uchar) (A)] #endif -static int wild_case_compare(const char *str,const char *str_end, +int wild_case_compare(const char *str,const char *str_end, const char *wildstr,const char *wildend, char escape) { @@ -676,7 +676,7 @@ int wild_case_compare(String &match,String &wild, char escape) ** The following is used when using LIKE on binary strings */ -static int wild_compare(const char *str,const char *str_end, +int wild_compare(const char *str,const char *str_end, const char *wildstr,const char *wildend,char escape) { int result= -1; // Not found, using wildcards |