summaryrefslogtreecommitdiff
path: root/sql/rpl_reporting.cc
diff options
context:
space:
mode:
authormats@kindahl-laptop.dnsalias.net <>2007-06-09 07:19:37 +0200
committermats@kindahl-laptop.dnsalias.net <>2007-06-09 07:19:37 +0200
commit9094e97aed8536e628cb6c5a81b79ecc6521be7a (patch)
treecdc21b3b7f0f7811d04f8bafebcee2697b8a7d3b /sql/rpl_reporting.cc
parentbba84e754d61918dd147f1926b338f5f82ee3150 (diff)
downloadmariadb-git-9094e97aed8536e628cb6c5a81b79ecc6521be7a.tar.gz
BUG#24954 (Last_errno and Last_error not set after master_retry_count was reached):
Adding new fields Last_{IO,SQL}_Errno and Last_{IO,SQL}_Error to output of SHOW SLAVE STATUS to hold errors from I/O and SQL thread respectively. Old fields Last_Error and Last_Errno are aliases for Last_SQL_Error and Last_SQL_Errno respectively. Fields are added last to output of SHOW SLAVE STATUS to allow old applications to use the same positional arguments into the row, while allowing new application to benefit from the added information. In addition, some new error codes are added (especially for the I/O thread) to be able to provide sensible error message.
Diffstat (limited to 'sql/rpl_reporting.cc')
-rw-r--r--sql/rpl_reporting.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/sql/rpl_reporting.cc b/sql/rpl_reporting.cc
new file mode 100644
index 00000000000..d14dbdcc930
--- /dev/null
+++ b/sql/rpl_reporting.cc
@@ -0,0 +1,47 @@
+
+#include "mysql_priv.h"
+#include "rpl_reporting.h"
+
+void
+Slave_reporting_capability::report(loglevel level, int err_code, const char *msg, ...)
+{
+ void (*report_function)(const char *, ...);
+ char buff[MAX_SLAVE_ERRMSG];
+ char *pbuff= buff;
+ uint pbuffsize= sizeof(buff);
+ va_list args;
+ va_start(args, msg);
+
+ switch (level)
+ {
+ case ERROR_LEVEL:
+ /*
+ It's an error, it must be reported in Last_error and Last_errno in SHOW
+ SLAVE STATUS.
+ */
+ pbuff= last_error.message;
+ pbuffsize= sizeof(last_error.message);
+ last_error.number = err_code;
+ report_function= sql_print_error;
+ break;
+ case WARNING_LEVEL:
+ report_function= sql_print_warning;
+ break;
+ case INFORMATION_LEVEL:
+ report_function= sql_print_information;
+ break;
+ default:
+ DBUG_ASSERT(0); // should not come here
+ return; // don't crash production builds, just do nothing
+ }
+
+ my_vsnprintf(pbuff, pbuffsize, msg, args);
+
+ va_end(args);
+
+ /* If the msg string ends with '.', do not add a ',' it would be ugly */
+ report_function("Slave %s: %s%s Error_code: %d",
+ m_thread_name, pbuff,
+ (pbuff[0] && *(strend(pbuff)-1) == '.') ? "" : ",",
+ err_code);
+}