summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <guilhem@gbichot2>2003-07-23 15:46:46 +0200
committerunknown <guilhem@gbichot2>2003-07-23 15:46:46 +0200
commitdae34fb60f81802853961efad3edfa3427215680 (patch)
treeba4d0cdade886107397f37a4680254ece9f37c1c /sql
parentcb8e29cb43e927f110b16ac959ee7afde82bf5df (diff)
downloadmariadb-git-dae34fb60f81802853961efad3edfa3427215680.tar.gz
On Feb 4th, 2003, Monty said he would push my patch to print replicate-do-table
and other replicate-*-table options in SHOW SLAVE STATUS. Seems like it had not been done, so I push it now: there's 4 new columns to SHOW SLAVE STATUS. mysql-test/r/rpl000015.result: Result update (more columns) mysql-test/r/rpl_empty_master_crash.result: Result update (more columns) mysql-test/r/rpl_flush_log_loop.result: Result update (more columns) mysql-test/r/rpl_log.result: Result update (more columns) mysql-test/r/rpl_log_pos.result: Result update (more columns) mysql-test/r/rpl_redirect.result: Result update (more columns) mysql-test/r/rpl_replicate_do.result: Result update (more columns) mysql-test/r/rpl_rotate_logs.result: Result update (more columns) mysql-test/t/rpl_replicate_do.test: Result update (more columns) sql/slave.cc: Print replicate_*_table options in SHOW SLAVE STATUS sql/slave.h: two functions to make a string of replicate_*_table lists.
Diffstat (limited to 'sql')
-rw-r--r--sql/slave.cc63
-rw-r--r--sql/slave.h2
2 files changed, 65 insertions, 0 deletions
diff --git a/sql/slave.cc b/sql/slave.cc
index c45c11f8bef..37979576b73 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1565,6 +1565,48 @@ int register_slave_on_master(MYSQL* mysql)
}
+/*
+ Builds a String from a HASH of TABLE_RULE_ENT. Cannot be used for any other
+ hash, as it assumes that the hash entries are TABLE_RULE_ENT.
+
+ SYNOPSIS
+ table_rule_ent_hash_to_str()
+ s pointer to the String to fill
+ h pointer to the HASH to read
+
+ RETURN VALUES
+ none
+*/
+
+void table_rule_ent_hash_to_str(String* s, HASH* h)
+{
+ s->length(0);
+ for (uint i=0 ; i < h->records ; i++)
+ {
+ TABLE_RULE_ENT* e= (TABLE_RULE_ENT*) hash_element(h, i);
+ if (s->length())
+ s->append(',');
+ s->append(e->db,e->key_len);
+ }
+}
+
+/*
+ Mostly the same thing as above
+*/
+
+void table_rule_ent_dynamic_array_to_str(String* s, DYNAMIC_ARRAY* a)
+{
+ s->length(0);
+ for (uint i=0 ; i < a->elements ; i++)
+ {
+ TABLE_RULE_ENT* e;
+ get_dynamic(a, (gptr)&e, i);
+ if (s->length())
+ s->append(',');
+ s->append(e->db,e->key_len);
+ }
+}
+
int show_master_info(THD* thd, MASTER_INFO* mi)
{
// TODO: fix this for multi-master
@@ -1594,6 +1636,10 @@ int show_master_info(THD* thd, MASTER_INFO* mi)
field_list.push_back(new Item_empty_string("Slave_SQL_Running", 3));
field_list.push_back(new Item_empty_string("Replicate_do_db", 20));
field_list.push_back(new Item_empty_string("Replicate_ignore_db", 20));
+ field_list.push_back(new Item_empty_string("Replicate_do_table", 20));
+ field_list.push_back(new Item_empty_string("Replicate_ignore_table", 23));
+ field_list.push_back(new Item_empty_string("Replicate_wild_do_table", 24));
+ field_list.push_back(new Item_empty_string("Replicate_wild_ignore_table", 28));
field_list.push_back(new Item_return_int("Last_errno", 4, MYSQL_TYPE_LONG));
field_list.push_back(new Item_empty_string("Last_error", 20));
field_list.push_back(new Item_return_int("Skip_counter", 10,
@@ -1626,6 +1672,23 @@ int show_master_info(THD* thd, MASTER_INFO* mi)
protocol->store(mi->rli.slave_running ? "Yes":"No", &my_charset_bin);
protocol->store(&replicate_do_db);
protocol->store(&replicate_ignore_db);
+ /*
+ We can't directly use some protocol->store for
+ replicate_*_table,
+ as Protocol doesn't know the TABLE_RULE_ENT struct.
+ We first build Strings and then pass them to protocol->store.
+ */
+ char buf[256];
+ String tmp(buf, sizeof(buf), &my_charset_bin);
+ table_rule_ent_hash_to_str(&tmp, &replicate_do_table);
+ protocol->store(&tmp);
+ table_rule_ent_hash_to_str(&tmp, &replicate_ignore_table);
+ protocol->store(&tmp);
+ table_rule_ent_dynamic_array_to_str(&tmp, &replicate_wild_do_table);
+ protocol->store(&tmp);
+ table_rule_ent_dynamic_array_to_str(&tmp, &replicate_wild_ignore_table);
+ protocol->store(&tmp);
+
protocol->store((uint32) mi->rli.last_slave_errno);
protocol->store(mi->rli.last_slave_error, &my_charset_bin);
protocol->store((uint32) mi->rli.slave_skip_counter);
diff --git a/sql/slave.h b/sql/slave.h
index 429456eb0bb..668fff52d08 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -398,6 +398,8 @@ int mysql_table_dump(THD* thd, const char* db,
int fetch_master_table(THD* thd, const char* db_name, const char* table_name,
MASTER_INFO* mi, MYSQL* mysql);
+void table_rule_ent_hash_to_str(String* s, HASH* h);
+void table_rule_ent_dynamic_array_to_str(String* s, DYNAMIC_ARRAY* a);
int show_master_info(THD* thd, MASTER_INFO* mi);
int show_binlog_info(THD* thd);