Commit 89ea5ee6 authored by nick@mysql.com's avatar nick@mysql.com

Added sync_slave_with_master [connection].

Equivalent to:
save_master_pos; connection slave; sync_with_master;
parent 10dd73d5
...@@ -76,3 +76,4 @@ zak@balfor.local ...@@ -76,3 +76,4 @@ zak@balfor.local
zak@linux.local zak@linux.local
zgreant@mysql.com zgreant@mysql.com
miguel@hegel.br miguel@hegel.br
nick@mysql.com
...@@ -185,7 +185,9 @@ Q_LET, Q_ECHO, ...@@ -185,7 +185,9 @@ Q_LET, Q_ECHO,
Q_WHILE, Q_END_BLOCK, Q_WHILE, Q_END_BLOCK,
Q_SYSTEM, Q_RESULT, Q_SYSTEM, Q_RESULT,
Q_REQUIRE, Q_SAVE_MASTER_POS, Q_REQUIRE, Q_SAVE_MASTER_POS,
Q_SYNC_WITH_MASTER, Q_ERROR, Q_SYNC_WITH_MASTER,
Q_SYNC_SLAVE_WITH_MASTER,
Q_ERROR,
Q_SEND, Q_REAP, Q_SEND, Q_REAP,
Q_DIRTY_CLOSE, Q_REPLACE, Q_DIRTY_CLOSE, Q_REPLACE,
Q_PING, Q_EVAL, Q_PING, Q_EVAL,
...@@ -233,6 +235,7 @@ const char *command_names[]= ...@@ -233,6 +235,7 @@ const char *command_names[]=
"require", "require",
"save_master_pos", "save_master_pos",
"sync_with_master", "sync_with_master",
"sync_slave_with_master",
"error", "error",
"send", "send",
"reap", "reap",
...@@ -966,14 +969,13 @@ int do_echo(struct st_query* q) ...@@ -966,14 +969,13 @@ int do_echo(struct st_query* q)
} }
int do_sync_with_master(struct st_query* q) int do_sync_with_master2(const char* p)
{ {
MYSQL_RES* res; MYSQL_RES* res;
MYSQL_ROW row; MYSQL_ROW row;
MYSQL* mysql = &cur_con->mysql; MYSQL* mysql = &cur_con->mysql;
char query_buf[FN_REFLEN+128]; char query_buf[FN_REFLEN+128];
int offset = 0; int offset = 0;
char* p = q->first_argument;
int rpl_parse; int rpl_parse;
if (!master_pos.file[0]) if (!master_pos.file[0])
...@@ -1005,6 +1007,10 @@ int do_sync_with_master(struct st_query* q) ...@@ -1005,6 +1007,10 @@ int do_sync_with_master(struct st_query* q)
return 0; return 0;
} }
int do_sync_with_master(struct st_query* q)
{
return do_sync_with_master2(q->first_argument);
}
int do_save_master_pos() int do_save_master_pos()
{ {
...@@ -1298,10 +1304,9 @@ void free_replace() ...@@ -1298,10 +1304,9 @@ void free_replace()
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
int select_connection(char *p)
int select_connection(struct st_query* q)
{ {
char* p=q->first_argument, *name; char* name;
struct connection *con; struct connection *con;
DBUG_ENTER("select_connection"); DBUG_ENTER("select_connection");
DBUG_PRINT("enter",("name: '%s'",p)); DBUG_PRINT("enter",("name: '%s'",p));
...@@ -2403,7 +2408,7 @@ int main(int argc, char** argv) ...@@ -2403,7 +2408,7 @@ int main(int argc, char** argv)
processed = 1; processed = 1;
switch (q->type) { switch (q->type) {
case Q_CONNECT: do_connect(q); break; case Q_CONNECT: do_connect(q); break;
case Q_CONNECTION: select_connection(q); break; case Q_CONNECTION: select_connection(q->first_argument); break;
case Q_DISCONNECT: case Q_DISCONNECT:
case Q_DIRTY_CLOSE: case Q_DIRTY_CLOSE:
close_connection(q); break; close_connection(q); break;
...@@ -2492,6 +2497,19 @@ int main(int argc, char** argv) ...@@ -2492,6 +2497,19 @@ int main(int argc, char** argv)
break; break;
case Q_SAVE_MASTER_POS: do_save_master_pos(); break; case Q_SAVE_MASTER_POS: do_save_master_pos(); break;
case Q_SYNC_WITH_MASTER: do_sync_with_master(q); break; case Q_SYNC_WITH_MASTER: do_sync_with_master(q); break;
case Q_SYNC_SLAVE_WITH_MASTER:
{
do_save_master_pos();
if (*q->first_argument)
select_connection(q->first_argument);
else
{
char buf[] = "slave";
select_connection(buf);
}
do_sync_with_master2("");
break;
}
case Q_COMMENT: /* Ignore row */ case Q_COMMENT: /* Ignore row */
case Q_COMMENT_WITH_COMMAND: case Q_COMMENT_WITH_COMMAND:
case Q_PING: case Q_PING:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment