diff options
author | Luis Soares <luis.soares@oracle.com> | 2011-07-15 12:42:06 +0100 |
---|---|---|
committer | Luis Soares <luis.soares@oracle.com> | 2011-07-15 12:42:06 +0100 |
commit | dbba17dad11764535d9cf98f635189c47afca98d (patch) | |
tree | c25cdf41def591bdb4b71275b1c94ce72bc64376 | |
parent | ce8077d8d37e37f4b007f64c5ca301d096699db8 (diff) | |
download | mariadb-git-dbba17dad11764535d9cf98f635189c47afca98d.tar.gz |
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.
-rw-r--r-- | sql/log_event.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc index 82a6d9e8ffc..fac3e3f264b 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -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: |