summaryrefslogtreecommitdiff
path: root/sql/sql_repl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r--sql/sql_repl.cc98
1 files changed, 48 insertions, 50 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 10f0c23f54d..d2e3e72618d 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -276,41 +276,39 @@ bool log_in_use(const char* log_name)
return result;
}
-int purge_error_message(THD* thd, int res)
+bool purge_error_message(THD* thd, int res)
{
- const char *errmsg= 0;
+ uint errmsg= 0;
switch (res) {
case 0: break;
- case LOG_INFO_EOF: errmsg= "Target log not found in binlog index"; break;
- case LOG_INFO_IO: errmsg= "I/O error reading log index file"; break;
- case LOG_INFO_INVALID:
- errmsg= "Server configuration does not permit binlog purge"; break;
- case LOG_INFO_SEEK: errmsg= "Failed on fseek()"; break;
- case LOG_INFO_MEM: errmsg= "Out of memory"; break;
- case LOG_INFO_FATAL: errmsg= "Fatal error during purge"; break;
- case LOG_INFO_IN_USE: errmsg= "A purgeable log is in use, will not purge";
- break;
- default: errmsg= "Unknown error during purge"; break;
+ case LOG_INFO_EOF: errmsg= ER_UNKNOWN_TARGET_BINLOG; break;
+ case LOG_INFO_IO: errmsg= ER_IO_ERR_LOG_INDEX_READ; break;
+ case LOG_INFO_INVALID:errmsg= ER_BINLOG_PURGE_PROHIBITED; break;
+ case LOG_INFO_SEEK: errmsg= ER_FSEEK_FAIL; break;
+ case LOG_INFO_MEM: errmsg= ER_OUT_OF_RESOURCES; break;
+ case LOG_INFO_FATAL: errmsg= ER_BINLOG_PURGE_FATAL_ERR; break;
+ case LOG_INFO_IN_USE: errmsg= ER_LOG_IN_USE; break;
+ default: errmsg= ER_LOG_PURGE_UNKNOWN_ERR; break;
}
if (errmsg)
{
- send_error(thd, 0, errmsg);
- return 1;
+ my_message(errmsg, ER(errmsg), MYF(0));
+ return TRUE;
}
send_ok(thd);
- return 0;
+ return FALSE;
}
-int purge_master_logs(THD* thd, const char* to_log)
+bool purge_master_logs(THD* thd, const char* to_log)
{
char search_file_name[FN_REFLEN];
if (!mysql_bin_log.is_open())
{
send_ok(thd);
- return 0;
+ return FALSE;
}
mysql_bin_log.make_log_name(search_file_name, to_log);
@@ -320,7 +318,7 @@ int purge_master_logs(THD* thd, const char* to_log)
}
-int purge_master_logs_before_date(THD* thd, time_t purge_time)
+bool purge_master_logs_before_date(THD* thd, time_t purge_time)
{
if (!mysql_bin_log.is_open())
{
@@ -756,7 +754,7 @@ err:
pthread_mutex_unlock(&LOCK_thread_count);
if (file >= 0)
(void) my_close(file, MYF(MY_WME));
- send_error(thd, my_errno, errmsg);
+ my_message(my_errno, errmsg, MYF(0));
DBUG_VOID_RETURN;
}
@@ -872,7 +870,7 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
if (slave_errno)
{
if (net_report)
- send_error(thd, slave_errno);
+ my_message(slave_errno, ER(slave_errno), MYF(0));
DBUG_RETURN(1);
}
else if (net_report)
@@ -922,7 +920,7 @@ int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report )
if (slave_errno)
{
if (net_report)
- send_error(thd, slave_errno);
+ my_message(slave_errno, ER(slave_errno), MYF(0));
return 1;
}
else if (net_report)
@@ -1003,7 +1001,7 @@ int reset_slave(THD *thd, MASTER_INFO* mi)
err:
unlock_slave_threads(mi);
- if (error)
+ if (error)
my_error(sql_errno, MYF(0), errmsg);
DBUG_RETURN(error);
}
@@ -1057,7 +1055,7 @@ void kill_zombie_dump_threads(uint32 slave_server_id)
}
-int change_master(THD* thd, MASTER_INFO* mi)
+bool change_master(THD* thd, MASTER_INFO* mi)
{
int thread_mask;
const char* errmsg= 0;
@@ -1068,9 +1066,9 @@ int change_master(THD* thd, MASTER_INFO* mi)
init_thread_mask(&thread_mask,mi,0 /*not inverse*/);
if (thread_mask) // We refuse if any slave thread is running
{
- net_printf(thd,ER_SLAVE_MUST_STOP);
+ my_message(ER_SLAVE_MUST_STOP, ER(ER_SLAVE_MUST_STOP), MYF(0));
unlock_slave_threads(mi);
- DBUG_RETURN(1);
+ DBUG_RETURN(TRUE);
}
thd->proc_info = "Changing master";
@@ -1078,9 +1076,9 @@ int change_master(THD* thd, MASTER_INFO* mi)
// TODO: see if needs re-write
if (init_master_info(mi, master_info_file, relay_log_info_file, 0))
{
- send_error(thd, ER_MASTER_INFO);
+ my_message(ER_MASTER_INFO, ER(ER_MASTER_INFO), MYF(0));
unlock_slave_threads(mi);
- DBUG_RETURN(1);
+ DBUG_RETURN(TRUE);
}
/*
@@ -1197,9 +1195,9 @@ int change_master(THD* thd, MASTER_INFO* mi)
0 /* not only reset, but also reinit */,
&errmsg))
{
- net_printf(thd, 0, "Failed purging old relay logs: %s",errmsg);
+ my_error(ER_RELAY_LOG_FAIL, MYF(0), errmsg);
unlock_slave_threads(mi);
- DBUG_RETURN(1);
+ DBUG_RETURN(TRUE);
}
}
else
@@ -1213,9 +1211,9 @@ int change_master(THD* thd, MASTER_INFO* mi)
0 /*no data lock*/,
&msg, 0))
{
- net_printf(thd,0,"Failed initializing relay log position: %s",msg);
+ my_error(ER_RELAY_LOG_INIT, MYF(0), msg);
unlock_slave_threads(mi);
- DBUG_RETURN(1);
+ DBUG_RETURN(TRUE);
}
}
mi->rli.group_master_log_pos = mi->master_log_pos;
@@ -1257,14 +1255,15 @@ int change_master(THD* thd, MASTER_INFO* mi)
unlock_slave_threads(mi);
thd->proc_info = 0;
send_ok(thd);
- DBUG_RETURN(0);
+ DBUG_RETURN(FALSE);
}
int reset_master(THD* thd)
{
if (!mysql_bin_log.is_open())
{
- my_error(ER_FLUSH_MASTER_BINLOG_CLOSED, MYF(ME_BELL+ME_WAITTANG));
+ my_message(ER_FLUSH_MASTER_BINLOG_CLOSED,
+ ER(ER_FLUSH_MASTER_BINLOG_CLOSED), MYF(ME_BELL+ME_WAITTANG));
return 1;
}
return mysql_bin_log.reset_logs(thd);
@@ -1288,7 +1287,7 @@ int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1,
}
-int show_binlog_events(THD* thd)
+bool show_binlog_events(THD* thd)
{
Protocol *protocol= thd->protocol;
DBUG_ENTER("show_binlog_events");
@@ -1302,7 +1301,7 @@ int show_binlog_events(THD* thd)
Log_event::init_show_field_list(&field_list);
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
if (mysql_bin_log.is_open())
{
@@ -1407,19 +1406,19 @@ err:
if (errmsg)
{
my_error(ER_ERROR_WHEN_EXECUTING_COMMAND, MYF(0),
- "SHOW BINLOG EVENTS", errmsg);
- DBUG_RETURN(-1);
+ "SHOW BINLOG EVENTS", errmsg);
+ DBUG_RETURN(TRUE);
}
send_eof(thd);
pthread_mutex_lock(&LOCK_thread_count);
thd->current_linfo = 0;
pthread_mutex_unlock(&LOCK_thread_count);
- DBUG_RETURN(0);
+ DBUG_RETURN(TRUE);
}
-int show_binlog_info(THD* thd)
+bool show_binlog_info(THD* thd)
{
Protocol *protocol= thd->protocol;
DBUG_ENTER("show_binlog_info");
@@ -1432,7 +1431,7 @@ int show_binlog_info(THD* thd)
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
protocol->prepare_for_resend();
if (mysql_bin_log.is_open())
@@ -1445,10 +1444,10 @@ int show_binlog_info(THD* thd)
protocol->store(&binlog_do_db);
protocol->store(&binlog_ignore_db);
if (protocol->write())
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
}
send_eof(thd);
- DBUG_RETURN(0);
+ DBUG_RETURN(FALSE);
}
@@ -1460,11 +1459,11 @@ int show_binlog_info(THD* thd)
thd Thread specific variable
RETURN VALUES
- 0 ok
- 1 error (Error message sent to client)
+ FALSE OK
+ TRUE error
*/
-int show_binlogs(THD* thd)
+bool show_binlogs(THD* thd)
{
IO_CACHE *index_file;
char fname[FN_REFLEN];
@@ -1475,15 +1474,14 @@ int show_binlogs(THD* thd)
if (!mysql_bin_log.is_open())
{
- //TODO: Replace with ER() error message
- send_error(thd, 0, "You are not using binary logging");
+ my_message(ER_NO_BINARY_LOGGING, ER(ER_NO_BINARY_LOGGING), MYF(0));
return 1;
}
field_list.push_back(new Item_empty_string("Log_name", 255));
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
- DBUG_RETURN(1);
+ DBUG_RETURN(TRUE);
mysql_bin_log.lock_index();
index_file=mysql_bin_log.get_index_file();
@@ -1501,11 +1499,11 @@ int show_binlogs(THD* thd)
}
mysql_bin_log.unlock_index();
send_eof(thd);
- DBUG_RETURN(0);
+ DBUG_RETURN(FALSE);
err:
mysql_bin_log.unlock_index();
- DBUG_RETURN(1);
+ DBUG_RETURN(TRUE);
}