summaryrefslogtreecommitdiff
path: root/sql/sql_repl.cc
diff options
context:
space:
mode:
authorunknown <dlenev@mysql.com>2003-09-14 01:57:09 +0400
committerunknown <dlenev@mysql.com>2003-09-14 01:57:09 +0400
commit95a16b697abde8ae0631bdad0fee0f578f573084 (patch)
tree9b95250006febf53e90b41329026267482bcd75e /sql/sql_repl.cc
parent1179d87a38d5f96b9dec23e7944c341cdd1cbf51 (diff)
parentdf7707c397e78a78bebcb8b5e395bbdc71024419 (diff)
downloadmariadb-git-95a16b697abde8ae0631bdad0fee0f578f573084.tar.gz
Manual merge after commiting START SLAVE UNTIL
sql/lex.h: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/repl_failsafe.cc: Auto merged include/mysqld_error.h: Manual merge mysql-test/r/rpl000015.result: Manual merge mysql-test/r/rpl_empty_master_crash.result: Manual merge mysql-test/r/rpl_flush_log_loop.result: Manual merge mysql-test/r/rpl_log.result: Manual merge mysql-test/r/rpl_log_pos.result: Manual merge mysql-test/r/rpl_redirect.result: Manual merge mysql-test/r/rpl_replicate_do.result: Manual merge mysql-test/r/rpl_rotate_logs.result: Manual merge sql/share/czech/errmsg.txt: Manual merge sql/share/danish/errmsg.txt: Manual merge sql/share/dutch/errmsg.txt: Manual merge sql/share/english/errmsg.txt: Manual merge sql/share/estonian/errmsg.txt: Manual merge sql/share/french/errmsg.txt: Manual merge sql/share/german/errmsg.txt: Manual merge sql/share/greek/errmsg.txt: Manual merge sql/share/hungarian/errmsg.txt: Manual merge sql/share/italian/errmsg.txt: Manual merge sql/share/japanese/errmsg.txt: Manual merge sql/share/korean/errmsg.txt: Manual merge sql/share/norwegian-ny/errmsg.txt: Manual merge sql/share/norwegian/errmsg.txt: Manual merge sql/share/polish/errmsg.txt: Manual merge sql/share/portuguese/errmsg.txt: Manual merge sql/share/romanian/errmsg.txt: Manual merge sql/share/russian/errmsg.txt: Manual merge sql/share/serbian/errmsg.txt: Manual merge sql/share/slovak/errmsg.txt: Manual merge sql/share/spanish/errmsg.txt: Manual merge sql/share/swedish/errmsg.txt: Manual merge sql/share/ukrainian/errmsg.txt: Manual merge sql/slave.cc: Manual merge sql/slave.h: Manual merge sql/sql_repl.cc: Manual merge sql/sql_yacc.yy: Manual merge
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r--sql/sql_repl.cc80
1 files changed, 75 insertions, 5 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 2489bc8df68..8e2c024e7b3 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -663,7 +663,7 @@ err:
int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
{
- int slave_errno;
+ int slave_errno= 0;
if (!thd)
thd = current_thd;
int thread_mask;
@@ -687,21 +687,88 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
if (init_master_info(mi,master_info_file,relay_log_info_file, 0))
slave_errno=ER_MASTER_INFO;
else if (server_id_supplied && *mi->host)
- slave_errno = start_slave_threads(0 /*no mutex */,
+ {
+ /*
+ If we will start SQL thread we will care about UNTIL options
+ If not and they are specified we will ignore them and warn user
+ about this fact.
+ */
+ if (thread_mask & SLAVE_SQL)
+ {
+ pthread_mutex_lock(&mi->rli.data_lock);
+
+ if (thd->lex.mi.pos)
+ {
+ mi->rli.until_condition= RELAY_LOG_INFO::UNTIL_MASTER_POS;
+ mi->rli.until_log_pos= thd->lex.mi.pos;
+ /*
+ We don't check thd->lex.mi.log_file_name for NULL here
+ since it is checked in sql_yacc.yy
+ */
+ strmake(mi->rli.until_log_name, thd->lex.mi.log_file_name,
+ sizeof(mi->rli.until_log_name)-1);
+ }
+ else if (thd->lex.mi.relay_log_pos)
+ {
+ mi->rli.until_condition= RELAY_LOG_INFO::UNTIL_RELAY_POS;
+ mi->rli.until_log_pos= thd->lex.mi.relay_log_pos;
+ strmake(mi->rli.until_log_name, thd->lex.mi.relay_log_name,
+ sizeof(mi->rli.until_log_name)-1);
+ }
+ else
+ clear_until_condition(&mi->rli);
+
+ if (mi->rli.until_condition != RELAY_LOG_INFO::UNTIL_NONE)
+ {
+ /* Preparing members for effective until condition checking */
+ const char *p= fn_ext(mi->rli.until_log_name);
+ char *p_end;
+ if (*p)
+ {
+ //p points to '.'
+ mi->rli.until_log_name_extension= strtoul(++p,&p_end, 10);
+ /*
+ p_end points to the first invalid character. If it equals
+ to p, no digits were found, error. If it contains '\0' it
+ means conversion went ok.
+ */
+ if(p_end==p || *p_end)
+ slave_errno=ER_BAD_SLAVE_UNTIL_COND;
+ }
+ else
+ slave_errno=ER_BAD_SLAVE_UNTIL_COND;
+
+ /* mark the cached result of the UNTIL comparison as "undefined" */
+ mi->rli.until_log_names_cmp_result=
+ RELAY_LOG_INFO::UNTIL_LOG_NAMES_CMP_UNKNOWN;
+
+ /* Issuing warning then started without --skip-slave-start */
+ if (!opt_skip_slave_start)
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_MISSING_SKIP_SLAVE,
+ ER(ER_MISSING_SKIP_SLAVE));
+ }
+
+ pthread_mutex_unlock(&mi->rli.data_lock);
+ }
+ else if (thd->lex.mi.pos || thd->lex.mi.relay_log_pos)
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_UNTIL_COND_IGNORED,
+ ER(ER_UNTIL_COND_IGNORED));
+
+
+ if(!slave_errno)
+ slave_errno = start_slave_threads(0 /*no mutex */,
1 /* wait for start */,
mi,
master_info_file,relay_log_info_file,
thread_mask);
+ }
else
slave_errno = ER_BAD_SLAVE;
}
else
- {
//no error if all threads are already started, only a warning
- slave_errno= 0;
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_SLAVE_WAS_RUNNING,
ER(ER_SLAVE_WAS_RUNNING));
- }
unlock_slave_threads(mi);
@@ -814,6 +881,8 @@ int reset_slave(THD *thd, MASTER_INFO* mi)
*/
init_master_info_with_options(mi);
clear_last_slave_error(&mi->rli);
+ clear_until_condition(&mi->rli);
+
// close master_info_file, relay_log_info_file, set mi->inited=rli->inited=0
end_master_info(mi);
// and delete these two files
@@ -1027,6 +1096,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
mi->rli.abort_pos_wait++; /* for MASTER_POS_WAIT() to abort */
/* Clear the error, for a clean start. */
clear_last_slave_error(&mi->rli);
+ clear_until_condition(&mi->rli);
/*
If we don't write new coordinates to disk now, then old will remain in
relay-log.info until START SLAVE is issued; but if mysqld is shutdown