Commit 7032533d authored by unknown's avatar unknown

Added ER_SAFE() for cases when the error message could be out of bands


sql/slave.cc:
  Cleanup up indentation.
  Change to use ER_SAFE() instead of ER().
sql/unireg.h:
  Added ER_SAFE()
parent 24d065d9
...@@ -909,37 +909,37 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) ...@@ -909,37 +909,37 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len)
// sanity check to make sure the master did not get a really bad // sanity check to make sure the master did not get a really bad
// error on the query // error on the query
if(!check_expected_error(thd, (expected_error = qev->error_code))) if (!check_expected_error(thd, (expected_error = qev->error_code)))
{
mysql_parse(thd, thd->query, q_len);
if (expected_error !=
(actual_error = thd->net.last_errno) && expected_error)
{ {
mysql_parse(thd, thd->query, q_len); const char* errmsg = "Slave: did not get the expected error\
if (expected_error !=
(actual_error = thd->net.last_errno) && expected_error)
{
const char* errmsg = "Slave: did not get the expected error\
running query from master - expected: '%s'(%d), got '%s'(%d)"; running query from master - expected: '%s'(%d), got '%s'(%d)";
sql_print_error(errmsg, ER(expected_error), expected_error, sql_print_error(errmsg, ER_SAFE(expected_error),
actual_error ? thd->net.last_error:"no error", expected_error,
actual_error actual_error ? thd->net.last_error:"no error",
); actual_error);
thd->query_error = 1; thd->query_error = 1;
}
else if (expected_error == actual_error)
{
thd->query_error = 0;
*last_slave_error = 0;
last_slave_errno = 0;
}
} }
else // master could be inconsistent, abort and tell DBA to else if (expected_error == actual_error)
// check/fix it
{ {
thd->db = thd->query = 0; thd->query_error = 0;
thd->convert_set = 0; *last_slave_error = 0;
close_thread_tables(thd); last_slave_errno = 0;
free_root(&thd->mem_root,0);
delete ev;
return 1;
} }
}
else
{
// master could be inconsistent, abort and tell DBA to check/fix it
thd->db = thd->query = 0;
thd->convert_set = 0;
close_thread_tables(thd);
free_root(&thd->mem_root,0);
delete ev;
return 1;
}
} }
thd->db = 0; // prevent db from being freed thd->db = 0; // prevent db from being freed
thd->query = 0; // just to be sure thd->query = 0; // just to be sure
......
...@@ -37,8 +37,9 @@ ...@@ -37,8 +37,9 @@
#define SHAREDIR "share/" #define SHAREDIR "share/"
#endif #endif
#define ER(X) ((X) >= 1000 && (X) < ER_ERROR_MESSAGES + 1000) ? \ #define ER(X) errmesg[(X)-1000]
errmesg[(X)-1000] : "Invalid error code" #define ER_SAFE(X) (((X) >= 1000 && (X) < ER_ERROR_MESSAGES + 1000) ? ER(X) : "Invalid error code")
#define ERRMAPP 1 /* Errormap f|r my_error */ #define ERRMAPP 1 /* Errormap f|r my_error */
#define LIBLEN FN_REFLEN-FN_LEN /* Max l{ngd p} dev */ #define LIBLEN FN_REFLEN-FN_LEN /* Max l{ngd p} dev */
......
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