mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
DBUG_PRINT in solaris does not work well with NULL parameters.
HA_ERR was returning 0 (null string) when no error happened
(error=0). Since HA_ERR is used in DBUG_PRINT, regardless there
was an error or not, the server could crash in solaris debug
builds.
We fix this by:
- deploying an assertion that ensures that the function
is not called when no error has happened;
- making sure that HA_ERR is only called when an error
happened;
- making HA_ERR return "No Error", instead of 0, for
non-debug builds if it is called when no error happened.
This will make HA_ERR return values to work with DBUG_PRINT on
solaris debug builds.
This commit is contained in:
@@ -59,6 +59,11 @@ static int rows_event_stmt_cleanup(Relay_log_info const *rli, THD* thd);
|
||||
|
||||
static const char *HA_ERR(int i)
|
||||
{
|
||||
/*
|
||||
This function should only be called in case of an error
|
||||
was detected
|
||||
*/
|
||||
DBUG_ASSERT(i != 0);
|
||||
switch (i) {
|
||||
case HA_ERR_KEY_NOT_FOUND: return "HA_ERR_KEY_NOT_FOUND";
|
||||
case HA_ERR_FOUND_DUPP_KEY: return "HA_ERR_FOUND_DUPP_KEY";
|
||||
@@ -111,7 +116,7 @@ static const char *HA_ERR(int i)
|
||||
case HA_ERR_CORRUPT_EVENT: return "HA_ERR_CORRUPT_EVENT";
|
||||
case HA_ERR_ROWS_EVENT_APPLY : return "HA_ERR_ROWS_EVENT_APPLY";
|
||||
}
|
||||
return 0;
|
||||
return "No Error!";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +137,7 @@ static void inline slave_rows_error_report(enum loglevel level, int ha_error,
|
||||
TABLE *table, const char * type,
|
||||
const char *log_name, ulong pos)
|
||||
{
|
||||
const char *handler_error= HA_ERR(ha_error);
|
||||
const char *handler_error= (ha_error ? HA_ERR(ha_error) : NULL);
|
||||
char buff[MAX_SLAVE_ERRMSG], *slider;
|
||||
const char *buff_end= buff + sizeof(buff);
|
||||
uint len;
|
||||
@@ -7596,7 +7601,8 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
|
||||
|
||||
error= do_exec_row(rli);
|
||||
|
||||
DBUG_PRINT("info", ("error: %s", HA_ERR(error)));
|
||||
if (error)
|
||||
DBUG_PRINT("info", ("error: %s", HA_ERR(error)));
|
||||
DBUG_ASSERT(error != HA_ERR_RECORD_DELETED);
|
||||
|
||||
table->in_use = old_thd;
|
||||
@@ -9344,7 +9350,8 @@ int Rows_log_event::find_row(const Relay_log_info *rli)
|
||||
restart_rnd_next:
|
||||
error= table->file->rnd_next(table->record[0]);
|
||||
|
||||
DBUG_PRINT("info", ("error: %s", HA_ERR(error)));
|
||||
if (error)
|
||||
DBUG_PRINT("info", ("error: %s", HA_ERR(error)));
|
||||
switch (error) {
|
||||
|
||||
case 0:
|
||||
|
||||
Reference in New Issue
Block a user